kifaru 1.0.185 → 1.0.187
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/dashboard/_astro/platform-route.D0CpHNCE.js +96 -0
- package/dashboard/administration/index.html +2 -2
- package/dashboard/agent/index.html +2 -2
- package/dashboard/assessments/index.html +2 -2
- package/dashboard/findings/index.html +2 -2
- package/dashboard/index.html +2 -2
- package/dashboard/lifecycle/index.html +2 -2
- package/dashboard/login/index.html +1 -1
- package/dashboard/reports/index.html +2 -2
- package/dashboard/runs/index.html +2 -2
- package/dashboard/workflows/index.html +2 -2
- package/extensions/kifaru-dossier.ts +473 -81
- package/extensions/kifaru-rerun-guard.ts +99 -0
- package/kifaru-gateway.js +328 -104
- package/kifaru-pi.js +317 -39
- package/package.json +2 -2
- package/dashboard/_astro/platform-route.ll8rL_N_.js +0 -96
- package/dashboard/evidence/index.html +0 -53
- package/dashboard/governance/index.html +0 -53
- package/dashboard/history/index.html +0 -53
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import{i as e,n as t,o as n,r,t as i}from"./react-dom.B--7n7g5.js";import{_ as a,b as o,c as s,d as c,f as l,g as u,h as d,l as f,m as p,n as m,p as h,r as g,t as _,u as v,v as y,y as b}from"./label.BKu82TGK.js";var x=o(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),S=o(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),C=o(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),w=o(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),T=o(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),E=o(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),D=o(`audio-lines`,[[`path`,{d:`M2 10v3`,key:`1fnikh`}],[`path`,{d:`M6 6v11`,key:`11sgs0`}],[`path`,{d:`M10 3v18`,key:`yhl04a`}],[`path`,{d:`M14 8v7`,key:`3a1oy3`}],[`path`,{d:`M18 5v13`,key:`123xd1`}],[`path`,{d:`M22 10v3`,key:`154ddg`}]]),O=o(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),k=o(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),A=o(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),j=o(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),M=o(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),ee=o(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),te=o(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),ne=o(`circle-x`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),re=o(`cloud-off`,[[`path`,{d:`M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057`,key:`1uxyv8`}],[`path`,{d:`M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78`,key:`99tcn7`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),ie=o(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),ae=o(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),oe=o(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),se=o(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ce=o(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),le=o(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]),ue=o(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]),de=o(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),fe=o(`key`,[[`path`,{d:`m2 21 9.6-9.6`,key:`9l79m3`}],[`path`,{d:`m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19`,key:`fw8biw`}],[`circle`,{cx:`15.5`,cy:`7.5`,r:`5.5`,key:`4wxmhb`}]]),pe=o(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),me=o(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),he=o(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),ge=o(`music`,[[`path`,{d:`M9 18V5l12-2v13`,key:`1jmyc2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`circle`,{cx:`18`,cy:`16`,r:`3`,key:`1hluhg`}]]),_e=o(`pen-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),ve=o(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),ye=o(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),be=o(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),xe=o(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Se=o(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),Ce=o(`search`,[[`path`,{d:`m21 21-4.34-4.34`,key:`14j7rj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}]]),we=o(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Te=o(`shield-question-mark`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Ee=o(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),De=o(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),Oe=o(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),ke=o(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),Ae=o(`trash`,[[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),je=o(`trash-2`,[[`path`,{d:`M10 11v6`,key:`nco0om`}],[`path`,{d:`M14 11v6`,key:`outv1u`}],[`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`,key:`miytrc`}],[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`,key:`e791ji`}]]),Me=o(`video`,[[`path`,{d:`m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5`,key:`ftymec`}],[`rect`,{x:`2`,y:`6`,width:`14`,height:`12`,rx:`2`,key:`158x01`}]]),Ne=o(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),Pe=o(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),N=n(t(),1),P=u(),Fe=Object.defineProperty,Ie=(e,t)=>Fe(e,`name`,{value:t,configurable:!0}),Le=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Re=N.forwardRef(Ie(function(e,t){return(0,P.jsx)(f.span,{...e,ref:t,style:{...Le,...e.style}})},`VisuallyHidden`)),ze=Object.defineProperty,Be=(e,t)=>ze(e,`name`,{value:t,configurable:!0});function Ve(e,t){let n=N.createContext(t);n.displayName=e+`Context`;let r=Be(e=>{let{children:t,...r}=e,i=N.useMemo(()=>r,Object.values(r));return(0,P.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=N.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return Be(i,`useContext`),[r,i]}Be(Ve,`createContext`);function He(e,t=[]){let n=[];function r(t,r){let i=N.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=Be(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=N.useMemo(()=>o,Object.values(o));return(0,P.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=N.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return Be(s,`useContext`),[o,s]}Be(r,`createContext`);let i=Be(()=>{let t=n.map(e=>N.createContext(e));return Be(function(n){let r=n?.[e]||t;return N.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,Ue(i,...t)]}Be(He,`createContextScope`);function Ue(...e){let t=e[0];if(e.length===1)return t;let n=Be(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return Be(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return N.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}Be(Ue,`composeContextScopes`);var We=Object.defineProperty,Ge=(e,t)=>We(e,`name`,{value:t,configurable:!0});function Ke(e){let t=e+`CollectionProvider`,[n,r]=He(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=Ge(e=>{let{scope:t,children:n}=e,r=N.useRef(null),a=N.useRef(new Map).current;return(0,P.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=h(s),l=N.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(s,n),o=d(t,i.collectionRef);return(0,P.jsx)(c,{ref:o,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,f=`data-radix-collection-item`,p=h(u),m=N.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=N.useRef(null),s=d(t,o),c=a(u,n);return N.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,P.jsx)(p,{[f]:``,ref:s,children:r})});m.displayName=u;function g(t){let n=a(e+`CollectionConsumer`,t);return N.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${f}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return Ge(g,`useCollection`),[{Provider:o,Slot:l,ItemSlot:m},g,r]}Ge(Ke,`createCollection`);var qe=new WeakMap,Je=class e extends Map{static{Ge(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],qe.set(this,!0)}set(e,t){return qe.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=Ze(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=Ye(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=Ye(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Ye(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function Ye(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=Xe(e,t);return n===-1?void 0:e[n]}Ge(Ye,`at`);function Xe(e,t){let n=e.length,r=Ze(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}Ge(Xe,`toSafeIndex`);function Ze(e){return e!==e||e===0?0:Math.trunc(e)}Ge(Ze,`toSafeInteger`);function Qe(e){let t=e+`CollectionProvider`,[n,r]=He(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Je,setItemMap:Ge(()=>void 0,`setItemMap`)}),o=Ge(({state:e,...t})=>e?(0,P.jsx)(c,{...t,state:e}):(0,P.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=Ge(e=>{let t=_();return(0,P.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=Ge(e=>{let{scope:t,children:n,state:r}=e,a=N.useRef(null),[o,s]=N.useState(null),c=d(a,s),[l,u]=r;return N.useEffect(()=>{if(!o)return;let e=nt(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,P.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=h(l),f=N.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=a(l,n),o=d(t,i.collectionRef);return(0,P.jsx)(u,{ref:o,children:r})});f.displayName=l;let p=e+`CollectionItemSlot`,m=h(p),g=N.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=N.useRef(null),[s,c]=N.useState(null),l=d(t,o,c),{setItemMap:u}=a(p,n),f=N.useRef(i);$e(f.current,i)||(f.current=i);let h=f.current;return N.useEffect(()=>{let e=h;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(tt):(t.set(s,{...e,element:s}),t.toSorted(tt)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new Je(e)))}},[s,h,u]),(0,P.jsx)(m,{"data-radix-collection-item":``,ref:l,children:r})});g.displayName=p;function _(){return N.useState(new Je)}Ge(_,`useInitCollection`);function v(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return Ge(v,`useCollection`),[{Provider:o,Slot:f,ItemSlot:g},{createCollectionScope:r,useCollection:v,useInitCollection:_}]}Ge(Qe,`createCollection`);function $e(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}Ge($e,`shallowEqual`);function et(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}Ge(et,`isElementPreceding`);function tt(e,t){return!e[1].element||!t[1].element?0:et(e[1].element,t[1].element)?-1:1}Ge(tt,`sortByDocumentPosition`);function nt(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}Ge(nt,`getChildListObserver`);var rt=Object.defineProperty,it=(e,t)=>rt(e,`name`,{value:t,configurable:!0}),at=!!(typeof window<`u`&&window.document&&window.document.createElement);function F(e,t,{checkForDefaultPrevented:n=!0}={}){return it(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}it(F,`composeEventHandlers`);function ot(e){if(!at)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}it(ot,`getOwnerWindow`);function st(e){if(!at)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}it(st,`getOwnerDocument`);function ct(e,t=!1){let{activeElement:n}=st(e);if(!n?.nodeName)return null;if(lt(n)&&n.contentDocument)return ct(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=st(n).getElementById(e);if(t)return t}}return n}it(ct,`getActiveElement`);function lt(e){return e.tagName===`IFRAME`}it(lt,`isFrame`);var ut=globalThis?.document?N.useLayoutEffect:()=>{},dt=Object.defineProperty,ft=(e,t)=>dt(e,`name`,{value:t,configurable:!0}),pt=N.useEffectEvent,mt=N.useInsertionEffect;function ht(e){if(typeof pt==`function`)return pt(e);let t=N.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof mt==`function`?mt(()=>{t.current=e}):ut(()=>{t.current=e}),N.useMemo(()=>((...e)=>t.current?.(...e)),[])}ft(ht,`useEffectEvent`);var gt=Object.defineProperty,_t=(e,t)=>gt(e,`name`,{value:t,configurable:!0}),vt=N.useInsertionEffect||ut;function yt({prop:e,defaultProp:t,onChange:n=_t(()=>{},`onChange`),caller:r}){let[i,a,o]=bt({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,N.useCallback(t=>{if(s){let n=xt(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}_t(yt,`useControllableState`);function bt({defaultProp:e,onChange:t}){let[n,r]=N.useState(e),i=N.useRef(n),a=N.useRef(t);return vt(()=>{a.current=t},[t]),N.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}_t(bt,`useUncontrolledState`);function xt(e){return typeof e==`function`}_t(xt,`isFunction`);var St=Symbol(`RADIX:SYNC_STATE`);function Ct(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=ht(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=N.useReducer((t,n)=>{if(n.type===St)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=N.useRef(p);N.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=N.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return N.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:St,state:i})},[i,d.state,c]),[h,f]}_t(Ct,`useControllableStateReducer`);var wt=Object.defineProperty,Tt=(e,t)=>wt(e,`name`,{value:t,configurable:!0});function Et(e,t){return N.useReducer((e,n)=>t[e][n]??e,e)}Tt(Et,`useStateMachine`);var Dt=Tt(e=>{let{present:t,children:n}=e,r=Ot(t),i=typeof n==`function`?n({present:r.isPresent}):N.Children.only(n),a=At(r.ref,Mt(i));return typeof n==`function`||r.isPresent?N.cloneElement(i,{ref:a}):null},`Presence`);function Ot(e){let[t,n]=N.useState(),r=N.useRef(null),i=N.useRef(e),a=N.useRef(`none`),o=N.useRef(void 0),[s,c]=Et(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return N.useEffect(()=>{s===`mounted`?(a.current=o.current??jt(r.current),o.current=void 0):a.current=`none`},[s]),ut(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=jt(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),ut(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=Tt(a=>{let o=jt(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=Tt(e=>{e.target===t&&(a.current=jt(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:N.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=jt(t)}else r.current=null;n(e)},[])}}Tt(Ot,`usePresence`);function kt(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Tt(kt,`setRef`);function At(...e){let t=N.useRef(e);return t.current=e,N.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=kt(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():kt(n[e],null)}}},[])}Tt(At,`useStableComposedRefs`);function jt(e){return e?.animationName||`none`}Tt(jt,`getAnimationName`);function Mt(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Tt(Mt,`getElementRef`);var Nt=Object.defineProperty,Pt=(e,t)=>Nt(e,`name`,{value:t,configurable:!0}),Ft=N.useId||(()=>void 0),It=0;function Lt(e){let[t,n]=N.useState(Ft());return ut(()=>{e||n(e=>e??String(It++))},[e]),e||(t?`radix-${t}`:``)}Pt(Lt,`useId`);var Rt=Object.defineProperty,zt=(e,t)=>Rt(e,`name`,{value:t,configurable:!0}),Bt=`Collapsible`,[Vt,Ht]=He(Bt),[Ut,Wt]=Vt(Bt),Gt=N.forwardRef(zt(function(e,t){let{__scopeCollapsible:n,open:r,defaultOpen:i,disabled:a,onOpenChange:o,...s}=e,[c,l]=yt({prop:r,defaultProp:i??!1,onChange:o,caller:Bt});return(0,P.jsx)(Ut,{scope:n,disabled:a,contentId:Lt(),open:c,onOpenToggle:N.useCallback(()=>l(e=>!e),[l]),children:(0,P.jsx)(f.div,{"data-state":Zt(c),"data-disabled":a?``:void 0,...s,ref:t})})},`Collapsible`)),Kt=`CollapsibleTrigger`,qt=N.forwardRef(zt(function(e,t){let{__scopeCollapsible:n,...r}=e,i=Wt(Kt,n);return(0,P.jsx)(f.button,{type:`button`,"aria-controls":i.open?i.contentId:void 0,"aria-expanded":i.open||!1,"data-state":Zt(i.open),"data-disabled":i.disabled?``:void 0,disabled:i.disabled,...r,ref:t,onClick:F(e.onClick,i.onOpenToggle)})},`CollapsibleTrigger`)),Jt=`CollapsibleContent`,Yt=N.forwardRef(zt(function(e,t){let{forceMount:n,...r}=e,i=Wt(Jt,e.__scopeCollapsible);return(0,P.jsx)(Dt,{present:n||i.open,children:({present:e})=>(0,P.jsx)(Xt,{...r,ref:t,present:e})})},`CollapsibleContent`)),Xt=N.forwardRef(zt(function(e,t){let{__scopeCollapsible:n,present:r,children:i,...a}=e,o=Wt(Jt,n),[s,c]=N.useState(r),l=N.useRef(null),u=d(t,l),p=N.useRef(0),m=p.current,h=N.useRef(0),g=h.current,_=o.open||s,v=N.useRef(_),y=N.useRef(void 0);return N.useEffect(()=>{let e=requestAnimationFrame(()=>v.current=!1);return()=>cancelAnimationFrame(e)},[]),ut(()=>{let e=l.current;if(e){y.current=y.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();p.current=t.height,h.current=t.width,v.current||(e.style.transitionDuration=y.current.transitionDuration,e.style.animationName=y.current.animationName),c(r)}},[o.open,r]),(0,P.jsx)(f.div,{"data-state":Zt(o.open),"data-disabled":o.disabled?``:void 0,id:o.contentId,hidden:!_,...a,ref:u,style:{"--radix-collapsible-content-height":m?`${m}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:_&&i})},`CollapsibleContentImpl`));function Zt(e){return e?`open`:`closed`}zt(Zt,`getState`);var Qt=Gt,$t=Object.defineProperty,en=(e,t)=>$t(e,`name`,{value:t,configurable:!0}),tn=N.createContext(void 0);function nn(e){let t=N.useContext(tn);return e||t||`ltr`}en(nn,`useDirection`);var rn=Object.defineProperty,an=(e,t)=>rn(e,`name`,{value:t,configurable:!0});function on(e){let t=N.useRef(e);return N.useEffect(()=>{t.current=e}),N.useMemo(()=>((...e)=>t.current?.(...e)),[])}an(on,`useCallbackRef`);var sn=Object.defineProperty,cn=(e,t)=>sn(e,`name`,{value:t,configurable:!0}),ln=`dismissableLayer.update`,un=`dismissableLayer.pointerDownOutside`,dn=`dismissableLayer.focusOutside`,fn,pn=N.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),mn=N.forwardRef(cn(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=N.useContext(pn),[p,m]=N.useState(null),h=p?.ownerDocument??globalThis?.document,[,g]=N.useState({}),_=d(t,m),v=Array.from(u.layers),[y]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),b=y?v.indexOf(y):-1,x=p?v.indexOf(p):-1,S=u.layersWithOutsidePointerEventsDisabled.size>0,C=x>=b,w=N.useRef(!1),T=_n(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:h,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:w,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:N.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return C&&!t},[u.branches,C])}),E=vn(e=>{if(r&&w.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},h),D=p?x===v.length-1:!1,O=on(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return N.useEffect(()=>{if(D)return h.addEventListener(`keydown`,O,{capture:!0}),()=>h.removeEventListener(`keydown`,O,{capture:!0})},[h,D,O]),N.useEffect(()=>{if(p)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(fn=h.body.style.pointerEvents,h.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(p)),u.layers.add(p),yn(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(p),u.layersWithOutsidePointerEventsDisabled.size===0&&(h.body.style.pointerEvents=fn))}},[p,h,n,u]),N.useEffect(()=>()=>{p&&(u.layers.delete(p),u.layersWithOutsidePointerEventsDisabled.delete(p),yn())},[p,u]),N.useEffect(()=>{let e=cn(()=>g({}),`handleUpdate`);return document.addEventListener(ln,e),()=>document.removeEventListener(ln,e)},[]),(0,P.jsx)(f.div,{...l,ref:_,style:{pointerEvents:S?C?`auto`:`none`:void 0,...e.style},onFocusCapture:F(e.onFocusCapture,E.onFocusCapture),onBlurCapture:F(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:F(e.onPointerDownCapture,T.onPointerDownCapture)})},`DismissableLayer`));function hn(){let e=N.useContext(pn),[t,n]=N.useState(null);return N.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}cn(hn,`useDismissableLayerSurface`);var gn=cn(()=>!0,`IS_TRUE`);function _n(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=gn}=t,s=on(e),c=N.useRef(!1),l=N.useRef(!1),u=N.useRef(new Map),d=N.useRef(()=>{});return N.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}cn(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}cn(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}cn(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}cn(p,`handleInteractionBubble`);let m=cn(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||bn(un,s,p,{discrete:!0})};if(cn(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:cn(()=>c.current=!0,`onPointerDownCapture`)}}cn(_n,`usePointerDownOutside`);function vn(e,t=globalThis?.document){let n=on(e),r=N.useRef(!1);return N.useEffect(()=>{let e=cn(e=>{e.target&&!r.current&&bn(dn,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:cn(()=>r.current=!0,`onFocusCapture`),onBlurCapture:cn(()=>r.current=!1,`onBlurCapture`)}}cn(vn,`useFocusOutside`);function yn(){let e=new CustomEvent(ln);document.dispatchEvent(e)}cn(yn,`dispatchUpdate`);function bn(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?v(i,a):i.dispatchEvent(a)}cn(bn,`handleAndDispatchCustomEvent`);var xn=Object.defineProperty,Sn=(e,t)=>xn(e,`name`,{value:t,configurable:!0}),Cn=`focusScope.autoFocusOnMount`,wn=`focusScope.autoFocusOnUnmount`,Tn={bubbles:!1,cancelable:!0},En=N.forwardRef(Sn(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=N.useState(null),l=on(i),u=on(a),p=N.useRef(null),m=d(t,c),h=N.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;N.useEffect(()=>{if(r){let e=function(e){if(h.paused||!s)return;let t=e.target;s.contains(t)?p.current=t:Nn(p.current,{select:!0})},t=function(e){if(h.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Nn(p.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Nn(s)};Sn(e,`handleFocusIn`),Sn(t,`handleFocusOut`),Sn(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,h.paused]),N.useEffect(()=>{if(s){Pn.add(h);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Cn,Tn);s.addEventListener(Cn,l),s.dispatchEvent(t),t.defaultPrevented||(Dn(Ln(kn(s)),{select:!0}),document.activeElement===e&&Nn(s))}return()=>{s.removeEventListener(Cn,l),setTimeout(()=>{let t=new CustomEvent(wn,Tn);s.addEventListener(wn,u),s.dispatchEvent(t),t.defaultPrevented||Nn(e??document.body,{select:!0}),s.removeEventListener(wn,u),Pn.remove(h)},0)}}},[s,l,u,h]);let g=N.useCallback(e=>{if(!n&&!r||h.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=On(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Nn(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Nn(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,h.paused]);return(0,P.jsx)(f.div,{tabIndex:-1,...o,ref:m,onKeyDown:g})},`FocusScope`));function Dn(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Nn(r,{select:t}),document.activeElement!==n)return}Sn(Dn,`focusFirst`);function On(e){let t=kn(e);return[An(t,e),An(t.reverse(),e)]}Sn(On,`getTabbableEdges`);function kn(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:Sn(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}Sn(kn,`getTabbableCandidates`);function An(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):jn(r,{upTo:t})))return r}Sn(An,`findVisible`);function jn(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}Sn(jn,`isHidden`);function Mn(e){return e instanceof HTMLInputElement&&`select`in e}Sn(Mn,`isSelectableInput`);function Nn(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Mn(e)&&t&&e.select()}}Sn(Nn,`focus`);var Pn=Fn();function Fn(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=In(e,t),e.unshift(t)},remove(t){e=In(e,t),e[0]?.resume()}}}Sn(Fn,`createFocusScopesStack`);function In(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}Sn(In,`arrayRemove`);function Ln(e){return e.filter(e=>e.tagName!==`A`)}Sn(Ln,`removeLinks`);var Rn=n(i(),1),zn=Object.defineProperty,Bn=N.forwardRef(((e,t)=>zn(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=N.useState(!1);ut(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Rn.createPortal((0,P.jsx)(f.div,{...r,ref:t}),o):null},`Portal`)),Vn=Object.defineProperty,Hn=(e,t)=>Vn(e,`name`,{value:t,configurable:!0}),Un=0,Wn=null;function Gn(e){return Kn(),e.children}Hn(Gn,`FocusGuards`);function Kn(){N.useEffect(()=>{Wn||={start:qn(),end:qn()};let{start:e,end:t}=Wn;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),Un++,()=>{Un===1&&(Wn?.start.remove(),Wn?.end.remove(),Wn=null),Un=Math.max(0,Un-1)}},[])}Hn(Kn,`useFocusGuards`);function qn(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}Hn(qn,`createFocusGuard`);var Jn=function(){return Jn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Jn.apply(this,arguments)};function Yn(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Xn(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Zn=`right-scroll-bar-position`,Qn=`width-before-scroll-bar`,$n=`with-scroll-bars-hidden`,er=`--removed-body-scroll-bar-size`;function tr(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function nr(e,t){var n=(0,N.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var rr=typeof window<`u`?N.useLayoutEffect:N.useEffect,ir=new WeakMap;function ar(e,t){var n=nr(t||null,function(t){return e.forEach(function(e){return tr(e,t)})});return rr(function(){var t=ir.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||tr(e,null)}),i.forEach(function(e){r.has(e)||tr(e,a)})}ir.set(n,e)},[e]),n}function or(e){return e}function sr(e,t){t===void 0&&(t=or);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function cr(e){e===void 0&&(e={});var t=sr(null);return t.options=Jn({async:!0,ssr:!1},e),t}var lr=function(e){var t=e.sideCar,n=Yn(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return N.createElement(r,Jn({},n))};lr.isSideCarExport=!0;function ur(e,t){return e.useMedium(t),lr}var dr=cr(),fr=function(){},pr=N.forwardRef(function(e,t){var n=N.useRef(null),r=N.useState({onScrollCapture:fr,onWheelCapture:fr,onTouchMoveCapture:fr}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=Yn(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=ar([n,t]),C=Jn(Jn({},b),i);return N.createElement(N.Fragment,null,u&&N.createElement(x,{sideCar:dr,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?N.cloneElement(N.Children.only(s),Jn(Jn({},C),{ref:S})):N.createElement(v,Jn({},C,{className:c,ref:S}),s))});pr.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},pr.classNames={fullWidth:Qn,zeroRight:Zn};var mr=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function hr(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=mr();return t&&e.setAttribute(`nonce`,t),e}function gr(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function _r(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var vr=function(){var e=0,t=null;return{add:function(n){e==0&&(t=hr())&&(gr(t,n),_r(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},yr=function(){var e=vr();return function(t,n){N.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},br=function(){var e=yr();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},xr={left:0,top:0,right:0,gap:0},Sr=function(e){return parseInt(e||``,10)||0},Cr=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[Sr(n),Sr(r),Sr(i)]},wr=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return xr;var t=Cr(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},Tr=br(),Er=`data-scroll-locked`,Dr=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
2
|
+
.${$n} {
|
|
3
|
+
overflow: hidden ${r};
|
|
4
|
+
padding-right: ${s}px ${r};
|
|
5
|
+
}
|
|
6
|
+
body[${Er}] {
|
|
7
|
+
overflow: hidden ${r};
|
|
8
|
+
overscroll-behavior: contain;
|
|
9
|
+
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
10
|
+
padding-left: ${i}px;
|
|
11
|
+
padding-top: ${a}px;
|
|
12
|
+
padding-right: ${o}px;
|
|
13
|
+
margin-left:0;
|
|
14
|
+
margin-top:0;
|
|
15
|
+
margin-right: ${s}px ${r};
|
|
16
|
+
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.${Zn} {
|
|
20
|
+
right: ${s}px ${r};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.${Qn} {
|
|
24
|
+
margin-right: ${s}px ${r};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.${Zn} .${Zn} {
|
|
28
|
+
right: 0 ${r};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.${Qn} .${Qn} {
|
|
32
|
+
margin-right: 0 ${r};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
body[${Er}] {
|
|
36
|
+
${er}: ${s}px;
|
|
37
|
+
}
|
|
38
|
+
`},Or=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},kr=function(){N.useEffect(function(){return document.body.setAttribute(Er,(Or()+1).toString()),function(){var e=Or()-1;e<=0?document.body.removeAttribute(Er):document.body.setAttribute(Er,e.toString())}},[])},Ar=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;kr();var a=N.useMemo(function(){return wr(i)},[i]);return N.createElement(Tr,{styles:Dr(a,!t,i,n?``:`!important`)})},jr=!1;if(typeof window<`u`)try{var Mr=Object.defineProperty({},"passive",{get:function(){return jr=!0,!0}});window.addEventListener(`test`,Mr,Mr),window.removeEventListener(`test`,Mr,Mr)}catch{jr=!1}var Nr=jr?{passive:!1}:!1,Pr=function(e){return e.tagName===`TEXTAREA`},Fr=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!Pr(e)&&n[t]===`visible`)},Ir=function(e){return Fr(e,`overflowY`)},Lr=function(e){return Fr(e,`overflowX`)},Rr=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),Vr(e,r)){var i=Hr(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},zr=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},Br=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},Vr=function(e,t){return e===`v`?Ir(t):Lr(t)},Hr=function(e,t){return e===`v`?zr(t):Br(t)},Ur=function(e,t){return e===`h`&&t===`rtl`?-1:1},Wr=function(e,t,n,r,i){var a=Ur(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=Hr(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&Vr(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},Gr=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},Kr=function(e){return[e.deltaX,e.deltaY]},qr=function(e){return e&&`current`in e?e.current:e},Jr=function(e,t){return e[0]===t[0]&&e[1]===t[1]},Yr=function(e){return`
|
|
39
|
+
.block-interactivity-${e} {pointer-events: none;}
|
|
40
|
+
.allow-interactivity-${e} {pointer-events: all;}
|
|
41
|
+
`},Xr=0,Zr=[];function Qr(e){var t=N.useRef([]),n=N.useRef([0,0]),r=N.useRef(),i=N.useState(Xr++)[0],a=N.useState(br)[0],o=N.useRef(e);N.useEffect(function(){o.current=e},[e]),N.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Xn([e.lockRef.current],(e.shards||[]).map(qr),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=N.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=Gr(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=Rr(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=Rr(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return Wr(h,t,e,h===`h`?s:c,!0)},[]),c=N.useCallback(function(e){var n=e;if(Zr.length&&Zr[Zr.length-1]===a){var r=`deltaY`in n?Kr(n):Gr(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&Jr(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(qr).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=N.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:$r(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=N.useCallback(function(e){n.current=Gr(e),r.current=void 0},[]),d=N.useCallback(function(t){l(t.type,Kr(t),t.target,s(t,e.lockRef.current))},[]),f=N.useCallback(function(t){l(t.type,Gr(t),t.target,s(t,e.lockRef.current))},[]);N.useEffect(function(){return Zr.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Nr),document.addEventListener(`touchmove`,c,Nr),document.addEventListener(`touchstart`,u,Nr),function(){Zr=Zr.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Nr),document.removeEventListener(`touchmove`,c,Nr),document.removeEventListener(`touchstart`,u,Nr)}},[]);var p=e.removeScrollBar,m=e.inert;return N.createElement(N.Fragment,null,m?N.createElement(a,{styles:Yr(i)}):null,p?N.createElement(Ar,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function $r(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var ei=ur(dr,Qr),ti=N.forwardRef(function(e,t){return N.createElement(pr,Jn({},e,{ref:t,sideCar:ei}))});ti.classNames=pr.classNames;var ni=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},ri=new WeakMap,ii=new WeakMap,ai={},oi=0,si=function(e){return e&&(e.host||si(e.parentNode))},ci=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=si(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},li=function(e,t,n,r){var i=ci(t,Array.isArray(e)?e:[e]);ai[n]||(ai[n]=new WeakMap);var a=ai[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(ri.get(e)||0)+1,l=(a.get(e)||0)+1;ri.set(e,c),a.set(e,l),o.push(e),c===1&&i&&ii.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),oi++,function(){o.forEach(function(e){var t=ri.get(e)-1,i=a.get(e)-1;ri.set(e,t),a.set(e,i),t||(ii.has(e)||e.removeAttribute(r),ii.delete(e)),i||e.removeAttribute(n)}),oi--,oi||(ri=new WeakMap,ri=new WeakMap,ii=new WeakMap,ai={})}},ui=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||ni(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),li(r,i,n,`aria-hidden`)):function(){return null}},di=Object.defineProperty,fi=(e,t)=>di(e,`name`,{value:t,configurable:!0}),pi=`Dialog`,[mi,hi]=He(pi),[gi,_i]=mi(pi),vi=fi(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=N.useRef(null),c=N.useRef(null),[l,u]=yt({prop:r,defaultProp:i??!1,onChange:a,caller:pi}),[d,f]=N.useState(0),[p,m]=N.useState(0);return(0,P.jsx)(gi,{scope:t,triggerRef:s,contentRef:c,contentId:Lt(),titleId:Lt(),descriptionId:Lt(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:N.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),yi=`DialogTrigger`,bi=N.forwardRef(fi(function(e,t){let{__scopeDialog:n,...r}=e,i=_i(yi,n),a=d(t,i.triggerRef);return(0,P.jsx)(f.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":Ri(i.open),...r,ref:a,onClick:F(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),xi=`DialogPortal`,[Si,Ci]=mi(xi,{forceMount:void 0}),wi=fi(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=_i(xi,t);return(0,P.jsx)(Si,{scope:t,forceMount:n,children:N.Children.map(r,e=>(0,P.jsx)(Dt,{present:n||a.open,children:(0,P.jsx)(Bn,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Ti=`DialogOverlay`,Ei=N.forwardRef(fi(function(e,t){let n=Ci(Ti,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=_i(Ti,e.__scopeDialog);return a.modal?(0,P.jsx)(Dt,{present:r||a.open,children:(0,P.jsx)(Oi,{...i,ref:t})}):null},`DialogOverlay`)),Di=h(`DialogOverlay.RemoveScroll`),Oi=N.forwardRef(fi(function(e,t){let{__scopeDialog:n,...r}=e,i=_i(Ti,n),a=hn(),o=d(t,a);return(0,P.jsx)(ti,{as:Di,allowPinchZoom:!0,shards:[i.contentRef],children:(0,P.jsx)(f.div,{"data-state":Ri(i.open),...r,ref:o,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),ki=`DialogContent`,Ai=N.forwardRef(fi(function(e,t){let n=Ci(ki,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=_i(ki,e.__scopeDialog);return(0,P.jsx)(Dt,{present:r||a.open,children:a.modal?(0,P.jsx)(ji,{...i,ref:t}):(0,P.jsx)(Mi,{...i,ref:t})})},`DialogContent`)),ji=N.forwardRef(fi(function(e,t){let n=_i(ki,e.__scopeDialog),r=N.useRef(null),i=d(t,n.contentRef,r);return N.useEffect(()=>{let e=r.current;if(e)return ui(e)},[]),(0,P.jsx)(Ni,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:F(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:F(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:F(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Mi=N.forwardRef(fi(function(e,t){let n=_i(ki,e.__scopeDialog),r=N.useRef(!1),i=N.useRef(!1);return(0,P.jsx)(Ni,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Ni=N.forwardRef(fi(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=_i(ki,n);return Kn(),(0,P.jsx)(P.Fragment,{children:(0,P.jsx)(En,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,P.jsx)(mn,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":Ri(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),Pi=`DialogTitle`,Fi=N.forwardRef(fi(function(e,t){let{__scopeDialog:n,...r}=e,i=_i(Pi,n),{setTitleCount:a}=i;return ut(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,P.jsx)(f.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),Ii=`DialogClose`,Li=N.forwardRef(fi(function(e,t){let{__scopeDialog:n,...r}=e,i=_i(Ii,n);return(0,P.jsx)(f.button,{type:`button`,...r,ref:t,onClick:F(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function Ri(e){return e?`open`:`closed`}fi(Ri,`getState`);var zi=Object.defineProperty,Bi=(e,t)=>zi(e,`name`,{value:t,configurable:!0}),Vi=`Avatar`,[Hi,Ui]=He(Vi),Wi=[0,()=>void 0],[Gi,Ki]=Hi(Vi),qi=N.forwardRef(Bi(function(e,t){let{__scopeAvatar:n,...r}=e,[i,a]=N.useState(`idle`),[o,s]=ea();return(0,P.jsx)(Gi,{scope:n,imageLoadingStatus:i,setImageLoadingStatus:a,imageCount:o,setImageCount:s,children:(0,P.jsx)(f.span,{...r,ref:t})})},`Avatar`)),Ji=`AvatarImage`,Yi=N.forwardRef(Bi(function(e,t){let{__scopeAvatar:n,src:r,onLoadingStatusChange:i,...a}=e,o=Ki(Ji,n);o.setImageCount;let s=Qi(r,{referrerPolicy:a.referrerPolicy,crossOrigin:a.crossOrigin,loadingStatus:o.imageLoadingStatus,setLoadingStatus:o.setImageLoadingStatus}),c=on(e=>{i?.(e)}),l=N.useRef(s);return ut(()=>{let e=l.current;l.current=s,s!==e&&c(s)},[s,c]),s===`loaded`?(0,P.jsx)(f.img,{...a,ref:t,src:r}):null},`AvatarImage`)),Xi=`AvatarFallback`,Zi=N.forwardRef(Bi(function(e,t){let{__scopeAvatar:n,delayMs:r,...i}=e,a=Ki(Xi,n),[o,s]=N.useState(r===void 0);return N.useEffect(()=>{if(r!==void 0){let e=window.setTimeout(()=>s(!0),r);return()=>window.clearTimeout(e)}},[r]),o&&a.imageLoadingStatus!==`loaded`?(0,P.jsx)(f.span,{...i,ref:t}):null},`AvatarFallback`));function Qi(e,{loadingStatus:t,setLoadingStatus:n,referrerPolicy:r,crossOrigin:i}){return ut(()=>{if(!e){n(`error`);return}let t=new window.Image,a=Bi(e=>{let t=e.currentTarget;n($i(t))},`handleLoad`),o=Bi(()=>n(`error`),`handleError`);return t.addEventListener(`load`,a),t.addEventListener(`error`,o),r&&(t.referrerPolicy=r),t.crossOrigin=i??null,t.src=e,n($i(t)),()=>{t.removeEventListener(`load`,a),t.removeEventListener(`error`,o),n(`idle`)}},[e,i,r,n]),t}Bi(Qi,`useImageLoadingStatus`);function $i(e){return e.complete?e.naturalWidth>0?`loaded`:`error`:`loading`}Bi($i,`getImageLoadingStatus`);function ea(){return Wi}Bi(ea,`useImageCount`);function ta(e){}Bi(ta,`useUpdateImageCount`);var na=Object.defineProperty,ra=(e,t)=>na(e,`name`,{value:t,configurable:!0});function ia(e){let[t,n]=N.useState(void 0);return ut(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}n(void 0)},[e]),t}ra(ia,`useSize`);var aa=[`top`,`right`,`bottom`,`left`],oa=Math.min,sa=Math.max,ca=Math.round,la=Math.floor,ua=e=>({x:e,y:e}),da={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function fa(e,t,n){return sa(e,oa(t,n))}function pa(e,t){return typeof e==`function`?e(t):e}function ma(e){return e.split(`-`)[0]}function ha(e){return e.split(`-`)[1]}function ga(e){return e===`x`?`y`:`x`}function _a(e){return e===`y`?`height`:`width`}function va(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function ya(e){return ga(va(e))}function ba(e,t,n){n===void 0&&(n=!1);let r=ha(e),i=ya(e),a=_a(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=ka(o)),[o,ka(o)]}function xa(e){let t=ka(e);return[Sa(e),t,Sa(t)]}function Sa(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var Ca=[`left`,`right`],wa=[`right`,`left`],Ta=[`top`,`bottom`],Ea=[`bottom`,`top`];function Da(e,t,n){switch(e){case`top`:case`bottom`:return n?t?wa:Ca:t?Ca:wa;case`left`:case`right`:return t?Ta:Ea;default:return[]}}function Oa(e,t,n,r){let i=ha(e),a=Da(ma(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(Sa)))),a}function ka(e){let t=ma(e);return da[t]+e.slice(t.length)}function Aa(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ja(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Aa(e)}function Ma(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function Na(e,t,n){let{reference:r,floating:i}=e,a=va(t),o=ya(t),s=_a(o),c=ma(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=ha(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Pa(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=pa(t,e),p=ja(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Ma(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=Ma(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var Fa=50,Ia=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Pa},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Na(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<Fa&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=Na(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},La=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=pa(e,t)||{};if(l==null)return{};let d=ja(u),f={x:n,y:r},p=ya(i),m=_a(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=oa(d[_],T),D=oa(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=fa(E,k,O),j=!c.arrow&&ha(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),Ra=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=pa(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=ma(r),_=va(o),v=ma(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[ka(o)]:xa(o)),x=p!==`none`;!d&&x&&b.push(...Oa(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=ba(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(u!==`alignment`||_===va(t)||T.every(e=>va(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=va(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function za(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Ba(e){return aa.some(t=>e[t]>=0)}var Va=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=pa(e,t);switch(i){case`referenceHidden`:{let e=za(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Ba(e)}}}case`escaped`:{let e=za(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Ba(e)}}}default:return{}}}}},Ha=new Set([`left`,`top`]);async function Ua(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ma(n),s=ha(n),c=va(n)===`y`,l=Ha.has(o)?-1:1,u=a&&c?-1:1,d=pa(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Wa=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Ua(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Ga=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=pa(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=va(i),p=ga(f),m=u[p],h=u[f],g=(e,t)=>fa(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Ka=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=pa(e,t),u={x:n,y:r},d=va(i),f=ga(d),p=u[f],m=u[d],h=pa(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Ha.has(ma(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},qa=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=pa(e,t),c=await i.detectOverflow(t,s),l=ma(n),u=ha(n),d=va(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=oa(p-c[m],g),y=oa(f-c[h],_),b=t.middlewareData.shift,x=!b,S=v,C=y;b!=null&&b.enabled.x&&(C=_),b!=null&&b.enabled.y&&(S=g),x&&!u&&(d?C=f-2*sa(c.left,c.right):S=p-2*sa(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Ja(){return typeof window<`u`}function Ya(e){return Qa(e)?(e.nodeName||``).toLowerCase():`#document`}function Xa(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Za(e){return((Qa(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Qa(e){return Ja()?e instanceof Node||e instanceof Xa(e).Node:!1}function $a(e){return Ja()?e instanceof Element||e instanceof Xa(e).Element:!1}function eo(e){return Ja()?e instanceof HTMLElement||e instanceof Xa(e).HTMLElement:!1}function to(e){return!Ja()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Xa(e).ShadowRoot}function no(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=mo(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ro(e){return/^(table|td|th)$/.test(Ya(e))}function io(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ao=/transform|translate|scale|rotate|perspective|filter/,oo=/paint|layout|strict|content/,so=e=>!!e&&e!==`none`,co;function lo(e){let t=$a(e)?mo(e):e;return so(t.transform)||so(t.translate)||so(t.scale)||so(t.rotate)||so(t.perspective)||!fo()&&(so(t.backdropFilter)||so(t.filter))||ao.test(t.willChange||``)||oo.test(t.contain||``)}function uo(e){let t=go(e);for(;eo(t)&&!po(t);){if(lo(t))return t;if(io(t))return null;t=go(t)}return null}function fo(){return co??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),co}function po(e){return/^(html|body|#document)$/.test(Ya(e))}function mo(e){return Xa(e).getComputedStyle(e)}function ho(e){return $a(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function go(e){if(Ya(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||to(e)&&e.host||Za(e);return to(t)?t.host:t}function _o(e){let t=go(e);return po(t)?(e.ownerDocument||e).body:eo(t)&&no(t)?t:_o(t)}function vo(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=_o(e),i=r===e.ownerDocument?.body,a=Xa(r);if(i){let e=yo(a);return t.concat(a,a.visualViewport||[],no(r)?r:[],e&&n?vo(e):[])}return t.concat(r,vo(r,[],n))}function yo(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function bo(e){let t=mo(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=eo(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ca(n)!==a||ca(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function xo(e){return $a(e)?e:e.contextElement}function So(e){let t=xo(e);if(!eo(t))return ua(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=bo(t),o=(a?ca(n.width):n.width)/r,s=(a?ca(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Co=ua(0);function wo(e){let t=Xa(e);return!fo()||!t.visualViewport?Co:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function To(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===Xa(e)}function Eo(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=xo(e),o=ua(1);t&&(r?$a(r)&&(o=So(r)):o=So(e));let s=To(a,n,r)?wo(a):ua(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=Xa(a),t=$a(r)?Xa(r):r,n=e,i=yo(n);for(;i&&t!==n;){let e=So(i),t=i.getBoundingClientRect(),r=mo(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=Xa(i),i=yo(n)}}return Ma({width:u,height:d,x:c,y:l})}function Do(e,t){let n=ho(e).scrollLeft;return t?t.left+n:Eo(Za(e)).left+n}function Oo(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Do(e,n),y:n.top+t.scrollTop}}function ko(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Za(r),s=t?io(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=ua(1),u=ua(0),d=eo(r);if((d||!a)&&((Ya(r)!==`body`||no(o))&&(c=ho(r)),d)){let e=Eo(r);l=So(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Oo(o,c):ua(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ao(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function jo(e){let t=ho(e),n=e.ownerDocument.body,r=sa(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=sa(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+Do(e),o=-t.scrollTop;return mo(n).direction===`rtl`&&(a+=sa(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var Mo=25;function No(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=Xa(e),a=Za(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!fo()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(Do(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=Mo&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Po(e,t){let n=Eo(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=So(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Fo(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=No(e,n,t);else if(t===`document`)r=jo(Za(e));else if($a(t))r=Po(t,n);else{let n=wo(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Ma(r)}function Io(e,t){let n=t.get(e);if(n)return n;let r=vo(e,[],!1).filter(e=>$a(e)&&Ya(e)!==`body`),i=null,a=mo(e).position===`fixed`,o=a?go(e):e;for(;$a(o)&&!po(o);){let e=mo(o),t=lo(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=go(o)}return t.set(e,r),r}function Lo(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?io(t)?[]:Io(t,this._c):[].concat(n),r],o=Fo(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Fo(t,a[e],i);s=sa(n.top,s),c=oa(n.right,c),l=oa(n.bottom,l),u=sa(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Ro(e){let{width:t,height:n}=bo(e);return{width:t,height:n}}function zo(e,t,n){let r=eo(t),i=Za(t),a=n===`fixed`,o=Eo(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=ua(0);if((r||!a)&&((Ya(t)!==`body`||no(i))&&(s=ho(t)),r)){let e=Eo(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=Do(i));let l=i&&!r&&!a?Oo(i,s):ua(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function Bo(e){return mo(e).position===`static`}function Vo(e,t){if(!eo(e)||mo(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Za(e)===n&&(n=n.ownerDocument.body),n}function Ho(e,t){let n=Xa(e);if(io(e))return n;if(!eo(e)){let t=go(e);for(;t&&!po(t);){if($a(t)&&!Bo(t))return t;t=go(t)}return n}let r=Vo(e,t);for(;r&&ro(r)&&Bo(r);)r=Vo(r,t);return r&&po(r)&&Bo(r)&&!lo(r)?n:r||uo(e)||n}var Uo=async function(e){let t=this.getOffsetParent||Ho,n=this.getDimensions,r=await n(e.floating);return{reference:zo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Wo(e){return mo(e).direction===`rtl`}var Go={convertOffsetParentRelativeRectToViewportRelativeRect:ko,getDocumentElement:Za,getClippingRect:Lo,getOffsetParent:Ho,getElementRects:Uo,getClientRects:Ao,getDimensions:Ro,getScale:So,isElement:$a,isRTL:Wo};function Ko(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function qo(e,t,n){let r=null,i,a=Za(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=la(d),h=la(a.clientWidth-(u+f)),g=la(a.clientHeight-(d+p)),_=la(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:sa(0,oa(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Ko(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(b,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(b,v)}r.observe(e)}let c=Xa(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Jo(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=xo(e),u=i||a?[...l?vo(l):[],...t?vo(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?qo(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Eo(e):null;c&&g();function g(){let t=Eo(e);h&&!Ko(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var Yo=Wa,Xo=Ga,Zo=Ra,Qo=qa,$o=Va,es=La,ts=Ka,ns=(e,t,n)=>{let r=new Map,i=n??{},a={...Go,...i.platform,_c:r};return Ia(e,t,{...i,platform:a})},rs=typeof document<`u`?N.useLayoutEffect:function(){};function is(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!is(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!is(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function as(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function os(e,t){let n=as(e);return Math.round(t*n)/n}function ss(e){let t=N.useRef(e);return rs(()=>{t.current=e}),t}function cs(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=N.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=N.useState(r);is(f,r)||p(r);let[m,h]=N.useState(null),[g,_]=N.useState(null),v=N.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=N.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=N.useRef(null),C=N.useRef(null),w=N.useRef(u),T=c!=null,E=ss(c),D=ss(i),O=ss(l),k=N.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),ns(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!is(w.current,t)&&(w.current=t,Rn.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);rs(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=N.useRef(!1);rs(()=>(A.current=!0,()=>{A.current=!1}),[]),rs(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=N.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=N.useMemo(()=>({reference:b,floating:x}),[b,x]),ee=N.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=os(M.floating,u.x),r=os(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...as(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return N.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:ee}),[u,k,j,M,ee])}var ls=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:es({element:r.current,padding:i}).fn(n):r?es({element:r,padding:i}).fn(n):{}}}},us=(e,t)=>{let n=Yo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ds=(e,t)=>{let n=Xo(e);return{name:n.name,fn:n.fn,options:[e,t]}},fs=(e,t)=>({fn:ts(e).fn,options:[e,t]}),ps=(e,t)=>{let n=Zo(e);return{name:n.name,fn:n.fn,options:[e,t]}},ms=(e,t)=>{let n=Qo(e);return{name:n.name,fn:n.fn,options:[e,t]}},hs=(e,t)=>{let n=$o(e);return{name:n.name,fn:n.fn,options:[e,t]}},gs=(e,t)=>{let n=ls(e);return{name:n.name,fn:n.fn,options:[e,t]}},_s=Object.defineProperty,vs=N.forwardRef(((e,t)=>_s(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,P.jsx)(f.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,P.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),ys=Object.defineProperty,bs=(e,t)=>ys(e,`name`,{value:t,configurable:!0}),xs=`Popper`,[Ss,Cs]=He(xs),[ws,Ts]=Ss(xs),Es=bs(e=>{let{__scopePopper:t,children:n}=e,[r,i]=N.useState(null),[a,o]=N.useState(void 0);return(0,P.jsx)(ws,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Ds=`PopperAnchor`,Os=N.forwardRef(bs(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Ts(Ds,n),o=N.useRef(null),s=a.onAnchorChange,c=N.useCallback(e=>{o.current=e,e&&s(e)},[s]),l=d(t,c),u=N.useRef(null);N.useEffect(()=>{if(!r)return;let e=u.current;u.current=r.current,e!==u.current&&s(u.current)});let p=a.placementState&&Rs(a.placementState),m=p?.[0],h=p?.[1];return r?null:(0,P.jsx)(f.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...i,ref:l})},`PopperAnchor`)),ks=`PopperContent`,[As,js]=Ss(ks),Ms=N.forwardRef(bs(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:p=`partial`,hideWhenDetached:m=!1,updatePositionStrategy:h=`optimized`,onPlaced:g,..._}=e,v=Ts(ks,n),[y,b]=N.useState(null),x=d(t,b),[S,C]=N.useState(null),w=ia(S),T=w?.width??0,E=w?.height??0,D=r+(a===`center`?``:`-`+a),O=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},k=Array.isArray(l)?l:[l],A=k.length>0,j={padding:O,boundary:k.filter(Is),altBoundary:A},{refs:M,floatingStyles:ee,placement:te,isPositioned:ne,middlewareData:re}=cs({strategy:`fixed`,placement:D,whileElementsMounted:bs((...e)=>Jo(...e,{animationFrame:h===`always`}),`whileElementsMounted`),elements:{reference:v.anchor},middleware:[us({mainAxis:i+E,alignmentAxis:o}),c&&ds({mainAxis:!0,crossAxis:!1,limiter:p===`partial`?fs():void 0,...j}),c&&ps({...j}),ms({...j,apply:bs(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),S&&gs({element:S,padding:s}),Ls({arrowWidth:T,arrowHeight:E}),m&&hs({strategy:`referenceHidden`,...j,boundary:A?j.boundary:void 0})]}),ie=v.setPlacementState;ut(()=>(ie(te),()=>{ie(void 0)}),[te,ie]);let[ae,oe]=Rs(te),se=on(g);ut(()=>{ne&&se?.()},[ne,se]);let ce=re.arrow?.x,le=re.arrow?.y,ue=re.arrow?.centerOffset!==0,[de,fe]=N.useState();return ut(()=>{y&&fe(window.getComputedStyle(y).zIndex)},[y]),(0,P.jsx)(`div`,{ref:M.setFloating,"data-radix-popper-content-wrapper":``,style:{...ee,transform:ne?ee.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:de,"--radix-popper-transform-origin":[re.transformOrigin?.x,re.transformOrigin?.y].join(` `),...re.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,P.jsx)(As,{scope:n,placedSide:ae,placedAlign:oe,onArrowChange:C,arrowX:ce,arrowY:le,shouldHideArrow:ue,children:(0,P.jsx)(f.div,{"data-side":ae,"data-align":oe,..._,ref:x,style:{..._.style,animation:ne?_.style?.animation:`none`}})})})},`PopperContent`)),Ns=`PopperArrow`,Ps={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Fs=N.forwardRef(bs(function(e,t){let{__scopePopper:n,...r}=e,i=js(Ns,n),a=Ps[i.placedSide];return(0,P.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,P.jsx)(vs,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function Is(e){return e!==null}bs(Is,`isNotNull`);var Ls=bs(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Rs(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Rs(e){let[t,n=`center`]=e.split(`-`);return[t,n]}bs(Rs,`getSideAndAlignFromPlacement`);var zs=Es,Bs=Os,Vs=Ms,Hs=Fs,Us=Object.defineProperty,Ws=(e,t)=>Us(e,`name`,{value:t,configurable:!0}),Gs=!1;function Ks(){let[e,t]=N.useState(Gs);return N.useEffect(()=>{Gs||(Gs=!0,t(!0))},[]),e}Ws(Ks,`useIsHydrated`);var qs=N.useSyncExternalStore;function Js(){return()=>{}}Ws(Js,`subscribe`);function Ys(){return qs(Js,()=>!0,()=>!1)}Ws(Ys,`useIsHydratedModern`);var Xs=typeof qs==`function`?Ys:Ks,Zs=Object.defineProperty,Qs=(e,t)=>Zs(e,`name`,{value:t,configurable:!0}),$s=`rovingFocusGroup.onEntryFocus`,ec={bubbles:!1,cancelable:!0},tc=`RovingFocusGroup`,[nc,rc,ic]=Ke(tc),[ac,oc]=He(tc,[ic]),[sc,cc]=ac(tc),lc=N.forwardRef(Qs(function(e,t){return(0,P.jsx)(nc.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,P.jsx)(nc.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,P.jsx)(uc,{...e,ref:t})})})},`RovingFocusGroup`)),uc=N.forwardRef(Qs(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...p}=e,m=N.useRef(null),h=d(t,m),g=nn(a),[_,v]=yt({prop:o,defaultProp:s??null,onChange:c,caller:tc}),[y,b]=N.useState(!1),x=on(l),S=rc(n),C=N.useRef(!1),[w,T]=N.useState(0);return N.useEffect(()=>{let e=m.current;if(e)return e.addEventListener($s,x),()=>e.removeEventListener($s,x)},[x]),(0,P.jsx)(sc,{scope:n,orientation:r,dir:g,loop:i,currentTabStopId:_,onItemFocus:N.useCallback(e=>v(e),[v]),onItemShiftTab:N.useCallback(()=>b(!0),[]),onFocusableItemAdd:N.useCallback(()=>T(e=>e+1),[]),onFocusableItemRemove:N.useCallback(()=>T(e=>e-1),[]),children:(0,P.jsx)(f.div,{tabIndex:y||w===0?-1:0,"data-orientation":r,...p,ref:h,style:{outline:`none`,...e.style},onMouseDown:F(e.onMouseDown,()=>{C.current=!0}),onFocus:F(e.onFocus,e=>{let t=!C.current;if(e.target===e.currentTarget&&t&&!y){let t=new CustomEvent($s,ec);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=S().filter(e=>e.focusable);gc([e.find(e=>e.active),e.find(e=>e.id===_),...e].filter(Boolean).map(e=>e.ref.current),u)}}C.current=!1}),onBlur:F(e.onBlur,()=>b(!1))})})},`RovingFocusGroupImpl`)),dc=`RovingFocusGroupItem`,fc=N.forwardRef(Qs(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Lt(),l=a||c,u=cc(dc,n),d=u.currentTabStopId===l,p=rc(n),{onFocusableItemAdd:m,onFocusableItemRemove:h,currentTabStopId:g}=u,_=Xs();return ut(()=>{if(_&&r)return m(),()=>h()},[_,r,m,h]),N.useEffect(()=>{if(!_&&r)return m(),()=>h()},[_,r,m,h]),(0,P.jsx)(nc.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,P.jsx)(f.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:F(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:F(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:F(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=hc(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=p().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?_c(n,r+1):n.slice(r+1)}setTimeout(()=>gc(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:g!=null}):o})})},`RovingFocusGroupItem`)),pc={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function mc(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}Qs(mc,`getDirectionAwareKey`);function hc(e,t,n){let r=mc(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return pc[r]}Qs(hc,`getFocusIntent`);function gc(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Qs(gc,`focusFirst`);function _c(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Qs(_c,`wrapArray`);var vc=lc,yc=fc,bc=Object.defineProperty,xc=(e,t)=>bc(e,`name`,{value:t,configurable:!0}),Sc=[`Enter`,` `],Cc=[`ArrowDown`,`PageUp`,`Home`],wc=[`ArrowUp`,`PageDown`,`End`],Tc=[...Cc,...wc],Ec={ltr:[...Sc,`ArrowRight`],rtl:[...Sc,`ArrowLeft`]},Dc={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},Oc=`Menu`,[kc,Ac,jc]=Ke(Oc),[Mc,Nc]=He(Oc,[jc,Cs,oc]),Pc=Cs(),Fc=oc(),[Ic,Lc]=Mc(Oc),[Rc,zc]=Mc(Oc),Bc=xc(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=Pc(t),[c,l]=N.useState(null),u=N.useRef(!1),d=on(a),f=nn(i);return N.useEffect(()=>{let e=xc(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=xc(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),N.useEffect(()=>{if(!n)return;let e=xc(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,P.jsx)(zs,{...s,children:(0,P.jsx)(Ic,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,P.jsx)(Rc,{scope:t,onClose:N.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),Vc=N.forwardRef(xc(function(e,t){let{__scopeMenu:n,...r}=e,i=Pc(n);return(0,P.jsx)(Bs,{...i,...r,ref:t})},`MenuAnchor`)),Hc=`MenuPortal`,[Uc,Wc]=Mc(Hc,{forceMount:void 0}),Gc=xc(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=Lc(Hc,t);return(0,P.jsx)(Uc,{scope:t,forceMount:n,children:(0,P.jsx)(Dt,{present:n||a.open,children:(0,P.jsx)(Bn,{asChild:!0,container:i,children:r})})})},`MenuPortal`),Kc=`MenuContent`,[qc,Jc]=Mc(Kc),Yc=N.forwardRef(xc(function(e,t){let n=Wc(Kc,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=Lc(Kc,e.__scopeMenu),o=zc(Kc,e.__scopeMenu);return(0,P.jsx)(kc.Provider,{scope:e.__scopeMenu,children:(0,P.jsx)(Dt,{present:r||a.open,children:(0,P.jsx)(kc.Slot,{scope:e.__scopeMenu,children:o.modal?(0,P.jsx)(Xc,{...i,ref:t}):(0,P.jsx)(Zc,{...i,ref:t})})})})},`MenuContent`)),Xc=N.forwardRef(xc(function(e,t){let n=Lc(Kc,e.__scopeMenu),r=N.useRef(null),i=d(t,r);return N.useEffect(()=>{let e=r.current;if(e)return ui(e)},[]),(0,P.jsx)($c,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:F(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Zc=N.forwardRef(xc(function(e,t){let n=Lc(Kc,e.__scopeMenu);return(0,P.jsx)($c,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Qc=h(`MenuContent.ScrollLock`),$c=N.forwardRef(xc(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=Lc(Kc,n),v=zc(Kc,n),y=Pc(n),b=Fc(n),x=Ac(n),[S,C]=N.useState(null),w=N.useRef(null),T=d(t,w,_.onContentChange),E=N.useRef(0),D=N.useRef(``),O=N.useRef(0),k=N.useRef(null),A=N.useRef(`right`),j=N.useRef(0),M=h?ti:N.Fragment,ee=h?{as:Qc,allowPinchZoom:!0}:void 0,te=xc(e=>{let t=D.current+e,n=x().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=jl(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;xc((function e(t){D.current=t,window.clearTimeout(E.current),t!==``&&(E.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);N.useEffect(()=>()=>window.clearTimeout(E.current),[]),Kn();let ne=N.useCallback(e=>A.current===k.current?.side&&Nl(e,k.current?.area),[]);return(0,P.jsx)(qc,{scope:n,searchRef:D,onItemEnter:N.useCallback(e=>{ne(e)&&e.preventDefault()},[ne]),onItemLeave:N.useCallback(e=>{ne(e)||(w.current?.focus(),C(null))},[ne]),onTriggerLeave:N.useCallback(e=>{ne(e)&&e.preventDefault()},[ne]),pointerGraceTimerRef:O,onPointerGraceIntentChange:N.useCallback(e=>{k.current=e},[]),children:(0,P.jsx)(M,{...ee,children:(0,P.jsx)(En,{asChild:!0,trapped:i,onMountAutoFocus:F(a,e=>{e.preventDefault(),w.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,P.jsx)(mn,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,P.jsx)(vc,{asChild:!0,...b,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:S,onCurrentTabStopIdChange:C,onEntryFocus:F(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,P.jsx)(Vs,{role:`menu`,"aria-orientation":`vertical`,"data-state":El(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:T,style:{outline:`none`,...g.style},onKeyDown:F(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&te(e.key));let i=w.current;if(e.target!==i||!Tc.includes(e.key))return;e.preventDefault();let a=x().filter(e=>!e.disabled).map(e=>e.ref.current);wc.includes(e.key)&&a.reverse(),kl(a)}),onBlur:F(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(E.current),D.current=``)}),onPointerMove:F(e.onPointerMove,Pl(e=>{let t=e.target,n=j.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>j.current?`right`:`left`;A.current=t,j.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),el=N.forwardRef(xc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{role:`group`,...r,ref:t})},`MenuGroup`)),tl=N.forwardRef(xc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{...r,ref:t})},`MenuLabel`)),nl=`MenuItem`,rl=`menu.itemSelect`,il=N.forwardRef(xc(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=N.useRef(null),o=zc(nl,e.__scopeMenu),s=Jc(nl,e.__scopeMenu),c=d(t,a),l=N.useRef(!1),u=xc(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(rl,{bubbles:!0,cancelable:!0});e.addEventListener(rl,e=>r?.(e),{once:!0}),v(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,P.jsx)(al,{...i,ref:c,disabled:n,onClick:F(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:F(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:F(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&Sc.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),al=N.forwardRef(xc(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Jc(nl,n),s=Fc(n),c=N.useRef(null),l=d(t,c),[u,p]=N.useState(!1),[m,h]=N.useState(``);return N.useEffect(()=>{let e=c.current;e&&h((e.textContent??``).trim())},[a.children]),(0,P.jsx)(kc.ItemSlot,{scope:n,disabled:r,textValue:i??m,children:(0,P.jsx)(yc,{asChild:!0,...s,focusable:!r,children:(0,P.jsx)(f.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:F(e.onPointerMove,Pl(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:F(e.onPointerLeave,Pl(e=>o.onItemLeave(e))),onFocus:F(e.onFocus,()=>p(!0)),onBlur:F(e.onBlur,()=>p(!1))})})})},`MenuItemImpl`)),ol=N.forwardRef(xc(function(e,t){let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,P.jsx)(pl,{scope:e.__scopeMenu,checked:n,children:(0,P.jsx)(il,{role:`menuitemcheckbox`,"aria-checked":Dl(n)?`mixed`:n,...i,ref:t,"data-state":Ol(n),onSelect:F(i.onSelect,()=>r?.(Dl(n)?!0:!n),{checkForDefaultPrevented:!1})})})},`MenuCheckboxItem`)),[sl,cl]=Mc(`MenuRadioGroup`,{value:void 0,onValueChange:xc(()=>{},`onValueChange`)}),ll=N.forwardRef(xc(function(e,t){let{value:n,onValueChange:r,...i}=e,a=on(r);return(0,P.jsx)(sl,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,P.jsx)(el,{...i,ref:t})})},`MenuRadioGroup`)),ul=`MenuRadioItem`,dl=N.forwardRef(xc(function(e,t){let{value:n,...r}=e,i=cl(ul,e.__scopeMenu),a=n===i.value;return(0,P.jsx)(pl,{scope:e.__scopeMenu,checked:a,children:(0,P.jsx)(il,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Ol(a),onSelect:F(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),fl=`MenuItemIndicator`,[pl,ml]=Mc(fl,{checked:!1}),hl=N.forwardRef(xc(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=ml(fl,n);return(0,P.jsx)(Dt,{present:r||Dl(a.checked)||a.checked===!0,children:(0,P.jsx)(f.span,{...i,ref:t,"data-state":Ol(a.checked)})})},`MenuItemIndicator`)),gl=N.forwardRef(xc(function(e,t){let{__scopeMenu:n,...r}=e;return(0,P.jsx)(f.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),_l=N.forwardRef(xc(function(e,t){let{__scopeMenu:n,...r}=e,i=Pc(n);return(0,P.jsx)(Hs,{...i,...r,ref:t})},`MenuArrow`)),vl=`MenuSub`,[yl,bl]=Mc(vl),xl=xc(e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=Lc(vl,t),o=Pc(t),[s,c]=N.useState(null),[l,u]=N.useState(null),d=on(i);return N.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,P.jsx)(zs,{...o,children:(0,P.jsx)(Ic,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,P.jsx)(yl,{scope:t,contentId:Lt(),triggerId:Lt(),trigger:s,onTriggerChange:c,children:n})})})},`MenuSub`),Sl=`MenuSubTrigger`,Cl=N.forwardRef(xc(function(e,t){let n=Lc(Sl,e.__scopeMenu),r=zc(Sl,e.__scopeMenu),i=bl(Sl,e.__scopeMenu),a=Jc(Sl,e.__scopeMenu),o=N.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=N.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);N.useEffect(()=>u,[u]),N.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let f=d(t,i.onTriggerChange);return(0,P.jsx)(Vc,{asChild:!0,...l,children:(0,P.jsx)(al,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":El(n.open),...e,ref:f,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:F(e.onPointerMove,Pl(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:F(e.onPointerLeave,Pl(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:F(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||(a.searchRef.current===``||t.key!==` `)&&Ec[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})},`MenuSubTrigger`)),wl=`MenuSubContent`,Tl=N.forwardRef(xc(function(e,t){let n=Wc(Kc,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=Lc(Kc,e.__scopeMenu),s=zc(Kc,e.__scopeMenu),c=bl(wl,e.__scopeMenu),l=N.useRef(null),u=d(t,l);return(0,P.jsx)(kc.Provider,{scope:e.__scopeMenu,children:(0,P.jsx)(Dt,{present:r||o.open,children:(0,P.jsx)(kc.Slot,{scope:e.__scopeMenu,children:(0,P.jsx)($c,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:u,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:F(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:F(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:F(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Dc[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})},`MenuSubContent`));function El(e){return e?`open`:`closed`}xc(El,`getOpenState`);function Dl(e){return e===`indeterminate`}xc(Dl,`isIndeterminate`);function Ol(e){return Dl(e)?`indeterminate`:e?`checked`:`unchecked`}xc(Ol,`getCheckedState`);function kl(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}xc(kl,`focusFirst`);function Al(e,t){return e.map((n,r)=>e[(t+r)%e.length])}xc(Al,`wrapArray`);function jl(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Al(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}xc(jl,`getNextMatch`);function Ml(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}xc(Ml,`isPointInPolygon`);function Nl(e,t){return t?Ml({x:e.clientX,y:e.clientY},t):!1}xc(Nl,`isPointerInGraceArea`);function Pl(e){return t=>t.pointerType===`mouse`?e(t):void 0}xc(Pl,`whenMouse`);var Fl=Bc,Il=Vc,Ll=Gc,Rl=Yc,zl=el,Bl=tl,Vl=il,Hl=ol,Ul=ll,Wl=dl,Gl=hl,Kl=gl,ql=_l,Jl=xl,Yl=Cl,Xl=Tl,Zl=e({Arrow:()=>Iu,CheckboxItem:()=>ju,Content:()=>Du,DropdownMenu:()=>ou,DropdownMenuArrow:()=>bu,DropdownMenuCheckboxItem:()=>hu,DropdownMenuContent:()=>du,DropdownMenuGroup:()=>fu,DropdownMenuItem:()=>mu,DropdownMenuItemIndicator:()=>vu,DropdownMenuLabel:()=>pu,DropdownMenuPortal:()=>lu,DropdownMenuRadioGroup:()=>gu,DropdownMenuRadioItem:()=>_u,DropdownMenuSeparator:()=>yu,DropdownMenuSub:()=>xu,DropdownMenuSubContent:()=>Cu,DropdownMenuSubTrigger:()=>Su,DropdownMenuTrigger:()=>cu,Group:()=>Ou,Item:()=>Au,ItemIndicator:()=>Pu,Label:()=>ku,Portal:()=>Eu,RadioGroup:()=>Mu,RadioItem:()=>Nu,Root:()=>wu,Separator:()=>Fu,Sub:()=>Lu,SubContent:()=>zu,SubTrigger:()=>Ru,Trigger:()=>Tu,createDropdownMenuScope:()=>nu}),Ql=Object.defineProperty,$l=(e,t)=>Ql(e,`name`,{value:t,configurable:!0}),eu=`DropdownMenu`,[tu,nu]=He(eu,[Nc]),ru=Nc(),[iu,au]=tu(eu),ou=$l(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=ru(t),l=N.useRef(null),[u,d]=yt({prop:i,defaultProp:a??!1,onChange:o,caller:eu});return(0,P.jsx)(iu,{scope:t,triggerId:Lt(),triggerRef:l,contentId:Lt(),open:u,onOpenChange:d,onOpenToggle:N.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,P.jsx)(Fl,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),su=`DropdownMenuTrigger`,cu=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=au(su,n),o=ru(n),s=d(t,a.triggerRef);return(0,P.jsx)(Il,{asChild:!0,...o,children:(0,P.jsx)(f.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:F(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:F(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),lu=$l(e=>{let{__scopeDropdownMenu:t,...n}=e,r=ru(t);return(0,P.jsx)(Ll,{...r,...n})},`DropdownMenuPortal`),uu=`DropdownMenuContent`,du=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=au(uu,n),a=ru(n),o=N.useRef(!1);return(0,P.jsx)(Rl,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:F(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:F(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),fu=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(n);return(0,P.jsx)(zl,{...i,...r,ref:t})},`DropdownMenuGroup`)),pu=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(n);return(0,P.jsx)(Bl,{...i,...r,ref:t})},`DropdownMenuLabel`)),mu=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(n);return(0,P.jsx)(Vl,{...i,...r,ref:t})},`DropdownMenuItem`)),hu=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(n);return(0,P.jsx)(Hl,{...i,...r,ref:t})},`DropdownMenuCheckboxItem`)),gu=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(n);return(0,P.jsx)(Ul,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),_u=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(n);return(0,P.jsx)(Wl,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),vu=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(n);return(0,P.jsx)(Gl,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),yu=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(n);return(0,P.jsx)(Kl,{...i,...r,ref:t})},`DropdownMenuSeparator`)),bu=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(n);return(0,P.jsx)(ql,{...i,...r,ref:t})},`DropdownMenuArrow`)),xu=$l(e=>{let{__scopeDropdownMenu:t,children:n,open:r,onOpenChange:i,defaultOpen:a}=e,o=ru(t),[s,c]=yt({prop:r,defaultProp:a??!1,onChange:i,caller:`DropdownMenuSub`});return(0,P.jsx)(Jl,{...o,open:s,onOpenChange:c,children:n})},`DropdownMenuSub`),Su=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(n);return(0,P.jsx)(Yl,{...i,...r,ref:t})},`DropdownMenuSubTrigger`)),Cu=N.forwardRef($l(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ru(n);return(0,P.jsx)(Xl,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuSubContent`)),wu=ou,Tu=cu,Eu=lu,Du=du,Ou=fu,ku=pu,Au=mu,ju=hu,Mu=gu,Nu=_u,Pu=vu,Fu=yu,Iu=bu,Lu=xu,Ru=Su,zu=Cu,Bu=Object.defineProperty,Vu=(e,t)=>Bu(e,`name`,{value:t,configurable:!0}),[Hu,Uu]=He(`Tooltip`,[Cs]),Wu=Cs(),Gu=`TooltipProvider`,Ku=700,qu=`tooltip.open`,[Ju,Yu]=Hu(Gu),Xu=Vu(e=>{let{__scopeTooltip:t,delayDuration:n=Ku,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=N.useRef(!0),s=N.useRef(!1),c=N.useRef(0);return N.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,P.jsx)(Ju,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:N.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:N.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:N.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),Zu=`Tooltip`,[Qu,$u]=Hu(Zu),ed=Vu(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Yu(Zu,e.__scopeTooltip),l=Wu(t),[u,d]=N.useState(null),[f,p]=N.useState(void 0),m=Lt(),h=N.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=N.useRef(!1),[y,b]=yt({prop:r,defaultProp:i??!1,onChange:Vu(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(qu))):c.onClose(),a?.(e)},`onChange`),caller:Zu}),x=N.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=N.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=N.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=N.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);N.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,P.jsx)(zs,{...l,children:(0,P.jsx)(Qu,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:N.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:N.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),td=`TooltipTrigger`,nd=N.forwardRef(Vu(function(e,t){let{__scopeTooltip:n,...r}=e,i=$u(td,n),a=Yu(td,n),o=Wu(n),s=N.useRef(null),c=d(t,s,i.onTriggerChange),l=N.useRef(!1),u=N.useRef(!1),p=N.useCallback(()=>l.current=!1,[]);return N.useEffect(()=>()=>document.removeEventListener(`pointerup`,p),[p]),(0,P.jsx)(Bs,{asChild:!0,...o,children:(0,P.jsx)(f.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:F(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:F(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:F(e.onPointerDown,()=>{i.open&&i.onClose(),l.current=!0,document.addEventListener(`pointerup`,p,{once:!0})}),onFocus:F(e.onFocus,()=>{l.current||i.onOpen()}),onBlur:F(e.onBlur,i.onClose),onClick:F(e.onClick,i.onClose)})})},`TooltipTrigger`)),rd=`TooltipPortal`,[id,ad]=Hu(rd,{forceMount:void 0}),od=Vu(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=$u(rd,t);return(0,P.jsx)(id,{scope:t,forceMount:n,children:(0,P.jsx)(Dt,{present:n||a.open,children:(0,P.jsx)(Bn,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),sd=`TooltipContent`,cd=N.forwardRef(Vu(function(e,t){let n=ad(sd,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=$u(sd,e.__scopeTooltip);return(0,P.jsx)(Dt,{present:r||o.open,children:o.disableHoverableContent?(0,P.jsx)(dd,{side:i,...a,ref:t}):(0,P.jsx)(ld,{side:i,...a,ref:t})})},`TooltipContent`)),ld=N.forwardRef(Vu(function(e,t){let n=$u(sd,e.__scopeTooltip),r=Yu(sd,e.__scopeTooltip),i=N.useRef(null),a=d(t,i),[o,s]=N.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:f}=r,p=N.useCallback(()=>{s(null),f(!1)},[f]),m=N.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=md(r,pd(r,n.getBoundingClientRect())),a=hd(t.getBoundingClientRect()),o=_d([...i,...a]);s(o),f(!0)},[f]);return N.useEffect(()=>()=>p(),[p]),N.useEffect(()=>{if(c&&u){let e=Vu(e=>m(e,u),`handleTriggerLeave`),t=Vu(e=>m(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,m,p]),N.useEffect(()=>{if(o){let e=Vu(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!gd(n,o);r?p():i&&(p(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,p]),(0,P.jsx)(dd,{...e,ref:a})},`TooltipContentHoverable`)),ud=p(`TooltipContent`),dd=N.forwardRef(Vu(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=$u(sd,n),u=Wu(n),{onClose:d}=l;N.useEffect(()=>(document.addEventListener(qu,d),()=>document.removeEventListener(qu,d)),[d]),N.useEffect(()=>{if(l.trigger){let e=Vu(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return ut(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,P.jsx)(mn,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,P.jsxs)(Vs,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,P.jsx)(ud,{children:r}),i?(0,P.jsx)(Re,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),fd=N.forwardRef(Vu(function(e,t){let{__scopeTooltip:n,...r}=e,i=Wu(n);return(0,P.jsx)(Hs,{...i,...r,ref:t})},`TooltipArrow`));function pd(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}Vu(pd,`getExitSideFromRect`);function md(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}Vu(md,`getPaddedExitPoints`);function hd(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}Vu(hd,`getPointsFromRect`);function gd(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Vu(gd,`isPointInPolygon`);function _d(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),vd(t)}Vu(_d,`getHull`);function vd(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}Vu(vd,`getHullPresorted`);var yd=Xu,bd=ed,xd=nd,Sd=od,Cd=cd,wd=fd,Td=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ed={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Dd=new class{#e=Ed;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}};function Od(e){setTimeout(e,0)}var kd=typeof window>`u`||`Deno`in globalThis;function Ad(){}function jd(e,t){return typeof e==`function`?e(t):e}function Md(e){return typeof e==`number`&&e>=0&&e!==1/0}function Nd(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Pd(e,t){return typeof e==`function`?e(t):e}function Fd(e,t){return typeof e==`function`?e(t):e}function Id(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Rd(o,t.options))return!1}else if(!Bd(t.queryKey,o))return!1}if(n!==`all`){let e=t.isActive();if(n===`active`&&!e||n===`inactive`&&e)return!1}return!(typeof s==`boolean`&&t.isStale()!==s||i&&i!==t.state.fetchStatus||a&&!a(t))}function Ld(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(zd(t.options.mutationKey)!==zd(a))return!1}else if(!Bd(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Rd(e,t){return(t?.queryKeyHashFn||zd)(e)}function zd(e){return JSON.stringify(e,(e,t)=>Gd(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Bd(e,t){return e===t?!0:typeof e==typeof t&&e&&t&&typeof e==`object`&&typeof t==`object`?Object.keys(t).every(n=>Bd(e[n],t[n])):!1}var Vd=Object.prototype.hasOwnProperty;function Hd(e,t){if(e===t)return e;let n=Wd(e)&&Wd(t);if(!n&&!(Gd(e)&&Gd(t)))return t;let r=(n?e:Object.keys(e)).length,i=n?t:Object.keys(t),a=i.length,o=n?Array(a):{},s=0;for(let c=0;c<a;c++){let a=n?c:i[c],l=e[a],u=t[a];if(l===u){o[a]=l,(n?c<r:Vd.call(e,a))&&s++;continue}if(l===null||u===null||typeof l!=`object`||typeof u!=`object`){o[a]=u;continue}let d=Hd(l,u);o[a]=d,d===l&&s++}return r===a&&s===r?e:o}function Ud(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function Wd(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Gd(e){if(!Kd(e))return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(!Kd(n)||!n.hasOwnProperty(`isPrototypeOf`)||Object.getPrototypeOf(e)!==Object.prototype)}function Kd(e){return Object.prototype.toString.call(e)===`[object Object]`}function qd(e){return new Promise(t=>{Dd.setTimeout(t,e)})}function Jd(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Hd(e,t)}function Yd(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Xd(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Zd=Symbol();function Qd(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Zd?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function $d(e,t){return typeof e==`function`?e(...t):!!e}var ef=new class extends Td{#e;#t;#n;constructor(){super(),this.#n=e=>{if(!kd&&window.addEventListener){let t=()=>e();return window.addEventListener(`visibilitychange`,t,!1),()=>{window.removeEventListener(`visibilitychange`,t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(e=>{typeof e==`boolean`?this.setFocused(e):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e==`boolean`?this.#e:globalThis.document?.visibilityState!==`hidden`}};function tf(){let e,t,n=new Promise((n,r)=>{e=n,t=r});n.status=`pending`,n.catch(()=>{});function r(e){Object.assign(n,e),delete n.resolve,delete n.reject}return n.resolve=t=>{r({status:`fulfilled`,value:t}),e(t)},n.reject=e=>{r({status:`rejected`,reason:e}),t(e)},n}var nf=Od;function rf(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=nf,a=r=>{t?e.push(r):i(()=>{n(r)})},o=()=>{let t=e;e=[],t.length&&i(()=>{r(()=>{t.forEach(e=>{n(e)})})})};return{batch:e=>{let n;t++;try{n=e()}finally{t--,t||o()}return n},batchCalls:e=>(...t)=>{a(()=>{e(...t)})},schedule:a,setNotifyFunction:e=>{n=e},setBatchNotifyFunction:e=>{r=e},setScheduler:e=>{i=e}}}var af=rf(),of=new class extends Td{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(!kd&&window.addEventListener){let t=()=>e(!0),n=()=>e(!1);return window.addEventListener(`online`,t,!1),window.addEventListener(`offline`,n,!1),()=>{window.removeEventListener(`online`,t),window.removeEventListener(`offline`,n)}}}}onSubscribe(){this.#t||this.setEventListener(this.#n)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#n=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(t=>{t(e)}))}isOnline(){return this.#e}};function sf(e){return Math.min(1e3*2**e,3e4)}function cf(e){return(e??`online`)!==`online`||of.isOnline()}var lf=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function uf(e){let t=!1,n=0,r,i=tf(),a=()=>i.status!==`pending`,o=t=>{if(!a()){let n=new lf(t);f(n),e.onCancel?.(n)}},s=()=>{t=!0},c=()=>{t=!1},l=()=>ef.isFocused()&&(e.networkMode===`always`||of.isOnline())&&e.canRun(),u=()=>cf(e.networkMode)&&e.canRun(),d=e=>{a()||(r?.(),i.resolve(e))},f=e=>{a()||(r?.(),i.reject(e))},p=()=>new Promise(t=>{r=e=>{(a()||l())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,a()||e.onContinue?.()}),m=()=>{if(a())return;let r,i=n===0?e.initialPromise:void 0;try{r=i??e.fn()}catch(e){r=Promise.reject(e)}Promise.resolve(r).then(d).catch(r=>{if(a())return;let i=e.retry??(kd?0:3),o=e.retryDelay??sf,s=typeof o==`function`?o(n,r):o,c=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!c){f(r);return}n++,e.onFail?.(n,r),qd(s).then(()=>l()?void 0:p()).then(()=>{t?f(r):m()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:s,continueRetry:c,canStart:u,start:()=>(u()?m():p().then(m),i)}}var df=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Md(this.gcTime)&&(this.#e=Dd.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(kd?1/0:3e5))}clearGcTimeout(){this.#e&&=(Dd.clearTimeout(this.#e),void 0)}},ff=class extends df{#e;#t;#n;#r;#i;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#r=e.client,this.#n=this.#r.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=mf(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#i?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=mf(this.options);e.data!==void 0&&(this.setData(e.data,{updatedAt:e.dataUpdatedAt,manual:!0}),this.#e=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#n.remove(this)}setData(e,t){let n=Jd(this.state.data,e,this.options);return this.#s({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e,t){this.#s({type:`setState`,state:e,setStateOptions:t})}cancel(e){let t=this.#i?.promise;return this.#i?.cancel(e),t?t.then(Ad).catch(Ad):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>Fd(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Zd||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Pd(e.options.staleTime,this)===`static`)}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e===`static`?!1:this.state.isInvalidated?!0:!Nd(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#i?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#i?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#i&&(this.#o?this.#i.cancel({revert:!0}):this.#i.cancelRetry()),this.scheduleGc()),this.#n.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#s({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#i?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#i)return this.#i.continueRetry(),this.#i.promise}if(e&&this.setOptions(e),!this.options.queryFn){let e=this.observers.find(e=>e.options.queryFn);e&&this.setOptions(e.options)}let n=new AbortController,r=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(this.#o=!0,n.signal)})},i=()=>{let e=Qd(this.options,t),n=(()=>{let e={client:this.#r,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#o=!1,this.options.persister?this.options.persister(e,n,this):e(n)},a=(()=>{let e={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#r,state:this.state,fetchFn:i};return r(e),e})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#s({type:`fetch`,meta:a.fetchOptions?.meta}),this.#i=uf({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof lf&&e.revert&&this.setState({...this.#t,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#s({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#s({type:`pause`})},onContinue:()=>{this.#s({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await this.#i.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#n.config.onSuccess?.(e,this),this.#n.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof lf){if(e.silent)return this.#i.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#s({type:`error`,error:e}),this.#n.config.onError?.(e,this),this.#n.config.onSettled?.(this.state.data,e,this),e}finally{this.scheduleGc()}}#s(e){let t=t=>{switch(e.type){case`failed`:return{...t,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case`pause`:return{...t,fetchStatus:`paused`};case`continue`:return{...t,fetchStatus:`fetching`};case`fetch`:return{...t,...pf(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,data:e.data,dataUpdateCount:t.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:`success`,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?n:void 0,n;case`error`:let r=e.error;return{...t,error:r,errorUpdateCount:t.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:t.fetchFailureCount+1,fetchFailureReason:r,fetchStatus:`idle`,status:`error`};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),af.batch(()=>{this.observers.forEach(e=>{e.onQueryUpdate()}),this.#n.notify({query:this,type:`updated`,action:e})})}};function pf(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:cf(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function mf(e){let t=typeof e.initialData==`function`?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt==`function`?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?`success`:`pending`,fetchStatus:`idle`}}var hf=class extends Td{constructor(e,t){super(),this.options=t,this.#e=e,this.#s=null,this.#o=tf(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),_f(this.#t,this.options)?this.#h():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return vf(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return vf(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#b(),this.#x(),this.#t.removeObserver(this)}setOptions(e){let t=this.options,n=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!=`boolean`&&typeof this.options.enabled!=`function`&&typeof Fd(this.options.enabled,this.#t)!=`boolean`)throw Error(`Expected enabled to be a boolean or a callback that returns a boolean`);this.#S(),this.#t.setOptions(this.options),t._defaulted&&!Ud(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&yf(this.#t,n,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==n||Fd(this.options.enabled,this.#t)!==Fd(t.enabled,this.#t)||Pd(this.options.staleTime,this.#t)!==Pd(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Fd(this.options.enabled,this.#t)!==Fd(t.enabled,this.#t)||i!==this.#p)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return xf(this,n)&&(this.#r=n,this.#a=this.options,this.#i=this.#t.state),n}getCurrentResult(){return this.#r}trackResult(e,t){return new Proxy(e,{get:(e,n)=>(this.trackProp(n),t?.(n),n===`promise`&&!this.options.experimental_prefetchInRender&&this.#o.status===`pending`&&this.#o.reject(Error(`experimental_prefetchInRender feature flag is not enabled`)),Reflect.get(e,n))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let t=this.#e.defaultQueryOptions(e),n=this.#e.getQueryCache().build(this.#e,t);return n.fetch().then(()=>this.createResult(n,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#h(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Ad)),t}#g(){this.#b();let e=Pd(this.options.staleTime,this.#t);if(kd||this.#r.isStale||!Md(e))return;let t=Nd(this.#r.dataUpdatedAt,e)+1;this.#d=Dd.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return(typeof this.options.refetchInterval==`function`?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#x(),this.#p=e,!kd&&Fd(this.options.enabled,this.#t)!==!1&&Md(this.#p)&&this.#p!==0&&(this.#f=Dd.setInterval(()=>{(this.options.refetchIntervalInBackground||ef.isFocused())&&this.#h()},this.#p))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#d&&=(Dd.clearTimeout(this.#d),void 0)}#x(){this.#f&&=(Dd.clearInterval(this.#f),void 0)}createResult(e,t){let n=this.#t,r=this.options,i=this.#r,a=this.#i,o=this.#a,s=e===n?this.#n:e.state,{state:c}=e,l={...c},u=!1,d;if(t._optimisticResults){let i=this.hasListeners(),a=!i&&_f(e,t),o=i&&yf(e,n,t,r);(a||o)&&(l={...l,...pf(c.data,e.options)}),t._optimisticResults===`isRestoring`&&(l.fetchStatus=`idle`)}let{error:f,errorUpdatedAt:p,status:m}=l;d=l.data;let h=!1;if(t.placeholderData!==void 0&&d===void 0&&m===`pending`){let e;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(e=i.data,h=!0):e=typeof t.placeholderData==`function`?t.placeholderData(this.#u?.state.data,this.#u):t.placeholderData,e!==void 0&&(m=`success`,d=Jd(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#c)d=this.#l;else try{this.#c=t.select,d=t.select(d),d=Jd(i?.data,d,t),this.#l=d,this.#s=null}catch(e){this.#s=e}}this.#s&&(f=this.#s,d=this.#l,p=Date.now(),m=`error`);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0,x={status:m,fetchStatus:l.fetchStatus,isPending:_,isSuccess:m===`success`,isError:v,isInitialLoading:y,isLoading:y,data:d,dataUpdatedAt:l.dataUpdatedAt,error:f,errorUpdatedAt:p,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>s.dataUpdateCount||l.errorUpdateCount>s.errorUpdateCount,isFetching:g,isRefetching:g&&!_,isLoadingError:v&&!b,isPaused:l.fetchStatus===`paused`,isPlaceholderData:u,isRefetchError:v&&b,isStale:bf(e,t),refetch:this.refetch,promise:this.#o,isEnabled:Fd(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let t=e=>{x.status===`error`?e.reject(x.error):x.data!==void 0&&e.resolve(x.data)},r=()=>{let e=this.#o=x.promise=tf();t(e)},i=this.#o;switch(i.status){case`pending`:e.queryHash===n.queryHash&&t(i);break;case`fulfilled`:(x.status===`error`||x.data!==i.value)&&r();break;case`rejected`:(x.status!==`error`||x.error!==i.reason)&&r()}}return x}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#u=this.#t),!Ud(t,e)&&(this.#r=t,this.#C({listeners:(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#m.size)return!0;let r=new Set(n??this.#m);return this.options.throwOnError&&r.add(`error`),Object.keys(this.#r).some(t=>{let n=t;return this.#r[n]!==e[n]&&r.has(n)})})()}))}#S(){let e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;let t=this.#t;this.#t=e,this.#n=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#y()}#C(e){af.batch(()=>{e.listeners&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}};function gf(e,t){return Fd(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||t.retryOnMount!==!1)}function _f(e,t){return gf(e,t)||e.state.data!==void 0&&vf(e,t,t.refetchOnMount)}function vf(e,t,n){if(Fd(t.enabled,e)!==!1&&Pd(t.staleTime,e)!==`static`){let r=typeof n==`function`?n(e):n;return r===`always`||r!==!1&&bf(e,t)}return!1}function yf(e,t,n,r){return(e!==t||Fd(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&bf(e,n)}function bf(e,t){return Fd(t.enabled,e)!==!1&&e.isStaleByTime(Pd(t.staleTime,e))}function xf(e,t){return!Ud(e.getCurrentResult(),t)}function Sf(e){return{onFetch:(t,n)=>{let r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],o=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},c=0,l=async()=>{let n=!1,l=e=>{Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(t.signal.aborted?n=!0:t.signal.addEventListener(`abort`,()=>{n=!0}),t.signal)})},u=Qd(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject();if(r==null&&e.pages.length)return Promise.resolve(e);let a=(()=>{let e={client:t.client,queryKey:t.queryKey,pageParam:r,direction:i?`backward`:`forward`,meta:t.options.meta};return l(e),e})(),o=await u(a),{maxPages:s}=t.options,c=i?Xd:Yd;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?wf:Cf,n={pages:a,pageParams:o};s=await d(n,t(r,n),e)}else{let t=e??a.length;do{let e=c===0?o[0]??r.initialPageParam:Cf(r,s);if(c>0&&e==null)break;s=await d(s,e),c++}while(c<t)}return s};t.fetchFn=t.options.persister?()=>t.options.persister?.(l,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n):l}}}function Cf(e,{pages:t,pageParams:n}){let r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function wf(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var Tf=class extends df{#e;#t;#n;constructor(e){super(),this.mutationId=e.mutationId,this.#t=e.mutationCache,this.#e=[],this.state=e.state||Ef(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#e.includes(e)||(this.#e.push(e),this.clearGcTimeout(),this.#t.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#e=this.#e.filter(t=>t!==e),this.scheduleGc(),this.#t.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#e.length||(this.state.status===`pending`?this.scheduleGc():this.#t.remove(this))}continue(){return this.#n?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#r({type:`continue`})};this.#n=uf({fn:()=>this.options.mutationFn?this.options.mutationFn(e):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#r({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#r({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#t.canRun(this)});let n=this.state.status===`pending`,r=!this.#n.canStart();try{if(n)t();else{this.#r({type:`pending`,variables:e,isPaused:r}),await this.#t.config.onMutate?.(e,this);let t=await this.options.onMutate?.(e);t!==this.state.context&&this.#r({type:`pending`,context:t,variables:e,isPaused:r})}let i=await this.#n.start();return await this.#t.config.onSuccess?.(i,e,this.state.context,this),await this.options.onSuccess?.(i,e,this.state.context),await this.#t.config.onSettled?.(i,null,this.state.variables,this.state.context,this),await this.options.onSettled?.(i,null,e,this.state.context),this.#r({type:`success`,data:i}),i}catch(t){try{throw await this.#t.config.onError?.(t,e,this.state.context,this),await this.options.onError?.(t,e,this.state.context),await this.#t.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this),await this.options.onSettled?.(void 0,t,e,this.state.context),t}finally{this.#r({type:`error`,error:t})}}finally{this.#t.runNext(this)}}#r(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),af.batch(()=>{this.#e.forEach(t=>{t.onMutationUpdate(e)}),this.#t.notify({mutation:this,type:`updated`,action:e})})}};function Ef(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Df=class extends Td{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Tf({mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Of(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Of(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Of(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=Of(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){af.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Ld(t,e))}findAll(e={}){return this.getAll().filter(t=>Ld(e,t))}notify(e){af.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return af.batch(()=>Promise.all(e.map(e=>e.continue().catch(Ad))))}};function Of(e){return e.options.scope?.id}var kf=class extends Td{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Ud(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&zd(t.mutationKey)!==zd(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??Ef();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){af.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context;e?.type===`success`?(this.#r.onSuccess?.(e.data,t,n),this.#r.onSettled?.(e.data,null,t,n)):e?.type===`error`&&(this.#r.onError?.(e.error,t,n),this.#r.onSettled?.(void 0,e.error,t,n))}this.listeners.forEach(e=>{e(this.#t)})})}},Af=class extends Td{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Rd(r,t),a=this.get(i);return a||(a=new ff({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){af.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Id(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Id(e,t)):t}notify(e){af.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){af.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){af.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},jf=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new Af,this.#t=e.mutationCache||new Df,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ef.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=of.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Pd(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=jd(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return af.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;af.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return af.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=af.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Ad).catch(Ad)}invalidateQueries(e,t={}){return af.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=af.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Ad)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Ad)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Pd(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ad).catch(Ad)}fetchInfiniteQuery(e){return e.behavior=Sf(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ad).catch(Ad)}ensureInfiniteQueryData(e){return e.behavior=Sf(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return of.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(zd(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Bd(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(zd(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Bd(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Rd(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===Zd&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Mf=N.createContext(void 0),Nf=e=>{let t=N.useContext(Mf);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Pf=({client:e,children:t})=>(N.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,P.jsx)(Mf.Provider,{value:e,children:t})),Ff=N.createContext(!1),If=()=>N.useContext(Ff);Ff.Provider;function Lf(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Rf=N.createContext(Lf()),zf=()=>N.useContext(Rf),Bf=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},Vf=e=>{N.useEffect(()=>{e.clearReset()},[e])},Hf=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||$d(n,[e.error,r])),Uf=e=>{if(e.suspense){let t=1e3,n=e=>e===`static`?e:Math.max(e??t,t),r=e.staleTime;e.staleTime=typeof r==`function`?(...e)=>n(r(...e)):n(r),typeof e.gcTime==`number`&&(e.gcTime=Math.max(e.gcTime,t))}},Wf=(e,t)=>e.isLoading&&e.isFetching&&!t,Gf=(e,t)=>e?.suspense&&t.isPending,Kf=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function qf(e,t,n){let r=If(),i=zf(),a=Nf(n),o=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?`isRestoring`:`optimistic`,Uf(o),Bf(o,i),Vf(i);let s=!a.getQueryCache().get(o.queryHash),[c]=N.useState(()=>new t(a,o)),l=c.getOptimisticResult(o),u=!r&&e.subscribed!==!1;if(N.useSyncExternalStore(N.useCallback(e=>{let t=u?c.subscribe(af.batchCalls(e)):Ad;return c.updateResult(),t},[c,u]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),N.useEffect(()=>{c.setOptions(o)},[o,c]),Gf(o,l))throw Kf(o,c,i);if(Hf({result:l,errorResetBoundary:i,throwOnError:o.throwOnError,query:a.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw l.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(o,l),o.experimental_prefetchInRender&&!kd&&Wf(l,r)&&(s?Kf(o,c,i):a.getQueryCache().get(o.queryHash)?.promise)?.catch(Ad).finally(()=>{c.updateResult()}),o.notifyOnChangeProps?l:c.trackResult(l)}function Jf(e,t){return qf(e,hf,t)}function Yf(e,t){let n=Nf(t),[r]=N.useState(()=>new kf(n,e));N.useEffect(()=>{r.setOptions(e)},[r,e]);let i=N.useSyncExternalStore(N.useCallback(e=>r.subscribe(af.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=N.useCallback((e,t)=>{r.mutate(e,t).catch(Ad)},[r]);if(i.error&&$d(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}Object.freeze({status:`aborted`});function I(e,t,n){function r(n,r){var i;Object.defineProperty(n,"_zod",{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r);for(let e in o.prototype)e in n||Object.defineProperty(n,e,{value:o.prototype[e].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var Xf=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Zf=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},Qf={};function $f(e){return e&&Object.assign(Qf,e),Qf}function ep(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function tp(e,t){return typeof t==`bigint`?t.toString():t}function np(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function rp(e){return e==null}function ip(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ap(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var op=Symbol(`evaluating`);function sp(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==op)return r===void 0&&(r=op,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function cp(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function lp(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function up(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function dp(e){return JSON.stringify(e)}var fp=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function pp(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var mp=np(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function hp(e){if(pp(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return pp(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function gp(e){return hp(e)?{...e}:Array.isArray(e)?[...e]:e}var _p=new Set([`string`,`number`,`symbol`]);function vp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function yp(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function L(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function bp(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var xp={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Sp(e,t){let n=e._zod.def;return yp(e,up(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return lp(this,`shape`,e),e},checks:[]}))}function Cp(e,t){let n=e._zod.def;return yp(e,up(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return lp(this,`shape`,r),r},checks:[]}))}function wp(e,t){if(!hp(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return yp(e,up(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return lp(this,`shape`,n),n},checks:[]}))}function Tp(e,t){if(!hp(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return yp(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return lp(this,`shape`,n),n},checks:e._zod.def.checks})}function Ep(e,t){return yp(e,up(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return lp(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Dp(e,t,n){return yp(t,up(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return lp(this,`shape`,i),i},checks:[]}))}function Op(e,t,n){return yp(t,up(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return lp(this,`shape`,i),i},checks:[]}))}function kp(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Ap(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function jp(e){return typeof e==`string`?e:e?.message}function Mp(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=jp(e.inst?._zod.def?.error?.(e))??jp(t?.error?.(e))??jp(n.customError?.(e))??jp(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Np(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Pp(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Fp=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,tp,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ip=I(`$ZodError`,Fp),Lp=I(`$ZodError`,Fp,{Parent:Error});function Rp(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function zp(e,t){let n=t||function(e){return e.message},r={_errors:[]},i=e=>{for(let t of e.issues)if(t.code===`invalid_union`&&t.errors.length)t.errors.map(e=>i({issues:e}));else if(t.code===`invalid_key`)i({issues:t.issues});else if(t.code===`invalid_element`)i({issues:t.issues});else if(t.path.length===0)r._errors.push(n(t));else{let e=r,i=0;for(;i<t.path.length;){let r=t.path[i];i===t.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(n(t))):e[r]=e[r]||{_errors:[]},e=e[r],i++}}};return i(e),r}var Bp=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new Xf;if(o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Mp(e,a,$f())));throw fp(t,i?.callee),t}return o.value},Vp=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>Mp(e,a,$f())));throw fp(t,i?.callee),t}return o.value},Hp=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Xf;return a.issues.length?{success:!1,error:new(e??Ip)(a.issues.map(e=>Mp(e,i,$f())))}:{success:!0,data:a.value}},Up=Hp(Lp),Wp=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Mp(e,i,$f())))}:{success:!0,data:a.value}},Gp=Wp(Lp),Kp=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Bp(e)(t,n,i)},qp=e=>(t,n,r)=>Bp(e)(t,n,r),Jp=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Vp(e)(t,n,i)},Yp=e=>async(t,n,r)=>Vp(e)(t,n,r),Xp=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Hp(e)(t,n,i)},Zp=e=>(t,n,r)=>Hp(e)(t,n,r),Qp=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Wp(e)(t,n,i)},$p=e=>async(t,n,r)=>Wp(e)(t,n,r),em=/^[cC][^\s-]{8,}$/,tm=/^[0-9a-z]+$/,nm=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,rm=/^[0-9a-vA-V]{20}$/,im=/^[A-Za-z0-9]{27}$/,am=/^[a-zA-Z0-9_-]{21}$/,om=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,sm=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,cm=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,lm=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,um=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function dm(){return new RegExp(um,`u`)}var fm=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,pm=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,mm=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,hm=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gm=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,_m=/^[A-Za-z0-9_-]*$/,vm=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,ym=/^\+(?:[0-9]){6,14}[0-9]$/,bm=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,xm=RegExp(`^${bm}$`);function Sm(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Cm(e){return RegExp(`^${Sm(e)}$`)}function wm(e){let t=Sm({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${bm}T(?:${r})$`)}var Tm=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Em=/^-?\d+$/,Dm=/^-?\d+(?:\.\d+)?/,Om=/^(?:true|false)$/i,km=/^null$/i,Am=/^[^A-Z]*$/,jm=/^[^a-z]*$/,Mm=I(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Nm={number:`number`,bigint:`bigint`,object:`date`},Pm=I(`$ZodCheckLessThan`,(e,t)=>{Mm.init(e,t);let n=Nm[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Fm=I(`$ZodCheckGreaterThan`,(e,t)=>{Mm.init(e,t);let n=Nm[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Im=I(`$ZodCheckMultipleOf`,(e,t)=>{Mm.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):ap(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Lm=I(`$ZodCheckNumberFormat`,(e,t)=>{Mm.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=xp[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=Em)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Rm=I(`$ZodCheckMaxLength`,(e,t)=>{var n;Mm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!rp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Np(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),zm=I(`$ZodCheckMinLength`,(e,t)=>{var n;Mm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!rp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Np(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Bm=I(`$ZodCheckLengthEquals`,(e,t)=>{var n;Mm.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!rp(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Np(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Vm=I(`$ZodCheckStringFormat`,(e,t)=>{var n,r;Mm.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Hm=I(`$ZodCheckRegex`,(e,t)=>{Vm.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Um=I(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Am,Vm.init(e,t)}),Wm=I(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=jm,Vm.init(e,t)}),Gm=I(`$ZodCheckIncludes`,(e,t)=>{Mm.init(e,t);let n=vp(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Km=I(`$ZodCheckStartsWith`,(e,t)=>{Mm.init(e,t);let n=RegExp(`^${vp(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),qm=I(`$ZodCheckEndsWith`,(e,t)=>{Mm.init(e,t);let n=RegExp(`.*${vp(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Jm=I(`$ZodCheckOverwrite`,(e,t)=>{Mm.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Ym=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
42
|
+
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
43
|
+
`))}},Xm={major:4,minor:1,patch:8},Zm=I(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Xm;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=kp(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new Xf;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=kp(e,t))});else{if(e.issues.length===t)continue;r||=kp(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(kp(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new Xf;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new Xf;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=Up(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Gp(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Qm=I(`$ZodString`,(e,t)=>{Zm.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Tm(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),$m=I(`$ZodStringFormat`,(e,t)=>{Vm.init(e,t),Qm.init(e,t)}),eh=I(`$ZodGUID`,(e,t)=>{t.pattern??=sm,$m.init(e,t)}),th=I(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=cm(e)}else t.pattern??=cm();$m.init(e,t)}),nh=I(`$ZodEmail`,(e,t)=>{t.pattern??=lm,$m.init(e,t)}),rh=I(`$ZodURL`,(e,t)=>{$m.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:vm.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),n.value=t.normalize?i.href:r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),ih=I(`$ZodEmoji`,(e,t)=>{t.pattern??=dm(),$m.init(e,t)}),ah=I(`$ZodNanoID`,(e,t)=>{t.pattern??=am,$m.init(e,t)}),oh=I(`$ZodCUID`,(e,t)=>{t.pattern??=em,$m.init(e,t)}),sh=I(`$ZodCUID2`,(e,t)=>{t.pattern??=tm,$m.init(e,t)}),ch=I(`$ZodULID`,(e,t)=>{t.pattern??=nm,$m.init(e,t)}),lh=I(`$ZodXID`,(e,t)=>{t.pattern??=rm,$m.init(e,t)}),uh=I(`$ZodKSUID`,(e,t)=>{t.pattern??=im,$m.init(e,t)}),dh=I(`$ZodISODateTime`,(e,t)=>{t.pattern??=wm(t),$m.init(e,t)}),fh=I(`$ZodISODate`,(e,t)=>{t.pattern??=xm,$m.init(e,t)}),ph=I(`$ZodISOTime`,(e,t)=>{t.pattern??=Cm(t),$m.init(e,t)}),mh=I(`$ZodISODuration`,(e,t)=>{t.pattern??=om,$m.init(e,t)}),hh=I(`$ZodIPv4`,(e,t)=>{t.pattern??=fm,$m.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),gh=I(`$ZodIPv6`,(e,t)=>{t.pattern??=pm,$m.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),_h=I(`$ZodCIDRv4`,(e,t)=>{t.pattern??=mm,$m.init(e,t)}),vh=I(`$ZodCIDRv6`,(e,t)=>{t.pattern??=hm,$m.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function yh(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var bh=I(`$ZodBase64`,(e,t)=>{t.pattern??=gm,$m.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{yh(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function xh(e){if(!_m.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return yh(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var Sh=I(`$ZodBase64URL`,(e,t)=>{t.pattern??=_m,$m.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{xh(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Ch=I(`$ZodE164`,(e,t)=>{t.pattern??=ym,$m.init(e,t)});function wh(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var Th=I(`$ZodJWT`,(e,t)=>{$m.init(e,t),e._zod.check=n=>{wh(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Eh=I(`$ZodNumber`,(e,t)=>{Zm.init(e,t),e._zod.pattern=e._zod.bag.pattern??Dm,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),Dh=I(`$ZodNumber`,(e,t)=>{Lm.init(e,t),Eh.init(e,t)}),Oh=I(`$ZodBoolean`,(e,t)=>{Zm.init(e,t),e._zod.pattern=Om,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),kh=I(`$ZodNull`,(e,t)=>{Zm.init(e,t),e._zod.pattern=km,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),Ah=I(`$ZodUnknown`,(e,t)=>{Zm.init(e,t),e._zod.parse=e=>e}),jh=I(`$ZodNever`,(e,t)=>{Zm.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Mh(e,t,n){e.issues.length&&t.issues.push(...Ap(n,e.issues)),t.value[n]=e.value}var Nh=I(`$ZodArray`,(e,t)=>{Zm.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>Mh(t,n,e))):Mh(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Ph(e,t,n,r){e.issues.length&&t.issues.push(...Ap(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Fh(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=bp(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Ih(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i of Object.keys(t)){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Ph(e,n,i,t))):Ph(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Lh=I(`$ZodObject`,(e,t)=>{Zm.init(e,t);let n=np(()=>Fh(t));sp(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=pp,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>Ph(n,t,e,s))):Ph(n,t,e,s)}return i?Ih(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Rh=I(`$ZodObjectJIT`,(e,t)=>{Lh.init(e,t);let n=e._zod.parse,r=np(()=>Fh(t)),i=e=>{let t=new Ym([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=dp(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let e of n.keys){let n=a[e],r=dp(e);t.write(`const ${n} = ${i(e)};`),t.write(`
|
|
44
|
+
if (${n}.issues.length) {
|
|
45
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
46
|
+
...iss,
|
|
47
|
+
path: iss.path ? [${r}, ...iss.path] : [${r}]
|
|
48
|
+
})));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if (${n}.value === undefined) {
|
|
53
|
+
if (${r} in input) {
|
|
54
|
+
newResult[${r}] = undefined;
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
newResult[${r}] = ${n}.value;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=pp,s=!Qf.jitless,c=s&&mp.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?Ih([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function zh(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!kp(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Mp(e,r,$f())))}),t)}var Bh=I(`$ZodUnion`,(e,t)=>{Zm.init(e,t),sp(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),sp(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),sp(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),sp(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>ip(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>zh(t,i,e,a)):zh(s,i,e,a)}}),Vh=I(`$ZodIntersection`,(e,t)=>{Zm.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Uh(e,t,n)):Uh(e,i,a)}});function Hh(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(hp(e)&&hp(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Hh(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Hh(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Uh(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),kp(e))return e;let r=Hh(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}var Wh=I(`$ZodRecord`,(e,t)=>{Zm.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!hp(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[];if(t.keyType._zod.values){let o=t.keyType._zod.values;n.value={};for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Ap(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Ap(e,o.issues)),n.value[e]=o.value)}let s;for(let e in i)o.has(e)||(s??=[],s.push(e));s&&s.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:s})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Mp(e,r,$f())),input:o,path:[o],inst:e}),n.value[s.value]=s.value;continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Ap(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Ap(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Gh=I(`$ZodEnum`,(e,t)=>{Zm.init(e,t);let n=ep(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>_p.has(typeof e)).map(e=>typeof e==`string`?vp(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Kh=I(`$ZodLiteral`,(e,t)=>{if(Zm.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);e._zod.values=new Set(t.values),e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?vp(e):e?vp(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(n,r)=>{let i=n.value;return e._zod.values.has(i)||n.issues.push({code:`invalid_value`,values:t.values,input:i,inst:e}),n}}),qh=I(`$ZodTransform`,(e,t)=>{Zm.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Zf(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Xf;return n.value=i,n}});function Jh(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var Yh=I(`$ZodOptional`,(e,t)=>{Zm.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,sp(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),sp(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ip(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Jh(t,e.value)):Jh(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Xh=I(`$ZodNullable`,(e,t)=>{Zm.init(e,t),sp(e._zod,`optin`,()=>t.innerType._zod.optin),sp(e._zod,`optout`,()=>t.innerType._zod.optout),sp(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${ip(e.source)}|null)$`):void 0}),sp(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Zh=I(`$ZodDefault`,(e,t)=>{Zm.init(e,t),e._zod.optin=`optional`,sp(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Qh(e,t)):Qh(r,t)}});function Qh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var $h=I(`$ZodPrefault`,(e,t)=>{Zm.init(e,t),e._zod.optin=`optional`,sp(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),eg=I(`$ZodNonOptional`,(e,t)=>{Zm.init(e,t),sp(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>tg(t,e)):tg(i,e)}});function tg(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var ng=I(`$ZodCatch`,(e,t)=>{Zm.init(e,t),sp(e._zod,`optin`,()=>t.innerType._zod.optin),sp(e._zod,`optout`,()=>t.innerType._zod.optout),sp(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Mp(e,n,$f()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>Mp(e,n,$f()))},input:e.value}),e.issues=[]),e)}}),rg=I(`$ZodPipe`,(e,t)=>{Zm.init(e,t),sp(e._zod,`values`,()=>t.in._zod.values),sp(e._zod,`optin`,()=>t.in._zod.optin),sp(e._zod,`optout`,()=>t.out._zod.optout),sp(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>ig(e,t.in,n)):ig(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>ig(e,t.out,n)):ig(r,t.out,n)}});function ig(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var ag=I(`$ZodReadonly`,(e,t)=>{Zm.init(e,t),sp(e._zod,`propValues`,()=>t.innerType._zod.propValues),sp(e._zod,`values`,()=>t.innerType._zod.values),sp(e._zod,`optin`,()=>t.innerType._zod.optin),sp(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(og):og(r)}});function og(e){return e.value=Object.freeze(e.value),e}var sg=I(`$ZodLazy`,(e,t)=>{Zm.init(e,t),sp(e._zod,`innerType`,()=>t.getter()),sp(e._zod,`pattern`,()=>e._zod.innerType._zod.pattern),sp(e._zod,`propValues`,()=>e._zod.innerType._zod.propValues),sp(e._zod,`optin`,()=>e._zod.innerType._zod.optin??void 0),sp(e._zod,`optout`,()=>e._zod.innerType._zod.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),cg=I(`$ZodCustom`,(e,t)=>{Mm.init(e,t),Zm.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>lg(t,n,r,e));lg(i,n,r,e)}});function lg(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Pp(e))}}var ug=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function dg(){return new ug}var fg=dg();function pg(e,t){return new e({type:`string`,...L(t)})}function mg(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...L(t)})}function hg(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...L(t)})}function gg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...L(t)})}function _g(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...L(t)})}function vg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...L(t)})}function yg(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...L(t)})}function bg(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...L(t)})}function xg(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...L(t)})}function Sg(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...L(t)})}function Cg(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...L(t)})}function wg(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...L(t)})}function Tg(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...L(t)})}function Eg(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...L(t)})}function Dg(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...L(t)})}function Og(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...L(t)})}function kg(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...L(t)})}function Ag(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...L(t)})}function jg(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...L(t)})}function Mg(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...L(t)})}function Ng(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...L(t)})}function Pg(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...L(t)})}function Fg(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...L(t)})}function Ig(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...L(t)})}function Lg(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...L(t)})}function Rg(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...L(t)})}function zg(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...L(t)})}function Bg(e,t){return new e({type:`number`,checks:[],...L(t)})}function Vg(e,t){return new e({type:`number`,coerce:!0,checks:[],...L(t)})}function Hg(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...L(t)})}function Ug(e,t){return new e({type:`boolean`,...L(t)})}function Wg(e,t){return new e({type:`null`,...L(t)})}function Gg(e){return new e({type:`unknown`})}function Kg(e,t){return new e({type:`never`,...L(t)})}function qg(e,t){return new Pm({check:`less_than`,...L(t),value:e,inclusive:!1})}function Jg(e,t){return new Pm({check:`less_than`,...L(t),value:e,inclusive:!0})}function Yg(e,t){return new Fm({check:`greater_than`,...L(t),value:e,inclusive:!1})}function Xg(e,t){return new Fm({check:`greater_than`,...L(t),value:e,inclusive:!0})}function Zg(e,t){return new Im({check:`multiple_of`,...L(t),value:e})}function Qg(e,t){return new Rm({check:`max_length`,...L(t),maximum:e})}function $g(e,t){return new zm({check:`min_length`,...L(t),minimum:e})}function e_(e,t){return new Bm({check:`length_equals`,...L(t),length:e})}function t_(e,t){return new Hm({check:`string_format`,format:`regex`,...L(t),pattern:e})}function n_(e){return new Um({check:`string_format`,format:`lowercase`,...L(e)})}function r_(e){return new Wm({check:`string_format`,format:`uppercase`,...L(e)})}function i_(e,t){return new Gm({check:`string_format`,format:`includes`,...L(t),includes:e})}function a_(e,t){return new Km({check:`string_format`,format:`starts_with`,...L(t),prefix:e})}function o_(e,t){return new qm({check:`string_format`,format:`ends_with`,...L(t),suffix:e})}function s_(e){return new Jm({check:`overwrite`,tx:e})}function c_(e){return s_(t=>t.normalize(e))}function l_(){return s_(e=>e.trim())}function u_(){return s_(e=>e.toLowerCase())}function d_(){return s_(e=>e.toUpperCase())}function f_(e,t,n){return new e({type:`array`,element:t,...L(n)})}function p_(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...L(n)})}function m_(e){let t=h_(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Pp(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Pp(r))}},e(n.value,n)));return t}function h_(e,t){let n=new Mm({check:`custom`,...L(t)});return n._zod.check=e,n}var g_=I(`ZodISODateTime`,(e,t)=>{dh.init(e,t),V_.init(e,t)});function __(e){return Ig(g_,e)}var v_=I(`ZodISODate`,(e,t)=>{fh.init(e,t),V_.init(e,t)});function y_(e){return Lg(v_,e)}var b_=I(`ZodISOTime`,(e,t)=>{ph.init(e,t),V_.init(e,t)});function x_(e){return Rg(b_,e)}var S_=I(`ZodISODuration`,(e,t)=>{mh.init(e,t),V_.init(e,t)});function C_(e){return zg(S_,e)}var w_=(e,t)=>{Ip.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>zp(e,t)},flatten:{value:t=>Rp(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,tp,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,tp,2)}},isEmpty:{get(){return e.issues.length===0}}})};I(`ZodError`,w_);var T_=I(`ZodError`,w_,{Parent:Error}),E_=Bp(T_),D_=Vp(T_),O_=Hp(T_),k_=Wp(T_),A_=Kp(T_),j_=qp(T_),M_=Jp(T_),N_=Yp(T_),P_=Xp(T_),F_=Zp(T_),I_=Qp(T_),L_=$p(T_),R_=I(`ZodType`,(e,t)=>(Zm.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),e.clone=(t,n)=>yp(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>E_(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>O_(e,t,n),e.parseAsync=async(t,n)=>D_(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>k_(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>A_(e,t,n),e.decode=(t,n)=>j_(e,t,n),e.encodeAsync=async(t,n)=>M_(e,t,n),e.decodeAsync=async(t,n)=>N_(e,t,n),e.safeEncode=(t,n)=>P_(e,t,n),e.safeDecode=(t,n)=>F_(e,t,n),e.safeEncodeAsync=async(t,n)=>I_(e,t,n),e.safeDecodeAsync=async(t,n)=>L_(e,t,n),e.refine=(t,n)=>e.check(Xv(t,n)),e.superRefine=t=>e.check(Zv(t)),e.overwrite=t=>e.check(s_(t)),e.optional=()=>Mv(e),e.nullable=()=>Pv(e),e.nullish=()=>Mv(Pv(e)),e.nonoptional=t=>Bv(e,t),e.array=()=>B(e),e.or=t=>xv([e,t]),e.and=t=>Cv(e,t),e.transform=t=>Wv(e,Av(t)),e.default=t=>Iv(e,t),e.prefault=t=>Rv(e,t),e.catch=t=>Hv(e,t),e.pipe=t=>Wv(e,t),e.readonly=()=>Kv(e),e.describe=t=>{let n=e.clone();return fg.add(n,{description:t}),n},Object.defineProperty(e,"description",{get(){return fg.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return fg.get(e);let n=e.clone();return fg.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),z_=I(`_ZodString`,(e,t)=>{Qm.init(e,t),R_.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(t_(...t)),e.includes=(...t)=>e.check(i_(...t)),e.startsWith=(...t)=>e.check(a_(...t)),e.endsWith=(...t)=>e.check(o_(...t)),e.min=(...t)=>e.check($g(...t)),e.max=(...t)=>e.check(Qg(...t)),e.length=(...t)=>e.check(e_(...t)),e.nonempty=(...t)=>e.check($g(1,...t)),e.lowercase=t=>e.check(n_(t)),e.uppercase=t=>e.check(r_(t)),e.trim=()=>e.check(l_()),e.normalize=(...t)=>e.check(c_(...t)),e.toLowerCase=()=>e.check(u_()),e.toUpperCase=()=>e.check(d_())}),B_=I(`ZodString`,(e,t)=>{Qm.init(e,t),z_.init(e,t),e.email=t=>e.check(mg(H_,t)),e.url=t=>e.check(bg(G_,t)),e.jwt=t=>e.check(Fg(ov,t)),e.emoji=t=>e.check(xg(K_,t)),e.guid=t=>e.check(hg(U_,t)),e.uuid=t=>e.check(gg(W_,t)),e.uuidv4=t=>e.check(_g(W_,t)),e.uuidv6=t=>e.check(vg(W_,t)),e.uuidv7=t=>e.check(yg(W_,t)),e.nanoid=t=>e.check(Sg(q_,t)),e.guid=t=>e.check(hg(U_,t)),e.cuid=t=>e.check(Cg(J_,t)),e.cuid2=t=>e.check(wg(Y_,t)),e.ulid=t=>e.check(Tg(X_,t)),e.base64=t=>e.check(Mg(rv,t)),e.base64url=t=>e.check(Ng(iv,t)),e.xid=t=>e.check(Eg(Z_,t)),e.ksuid=t=>e.check(Dg(Q_,t)),e.ipv4=t=>e.check(Og($_,t)),e.ipv6=t=>e.check(kg(ev,t)),e.cidrv4=t=>e.check(Ag(tv,t)),e.cidrv6=t=>e.check(jg(nv,t)),e.e164=t=>e.check(Pg(av,t)),e.datetime=t=>e.check(__(t)),e.date=t=>e.check(y_(t)),e.time=t=>e.check(x_(t)),e.duration=t=>e.check(C_(t))});function R(e){return pg(B_,e)}var V_=I(`ZodStringFormat`,(e,t)=>{$m.init(e,t),z_.init(e,t)}),H_=I(`ZodEmail`,(e,t)=>{nh.init(e,t),V_.init(e,t)}),U_=I(`ZodGUID`,(e,t)=>{eh.init(e,t),V_.init(e,t)}),W_=I(`ZodUUID`,(e,t)=>{th.init(e,t),V_.init(e,t)}),G_=I(`ZodURL`,(e,t)=>{rh.init(e,t),V_.init(e,t)}),K_=I(`ZodEmoji`,(e,t)=>{ih.init(e,t),V_.init(e,t)}),q_=I(`ZodNanoID`,(e,t)=>{ah.init(e,t),V_.init(e,t)}),J_=I(`ZodCUID`,(e,t)=>{oh.init(e,t),V_.init(e,t)}),Y_=I(`ZodCUID2`,(e,t)=>{sh.init(e,t),V_.init(e,t)}),X_=I(`ZodULID`,(e,t)=>{ch.init(e,t),V_.init(e,t)}),Z_=I(`ZodXID`,(e,t)=>{lh.init(e,t),V_.init(e,t)}),Q_=I(`ZodKSUID`,(e,t)=>{uh.init(e,t),V_.init(e,t)}),$_=I(`ZodIPv4`,(e,t)=>{hh.init(e,t),V_.init(e,t)}),ev=I(`ZodIPv6`,(e,t)=>{gh.init(e,t),V_.init(e,t)}),tv=I(`ZodCIDRv4`,(e,t)=>{_h.init(e,t),V_.init(e,t)}),nv=I(`ZodCIDRv6`,(e,t)=>{vh.init(e,t),V_.init(e,t)}),rv=I(`ZodBase64`,(e,t)=>{bh.init(e,t),V_.init(e,t)}),iv=I(`ZodBase64URL`,(e,t)=>{Sh.init(e,t),V_.init(e,t)}),av=I(`ZodE164`,(e,t)=>{Ch.init(e,t),V_.init(e,t)}),ov=I(`ZodJWT`,(e,t)=>{Th.init(e,t),V_.init(e,t)}),sv=I(`ZodNumber`,(e,t)=>{Eh.init(e,t),R_.init(e,t),e.gt=(t,n)=>e.check(Yg(t,n)),e.gte=(t,n)=>e.check(Xg(t,n)),e.min=(t,n)=>e.check(Xg(t,n)),e.lt=(t,n)=>e.check(qg(t,n)),e.lte=(t,n)=>e.check(Jg(t,n)),e.max=(t,n)=>e.check(Jg(t,n)),e.int=t=>e.check(lv(t)),e.safe=t=>e.check(lv(t)),e.positive=t=>e.check(Yg(0,t)),e.nonnegative=t=>e.check(Xg(0,t)),e.negative=t=>e.check(qg(0,t)),e.nonpositive=t=>e.check(Jg(0,t)),e.multipleOf=(t,n)=>e.check(Zg(t,n)),e.step=(t,n)=>e.check(Zg(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function z(e){return Bg(sv,e)}var cv=I(`ZodNumberFormat`,(e,t)=>{Dh.init(e,t),sv.init(e,t)});function lv(e){return Hg(cv,e)}var uv=I(`ZodBoolean`,(e,t)=>{Oh.init(e,t),R_.init(e,t)});function dv(e){return Ug(uv,e)}var fv=I(`ZodNull`,(e,t)=>{kh.init(e,t),R_.init(e,t)});function pv(e){return Wg(fv,e)}var mv=I(`ZodUnknown`,(e,t)=>{Ah.init(e,t),R_.init(e,t)});function hv(){return Gg(mv)}var gv=I(`ZodNever`,(e,t)=>{jh.init(e,t),R_.init(e,t)});function _v(e){return Kg(gv,e)}var vv=I(`ZodArray`,(e,t)=>{Nh.init(e,t),R_.init(e,t),e.element=t.element,e.min=(t,n)=>e.check($g(t,n)),e.nonempty=t=>e.check($g(1,t)),e.max=(t,n)=>e.check(Qg(t,n)),e.length=(t,n)=>e.check(e_(t,n)),e.unwrap=()=>e.element});function B(e,t){return f_(vv,e,t)}var yv=I(`ZodObject`,(e,t)=>{Rh.init(e,t),R_.init(e,t),sp(e,`shape`,()=>t.shape),e.keyof=()=>H(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:hv()}),e.loose=()=>e.clone({...e._zod.def,catchall:hv()}),e.strict=()=>e.clone({...e._zod.def,catchall:_v()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>wp(e,t),e.safeExtend=t=>Tp(e,t),e.merge=t=>Ep(e,t),e.pick=t=>Sp(e,t),e.omit=t=>Cp(e,t),e.partial=(...t)=>Dp(jv,e,t[0]),e.required=(...t)=>Op(zv,e,t[0])});function V(e,t){return new yv({type:`object`,get shape(){return lp(this,`shape`,e?cp(e):{}),this.shape},...L(t)})}var bv=I(`ZodUnion`,(e,t)=>{Bh.init(e,t),R_.init(e,t),e.options=t.options});function xv(e,t){return new bv({type:`union`,options:e,...L(t)})}var Sv=I(`ZodIntersection`,(e,t)=>{Vh.init(e,t),R_.init(e,t)});function Cv(e,t){return new Sv({type:`intersection`,left:e,right:t})}var wv=I(`ZodRecord`,(e,t)=>{Wh.init(e,t),R_.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function Tv(e,t,n){return new wv({type:`record`,keyType:e,valueType:t,...L(n)})}var Ev=I(`ZodEnum`,(e,t)=>{Gh.init(e,t),R_.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Ev({...t,checks:[],...L(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Ev({...t,checks:[],...L(r),entries:i})}});function H(e,t){return new Ev({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...L(t)})}var Dv=I(`ZodLiteral`,(e,t)=>{Kh.init(e,t),R_.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function Ov(e,t){return new Dv({type:`literal`,values:Array.isArray(e)?e:[e],...L(t)})}var kv=I(`ZodTransform`,(e,t)=>{qh.init(e,t),R_.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Zf(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Pp(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Pp(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Av(e){return new kv({type:`transform`,transform:e})}var jv=I(`ZodOptional`,(e,t)=>{Yh.init(e,t),R_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Mv(e){return new jv({type:`optional`,innerType:e})}var Nv=I(`ZodNullable`,(e,t)=>{Xh.init(e,t),R_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Pv(e){return new Nv({type:`nullable`,innerType:e})}var Fv=I(`ZodDefault`,(e,t)=>{Zh.init(e,t),R_.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Iv(e,t){return new Fv({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():gp(t)}})}var Lv=I(`ZodPrefault`,(e,t)=>{$h.init(e,t),R_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Rv(e,t){return new Lv({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():gp(t)}})}var zv=I(`ZodNonOptional`,(e,t)=>{eg.init(e,t),R_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Bv(e,t){return new zv({type:`nonoptional`,innerType:e,...L(t)})}var Vv=I(`ZodCatch`,(e,t)=>{ng.init(e,t),R_.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Hv(e,t){return new Vv({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Uv=I(`ZodPipe`,(e,t)=>{rg.init(e,t),R_.init(e,t),e.in=t.in,e.out=t.out});function Wv(e,t){return new Uv({type:`pipe`,in:e,out:t})}var Gv=I(`ZodReadonly`,(e,t)=>{ag.init(e,t),R_.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Kv(e){return new Gv({type:`readonly`,innerType:e})}var qv=I(`ZodLazy`,(e,t)=>{sg.init(e,t),R_.init(e,t),e.unwrap=()=>e._zod.def.getter()});function Jv(e){return new qv({type:`lazy`,getter:e})}var Yv=I(`ZodCustom`,(e,t)=>{cg.init(e,t),R_.init(e,t)});function Xv(e,t={}){return p_(Yv,e,t)}function Zv(e){return m_(e)}function Qv(e){let t=Jv(()=>xv([R(e),z(),dv(),pv(),B(t),Tv(R(),t)]));return t}function $v(e){return Vg(sv,e)}var U=R().uuid(),W=R().datetime({offset:!0}),ey=R().regex(/^[a-f0-9]{64}$/);R().trim().min(1);var ty=H([`owner`,`admin`,`security_manager`,`operator`,`viewer`,`auditor`]),ny=H([`R0`,`R1`,`R2`]),ry=H([`public`,`internal`,`confidential`,`restricted`]);V({cursor:R().min(1).optional(),limit:$v().int().min(1).max(200).default(50)}),V({nextCursor:R().min(1).optional(),hasMore:dv()}),V({idempotencyKey:R().trim().min(8).max(200),expectedVersion:z().int().nonnegative().optional()}),V({type:R().default(`about:blank`),title:R(),status:z().int().min(400).max(599),detail:R().optional(),instance:R().optional(),code:R().regex(/^[a-z0-9_]+$/),requestId:R(),errors:B(V({path:R(),message:R(),code:R().optional()})).optional()});var iy=V({providerId:R().nullable(),modelId:R().nullable(),inputTokens:z().int().nonnegative(),outputTokens:z().int().nonnegative(),reasoningTokens:z().int().nonnegative(),cacheReadTokens:z().int().nonnegative(),cacheWriteTokens:z().int().nonnegative(),estimatedCostUsd:z().nonnegative(),pricingSource:R().nullable(),pricingAsOf:R().nullable()}),ay=V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U.nullable(),externalSessionId:R().nullable(),createdBy:U,status:H([`active`,`waiting`,`completed`,`failed`,`cancelled`]),mode:H([`autonomous`,`guided`]),model:R().nullable(),costUsd:z().nonnegative(),usage:iy,sensitive:dv(),createdAt:W,lastActivityAt:W}),oy=V({id:U,sessionId:U,role:H([`user`,`assistant`,`system`,`tool`]),redactedPreview:R(),sensitivePayloadArtifactId:U.nullable(),createdAt:W}),sy=V({id:U,sessionId:U,runId:U.nullable(),stageId:U.nullable(),externalToolCallId:R().nullable(),toolName:R().min(1),status:H([`running`,`completed`,`failed`,`cancelled`]),inputHash:ey,outputArtifactId:U.nullable(),startedAt:W,completedAt:W.nullable()});V({session:ay,messages:B(oy),toolActivities:B(sy)}),V({expectedRunVersion:z().int().nonnegative(),reason:R().trim().min(1).max(1e3)}),new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var cy=H([`informational`,`low`,`medium`,`high`,`critical`]),ly=H([`clean`,`informational`,`actionable`,`critical`]),uy=V({fingerprint:ey.optional(),title:R().min(1),severity:H([`info`,`low`,`medium`,`high`,`critical`]),details:R().default(``),targetUrl:R().optional(),cvss:R().default(``),cweId:R().default(``),invariant:R().default(``),rootCause:R().default(``),impact:R().default(``),reproduction:B(R().min(1)).default([]),remediation:R().default(``),disposition:H([`candidate`,`confirmed`,`refuted`,`inconclusive`]).default(`candidate`),evidenceRefs:B(ey).default([])}),dy=V({description:R().min(1),artifactType:R().min(1),data:Qv().refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=65536,{message:`Evidence metadata must not exceed 64 KiB.`}).default(null),timestamp:z().int().nonnegative(),stageId:U.optional(),agentSessionId:U.optional()}),fy=H([`observation`,`artifact`,`control_result`,`manual_confirmation`,`report`]),py=V({fingerprint:ey,title:R().min(1),description:R().default(``),severity:cy,cvss:R().default(``),cweId:R().default(``),invariant:R().default(``),rootCause:R().default(``),impact:R().default(``),reproduction:B(R()).default([]),remediation:R().default(``),targetUrl:R().optional(),disposition:H([`candidate`,`confirmed`,`refuted`,`inconclusive`]),evidenceRefs:B(ey).default([]),status:H([`open`]).default(`open`)}).strict(),my=V({fingerprint:ey,kind:fy,title:R().min(1),summary:R().default(``),artifactType:R(),sha256:ey,timestamp:z().int().nonnegative(),stageId:U.optional(),agentSessionId:U.optional(),classification:ry.default(`confidential`)}).strict(),hy=V({satisfied:dv(),missing:B(R())}).strict(),gy=V({id:U,runId:U,projectId:U,workflowKey:R().min(1),workflowVersionId:U,version:z().int().nonnegative(),contentHash:ey,target:R().min(1),scopeOrigins:B(R()).default([]),summary:R().default(``),posture:ly,findings:B(py).default([]),unverifiedLeads:B(py).default([]),evidence:B(my).default([]),negativeControls:B(R()).default([]),classification:ry.default(`confidential`),publicationState:H([`draft`,`blocked`,`published`]).default(`draft`),gate:hy,parentContentHash:ey.nullable().default(null),editorialMarkdownHash:ey.nullable().default(null),publishedAt:W.optional(),createdAt:W}).strict();V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),target:R().min(1),model:R().min(1)}),V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),description:R().min(1),artifactType:R().min(1),data:Qv().refine(e=>new TextEncoder().encode(JSON.stringify(e)).byteLength<=65536,{message:`Evidence metadata must not exceed 64 KiB.`}).default(null),timestamp:z().int().nonnegative()}),V({agentSessionId:R().min(1),runId:U.optional(),stageId:U.optional(),stageKey:R().min(1),workflowKey:R().min(1),status:H([`succeeded`,`blocked`,`inconclusive`,`failed`]),findings:z().int().nonnegative(),evidence:z().int().nonnegative(),findingItems:B(uy).default([]),evidenceItems:B(dy).default([]),negativeControls:B(R().min(1).max(4e3)).max(500).default([]),toolAttempts:z().int().nonnegative(),toolsExecuted:z().int().nonnegative(),toolsErrored:z().int().nonnegative(),pricingUnknown:dv().optional()}),V({id:U,organizationId:U,name:R().trim().min(1).max(120),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),version:z().int().nonnegative(),createdAt:W,updatedAt:W}),V({id:U,organizationId:U,workspaceId:U,name:R().trim().min(1).max(160),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),archivedAt:W.nullable(),version:z().int().nonnegative(),createdAt:W,updatedAt:W}),V({name:R().trim().min(1).max(160),slug:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/)});var _y=V({id:U,kind:H([`domain`,`ip`,`cidr`,`url`,`repository`,`api`,`android`,`ios`,`custom`]),locator:R().trim().min(1).max(2048),displayName:R().trim().min(1).max(240)}),vy=V({id:U,owner:R().trim().min(1),documentArtifactId:U,validFrom:W,validUntil:W,allowedActions:B(R().min(1)).min(1),prohibitedActions:B(R().min(1)),sha256:ey}),yy=V({requestsPerSecond:z().positive().optional(),concurrency:z().int().positive().optional(),durationSeconds:z().int().positive(),costUsd:z().nonnegative().optional(),modelTokens:z().int().nonnegative().optional()}),by=V({projectId:U,name:R().trim().min(1).max(160),targets:B(_y).min(1),exclusions:B(R().trim().min(1)),authorization:vy.optional(),allowedRisk:ny,allowedActions:B(R().min(1)),prohibitedActions:B(R().min(1)),limits:yy,requiredWorkerClass:R().trim().min(1),requiredCapabilities:B(R().trim().min(1)),credentialReferences:B(R().trim().min(1)),dataClassification:ry,retentionPolicyId:U.optional(),notificationChannels:B(R().trim().min(1))}).extend({id:U,organizationId:U,workspaceId:U,revision:z().int().positive(),inputHash:ey,createdAt:W,createdBy:U}),xy=H([`open`,`in_progress`,`accepted_risk`,`false_positive`,`remediated`,`verified`]);V({id:U,organizationId:U,workspaceId:U,projectId:U,title:R().min(1),description:R(),severity:H([`informational`,`low`,`medium`,`high`,`critical`]),status:xy,fingerprint:ey,version:z().int().nonnegative(),firstSeenAt:W,lastSeenAt:W}),V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U.nullable(),stageId:U.nullable(),agentSessionId:U.nullable(),toolCallId:U.nullable(),kind:H([`observation`,`artifact`,`report`,`manual_confirmation`,`control_result`]),title:R().min(1),summary:R(),classification:ry,artifactId:U.nullable(),sha256:ey,createdAt:W});var Sy=V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,objectKey:R().min(1),sha256:ey,mimeType:R().min(1),size:z().int().nonnegative(),classification:ry,createdBy:U,createdAt:W}),Cy=H([`internal-infrastructure`,`external-infrastructure`,`web-application`,`api-security`,`mobile-application`,`red-team-campaign`,`purple-team-validation`,`nist-csf-2`,`cis-controls-8-1`,`advanced-security-testing`,`remediation-validation`,`network-security-audit`]),wy=V({key:R().regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/),name:R().min(1),description:R().min(1),risk:ny,optional:dv().default(!1),requiredCapabilities:B(R().min(1)),skillRefs:B(R().min(1).max(80)).max(64).default([]),retrySafe:dv(),approvalCheckpoint:dv(),timeoutSeconds:z().int().positive()}),Ty=V({id:U,key:Cy,version:R().regex(/^\d+\.\d+\.\d+$/),name:R().min(1),description:R().min(1),inputSchema:Tv(R(),hv()),requiredCapabilities:B(R().min(1)),requiredIntegrations:B(R().min(1)),stages:B(wy).min(1),evidenceRequirements:B(R().min(1)).min(1),completionCriteria:B(R().min(1)).min(1),publishedAt:W,contentHash:ey}),Ey=V({code:H([`authorization_missing`,`authorization_expired`,`capability_missing`,`worker_missing`,`integration_missing`,`credential_missing`,`scope_invalid`,`approval_required`]),message:R().min(1),stageKey:R().optional(),capability:R().optional()}),Dy=V({ready:dv(),launchState:H([`ready`,`blocked`,`awaiting_approval`]),highestRisk:ny,reasons:B(Ey),matchingWorkerIds:B(U),inputHash:ey}),Oy=H([`draft`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`cancel_requested`,`succeeded`,`failed`,`cancelled`,`expired`]),ky=H([`pending`,`blocked`,`awaiting_approval`,`queued`,`leased`,`running`,`paused`,`succeeded`,`failed`,`cancel_requested`,`cancelled`,`expired`,`skipped`]);V({projectId:U,assessmentProfileId:U,workflowKey:Cy,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:Tv(R(),hv()),workerClass:R().min(1),mode:H([`autonomous`,`guided`]).default(`autonomous`)});var Ay=V({id:U,organizationId:U,workspaceId:U,projectId:U,assessmentId:U,assessmentProfileId:U,workflowVersionId:U,workflowKey:Cy,requestedBy:U,state:Oy,risk:ny,inputHash:ey,workerClass:R(),mode:H([`autonomous`,`guided`]),attempt:z().int().positive(),retryOfRunId:U.nullable(),agentSessionId:U.nullable(),usage:iy,version:z().int().nonnegative(),createdAt:W,startedAt:W.nullable(),completedAt:W.nullable()}),jy=V({id:U,runId:U,key:R().min(1),position:z().int().nonnegative(),risk:ny,state:ky,workerId:U.nullable(),version:z().int().nonnegative(),startedAt:W.nullable(),completedAt:W.nullable()});V({id:z().int().positive(),runId:U,stageId:U.nullable(),type:R().min(1),payload:Tv(R(),hv()),occurredAt:W}),V({after:z().int().nonnegative().default(0)});var My=H([`internal-infrastructure`,`external-infrastructure`,`web-application`,`api-security`,`network-security-audit`]);V({target:R().trim().min(1).max(2048),workflowKey:My,workflowVersionId:U,selectedStageKeys:B(R().min(1)).min(1).optional(),inputs:Tv(R(),hv()).default({})}).extend({mode:H([`autonomous`,`guided`]).default(`autonomous`)}),V({owner:R().trim().min(2).max(200),statement:R().trim().min(20).max(2e3),validUntil:W});var Ny=V({profile:by,authorization:vy,artifact:Sy}),Py=V({projectId:U,target:_y,dossierKey:R().min(1),profileId:U,profileName:R().min(1),reusedProfile:dv()}),Fy=V({binding:Py,readiness:Dy}),Iy=V({binding:Py,run:Ay,stages:B(jy),agentSession:ay}),Ly=H([`pending`,`approved`,`rejected`,`expired`,`invalidated`]);V({id:U,organizationId:U,workspaceId:U,projectId:U,runId:U,stageId:U.nullable(),risk:ny,state:Ly,requestedBy:U,requiredRole:H([`security_manager`,`owner_or_admin`]),decidedBy:U.nullable(),decisionRole:H([`owner`,`admin`,`security_manager`]).nullable(),workflowVersionId:U,inputHash:ey,scopeHash:ey,targetSetHash:ey,workerClass:R().min(1),actionSetHash:ey,expiresAt:W,decidedAt:W.nullable(),reason:R().nullable()}),V({decision:H([`approve`,`reject`]),reason:R().trim().min(1).max(2e3),passwordConfirmation:R().min(1),totpCode:R().regex(/^\d{6}$/).optional()}),V({id:U,sequence:z().int().positive(),organizationId:U,workspaceId:U,projectId:U.nullable(),actorId:U.nullable(),authSessionId:U.nullable(),action:R().min(1),resourceType:R().min(1),resourceId:R().min(1),requestId:R().min(1),correlationId:R().nullable(),ip:R().nullable(),userAgent:R().nullable(),outcome:H([`succeeded`,`denied`,`failed`]),reason:R().nullable(),beforeHash:ey.nullable(),afterHash:ey.nullable(),previousEventHash:ey.nullable(),eventHash:ey,occurredAt:W}),V({id:U,workspaceId:U,governanceDays:z().int().min(2555),assessmentDaysAfterClosure:z().int().min(1095),rawSessionDays:z().int().min(180),authSessionInvestigationDays:z().int().min(30),version:z().int().nonnegative()}),V({id:U,workspaceId:U,name:R().min(1),reason:R().min(1),resourceType:H([`assessment`,`run`,`agent_session`,`finding`,`artifact`]),resourceId:U,releasedAt:W.nullable(),createdAt:W});var Ry=H([`workspace:admin`,`project:write`,`workflow:configure`,`run:launch`,`run:approve:r1`,`run:approve:r2`,`finding:write`,`session:read`,`session:read_sensitive`,`evidence:read`,`evidence:read_sensitive`,`governance:read`,`governance:write`]);V({user:V({id:U,email:R().email(),displayName:R().min(1),mfaEnrolled:dv(),createdAt:W}),organizationId:U,memberships:B(V({workspaceId:U,workspaceName:R().min(1),role:ty,permissions:B(Ry)})),activeWorkspaceId:U}),V({id:U,userId:U,createdAt:W,lastSeenAt:W,expiresAt:W,ip:R().nullable(),userAgent:R().nullable(),current:dv()}),V({password:R().min(1),totpCode:R().regex(/^\d{6}$/).optional()}),V({id:U,workspaceId:U,email:R().email(),role:ty,expiresAt:W,acceptedAt:W.nullable(),createdAt:W});var zy=z().int().nonnegative(),By=R().min(1),Vy=H([`info`,`low`,`medium`,`high`,`critical`]),Hy=H([`open`,`unverified`,`confirmed`,`remediating`,`remediated`,`verified`,`false_positive`,`accepted_risk`,`suppressed`]),Uy=H([`cli`,`tui`,`web`,`github`,`system`]),Wy=H([`scan`,`hunt`,`verify`,`import`]),Gy=H([`queued`,`running`,`completed`,`failed`,`cancelled`]),Ky=Tv(R(),hv()),qy=V({id:By,workspaceID:By,projectID:By.nullable(),repositoryID:By.nullable(),engagementID:By.nullable(),targetID:By.nullable(),parentRunID:By.nullable(),sessionID:By.nullable(),source:Uy,kind:Wy,status:Gy,title:R(),requestedBy:R().nullable(),baseRevision:R().nullable(),headRevision:R().nullable(),promptRevision:R().nullable(),promptFingerprint:R().nullable(),configuration:Ky.nullable(),summary:Ky.nullable(),error:Ky.nullable(),idempotencyKey:R().nullable(),createdAt:zy,startedAt:zy.nullable(),completedAt:zy.nullable(),updatedAt:zy}),Jy=V({runs:B(qy),nextCursor:R().optional()}),Yy=V({id:By,fingerprint:R().min(1),title:R(),description:R().nullable(),severity:Vy,status:Hy,path:R().nullable(),line:z().int().nullable(),category:R().nullable(),firstSeenAt:zy,lastSeenAt:zy,updatedAt:zy}),Xy=V({findings:B(Yy),total:z().int().nonnegative()}),Zy=V({id:By,runID:By.nullable(),operationID:By.nullable(),kind:R(),verdict:R(),reason:R().nullable(),payload:Ky.nullable(),createdAt:zy}),Qy=V({finding:Yy.extend({cwe:R().nullable(),cve:R().nullable(),cvssScore:z().nullable(),cvssVector:R().nullable(),remediation:R().nullable(),assignee:R().nullable(),resolvedAt:zy.nullable(),evidence:B(Zy)})}),$y=V({id:By,runID:By,tool:R(),runtime:R(),status:R(),outcome:R(),title:R().nullable(),input:Ky.nullable(),outputPreview:R().nullable(),error:Ky.nullable(),startedAt:zy,completedAt:zy.nullable()}),eb=V({run:qy,operations:B($y.omit({runID:!0})),findings:B(Yy)}),tb=V({id:By,title:R(),kind:R(),source:R(),status:H([`running`,`failed`,`completed`]),runCount:z().int().nonnegative(),operationCount:z().int().nonnegative(),findingCount:z().int().nonnegative(),startedAt:zy,lastActivityAt:zy}),nb=V({session:tb,runs:B(qy),operations:B($y),findings:B(Yy)}),rb=V({id:By,sequence:z().int().positive(),actorID:R().nullable(),action:R().min(1),objectType:R().min(1),objectID:R().min(1),outcome:H([`succeeded`,`denied`,`failed`]),details:Ky.nullable(),createdAt:zy}),ib=V({id:By,workspaceId:By,name:R(),slug:R(),archivedAt:zy.nullable(),createdAt:zy,updatedAt:zy}),ab=V({id:By,name:R(),role:R(),createdAt:zy,updatedAt:zy}),ob=V({id:By,name:R(),status:R(),capabilities:B(R()).default([]),lastSeenAt:zy.nullable()}),sb=V({sessionId:R().nullable().optional(),runs:Tv(R(),z()),findings:V({total:z().int().nonnegative(),bySeverity:Tv(R(),z()),byStatus:Tv(R(),z())}),recentRuns:B(qy),recentFindings:B(Yy)}),cb=V({count:z().int().nonnegative(),limit:z().int().positive(),hasMore:dv()});function lb(e){return V({items:B(e),page:cb})}V({workspaceId:U,clientId:U,batchId:U,records:B(V({id:U,kind:H([`agent_session`,`evidence`,`finding`,`governance_event`]),localSequence:z().int().positive(),payload:Tv(R(),hv()),payloadHash:ey,occurredAt:W})).min(1).max(500)}),V({batchId:U,accepted:B(U),rejected:B(V({id:U,code:R(),detail:R()})),centralizedApproval:Ov(!1)});var ub=H([`command_execution`,`read_files`,`write_files`,`http_request`,`run_exploit`,`dns_recon`,`state_mutation`,`skill_load`]);V({stageId:R().uuid(),workflowVersionId:R().uuid(),stageKey:R().min(1),requiredCapabilities:B(R().min(1)),allowedToolCategories:B(ub),allowedSkills:B(R().min(1).max(80)).max(64).default([]),retrySafe:dv(),timeoutMs:z().int().positive()});var db=V({workerClass:H([`network`,`web-api`,`mobile-lab`,`advanced-analysis`,`passive`]),capabilities:B(R().min(1)),tools:Tv(R(),R()),networkLocation:R().nullable(),devices:B(V({id:R(),platform:H([`android`,`ios`]),version:R()})),limits:V({concurrency:z().int().positive(),memoryMb:z().int().positive(),cpuMillis:z().int().positive(),durationSeconds:z().int().positive()})});V({token:R().min(32),name:R().trim().min(1).max(160),publicKey:R().min(32),capabilities:db}),V({expiresAt:W}),V({token:R().min(32),expiresAt:W}),V({worker:V({id:U,organizationId:U,workspaceId:U,name:R(),publicKey:R(),capabilities:db,status:H([`enrolling`,`online`,`offline`,`revoked`]),lastHeartbeatAt:W.nullable(),createdAt:W}),accessToken:R().min(32),expiresAt:W}),V({capabilities:db.optional(),runningJobIds:B(U)}),V({id:U,runId:U,stageId:U,workerId:U,leaseToken:R().min(32),leaseExpiresAt:W,attempt:z().int().positive(),payload:Tv(R(),hv())}),V({leaseToken:R().min(32),events:B(V({idempotencyKey:R().min(8),type:R().min(1),occurredAt:W,payload:Tv(R(),hv())})).min(1).max(500)});var fb=V({leaseToken:R().min(32)});fb.extend({extendSeconds:z().int().min(10).max(300).default(60)}),fb.extend({outcome:H([`succeeded`,`failed`,`cancelled`]),summary:Tv(R(),hv()).default({}),error:R().max(2e4).optional(),retrySafe:dv().default(!1)});var pb=V({items:B(Ty)}),mb=lb(ab),hb=lb(ib),gb=V({items:B(by)}),_b=lb(tb),vb=lb(rb),yb=lb(ob),bb=V({id:R(),label:R(),prefix:R().optional().default(``),tokenPrefix:R().optional(),role:R().optional().default(`admin`),workspaceId:R().optional().default(`default`),createdAt:R(),expiresAt:R().nullable().optional(),lastUsedAt:R().nullable().optional()}),xb=bb.extend({token:R()}),Sb=V({items:B(bb)}),Cb=V({items:B(V({version:z().int().nonnegative(),posture:R(),target:R(),contentHash:R(),classification:R(),publicationState:H([`draft`,`blocked`,`published`]),gate:V({satisfied:dv(),missing:B(R())}),publishedAt:R().nullable(),createdAt:R()}))}),wb=V({ext:R(),mimeType:R(),url:R().nullable(),rendered:dv()}),Tb=V({version:z().int().nonnegative(),contentHash:R(),posture:R(),target:R(),classification:R(),record:gy,renditions:B(wb)}),Eb=V({artifacts:B(V({artifactId:R(),mimeType:R(),size:z(),sha256:R()}))}),Db=V({version:z().int().nonnegative(),contentHash:R(),posture:R()}),Ob=class extends Error{status;code;constructor(e,t,n){super(n),this.status=e,this.code=t}};function kb(e=fetch){async function t(t,n,r){let i=document.querySelector(`meta[name="csrf-token"]`)?.content||sessionStorage.getItem(`kifaru-csrf`)||document.cookie.split(`;`).map(e=>e.trim()).find(e=>e.startsWith(`kifaru_csrf=`))?.slice(12),a=r?.method?.toUpperCase()??`GET`,o=await e(t,{credentials:`same-origin`,...r,headers:{accept:`application/json`,...a!==`GET`&&a!==`HEAD`&&i?{"x-csrf-token":i}:{},...r?.headers}});if(!o.ok&&o.status===401&&typeof window<`u`&&!window.location.pathname.startsWith(`/login`))throw window.location.href=`/login?redirect=${encodeURIComponent(window.location.pathname+window.location.search)}`,new Ob(401,`unauthorized`,`Session expired. Redirecting to login.`);let s=await o.json().catch(()=>void 0);if(!o.ok){let e=s;throw new Ob(o.status,e?.code??`request_failed`,e?.detail??`Request failed.`)}return n.parse(s)}return{workflows:()=>t(`/api/v1/workflows`,pb),runs:e=>{let n=e&&typeof e==`object`&&(`limit`in e||`sessionId`in e)?e:void 0,r=new URLSearchParams;return r.set(`limit`,String(n?.limit??20)),n?.sessionId&&r.set(`sessionId`,n.sessionId),t(`/api/v1/runs?${r.toString()}`,Jy)},runDetail:e=>t(`/api/v1/runs/${encodeURIComponent(e)}`,eb),workspaces:()=>t(`/api/v1/workspaces`,mb),projects:()=>t(`/api/v1/projects`,hb),assessmentProfiles:()=>t(`/api/v1/assessment-profiles`,gb),authorizeAssessmentProfile:(e,n)=>t(`/api/v1/assessment-profiles/${encodeURIComponent(e)}/authorization-attestations`,Ny,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(n)}),findings:e=>{let n=e&&typeof e==`object`&&(`limit`in e||`sessionId`in e||`runId`in e)?e:void 0,r=new URLSearchParams;return r.set(`limit`,String(n?.limit??50)),n?.sessionId&&r.set(`sessionId`,n.sessionId),n?.runId&&r.set(`runId`,n.runId),t(`/api/v1/findings?${r.toString()}`,Xy)},finding:e=>t(`/api/v1/findings/${encodeURIComponent(e)}`,Qy),updateFindingStatus:(e,n,r)=>t(`/api/v1/findings/${encodeURIComponent(e)}/status`,Qy,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({status:n,...r?{note:r}:{}})}),agentSessions:()=>t(`/api/v1/agent/sessions?limit=50`,_b),agentSession:e=>t(`/api/v1/agent/sessions/${encodeURIComponent(e)}`,nb),governanceEvents:()=>t(`/api/v1/governance/audit-events?limit=50`,vb),workers:()=>t(`/api/v1/workers`,yb),overview:e=>{let n;return typeof e==`string`?n=e:e&&typeof e==`object`&&`sessionId`in e&&typeof e.sessionId==`string`&&(n=e.sessionId),t(n?`/api/v1/overview?sessionId=${encodeURIComponent(n)}`:`/api/v1/overview`,sb)},tokens:()=>t(`/api/v1/tokens`,Sb),mintToken:e=>t(`/api/v1/tokens`,xb,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}),revokeToken:e=>t(`/api/v1/tokens/${encodeURIComponent(e)}`,V({ok:dv()}),{method:`DELETE`}),targetAssessmentReadiness:e=>t(`/api/v1/assessments/readiness`,Fy,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),startTargetAssessment:e=>t(`/api/v1/assessments`,Iy,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify(e)}),reportVersions:e=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports`,Cb),reportVersion:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}`,Tb),renderReportRenditions:(e,n)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}/renditions`,Eb,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({})}),publishEditedMarkdown:(e,n,r)=>t(`/api/v1/runs/${encodeURIComponent(e)}/reports/${n}/editor`,Db,{method:`POST`,headers:{"content-type":`application/json`,"idempotency-key":crypto.randomUUID()},body:JSON.stringify({markdown:r})})}}var Ab=kb(),jb=[{n:1,name:`Collection & Onboarding`,v:`--s1`},{n:2,name:`Storage & Security`,v:`--s2`},{n:3,name:`Use & Processing`,v:`--s3`},{n:4,name:`Sharing & Disclosure`,v:`--s4`},{n:5,name:`Retention`,v:`--s5`},{n:6,name:`Disposal & Erasure`,v:`--s6`}];function Mb(e){return jb[Math.min(Math.max(e,1),jb.length)-1]}function Nb(e){return e.name.split(` `)[0]}var Pb=[`Governance`,`Technical`,`People & 3rd-party`,`Assurance`],Fb=[`critical`,`high`,`medium`,`low`,`info`],Ib={critical:0,high:1,medium:2,low:3,info:4},Lb={critical:`--crit`,high:`--high`,medium:`--med`,low:`--low`,info:`--info`},Rb={critical:`Critical`,high:`High`,medium:`Medium`,low:`Low`,info:`Info`};function zb(e){return e===`informational`?`info`:Fb.includes(e)?e:`info`}function Bb(e){return e.length?[...e].sort((e,t)=>Ib[e.severity]-Ib[t.severity])[0].severity:null}function Vb(e){return[...e].sort((e,t)=>Ib[e.severity]-Ib[t.severity])}function Hb(e){return e.status!==`remediated`&&e.status!==`verified`}var Ub=/^(?:L|stage )([1-6])\s*·\s*P([0-3])\s*·\s*(.+)$/i;function Wb(e,t){let n=(e??``).trim(),r=Ub.exec(n);if(r)return{stage:Number(r[1]),pillar:Number(r[2]),category:r[3],inferred:!1};let i=`${n} ${t??``}`.toLowerCase();return{stage:/sharing|disclos|transfer|cross-border|offshore|sftp|export|feed|webhook|api partner|integration/.test(i)?4:/retention|purge|backup|archive|dr site|snapshot|data lake/.test(i)?5:/eras|disposal|destroy|delete|decommission|shred/.test(i)?6:/consent|intake|onboarding|collection|telematics|form capture|survey/.test(i)?1:/encrypt|at rest|bucket|object store|database exposure|unencrypted|storage|nas|s3/.test(i)?2:3,pillar:/governance|dpia|retention schedule|policy|register|oversight|audit/.test(i)?0:/shared credential|third-party|tpa|vendor|partner|outsourc|staff|insider/.test(i)?2:1,category:n||`Agent finding`,inferred:!0}}function Gb(e){return e.map(e=>{let t=Wb(e.category,e.title);return{...e,severity:zb(e.severity),stage:t.stage,pillar:t.pillar,displayCategory:t.inferred?`${t.category} (stage inferred)`:t.category,inferred:t.inferred}})}function Kb(e){return Bb(e.filter(e=>e.status===`confirmed`||e.status===`verified`))}function qb({title:e,sub:t,surface:n=!0,children:r}){return(0,P.jsxs)(`section`,{className:n?`bg-card rounded-xl border p-5`:void 0,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-baseline justify-between gap-3`,children:[(0,P.jsx)(`h2`,{children:e}),t?(0,P.jsx)(`span`,{className:`text-muted-foreground shrink-0 text-xs`,children:t}):null]}),r]})}function Jb({children:e}){return(0,P.jsx)(`div`,{className:`kpis`,children:e})}function Yb({label:e,value:t,meta:n,hero:r,tone:i}){return(0,P.jsxs)(`div`,{className:r?`kpi hero`:`kpi`,children:[(0,P.jsx)(`div`,{className:`lab`,children:e}),r?(0,P.jsxs)(`div`,{className:`posture-pill val`,style:i?{color:`var(${Lb[i]})`}:void 0,children:[(0,P.jsx)(`span`,{className:`sq`}),t]}):(0,P.jsx)(`div`,{className:`val`,children:t}),n?(0,P.jsx)(`div`,{className:`meta`,children:n}):null]})}function Xb({counts:e}){let t=Math.max(...Fb.map(t=>e[t]),1);return(0,P.jsx)(`div`,{children:Fb.map(n=>(0,P.jsxs)(`div`,{className:`sevrow`,children:[(0,P.jsxs)(`span`,{className:`name`,children:[(0,P.jsx)(`span`,{className:`chip`,style:{background:`var(${Lb[n]})`}}),Rb[n]]}),(0,P.jsx)(`div`,{className:`track`,children:(0,P.jsx)(`div`,{className:`fill`,"data-empty":e[n]===0,style:{width:`${e[n]/t*100}%`,background:`var(${Lb[n]})`}})}),(0,P.jsx)(`span`,{className:`n`,children:e[n]})]},n))})}function Zb({findings:e}){let t=jb.map(t=>e.filter(e=>e.stage===t.n).length),n=Math.max(...t,1);return(0,P.jsx)(`div`,{className:`stagebars`,children:jb.map((e,r)=>{let i=t[r];return(0,P.jsxs)(`div`,{className:`sbar`,children:[(0,P.jsx)(`span`,{className:`cnt`,children:i}),(0,P.jsx)(`div`,{className:`col`,style:{height:`${Math.max(i/n*112,i?10:2)}px`,background:`var(${e.v})`}}),(0,P.jsx)(`span`,{className:`idx`,children:e.n}),(0,P.jsx)(`span`,{className:`lb`,children:Nb(e)})]},e.n)})})}function Qb({findings:e,onSelect:t,emptyLabel:n=`No findings.`}){return e.length?(0,P.jsx)(`div`,{className:`flist`,children:e.map(e=>{let n=Mb(e.stage);return(0,P.jsxs)(`button`,{className:`frow`,type:`button`,onClick:t?()=>t(e):void 0,children:[(0,P.jsx)(`span`,{className:`sevtag sev-${e.severity}`,children:Rb[e.severity]}),(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`span`,{className:`ftitle`,children:e.title}),(0,P.jsxs)(`span`,{className:`fmeta`,children:[(0,P.jsxs)(`span`,{className:`stagetag`,children:[(0,P.jsx)(`span`,{className:`d`,style:{background:`var(${n.v})`}}),`Stage `,n.n,` · `,Nb(n)]}),(0,P.jsx)(`span`,{children:e.displayCategory}),e.path?(0,P.jsx)(`span`,{className:`font-mono`,children:e.path}):null]})]}),(0,P.jsx)(`span`,{className:`fright`,children:(0,P.jsx)(`span`,{className:`inline-flex shrink-0 self-start rounded-full border px-2.5 py-[3px] text-2xs font-semibold tracking-wide uppercase whitespace-nowrap text-muted-foreground`,children:e.status.replaceAll(`_`,` `)})})]},e.id)})}):(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n})}function $b({findings:e,selected:t,onSelect:n}){return(0,P.jsx)(`div`,{className:`chain`,children:jb.map(r=>{let i=e.filter(e=>e.stage===r.n),a=Bb(i);return(0,P.jsxs)(`button`,{className:`stagenode`,type:`button`,"aria-pressed":r.n===t,onClick:()=>n(r.n),children:[(0,P.jsx)(`div`,{className:`top`,style:{background:`var(${r.v})`}}),a?(0,P.jsx)(`span`,{className:`worst`,style:{background:`var(${Lb[a]})`}}):null,(0,P.jsxs)(`div`,{className:`sn`,children:[`STAGE `,r.n]}),(0,P.jsx)(`div`,{className:`st`,children:r.name}),(0,P.jsxs)(`div`,{className:`sc`,style:{color:`var(${r.v})`},children:[i.length,(0,P.jsxs)(`small`,{children:[`finding`,i.length===1?``:`s`]})]})]},r.n)})})}function ex({findings:e,onSelectStage:t}){return(0,P.jsx)(`div`,{style:{overflowX:`auto`},children:(0,P.jsxs)(`table`,{className:`matrix`,children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{className:`rh`}),jb.map(e=>(0,P.jsxs)(`th`,{children:[(0,P.jsx)(`span`,{className:`flex flex-wrap gap-4 text-xs font-medium`,children:(0,P.jsx)(`i`,{className:`mcap`,style:{background:`var(${e.v})`}})}),(0,P.jsx)(`br`,{}),e.n]},e.n))]})}),(0,P.jsx)(`tbody`,{children:Pb.map((n,r)=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{className:`rh`,children:n}),jb.map(i=>{let a=e.filter(e=>e.pillar===r&&e.stage===i.n),o=Bb(a);return o?(0,P.jsx)(`td`,{className:`has`,style:{background:`var(${Lb[o]})`,cursor:`pointer`},title:`${a.length} open at ${n} · stage ${i.n}`,onClick:()=>t(i.n),children:a.length},i.n):(0,P.jsx)(`td`,{children:`·`},i.n)})]},n))})]})})}function tx({items:e}){return(0,P.jsx)(`div`,{className:`my-3.5 grid grid-cols-2 gap-3 sm:grid-cols-4`,children:e.map(e=>(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`k`,children:e.k}),(0,P.jsx)(`div`,{className:e.mono?`v mono`:`v`,children:e.v})]},e.k))})}function nx({title:e,children:t}){return(0,P.jsxs)(`div`,{className:`border-[var(--hair)] mt-4 border-t pt-3.5 [&>h3]:text-muted-foreground [&>h3]:mb-2 [&>h3]:text-[11px] [&>h3]:font-semibold [&>h3]:tracking-[0.1em] [&>h3]:uppercase`,children:[(0,P.jsx)(`h3`,{children:e}),t]})}function rx({title:e,detail:t,verdict:n}){return(0,P.jsxs)(`div`,{className:`evi`,children:[(0,P.jsxs)(`svg`,{className:`ei`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,P.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,P.jsx)(`path`,{d:`M14 2v6h6`})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`et`,children:e}),(0,P.jsx)(`div`,{className:`ed`,children:t})]}),(0,P.jsx)(`span`,{className:`verdict`,children:n})]})}var ix=y(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`,critical:`border-[color-mix(in_srgb,var(--crit)_35%,transparent)] bg-[var(--crit-bg)] text-[var(--crit)]`,high:`border-[color-mix(in_srgb,var(--high)_35%,transparent)] bg-[var(--high-bg)] text-[var(--high)]`,medium:`border-[color-mix(in_srgb,var(--med)_35%,transparent)] bg-[var(--med-bg)] text-[var(--med)]`,low:`border-[color-mix(in_srgb,var(--low)_35%,transparent)] bg-[var(--low-bg)] text-[var(--low)]`,success:`border-[color-mix(in_srgb,var(--good)_35%,transparent)] bg-[var(--good-bg)] text-[var(--good)]`,info:`bg-[var(--info-bg)] text-[var(--info)]`}},defaultVariants:{variant:`default`}}),ax={critical:`critical`,failed:`critical`,blocked:`critical`,R2:`critical`,high:`high`,awaiting_approval:`high`,cancel_requested:`high`,R1:`high`,medium:`medium`,queued:`medium`,low:`low`,running:`low`,R0:`low`,succeeded:`success`,completed:`success`,confirmed:`success`,ok:`success`,verified:`success`,remediated:`success`,info:`info`,informational:`info`};function ox(e){return e?ax[e]??`secondary`:`secondary`}function sx({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?c:`span`;return(0,P.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:a(ix({variant:t}),e),...r})}function cx(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var lx=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ux=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,dx={};function fx(e,t){return((t||dx).jsx?ux:lx).test(e)}var px=/[ \t\n\f\r]/g;function mx(e){return typeof e==`object`?e.type===`text`&&hx(e.value):hx(e)}function hx(e){return e.replace(px,``)===``}var gx=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};gx.prototype.normal={},gx.prototype.property={},gx.prototype.space=void 0;function _x(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new gx(n,r,t)}function vx(e){return e.toLowerCase()}var yx=class{constructor(e,t){this.attribute=t,this.property=e}};yx.prototype.attribute=``,yx.prototype.booleanish=!1,yx.prototype.boolean=!1,yx.prototype.commaOrSpaceSeparated=!1,yx.prototype.commaSeparated=!1,yx.prototype.defined=!1,yx.prototype.mustUseProperty=!1,yx.prototype.number=!1,yx.prototype.overloadedBoolean=!1,yx.prototype.property=``,yx.prototype.spaceSeparated=!1,yx.prototype.space=void 0;var bx=e({boolean:()=>G,booleanish:()=>Sx,commaOrSpaceSeparated:()=>Ex,commaSeparated:()=>Tx,number:()=>K,overloadedBoolean:()=>Cx,spaceSeparated:()=>wx}),xx=0,G=Dx(),Sx=Dx(),Cx=Dx(),K=Dx(),wx=Dx(),Tx=Dx(),Ex=Dx();function Dx(){return 2**++xx}var Ox=Object.keys(bx),kx=class extends yx{constructor(e,t,n,r){let i=-1;if(super(e,t),Ax(this,`space`,r),typeof n==`number`)for(;++i<Ox.length;){let e=Ox[i];Ax(this,Ox[i],(n&bx[e])===bx[e])}}};kx.prototype.defined=!0;function Ax(e,t,n){n&&(e[t]=n)}function jx(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new kx(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[vx(r)]=r,n[vx(a.attribute)]=r}return new gx(t,n,e.space)}var Mx=jx({properties:{ariaActiveDescendant:null,ariaAtomic:Sx,ariaAutoComplete:null,ariaBusy:Sx,ariaChecked:Sx,ariaColCount:K,ariaColIndex:K,ariaColSpan:K,ariaControls:wx,ariaCurrent:null,ariaDescribedBy:wx,ariaDetails:null,ariaDisabled:Sx,ariaDropEffect:wx,ariaErrorMessage:null,ariaExpanded:Sx,ariaFlowTo:wx,ariaGrabbed:Sx,ariaHasPopup:null,ariaHidden:Sx,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:wx,ariaLevel:K,ariaLive:null,ariaModal:Sx,ariaMultiLine:Sx,ariaMultiSelectable:Sx,ariaOrientation:null,ariaOwns:wx,ariaPlaceholder:null,ariaPosInSet:K,ariaPressed:Sx,ariaReadOnly:Sx,ariaRelevant:null,ariaRequired:Sx,ariaRoleDescription:wx,ariaRowCount:K,ariaRowIndex:K,ariaRowSpan:K,ariaSelected:Sx,ariaSetSize:K,ariaSort:null,ariaValueMax:K,ariaValueMin:K,ariaValueNow:K,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Nx(e,t){return t in e?e[t]:t}function Px(e,t){return Nx(e,t.toLowerCase())}var Fx=jx({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:Tx,acceptCharset:wx,accessKey:wx,action:null,allow:null,allowFullScreen:G,allowPaymentRequest:G,allowUserMedia:G,alpha:G,alt:null,as:null,async:G,autoCapitalize:null,autoComplete:wx,autoFocus:G,autoPlay:G,blocking:wx,capture:null,charSet:null,checked:G,cite:null,className:wx,closedBy:null,colorSpace:null,cols:K,colSpan:K,command:null,commandFor:null,content:null,contentEditable:Sx,controls:G,controlsList:wx,coords:K|Tx,crossOrigin:null,data:null,dateTime:null,decoding:null,default:G,defer:G,dir:null,dirName:null,disabled:G,download:Cx,draggable:Sx,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:G,formTarget:null,headers:wx,height:K,hidden:Cx,high:K,href:null,hrefLang:null,htmlFor:wx,httpEquiv:wx,id:null,imageSizes:null,imageSrcSet:null,inert:G,inputMode:null,integrity:null,is:null,isMap:G,itemId:null,itemProp:wx,itemRef:wx,itemScope:G,itemType:wx,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:G,low:K,manifest:null,max:null,maxLength:K,media:null,method:null,min:null,minLength:K,multiple:G,muted:G,name:null,nonce:null,noModule:G,noValidate:G,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:G,optimum:K,pattern:null,ping:wx,placeholder:null,playsInline:G,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:G,referrerPolicy:null,rel:wx,required:G,reversed:G,rows:K,rowSpan:K,sandbox:wx,scope:null,scoped:G,seamless:G,selected:G,shadowRootClonable:G,shadowRootCustomElementRegistry:G,shadowRootDelegatesFocus:G,shadowRootMode:null,shadowRootSerializable:G,shape:null,size:K,sizes:null,slot:null,span:K,spellCheck:Sx,src:null,srcDoc:null,srcLang:null,srcSet:null,start:K,step:null,style:null,tabIndex:K,target:null,title:null,translate:null,type:null,typeMustMatch:G,useMap:null,value:Sx,width:K,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:wx,axis:null,background:null,bgColor:null,border:K,borderColor:null,bottomMargin:K,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:G,declare:G,event:null,face:null,frame:null,frameBorder:null,hSpace:K,leftMargin:K,link:null,longDesc:null,lowSrc:null,marginHeight:K,marginWidth:K,noResize:G,noHref:G,noShade:G,noWrap:G,object:null,profile:null,prompt:null,rev:null,rightMargin:K,rules:null,scheme:null,scrolling:Sx,standby:null,summary:null,text:null,topMargin:K,valueType:null,version:null,vAlign:null,vLink:null,vSpace:K,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:G,disablePictureInPicture:G,disableRemotePlayback:G,exportParts:Tx,part:wx,prefix:null,property:null,results:K,security:null,unselectable:null},space:`html`,transform:Px}),Ix=jx({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:Ex,accentHeight:K,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:K,amplitude:K,arabicForm:null,ascent:K,attributeName:null,attributeType:null,azimuth:K,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:K,by:null,calcMode:null,capHeight:K,className:wx,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:K,diffuseConstant:K,direction:null,display:null,dur:null,divisor:K,dominantBaseline:null,download:G,dx:null,dy:null,edgeMode:null,editable:null,elevation:K,enableBackground:null,end:null,event:null,exponent:K,externalResourcesRequired:null,fill:null,fillOpacity:K,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Tx,g2:Tx,glyphName:Tx,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:K,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:K,horizOriginX:K,horizOriginY:K,id:null,ideographic:K,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:K,k:K,k1:K,k2:K,k3:K,k4:K,kernelMatrix:Ex,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:K,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:K,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:K,overlineThickness:K,paintOrder:null,panose1:null,path:null,pathLength:K,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:wx,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:K,pointsAtY:K,pointsAtZ:K,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Ex,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Ex,rev:Ex,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Ex,requiredFeatures:Ex,requiredFonts:Ex,requiredFormats:Ex,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:K,specularExponent:K,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:K,strikethroughThickness:K,string:null,stroke:null,strokeDashArray:Ex,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:K,strokeOpacity:K,strokeWidth:null,style:null,surfaceScale:K,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Ex,tabIndex:K,tableValues:null,target:null,targetX:K,targetY:K,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Ex,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:K,underlineThickness:K,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:K,values:null,vAlphabetic:K,vMathematical:K,vectorEffect:null,vHanging:K,vIdeographic:K,version:null,vertAdvY:K,vertOriginX:K,vertOriginY:K,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:K,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Nx}),Lx=jx({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Rx=jx({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Px}),zx=jx({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Bx={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},Vx=/[A-Z]/g,Hx=/-[a-z]/g,Ux=/^data[-\w.:]+$/i;function Wx(e,t){let n=vx(t),r=t,i=yx;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Ux.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Hx,Kx);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Hx.test(e)){let n=e.replace(Vx,Gx);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=kx}return new i(r,t)}function Gx(e){return`-`+e.toLowerCase()}function Kx(e){return e.charAt(1).toUpperCase()}var qx=_x([Mx,Fx,Lx,Rx,zx],`html`),Jx=_x([Mx,Ix,Lx,Rx,zx],`svg`);function Yx(e){return e.join(` `).trim()}var Xx=r(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
|
|
61
|
+
`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),Zx=r((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(Xx());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),Qx=r((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),$x=r(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Zx()),r=Qx();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),eS=nS(`end`),tS=nS(`start`);function nS(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function rS(e){let t=tS(e),n=eS(e);if(t&&n)return{start:t,end:n}}function iS(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?oS(e.position):`start`in e||`end`in e?oS(e):`line`in e||`column`in e?aS(e):``}function aS(e){return sS(e&&e.line)+`:`+sS(e&&e.column)}function oS(e){return aS(e&&e.start)+`-`+aS(e&&e.end)}function sS(e){return e&&typeof e==`number`?e:1}var cS=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=iS(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};cS.prototype.file=``,cS.prototype.name=``,cS.prototype.reason=``,cS.prototype.message=``,cS.prototype.stack=``,cS.prototype.column=void 0,cS.prototype.line=void 0,cS.prototype.ancestors=void 0,cS.prototype.cause=void 0,cS.prototype.fatal=void 0,cS.prototype.place=void 0,cS.prototype.ruleId=void 0,cS.prototype.source=void 0;var lS=n($x(),1),uS={}.hasOwnProperty,dS=new Map,fS=/[A-Z]/g,pS=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),mS=new Set([`td`,`th`]),hS=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function gS(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=DS(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=ES(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?Jx:qx,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=_S(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function _S(e,t,n){if(t.type===`element`)return vS(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return yS(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return xS(e,t,n);if(t.type===`mdxjsEsm`)return bS(e,t);if(t.type===`root`)return SS(e,t,n);if(t.type===`text`)return CS(e,t)}function vS(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Jx,e.schema=i),e.ancestors.push(t);let a=NS(e,t.tagName,!1),o=OS(e,t),s=AS(e,t);return pS.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!mx(e)})),wS(e,o,a,t),TS(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function yS(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}PS(e,t.position)}function bS(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);PS(e,t.position)}function xS(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Jx,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:NS(e,t.name,!0),o=kS(e,t),s=AS(e,t);return wS(e,o,a,t),TS(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function SS(e,t,n){let r={};return TS(r,AS(e,t)),e.create(t,e.Fragment,r,n)}function CS(e,t){return t.value}function wS(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function TS(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function ES(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function DS(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=tS(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function OS(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&uS.call(t.properties,i)){let a=jS(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&mS.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function kS(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else PS(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else PS(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function AS(e,t){let n=[],r=-1,i=e.passKeys?new Map:dS;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=_S(e,a,o);s!==void 0&&n.push(s)}return n}function jS(e,t,n){let r=Wx(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?cx(n):Yx(n)),r.property===`style`){let t=typeof n==`object`?n:MS(e,String(n));return e.stylePropertyNameCase===`css`&&(t=FS(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Bx[r.property]||r.property:r.attribute,n]}}function MS(e,t){try{return(0,lS.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new cS("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=hS+`#cannot-parse-style-attribute`,r}}function NS(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=fx(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=fx(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return uS.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);PS(e)}function PS(e,t){let n=new cS("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=hS+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function FS(e){let t={},n;for(n in e)uS.call(e,n)&&(t[IS(n)]=e[n]);return t}function IS(e){let t=e.replace(fS,LS);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function LS(e){return`-`+e.toLowerCase()}var RS={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},zS={};function BS(e,t){let n=t||zS;return VS(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function VS(e,t,n){if(US(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return HS(e.children,t,n)}return Array.isArray(e)?HS(e,t,n):``}function HS(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=VS(e[i],t,n);return r.join(``)}function US(e){return!!(e&&typeof e==`object`)}var WS=document.createElement(`i`);function GS(e){let t=`&`+e+`;`;WS.innerHTML=t;let n=WS.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function KS(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function qS(e,t){return e.length>0?(KS(e,e.length,0,t),e):t}var JS={}.hasOwnProperty;function YS(e){let t={},n=-1;for(;++n<e.length;)XS(t,e[n]);return t}function XS(e,t){let n;for(n in t){let r=(JS.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){JS.call(r,a)||(r[a]=[]);let e=i[a];ZS(r[a],Array.isArray(e)?e:e?[e]:[])}}}function ZS(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);KS(e,0,0,r)}function QS(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function $S(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var eC=dC(/[A-Za-z]/),tC=dC(/[\dA-Za-z]/),nC=dC(/[#-'*+\--9=?A-Z^-~]/);function rC(e){return e!==null&&(e<32||e===127)}var iC=dC(/\d/),aC=dC(/[\dA-Fa-f]/),oC=dC(/[!-/:-@[-`{-~]/);function q(e){return e!==null&&e<-2}function sC(e){return e!==null&&(e<0||e===32)}function cC(e){return e===-2||e===-1||e===32}var lC=dC(/\p{P}|\p{S}/u),uC=dC(/\s/);function dC(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function fC(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&tC(e.charCodeAt(n+1))&&tC(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function pC(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return cC(r)?(e.enter(n),s(r)):t(r)}function s(r){return cC(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var mC={tokenize:hC};function hC(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),pC(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return q(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var gC={tokenize:vC},_C={tokenize:yC};function vC(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return KS(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(_C,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m(e)}function f(n){return t.containerState={},e.attempt(_C,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return q(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;KS(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function yC(e,t,n){return pC(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function bC(e){if(e===null||sC(e)||uC(e))return 1;if(lC(e))return 2}function xC(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var SC={name:`attention`,resolveAll:CC,tokenize:wC};function CC(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};TC(d,-c),TC(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=qS(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=qS(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=qS(l,xC(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=qS(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=qS(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,KS(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function wC(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=bC(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=bC(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function TC(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var EC={name:`autolink`,tokenize:DC};function DC(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return eC(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||tC(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||tC(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||rC(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):nC(t)?(e.consume(t),l):n(t)}function u(e){return tC(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||tC(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var OC={partial:!0,tokenize:kC};function kC(e,t,n){return r;function r(t){return cC(t)?pC(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||q(e)?t(e):n(e)}}var AC={continuation:{tokenize:MC},exit:NC,name:`blockQuote`,tokenize:jC};function jC(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return cC(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function MC(e,t,n){let r=this;return i;function i(t){return cC(t)?pC(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(AC,t,n)(r)}}function NC(e){e.exit(`blockQuote`)}var PC={name:`characterEscape`,tokenize:FC};function FC(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return oC(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var IC={name:`characterReference`,tokenize:LC};function LC(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=tC,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=aC,u):(e.enter(`characterReferenceValue`),a=7,o=iC,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===tC&&!GS(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var RC={partial:!0,tokenize:VC},zC={concrete:!0,name:`codeFenced`,tokenize:BC};function BC(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),cC(t)?pC(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||q(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(RC,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):cC(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),pC(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||q(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||q(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&cC(t)?pC(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||q(t)?e.check(RC,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||q(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),cC(t)?pC(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),cC(t)?pC(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||q(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function VC(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var HC={name:`codeIndented`,tokenize:WC},UC={partial:!0,tokenize:GC};function WC(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),pC(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):q(t)?e.attempt(UC,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||q(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function GC(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):pC(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):q(e)?i(e):n(e)}}var KC={name:`codeText`,previous:JC,resolve:qC,tokenize:YC};function qC(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function JC(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function YC(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||q(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var XC=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&ZC(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),ZC(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),ZC(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);ZC(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);ZC(this.left,t.reverse())}}}};function ZC(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function QC(e){let t={},n=-1,r,i,a,o,s,c,l,u=new XC(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,$C(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return KS(e,0,1/0,u.slice(0)),!l}function $C(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var ew={resolve:nw,tokenize:rw},tw={partial:!0,tokenize:iw};function nw(e){return QC(e),e}function rw(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):q(t)?e.check(tw,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function iw(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),pC(e,a,`linePrefix`)}function a(i){if(i===null||q(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function aw(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||rC(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||q(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||sC(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||rC(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function ow(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):q(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||q(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!cC(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function sw(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),pC(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||q(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function cw(e,t){let n;return r;function r(i){return q(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):cC(i)?pC(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var lw={name:`definition`,tokenize:dw},uw={partial:!0,tokenize:fw};function dw(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return ow.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=$S(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return sC(t)?cw(e,l)(t):l(t)}function l(t){return aw(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(uw,d,d)(t)}function d(t){return cC(t)?pC(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||q(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function fw(e,t,n){return r;function r(t){return sC(t)?cw(e,i)(t):n(t)}function i(t){return sw(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return cC(t)?pC(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||q(e)?t(e):n(e)}}var pw={name:`hardBreakEscape`,tokenize:mw};function mw(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return q(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var hw={name:`headingAtx`,resolve:gw,tokenize:_w};function gw(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},KS(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function _w(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||sC(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||q(n)?(e.exit(`atxHeading`),t(n)):cC(n)?pC(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||sC(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var vw=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),yw=[`pre`,`script`,`style`,`textarea`],bw={concrete:!0,name:`htmlFlow`,resolveTo:Cw,tokenize:ww},xw={partial:!0,tokenize:Ew},Sw={partial:!0,tokenize:Tw};function Cw(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function ww(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:re):eC(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):eC(a)?(e.consume(a),i=4,r.interrupt?t:re):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:re):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return eC(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||sC(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&yw.includes(l)?(i=1,r.interrupt?t(s):O(s)):vw.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||tC(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return cC(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||eC(t)?(e.consume(t),b):cC(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||tC(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):cC(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):cC(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||q(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||sC(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||cC(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||q(t)?O(t):cC(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),ee):t===62&&i===4?(e.consume(t),ie):t===63&&i===3?(e.consume(t),re):t===93&&i===5?(e.consume(t),ne):q(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(xw,ae,k)(t)):t===null||q(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(Sw,A,ae)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||q(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),re):O(t)}function ee(t){return t===47?(e.consume(t),o=``,te):O(t)}function te(t){if(t===62){let n=o.toLowerCase();return yw.includes(n)?(e.consume(t),ie):O(t)}return eC(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),te):O(t)}function ne(t){return t===93?(e.consume(t),re):O(t)}function re(t){return t===62?(e.consume(t),ie):t===45&&i===2?(e.consume(t),re):O(t)}function ie(t){return t===null||q(t)?(e.exit(`htmlFlowData`),ae(t)):(e.consume(t),ie)}function ae(n){return e.exit(`htmlFlow`),t(n)}}function Tw(e,t,n){let r=this;return i;function i(t){return q(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function Ew(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(OC,t,n)}}var Dw={name:`htmlText`,tokenize:Ow};function Ow(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):eC(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):eC(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):q(t)?(o=d,ee(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):q(t)?(o=h,ee(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):q(t)?(o=v,ee(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):q(t)?(o=y,ee(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return eC(t)?(e.consume(t),S):n(t)}function S(t){return t===45||tC(t)?(e.consume(t),S):C(t)}function C(t){return q(t)?(o=C,ee(t)):cC(t)?(e.consume(t),C):M(t)}function w(t){return t===45||tC(t)?(e.consume(t),w):t===47||t===62||sC(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||eC(t)?(e.consume(t),E):q(t)?(o=T,ee(t)):cC(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||tC(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):q(t)?(o=D,ee(t)):cC(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):q(t)?(o=O,ee(t)):cC(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):q(t)?(o=k,ee(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||sC(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||sC(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function ee(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),te}function te(t){return cC(t)?pC(e,ne,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):ne(t)}function ne(t){return e.enter(`htmlTextData`),o(t)}}var kw={name:`labelEnd`,resolveAll:Nw,resolveTo:Pw,tokenize:Fw},Aw={tokenize:Iw},jw={tokenize:Lw},Mw={tokenize:Rw};function Nw(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&KS(e,0,e.length,n),e}function Pw(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=qS(s,e.slice(a+1,a+r+3)),s=qS(s,[[`enter`,u,t]]),s=qS(s,xC(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=qS(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=qS(s,e.slice(o+1)),s=qS(s,[[`exit`,c,t]]),KS(e,a,e.length,s),e}function Fw(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes($S(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Aw,u,o?u:d)(t):t===91?e.attempt(jw,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Mw,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function Iw(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return sC(t)?cw(e,a)(t):a(t)}function a(t){return t===41?u(t):aw(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return sC(t)?cw(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?sw(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return sC(t)?cw(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Lw(e,t,n){let r=this;return i;function i(t){return ow.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes($S(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Rw(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var zw={name:`labelStartImage`,resolveAll:kw.resolveAll,tokenize:Bw};function Bw(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Vw={name:`labelStartLink`,resolveAll:kw.resolveAll,tokenize:Hw};function Hw(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Uw={name:`lineEnding`,tokenize:Ww};function Ww(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),pC(e,t,`linePrefix`)}}var Gw={name:`thematicBreak`,tokenize:Kw};function Kw(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||q(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),cC(t)?pC(e,s,`whitespace`)(t):s(t))}}var qw={continuation:{tokenize:Zw},exit:$w,name:`list`,tokenize:Xw},Jw={partial:!0,tokenize:eT},Yw={partial:!0,tokenize:Qw};function Xw(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:iC(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Gw,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return iC(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(OC,r.interrupt?n:u,e.attempt(Jw,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return cC(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function Zw(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(OC,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,pC(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!cC(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Yw,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,pC(e,e.attempt(qw,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function Qw(e,t,n){let r=this;return pC(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function $w(e){e.exit(this.containerState.type)}function eT(e,t,n){let r=this;return pC(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!cC(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var tT={name:`setextUnderline`,resolveTo:nT,tokenize:rT};function nT(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function rT(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),cC(t)?pC(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||q(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var iT={tokenize:aT};function aT(e){let t=this,n=e.attempt(OC,r,e.attempt(this.parser.constructs.flowInitial,i,pC(e,e.attempt(this.parser.constructs.flow,i,e.attempt(ew,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var oT={resolveAll:uT()},sT=lT(`string`),cT=lT(`text`);function lT(e){return{resolveAll:uT(e===`text`?dT:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function uT(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function dT(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var fT=e({attentionMarkers:()=>bT,contentInitial:()=>mT,disable:()=>xT,document:()=>pT,flow:()=>gT,flowInitial:()=>hT,insideSpan:()=>yT,string:()=>_T,text:()=>vT}),pT={42:qw,43:qw,45:qw,48:qw,49:qw,50:qw,51:qw,52:qw,53:qw,54:qw,55:qw,56:qw,57:qw,62:AC},mT={91:lw},hT={[-2]:HC,[-1]:HC,32:HC},gT={35:hw,42:Gw,45:[tT,Gw],60:bw,61:tT,95:Gw,96:zC,126:zC},_T={38:IC,92:PC},vT={[-5]:Uw,[-4]:Uw,[-3]:Uw,33:zw,38:IC,42:SC,60:[EC,Dw],91:Vw,92:[pw,PC],93:kw,95:SC,96:KC},yT={null:[SC,oT]},bT={null:[42,95]},xT={null:[]};function ST(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=qS(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=xC(a,l.events,l),l.events):[]}function f(e,t){return wT(p(e),t)}function p(e){return CT(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){q(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&KS(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function CT(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function wT(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
|
|
62
|
+
`;break;case-3:o=`\r
|
|
63
|
+
`;break;case-2:o=t?` `:` `;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function TT(e){let t={constructs:YS([fT,...(e||{}).extensions||[]]),content:n(mC),defined:[],document:n(gC),flow:n(iT),lazy:{},string:n(sT),text:n(cT)};return t;function n(e){return n;function n(n){return ST(t,e,n)}}}function ET(e){for(;!QC(e););return e}var DT=/[\0\t\n\r]/g;function OT(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(DT.lastIndex=u,c=DT.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var kT=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function AT(e){return e.replace(kT,jT)}function jT(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;return QS(n.slice(t?2:1),t?16:10)}return GS(n)||e}var MT={}.hasOwnProperty;function NT(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),PT(n)(ET(TT(n).document().write(OT()(e,t,!0))))}function PT(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(Se),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(ve),blockQuote:a(pe),characterEscape:T,characterReference:T,codeFenced:a(me),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(me,o),codeText:a(he,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(ge),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(_e),hardBreakEscape:a(ye),hardBreakTrailing:a(ye),htmlFlow:a(be,o),htmlFlowData:T,htmlText:a(be,o),htmlTextData:T,image:a(xe),label:o,link:a(Se),listItem:a(we),listItemValue:f,listOrdered:a(Ce,d),listUnordered:a(Ce),paragraph:a(Te),reference:oe,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(ve),strong:a(Ee),thematicBreak:a(Oe)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:fe,autolinkProtocol:de,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ce,characterReferenceMarkerNumeric:ce,characterReferenceValue:le,characterReference:ue,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(ee),label:ne,labelText:te,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:re,resourceTitleString:ie,resource:ae,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};IT(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];MT.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||RT).call(a,void 0,e[0])}for(r.position={start:FT(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:FT(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:FT(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||RT).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+iS({start:e.start,end:e.end})+`): it’s not open`);n.position.end=FT(e.end)}function u(){return BS(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=$S(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=De(),n.position={start:FT(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=FT(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=FT(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function ee(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function te(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=AT(t),n.identifier=$S(t).toLowerCase()}function ne(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function re(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function ie(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ae(){this.data.inReference=void 0}function oe(){this.data.referenceType=`collapsed`}function se(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=$S(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function ce(e){this.data.characterReferenceType=e.type}function le(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=QS(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=GS(t);let i=this.stack[this.stack.length-1];i.value+=r}function ue(e){let t=this.stack.pop();t.position.end=FT(e.end)}function de(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function fe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function pe(){return{type:`blockquote`,children:[]}}function me(){return{type:`code`,lang:null,meta:null,value:``}}function he(){return{type:`inlineCode`,value:``}}function ge(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function _e(){return{type:`emphasis`,children:[]}}function ve(){return{type:`heading`,depth:0,children:[]}}function ye(){return{type:`break`}}function be(){return{type:`html`,value:``}}function xe(){return{type:`image`,title:null,url:``,alt:null}}function Se(){return{type:`link`,title:null,url:``,children:[]}}function Ce(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function we(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function Te(){return{type:`paragraph`,children:[]}}function Ee(){return{type:`strong`,children:[]}}function De(){return{type:`text`,value:``}}function Oe(){return{type:`thematicBreak`}}}function FT(e){return{line:e.line,column:e.column,offset:e.offset}}function IT(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?IT(e,r):LT(e,r)}}function LT(e,t){let n;for(n in t)if(MT.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function RT(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+iS({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+iS({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+iS({start:t.start,end:t.end})+`) is still open`)}function zT(e){let t=this;t.parser=n;function n(n){return NT(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function BT(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function VT(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
|
|
64
|
+
`}]}function HT(e,t){let n=t.value?t.value+`
|
|
65
|
+
`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function UT(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function WT(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GT(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=fC(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function KT(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qT(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function JT(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function YT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return JT(e,t);let i={src:fC(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function XT(e,t){let n={src:fC(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function ZT(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function QT(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return JT(e,t);let i={href:fC(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function $T(e,t){let n={href:fC(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function eE(e,t,n){let r=e.all(t),i=n?tE(n):nE(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
66
|
+
`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
|
|
67
|
+
`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function tE(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=nE(n[r])}return t}function nE(e){return e.spread??e.children.length>1}function rE(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function iE(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function aE(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function oE(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function sE(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=tS(t.children[1]),o=eS(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function cE(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function lE(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var uE=9,dE=32;function fE(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(pE(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(pE(t.slice(i),i>0,!1)),a.join(``)}function pE(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===uE||t===dE;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===uE||t===dE;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function mE(e,t){let n={type:`text`,value:fE(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function hE(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var gE={blockquote:BT,break:VT,code:HT,delete:UT,emphasis:WT,footnoteReference:GT,heading:KT,html:qT,imageReference:YT,image:XT,inlineCode:ZT,linkReference:QT,link:$T,listItem:eE,list:rE,paragraph:iE,root:aE,strong:oE,table:sE,tableCell:lE,tableRow:cE,text:mE,thematicBreak:hE,toml:_E,yaml:_E,definition:_E,footnoteDefinition:_E};function _E(){}var{defineProperty:vE}=Object,yE=typeof self==`object`?self:globalThis,bE=(e,t)=>{switch(e){case`Function`:case`SharedWorker`:case`Worker`:case`eval`:case`setInterval`:case`setTimeout`:throw TypeError(`unable to deserialize `+e)}return new yE[e](t)},xE=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o){let i=r(t),a=r(n);i===`__proto__`?vE(e,i,{value:a,configurable:!0,enumerable:!0,writable:!0}):e[i]=a}return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(typeof yE[e]==`function`?bE(e,t):Error(t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}case`-0`:return-0}return n(bE(a,o),i)};return r},SE=e=>xE(new Map,e)(0),CE=``,{toString:wE}={},{keys:TE,is:EE}=Object,DE=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=wE.call(e).slice(8,-1);switch(n){case`Array`:return[1,CE];case`Object`:return[2,CE];case`Date`:return[3,CE];case`RegExp`:return[4,CE];case`Map`:return[5,CE];case`Set`:return[6,CE];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:e instanceof Error?[7,e.name||`Error`]:[2,n]},OE=([e,t])=>e===0&&(t===`function`||t===`symbol`),kE=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=o=>{if(n.has(o))return n.get(o);let[s,c]=DE(o);switch(s){case 0:{let t=o;switch(c){case`bigint`:s=8,t=o.toString();break;case`number`:if(!o&&EE(o,-0))return r.push([`-0`])-1;break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+c);t=null;break;case`undefined`:return i([-1],o)}return i([s,t],o)}case 1:{if(c){let e=o;return c===`DataView`?e=new Uint8Array(o.buffer):c===`ArrayBuffer`&&(e=new Uint8Array(o)),i([c,[...e]],o)}let e=[],t=i([s,e],o);for(let t of o)e.push(a(t));return t}case 2:{if(c)switch(c){case`BigInt`:return i([c,o.toString()],o);case`Boolean`:case`Number`:case`String`:return i([c,o.valueOf()],o)}if(t&&`toJSON`in o)return a(o.toJSON());let n=[],r=i([s,n],o);for(let t of TE(o))(e||!OE(DE(o[t])))&&n.push([a(t),a(o[t])]);return r}case 3:return i([s,isNaN(o.getTime())?CE:o.toISOString()],o);case 4:{let{source:e,flags:t}=o;return i([s,{source:e,flags:t}],o)}case 5:{let t=[],n=i([s,t],o);for(let[n,r]of o)(e||!(OE(DE(n))||OE(DE(r))))&&t.push([a(n),a(r)]);return n}case 6:{let t=[],n=i([s,t],o);for(let n of o)(e||!OE(DE(n)))&&t.push(a(n));return n}}let{message:l}=o;return i([s,{name:c,message:l}],o)};return a},AE=(e,{json:t,lossy:n}={})=>{let r=[];return kE(!(t||n),!!t,new Map,r)(e),r},jE=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?SE(AE(e,t)):structuredClone(e):(e,t)=>SE(AE(e,t));function ME(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function NE(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function PE(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||ME,r=e.options.footnoteBackLabel||NE,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=fC(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...jE(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
|
|
68
|
+
`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
|
|
69
|
+
`}]}}var FE=(function(e){if(e==null)return BE;if(typeof e==`function`)return zE(e);if(typeof e==`object`)return Array.isArray(e)?IE(e):LE(e);if(typeof e==`string`)return RE(e);throw Error(`Expected function, string, or object as test`)});function IE(e){let t=[],n=-1;for(;++n<e.length;)t[n]=FE(e[n]);return zE(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function LE(e){let t=e;return zE(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function RE(e){return zE(t);function t(t){return t&&t.type===e}}function zE(e){return t;function t(t,n,r){return!!(VE(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function BE(){return!0}function VE(e){return typeof e==`object`&&!!e&&`type`in e}function HE(e){return e}var UE=[];function WE(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=FE(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+HE(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=UE,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=GE(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function GE(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?UE:[e]}function KE(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),WE(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var qE={}.hasOwnProperty,JE={};function YE(e,t){let n=t||JE,r=new Map,i=new Map,a={all:s,applyData:ZE,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...gE,...n.handlers},one:o,options:n,patch:XE,wrap:$E};return KE(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(qE.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=jE(n);return r.children=a.all(e),r}return jE(e)}return(a.options.unknownHandler||QE)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=eD(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=eD(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function XE(e,t){e.position&&(t.position=rS(e))}function ZE(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,jE(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function QE(e,t){let n=t.data||{},r=`value`in t&&!(qE.call(n,`hProperties`)||qE.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function $E(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
|
|
70
|
+
`});++r<e.length;)r&&n.push({type:`text`,value:`
|
|
71
|
+
`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
|
|
72
|
+
`}),n}function eD(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function tD(e,t){let n=YE(e,t),r=n.one(e,void 0),i=PE(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
|
|
73
|
+
`},i)),a}function nD(e,t){return e&&`run`in e?async function(n,r){let i=tD(n,{file:r,...t});await e.run(i,r)}:function(n,r){return tD(n,{file:r,...e||t})}}function rD(e){if(e)throw e}var iD=r(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{},c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}));function aD(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function oD(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?sD(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function sD(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var cD={basename:lD,dirname:uD,extname:dD,join:fD,sep:`/`};function lD(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);hD(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function uD(e){if(hD(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function dD(e){hD(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function fD(...e){let t=-1,n;for(;++t<e.length;)hD(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:pD(n)}function pD(e){hD(e);let t=e.codePointAt(0)===47,n=mD(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function mD(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function hD(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var gD={cwd:_D};function _D(){return`/`}function vD(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function yD(e){if(typeof e==`string`)e=new URL(e);else if(!vD(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return bD(e)}function bD(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var xD=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],SD=class{constructor(e){let t;t=e?vD(e)?{path:e}:typeof e==`string`||ED(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:gD.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<xD.length;){let e=xD[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)xD.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?cD.basename(this.path):void 0}set basename(e){wD(e,`basename`),CD(e,`basename`),this.path=cD.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?cD.dirname(this.path):void 0}set dirname(e){TD(this.basename,`dirname`),this.path=cD.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?cD.extname(this.path):void 0}set extname(e){if(CD(e,`extname`),TD(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=cD.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){vD(e)&&(e=yD(e)),wD(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?cD.basename(this.path,this.extname):void 0}set stem(e){wD(e,`stem`),CD(e,`stem`),this.path=cD.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new cS(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function CD(e,t){if(e&&e.includes(cD.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+cD.sep+"`")}function wD(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function TD(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function ED(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var DD=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),OD=n(iD(),1),kD={}.hasOwnProperty,AD=new class e extends DD{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=oD()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,OD.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(ND(`data`,this.frozen),this.namespace[e]=t,this):kD.call(this.namespace,e)&&this.namespace[e]||void 0:e?(ND(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=ID(e),n=this.parser||this.Parser;return jD(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),jD(`process`,this.parser||this.Parser),MD(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=ID(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);RD(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),jD(`processSync`,this.parser||this.Parser),MD(`processSync`,this.compiler||this.Compiler),this.process(e,r),FD(`processSync`,`process`,t),n;function r(e,r){t=!0,rD(e),n=r}}run(e,t,n){PD(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=ID(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),FD(`runSync`,`run`,n),r;function i(e,t){rD(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=ID(t),r=this.compiler||this.Compiler;return MD(`stringify`,r),PD(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(ND(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,OD.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];aD(o)&&aD(r)&&(r=(0,OD.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function jD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function MD(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function ND(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function PD(e){if(!aD(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function FD(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function ID(e){return LD(e)?e:new SD(e)}function LD(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function RD(e){return typeof e==`string`||zD(e)}function zD(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var BD=[],VD={allowDangerousHtml:!0},HD=/^(https?|ircs?|mailto|xmpp)$/i,UD=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function WD(e){let t=GD(e),n=KD(e);return qD(t.runSync(t.parse(n),n),e)}function GD(e){let t=e.rehypePlugins||BD,n=e.remarkPlugins||BD,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...VD}:VD;return AD().use(zT).use(n).use(nD,r).use(t)}function KD(e){let t=e.children||``,n=new SD;return typeof t==`string`?n.value=t:``+t,n}function qD(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||JD;for(let e of UD)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return KE(e,l),gS(e,{Fragment:P.Fragment,components:i,ignoreInvalidStyle:!0,jsx:P.jsx,jsxs:P.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in RS)if(Object.hasOwn(RS,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=RS[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function JD(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||HD.test(e.slice(0,t))?e:``}function YD(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function XD(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function ZD(e,t,n){let r=FE((n||{}).ignore||[]),i=QD(t),a=-1;for(;++a<i.length;)WE(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function QD(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([$D(e[0]),eO(e[1])])}return t}function $D(e){return typeof e==`string`?new RegExp(XD(e),`g`):e}function eO(e){return typeof e==`function`?e:function(){return e}}var tO=`phrasing`,nO=[`autolink`,`link`,`image`,`label`];function rO(){return{transforms:[dO],enter:{literalAutolink:aO,literalAutolinkEmail:oO,literalAutolinkHttp:oO,literalAutolinkWww:oO},exit:{literalAutolink:uO,literalAutolinkEmail:lO,literalAutolinkHttp:sO,literalAutolinkWww:cO}}}function iO(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:tO,notInConstruct:nO},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:tO,notInConstruct:nO},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:tO,notInConstruct:nO}]}}function aO(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function oO(e){this.config.enter.autolinkProtocol.call(this,e)}function sO(e){this.config.exit.autolinkProtocol.call(this,e)}function cO(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function lO(e){this.config.exit.autolinkEmail.call(this,e)}function uO(e){this.exit(e)}function dO(e){ZD(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,fO],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,pO]],{ignore:[`link`,`linkReference`]})}function fO(e,t,n,r,i){let a=``;if(!gO(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!mO(n)))return!1;let o=hO(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function pO(e,t,n,r){return!gO(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function mO(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function hO(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=YD(e,`(`),a=YD(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function gO(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||uC(n)||lC(n))&&(!t||n!==47)}EO.peek=TO;function _O(){this.buffer()}function vO(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function yO(){this.buffer()}function bO(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function xO(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=$S(this.sliceSerialize(e)).toLowerCase(),n.label=t}function SO(e){this.exit(e)}function CO(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=$S(this.sliceSerialize(e)).toLowerCase(),n.label=t}function wO(e){this.exit(e)}function TO(){return`[`}function EO(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function DO(){return{enter:{gfmFootnoteCallString:_O,gfmFootnoteCall:vO,gfmFootnoteDefinitionLabelString:yO,gfmFootnoteDefinition:bO},exit:{gfmFootnoteCallString:xO,gfmFootnoteCall:SO,gfmFootnoteDefinitionLabelString:CO,gfmFootnoteDefinition:wO}}}function OO(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:EO},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
|
|
74
|
+
`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?AO:kO))),s(),o}}function kO(e,t,n){return t===0?e:AO(e,t,n)}function AO(e,t,n){return(n?``:` `)+e}var jO=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];IO.peek=LO;function MO(){return{canContainEols:[`delete`],enter:{strikethrough:PO},exit:{strikethrough:FO}}}function NO(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:jO}],handlers:{delete:IO}}}function PO(e){this.enter({type:`delete`,children:[]},e)}function FO(e){this.exit(e)}function IO(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function LO(){return`~`}function RO(e){return e.length}function zO(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||RO,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=BO(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=VO(r[d]);else{let e=VO(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
|
|
75
|
+
`)}function BO(e){return e==null?``:String(e)}function VO(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function HO(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),UO);return i(),o}function UO(e,t,n){return`>`+(n?``:` `)+e}function WO(e,t){return GO(e,t.inConstruct,!0)&&!GO(e,t.notInConstruct,!1)}function GO(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function KO(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
|
|
76
|
+
`&&WO(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
|
|
77
|
+
`}function qO(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function JO(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function YO(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function XO(e,t,n,r){let i=YO(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(JO(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,ZO);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(qO(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
|
|
78
|
+
`,encode:["`"],...s.current()})),t()}return u+=s.move(`
|
|
79
|
+
`),a&&(u+=s.move(a+`
|
|
80
|
+
`)),u+=s.move(c),l(),u}function ZO(e,t,n){return(n?``:` `)+e}function QO(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function $O(e,t,n,r){let i=QO(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
|
|
81
|
+
`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function ek(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function tk(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function nk(e,t,n){let r=bC(e),i=bC(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}rk.peek=ik;function rk(e,t,n,r){let i=ek(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=nk(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=tk(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=nk(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+tk(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function ik(e,t,n){return n.options.emphasis||`*`}function ak(e,t){let n=!1;return KE(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&BS(e)&&(t.options.setext||n))}function ok(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(ak(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
|
|
82
|
+
`,after:`
|
|
83
|
+
`});return r(),t(),o+`
|
|
84
|
+
`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
|
|
85
|
+
`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
|
|
86
|
+
`,...a.current()});return/^[\t ]/.test(l)&&(l=tk(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}sk.peek=ck;function sk(e){return e.value||``}function ck(){return`<`}lk.peek=uk;function lk(e,t,n,r){let i=QO(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function uk(){return`!`}dk.peek=fk;function dk(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function fk(){return`!`}pk.peek=mk;function pk(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function mk(){return"`"}function hk(e,t){let n=BS(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}gk.peek=_k;function gk(e,t,n,r){let i=QO(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(hk(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function _k(e,t,n){return hk(e,n)?`<`:`[`}vk.peek=yk;function vk(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function yk(){return`[`}function bk(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function xk(e){let t=bk(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Sk(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ck(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function wk(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Sk(n):bk(n),s=e.ordered?o===`.`?`)`:`.`:xk(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Ck(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Tk(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Ek(e,t,n,r){let i=Tk(n),a=n.bulletCurrent||bk(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function Dk(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var Ok=FE([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function kk(e,t,n,r){return(e.children.some(function(e){return Ok(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Ak(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}jk.peek=Mk;function jk(e,t,n,r){let i=Ak(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=nk(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=tk(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=nk(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+tk(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Mk(e,t,n){return n.options.strong||`*`}function Nk(e,t,n,r){return n.safe(e.value,r)}function Pk(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Fk(e,t,n){let r=(Ck(n)+(n.options.ruleSpaces?` `:``)).repeat(Pk(n));return n.options.ruleSpaces?r.slice(0,-1):r}var Ik={blockquote:HO,break:KO,code:XO,definition:$O,emphasis:rk,hardBreak:KO,heading:ok,html:sk,image:lk,imageReference:dk,inlineCode:pk,link:gk,linkReference:vk,list:wk,listItem:Ek,paragraph:Dk,root:kk,strong:jk,text:Nk,thematicBreak:Fk};function Lk(){return{enter:{table:Rk,tableData:Hk,tableHeader:Hk,tableRow:Bk},exit:{codeText:Uk,table:zk,tableData:Vk,tableHeader:Vk,tableRow:Vk}}}function Rk(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function zk(e){this.exit(e),this.data.inTable=void 0}function Bk(e){this.enter({type:`tableRow`,children:[]},e)}function Vk(e){this.exit(e)}function Hk(e){this.enter({type:`tableCell`,children:[]},e)}function Uk(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Wk));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Wk(e,t){return t===`|`?t:e}function Gk(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
|
|
87
|
+
`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
|
|
88
|
+
`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return zO(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Ik.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Kk(){return{exit:{taskListCheckValueChecked:Jk,taskListCheckValueUnchecked:Jk,paragraph:Yk}}}function qk(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Xk}}}function Jk(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Yk(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Xk(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Ik.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Zk(){return[rO(),DO(),MO(),Lk(),Kk()]}function Qk(e){return{extensions:[iO(),OO(e),NO(),Gk(e),qk()]}}var $k={tokenize:pA,partial:!0},eA={tokenize:mA,partial:!0},tA={tokenize:hA,partial:!0},nA={tokenize:gA,partial:!0},rA={tokenize:_A,partial:!0},iA={name:`wwwAutolink`,tokenize:dA,previous:vA},aA={name:`protocolAutolink`,tokenize:fA,previous:yA},oA={name:`emailAutolink`,tokenize:uA,previous:bA},sA={};function cA(){return{text:sA}}for(var lA=48;lA<123;)sA[lA]=oA,lA++,lA===58?lA=65:lA===91&&(lA=97);sA[43]=oA,sA[45]=oA,sA[46]=oA,sA[95]=oA,sA[72]=[oA,aA],sA[104]=[oA,aA],sA[87]=[oA,iA],sA[119]=[oA,iA];function uA(e,t,n){let r=this,i,a;return o;function o(t){return!xA(t)||!bA.call(r,r.previous)||SA(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return xA(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(rA,u,l)(t):t===45||t===95||tC(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&eC(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function dA(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!vA.call(r,r.previous)||SA(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check($k,e.attempt(eA,e.attempt(tA,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function fA(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&yA.call(r,r.previous)&&!SA(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(eC(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||rC(t)||sC(t)||uC(t)||lC(t)?n(t):e.attempt(eA,e.attempt(tA,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function pA(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function mA(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(nA,c,s)(t):t===null||sC(t)||uC(t)||t!==45&&lC(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function hA(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(nA,t,a)(o):o===null||sC(o)||uC(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function gA(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||sC(o)||uC(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||sC(e)||uC(e)?t(e):r(e)}function a(e){return eC(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):eC(t)?(e.consume(t),o):n(t)}}function _A(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return tC(e)?n(e):t(e)}}function vA(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||sC(e)}function yA(e){return!eC(e)}function bA(e){return!(e===47||xA(e))}function xA(e){return e===43||e===45||e===46||e===95||tC(e)}function SA(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var CA={tokenize:jA,partial:!0};function wA(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:OA,continuation:{tokenize:kA},exit:AA}},text:{91:{name:`gfmFootnoteCall`,tokenize:DA},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:TA,resolveTo:EA}}}}function TA(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=$S(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function EA(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function DA(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||sC(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes($S(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return sC(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function OA(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||sC(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=$S(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return sC(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),pC(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function kA(e,t,n){return e.check(OC,t,e.attempt(CA,t,n))}function AA(e){e.exit(`gfmFootnoteDefinition`)}function jA(e,t,n){let r=this;return pC(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function MA(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&KS(o,o.length,0,xC(s,e.slice(r+1,n),t)),KS(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),KS(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=bC(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=bC(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var NA=class{constructor(){this.map=[],this.index=new Map}add(e,t,n){PA(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0,this.index.clear()}};function PA(e,t,n,r){if(n===0&&r.length===0)return;let i=e.index.get(t);if(i){i[1]+=n,i[2].push(...r);return}let a=[t,n,r];e.map.push(a),e.index.set(t,a)}function FA(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function IA(){return{flow:{null:{name:`table`,tokenize:LA,resolveAll:RA}}}}function LA(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let{type:e}=r.events[t][1];if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):q(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):cC(t)?pC(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||sC(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,cC(t)?pC(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return cC(t)?pC(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||q(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return cC(t)?pC(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||q(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||q(n)?(e.exit(`tableRow`),t(n)):cC(n)?pC(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||sC(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function RA(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new NA;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(BA(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=zA(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=zA(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=zA(f,t,o,i,n,d)):(o[0]=o[1],d=zA(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&BA(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=FA(t.events,n))}return e}function zA(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},VA(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=VA(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=VA(t.events,n[2]),a=VA(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},VA(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function BA(e,t,n,r,i){let a=[],o=VA(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function VA(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var HA={name:`tasklistCheck`,tokenize:WA};function UA(){return{text:{91:HA}}}function WA(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return sC(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return q(r)?t(r):cC(r)?e.check({tokenize:GA},t,n)(r):n(r)}}function GA(e,t,n){return pC(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function KA(e){return YS([cA(),wA(),MA(e),IA(),UA()])}var qA={};function JA(e){let t=this,n=e||qA,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(KA(n)),a.push(Zk()),o.push(Qk(n))}var YA={a:({children:e,...t})=>(0,P.jsx)(`a`,{...t,target:`_blank`,rel:`noreferrer`,className:`text-primary underline underline-offset-2`,children:e}),code:({className:e,children:t,...n})=>/language-/.test(e??``)?(0,P.jsx)(`code`,{...n,className:`block overflow-auto rounded-md border bg-[var(--plane)] p-3 font-mono text-xs whitespace-pre-wrap`,children:t}):(0,P.jsx)(`code`,{...n,className:`rounded-sm bg-[var(--plane)] px-1 py-0.5 font-mono text-[0.85em]`,children:t}),pre:({children:e,...t})=>(0,P.jsx)(`pre`,{...t,className:`my-1 overflow-auto`,children:e}),blockquote:({children:e,...t})=>(0,P.jsx)(`blockquote`,{...t,className:`border-l-2 border-border pl-3 text-muted-foreground`,children:e}),table:({children:e,...t})=>(0,P.jsx)(`div`,{className:`overflow-auto`,children:(0,P.jsx)(`table`,{...t,className:`w-full text-xs`,children:e})})};function XA({children:e,className:t}){return(0,P.jsx)(`div`,{className:a(`md-body grid gap-2 text-sm leading-relaxed [&_h1]:mt-1 [&_h2]:mt-2 [&_h3]:mt-1`,t),children:(0,P.jsx)(WD,{remarkPlugins:[JA],components:YA,children:e})})}var ZA={clean:`success`,informational:`neutral`,actionable:`warning`,critical:`critical`},QA={critical:`critical`,high:`error`,medium:`warning`,low:`neutral`,informational:`neutral`};function $A(){let e=Nf(),t=Jf({queryKey:[`runs`],queryFn:()=>Ab.runs()}),n=t.data?.runs??[],[r,i]=(0,N.useState)(null),a=Jf({queryKey:[`report-versions`,r],queryFn:()=>Ab.reportVersions(r),enabled:!!r}).data?.items??[],[o,c]=(0,N.useState)(null);(0,N.useEffect)(()=>{n.length>0&&!n.some(e=>e.id===r)&&i(n[0].id)},[n,r]),(0,N.useEffect)(()=>{if(a.length===0){c(null);return}a.some(e=>e.version===o)||c(a[0].version)},[r,a,o]);let l=Jf({queryKey:[`report-version`,r,o],queryFn:()=>Ab.reportVersion(r,o),enabled:!!r&&o!==null}),u=l.data?.record,d=l.data?.renditions.find(e=>e.ext===`md`)?.url??null,f=Jf({queryKey:[`report-md`,r,o],queryFn:async()=>{let e=await fetch(d,{credentials:`same-origin`});if(!e.ok)throw Error(`Rendition fetch failed: ${e.status}`);return e.text()},enabled:d!==null}),[p,m]=(0,N.useState)(!1),[h,_]=(0,N.useState)(null),v=()=>{e.invalidateQueries({queryKey:[`report-versions`,r]}),e.invalidateQueries({queryKey:[`report-version`,r]}),e.invalidateQueries({queryKey:[`report-md`,r]})},y=Yf({mutationFn:()=>Ab.renderReportRenditions(r,o),onSuccess:()=>{m(!1),v()}}),b=Yf({mutationFn:()=>Ab.publishEditedMarkdown(r,o,h),onSuccess:e=>{_(null),m(!1),c(e.version),v()}});return t.isLoading?(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading runs…`})}):n.length===0?(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`No runs yet. Launch an assessment and its report will appear here on completion.`})}):(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`mb-0`,children:`Generated report`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`The structured record is read-only; edits create new auditable versions.`})]}),(0,P.jsxs)(`div`,{className:`bg-card flex flex-wrap items-center gap-x-4 gap-y-2 rounded-xl border p-3`,children:[(0,P.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Run`}),(0,P.jsx)(`select`,{className:`rounded-md border bg-transparent px-2 py-1 text-sm`,value:r??``,onChange:e=>{i(e.target.value),c(null)},children:n.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.title,` — `,ej(e.status)]},e.id))})]}),a.length>0?(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Version`}),a.map(e=>(0,P.jsxs)(s,{variant:e.version===o?`secondary`:`outline`,size:`sm`,className:`aria-pressed:border-primary`,"aria-pressed":e.version===o,onClick:()=>{c(e.version),m(!1)},children:[`v`,e.version,` · `,e.publicationState]},e.version))]}):null]}),a.length===0?(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No report has been generated for this run yet. Reports are produced when a run reaches a terminal state.`})}):(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[u?(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(sx,{variant:ox(ZA[u.posture]??`neutral`),children:u.posture.toUpperCase()}),(0,P.jsxs)(`span`,{className:`text-muted-foreground`,children:[`v`,l.data?.version,` · `,u.contentHash.slice(0,12),` · `,u.classification,` ·`,` `,u.publicationState]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,P.jsx)(`h2`,{children:u.target}),(0,P.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Export`}),l.data?.renditions.filter(e=>e.url).length?l.data.renditions.filter(e=>e.url).map(e=>(0,P.jsx)(s,{variant:`outline`,size:`sm`,asChild:!0,children:(0,P.jsxs)(`a`,{href:e.url,download:!0,children:[(0,P.jsx)(ae,{}),` `,e.ext.toUpperCase()]})},e.ext)):(0,P.jsx)(`span`,{className:`text-muted-foreground text-sm`,children:u.publicationState===`published`?`Use “Ensure renditions” below to generate files.`:`Publish to generate downloadable files.`})]})]}),(0,P.jsxs)(`p`,{className:`text-muted-foreground`,children:[u.workflowKey,` · `,u.findings.length,` finding(s) · `,u.evidence.length,` evidence row(s)`]}),u.gate.satisfied?null:(0,P.jsxs)(`p`,{className:`text-destructive text-sm`,children:[`Publication blocked: missing `,u.gate.missing.join(`, `),`.`]}),u.summary?(0,P.jsx)(`p`,{children:u.summary}):null,u.findings.length>0?(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Severity`}),(0,P.jsx)(`th`,{children:`Finding`}),(0,P.jsx)(`th`,{children:`Target`})]})}),(0,P.jsx)(`tbody`,{children:u.findings.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{children:(0,P.jsx)(sx,{variant:ox(QA[e.severity]??`neutral`),children:e.severity})}),(0,P.jsx)(`td`,{children:e.title}),(0,P.jsx)(`td`,{className:`text-muted-foreground`,children:e.targetUrl??`—`})]},e.fingerprint))})]}):(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`No confirmed findings recorded — posture never claims a clean bill by default.`}),u.unverifiedLeads.length>0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`h3`,{children:`Unverified leads`}),(0,P.jsx)(`ul`,{children:u.unverifiedLeads.map(e=>(0,P.jsxs)(`li`,{children:[e.title,` `,(0,P.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.disposition,`)`]})]},e.fingerprint))})]}):null,u.negativeControls.length>0?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`h3`,{children:`Negative controls`}),(0,P.jsx)(`ul`,{children:u.negativeControls.map(e=>(0,P.jsx)(`li`,{children:e},e))})]}):null]}):(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{children:`Select a run and version.`})}),l.data?(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(`h3`,{children:`Markdown rendition`}),(0,P.jsx)(`span`,{className:`flex flex-wrap items-center gap-2.5`,children:l.data.renditions.filter(e=>e.url).map(e=>(0,P.jsx)(s,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,P.jsxs)(`a`,{href:e.url,download:!0,children:[(0,P.jsx)(ae,{}),` `,e.ext]})},e.ext))})]}),(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,style:{margin:`0.5rem 0`},children:[(0,P.jsxs)(s,{variant:`ghost`,onClick:()=>m(e=>!e),disabled:b.isPending,children:[p?(0,P.jsx)(se,{}):(0,P.jsx)(_e,{}),` `,p?`View`:`Edit`]}),(0,P.jsxs)(s,{variant:`ghost`,onClick:()=>y.mutate(),disabled:y.isPending||u?.publicationState!==`published`,title:`Create any missing immutable report renditions`,children:[(0,P.jsx)(xe,{}),` Ensure renditions`]})]}),p?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`textarea`,{className:`w-full resize-y rounded-lg border bg-[var(--plane)] p-3 font-mono text-[0.85rem] leading-normal`,value:h??f.data??``,onChange:e=>_(e.target.value),rows:24}),(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,style:{marginTop:`0.5rem`},children:[(0,P.jsxs)(s,{onClick:()=>b.mutate(),disabled:b.isPending||!h?.trim(),children:[(0,P.jsx)(Se,{}),` Save as v`,(l.data?.version??0)+1]}),b.isError?(0,P.jsxs)(`span`,{className:`text-destructive text-sm`,children:[`Save failed: `,String(b.error)]}):null]})]}):f.isLoading?(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading markdown…`}):f.isError||d===null?(0,P.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No rendered markdown yet`,d===null?``:` (unavailable)`,` — regenerate to produce it.`]}):(0,P.jsx)(`div`,{className:`max-h-[32rem] overflow-auto rounded-lg border bg-[var(--plane)] p-4`,children:(0,P.jsx)(XA,{children:f.data??``})})]}):null]})]})}function ej(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var tj=[`Reported`,`Confirmed`,`Remediating`,`Resolved`],nj={open:0,unverified:0,confirmed:1,remediating:2,remediated:3,verified:3},rj={false_positive:`Dismissed as a false positive`,accepted_risk:`Accepted as residual risk`,suppressed:`Suppressed`};function ij(e){let t={label:`Confirm as risk`,status:`confirmed`,icon:(0,P.jsx)(we,{size:14})},n={label:`Dismiss (false positive)`,status:`false_positive`,icon:(0,P.jsx)(ne,{size:14}),variant:`outline`},r={label:`Start remediation`,status:`remediating`,icon:(0,P.jsx)(Ne,{size:14})},i={label:`Mark resolved`,status:`remediated`,icon:(0,P.jsx)(A,{size:14})},a={label:`Verify fix`,status:`verified`,icon:(0,P.jsx)(b,{size:14})},o={label:`Accept risk`,status:`accepted_risk`,icon:(0,P.jsx)(b,{size:14}),variant:`outline`},s={label:`Reopen`,status:`confirmed`,icon:(0,P.jsx)(w,{size:14}),variant:`outline`};switch(e){case`open`:case`unverified`:return[t,n];case`confirmed`:return[r,i,o,n];case`remediating`:return[i,a,o];case`remediated`:return[a,s];case`verified`:return[s];default:return[{...s,label:`Reopen finding`}]}}function aj({findingId:e,onBack:t}){let n=Nf(),r=Jf({queryKey:[`finding`,e],queryFn:()=>Ab.finding(e)}),i=Yf({mutationFn:t=>Ab.updateFindingStatus(e,t),onSuccess:()=>{n.invalidateQueries({queryKey:[`finding`,e]}),n.invalidateQueries({queryKey:[`findings`]}),n.invalidateQueries({queryKey:[`overview`]})}});if(r.isLoading)return(0,P.jsx)(g,{children:(0,P.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading finding…`})});if(r.isError||!r.data)return(0,P.jsx)(g,{children:(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsx)(`p`,{className:`text-destructive`,children:`Could not load this finding.`}),t?(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:t,children:[(0,P.jsx)(w,{size:14}),` Back`]}):null]})});let a=r.data.finding,o=zb(a.severity),c=Wb(a.category,a.title),l=Mb(c.stage),u=nj[a.status],d=rj[a.status],f=ij(a.status);return(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`grid gap-2`,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(sx,{variant:ox(o),children:Rb[o]}),(0,P.jsx)(sx,{variant:ox(a.status),children:sj(a.status)}),a.cvssScore==null?null:(0,P.jsxs)(sx,{variant:`outline`,children:[`CVSS `,a.cvssScore]})]}),(0,P.jsx)(`h1`,{className:`text-xl font-semibold`,children:a.title}),(0,P.jsxs)(`p`,{className:`text-muted-foreground text-sm`,children:[a.path??`unscoped asset`,a.line==null?``:`:${a.line}`,` · Stage `,c.stage,` `,Nb(l),` · Pillar `,Pb[c.pillar],c.inferred?` (inferred)`:``]})]}),t?(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:t,children:[(0,P.jsx)(w,{size:14}),` Back`]}):null]}),(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Resolution`}),d?(0,P.jsx)(sx,{variant:`secondary`,children:d}):null]}),d?(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This finding is off the remediation track. Reopen it to return it to the queue.`}):(0,P.jsx)(`ol`,{className:`mt-1 grid grid-cols-4 gap-2`,"aria-label":`Resolution progress`,children:tj.map((e,t)=>(0,P.jsxs)(`li`,{className:`grid gap-1.5`,children:[(0,P.jsx)(`span`,{className:`h-1.5 rounded-full`,style:{background:u!=null&&t<=u?`var(--good)`:`var(--border)`},"aria-hidden":`true`}),(0,P.jsx)(`span`,{className:u===t?`text-xs font-semibold`:`text-muted-foreground text-xs`,children:e})]},e))})]}),(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Verify & triage`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Move this finding through its lifecycle. Changes are audited.`}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:f.map(e=>(0,P.jsxs)(s,{size:`sm`,variant:e.variant??`default`,disabled:i.isPending,onClick:()=>i.mutate(e.status),children:[e.icon,` `,e.label]},`${e.label}:${e.status}`))}),i.isError?(0,P.jsxs)(`p`,{className:`text-destructive text-sm`,children:[`Update failed: `,String(i.error?.message??i.error)]}):null]}),a.description?(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Description`}),(0,P.jsx)(XA,{children:a.description})]}):null,a.remediation?(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Remediation`}),(0,P.jsx)(XA,{children:a.remediation})]}):null,(0,P.jsxs)(g,{children:[(0,P.jsxs)(`h3`,{className:`text-sm font-semibold`,children:[`Evidence (`,a.evidence.length,`)`]}),a.evidence.length?(0,P.jsx)(`div`,{className:`grid gap-2`,children:a.evidence.map(e=>(0,P.jsx)(rx,{title:`${e.kind}${e.reason?` — ${e.reason}`:``}`,detail:(0,P.jsxs)(`span`,{className:`text-muted-foreground`,children:[new Date(e.createdAt).toLocaleString(),e.runID?` · run ${e.runID.slice(0,12)}`:``]}),verdict:e.verdict},e.id))}):(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No operation-level evidence linked yet. Source findings stay unverified until evidence confirms them.`})]}),(a.cwe||a.cve||a.cvssVector||a.assignee||a.resolvedAt)&&(0,P.jsxs)(g,{children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Metadata`}),(0,P.jsxs)(`dl`,{className:`grid gap-1.5 text-sm sm:grid-cols-2`,children:[a.cwe?(0,P.jsx)(oj,{k:`CWE`,v:a.cwe}):null,a.cve?(0,P.jsx)(oj,{k:`CVE`,v:a.cve}):null,a.cvssVector?(0,P.jsx)(oj,{k:`CVSS vector`,v:a.cvssVector,mono:!0}):null,a.assignee?(0,P.jsx)(oj,{k:`Assignee`,v:a.assignee}):null,a.resolvedAt?(0,P.jsx)(oj,{k:`Resolved`,v:new Date(a.resolvedAt).toLocaleString()}):null,(0,P.jsx)(oj,{k:`Fingerprint`,v:a.fingerprint,mono:!0})]})]})]})}function oj({k:e,v:t,mono:n}){return(0,P.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,P.jsx)(`dt`,{className:`text-muted-foreground text-2xs w-28 shrink-0 font-semibold tracking-[0.08em] uppercase`,children:e}),(0,P.jsx)(`dd`,{className:n?`font-mono text-xs break-all`:``,children:t})]})}function sj(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}var cj=null;function lj(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=cj;cj=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{cj=n}}function uj(){if(!cj)throw Error(`No resource fiber available`);return cj}function dj(){return cj}var fj=typeof process<`u`&&!1,pj=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),mj=e=>{e.committedVersion=e.version;for(let t of e.changelog)t.logged=!1,t.settled||(t.settled=!0,e.unsettledCount--),e.committedLog.push(t);e.changelog.length=0,e.unsettledCount===0&&(e.committedLog.length=0),e.rollbackCallbacks.length=0},hj=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t=0;t<e.rollbackCallbacks.length;t++)e.rollbackCallbacks[t]();if(e.rollbackCallbacks.length=0,t<=e.committedVersion){let n=[];for(;e.committedVersion-n.length>t;){let t=e.committedLog.pop();if(t===void 0){if(fj)throw Error(`tap: committed history is shorter than the replay base.`);break}yj(t.fiber,t.cell),t.cell.workInProgress=t.prevState,n.push({record:t,prevState:t.prevState,eagerState:t.eagerState,hasEagerState:t.hasEagerState})}if(n.length>0){let t=e.committedVersion;vj(e,()=>{for(let t=n.length-1;t>=0;t--){let r=n[t];r.record.prevState=r.prevState,r.record.eagerState=r.eagerState,r.record.hasEagerState=r.hasEagerState,e.committedLog.push(r.record)}e.committedVersion=t})}e.committedVersion=t;for(let t of e.changelog)t.logged=!1;e.changelog.length=0}else{for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop().logged=!1;for(let t=0;t<e.changelog.length;t++)gj(e.changelog[t]);mj(e)}}},gj=e=>{yj(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},_j=(e,t)=>{e.wipCommitCallbacks.push(t)},vj=(e,t)=>{e.rollbackCallbacks.push(t)},yj=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),vj(e.root,()=>{if(t.queue!==null){for(let e of t.queue)e.queued=!1;t.queue=null}t.workInProgress=t.current,t.isDirty=!1}))},bj=Symbol.for(`react.memo_cache_sentinel`),xj=e=>Array(e).fill(bj),Sj=(e,t)=>{let n=e.memoCache,r=n.workInProgress;if(r===null){let t=n.current;r=t===null?[]:t.map(e=>e.slice()),n.workInProgress=r,vj(e.root,()=>{n.workInProgress=null})}let i=n.index++,a=r[i];return a===void 0?(a=xj(t),r[i]=a):fj&&a.length!==t&&console.error(`Expected a constant size argument for each invocation of c(). The previous cache was allocated with size ${a.length} but size ${t} was requested.`),a},Cj=e=>Sj(uj(),e),wj=N.default.__COMPILER_RUNTIME?.c??(e=>(0,N.useMemo)(()=>{let t=xj(e);return t[bj]=!0,t},[])),Tj=()=>dj()!==null,J=e=>Tj()?Cj(e):wj(e),Ej=(e,...t)=>Object.assign(Object.create(null),e,...t),Dj=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},Oj=()=>{throw Error(`Hook order changed between renders`)},kj=()=>({type:`effect`,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function Aj(e,t){let n=uj(),r=n.currentIndex++,i=n.cells[r],a=i===void 0?kj():i.type===`effect`?i:Oj();if(i===void 0&&(n.isFirstRender||Dj(),n.cells[r]=a,n.effectCells.push(a)),a.deps!==null&&!!t!=!!a.deps)throw Error(`useEffect called with and without dependencies across re-renders`);_j(n,()=>{a.setup=e,a.setupDeps=t,a.generation++})}var jj=(e,t)=>{fj&&e.length!==t.length&&console.error(`The final argument passed to a hook changed size between renders. The order and size of this array must remain constant.
|
|
89
|
+
|
|
90
|
+
Previous: [${e.join(`, `)}]\nIncoming: [${t.join(`, `)}]`);for(let n=0;n<e.length&&n<t.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},Mj=(e,t)=>{_j(e,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},Nj=(e,t)=>{let n=uj(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){n.isFirstRender||Dj();let a=e();return fj&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&Oj();let a=i;if(jj(a.wipDeps,t))return a.isDirty&&Mj(n,a),a.wip;let o=e();return fj&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,vj(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),Mj(n,a),o};function Pj(e){return Nj(()=>({current:e}),[])}var Fj=Symbol(`tap.Context.defaultValue`),Ij=e=>e,Lj=new Map,Rj=new Set,zj=()=>new Map(Lj),Bj=(e,t)=>{let n=Lj;Lj=e;try{return t()}finally{Lj=n}},Vj=(e,t)=>{e[Fj]=t},Hj=e=>typeof e==`object`&&!!e&&Fj in e,Uj=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),Wj=e=>Hj(e)||Uj(e),Gj=e=>{if(!Hj(e)){if(Uj(e)){Vj(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},Kj=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);Gj(e);let r=e,i=uj(),a=Pj(void 0),o=a.current===void 0||!Object.is(a.current.value,t);Aj(()=>{a.current={value:t}},[t]);let s=Lj.get(r),c=s!==void 0||Lj.has(r);Lj.set(r,{value:t,source:i});try{return qj(r,o,n)}finally{c?Lj.set(r,s):Lj.delete(r)}},qj=(e,t,n)=>{let r=Rj.has(e);t?Rj.add(e):Rj.delete(e);try{return n()}finally{r?Rj.add(e):Rj.delete(e)}},Jj=e=>{Gj(e);let t=e,n=Yj(t,e),r=uj();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},Yj=(e,t)=>Lj.get(e)??{value:Ij(t)[Fj],source:null},Xj=(e,t,n,r)=>{if(!r)return n;let i=n;for(let[n,a]of r)a!==t&&a!==e&&(i??=new Map).set(n,a);return i},Zj=(e,t=e.wipContextDeps)=>{let n=dj();n&&t&&(n.wipContextDeps=Xj(n,e,n.wipContextDeps,t))},Qj=()=>Rj.size>0,$j=e=>{if(!e.contextDeps||!Qj())return!1;for(let t of Rj.keys())if(e.contextDeps.has(t))return!0;return!1},eM=(e,t,n)=>{if(e.isNeverMounted)throw Error(`Resource updated before mount`);let r=!1,i=!0;e.root.unsettledCount++,e.root.dispatchUpdate(()=>r?i:(r=!0,n&&e.root.changelog.length===0&&!t.cell.isDirty&&!t.hasEagerState&&(t.prevState=t.cell.workInProgress,t.eagerState=n(t.cell.workInProgress,t.action),t.hasEagerState=!0,i=!Object.is(t.cell.current,t.eagerState),!i&&!t.settled&&(t.settled=!0,e.root.unsettledCount--)),i),()=>(r=!0,i=!0,gj(t),t.logged||(t.logged=!0,e.root.changelog.push(t)),!0))},tM=(e,t,n,r,i)=>{let a=r?r(n):n;fj&&e.devStrictMode&&r&&r(n);let o={type:`reducer`,workInProgress:a,current:a,isDirty:!1,queue:null,renderQueue:null,reducer:t,dispatch:n=>{let r=dj();if(r!==null){if(r!==e)throw Error(`Cannot update a resource while rendering a different resource.`);(e.renderPendingCells??=new Set).add(o),(o.renderQueue??=[]).push(n)}else eM(e,{fiber:e,cell:o,action:n,hasEagerState:!1,eagerState:void 0,prevState:o.current,settled:!1,queued:!1,logged:!1},i?t:void 0)}};return o};function nM(e,t,n,r){let i=uj(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:Oj();i.isFirstRender||Dj();let s=tM(i,e,t,n,r);return i.cells[a]=s,s})(),c=s.queue;if(c!==null){let t=e===s.reducer;for(let n=0;n<c.length;n++){let r=c[n];!r.hasEagerState||!t||!Object.is(r.prevState,s.workInProgress)?(r.prevState=s.workInProgress,r.eagerState=e(s.workInProgress,r.action),r.hasEagerState=!0,fj&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):fj&&i.devStrictMode&&e(s.workInProgress,r.action),r.queued=!1,s.workInProgress=r.eagerState}s.queue=null}if(s.reducer=e,s.renderQueue!==null){let t=s.workInProgress;for(let n of s.renderQueue)t=e(t,n);s.renderQueue=null,i.renderPendingCells?.delete(s),Object.is(t,s.workInProgress)||(yj(i,s),s.workInProgress=t)}return s.isDirty&&_j(i,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function rM(e,t,n){return nM(e,t,n,!1)}var iM=(e,t)=>typeof t==`function`?t(e):t,aM=e=>e===void 0?void 0:typeof e==`function`?e():e;function oM(e){return nM(iM,e,aM,!0)}var sM=(e,t)=>Nj(()=>e,t);function cM(e){let t=uj(),n=Pj(e);return n.current!==e&&_j(t,()=>{n.current=e}),sM(((...e)=>{if(fj&&dj())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var lM=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,uM=()=>{},dM=e=>{let t=e;switch(typeof t.status==`string`?t.status!==`fulfilled`&&t.status!==`rejected`&&e.then(uM,uM):(t.status=`pending`,e.then(e=>{t.status===`pending`&&(t.status=`fulfilled`,t.value=e)},e=>{t.status===`pending`&&(t.status=`rejected`,t.reason=e)})),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason;default:throw e}},fM=e=>lM(e)?dM(e):Jj(e),pM=!1,mM=(e,t,n=t)=>{let r=uj().isNeverMounted,i=r?n():t();fj&&!pM&&(!r||n===t)&&(Object.is(i,t())||(pM=!0,console.error(`The result of getSnapshot should be cached to avoid an infinite loop`)));let[,a]=rM(e=>e+1,0),o=Pj(0),s=cM(()=>{try{if(Object.is(i,t()))return o.current=0,!1}catch{}return!0});return Aj(()=>e(()=>{s()&&a()}),[e]),Aj(()=>{if(s()){if(++o.current>50)throw o.current=0,Error(`Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.`);a()}},[e,i,t]),i},hM=(e,t)=>{},gM=0,_M=()=>{let e=Pj(null);return e.current??=`:tap${gM++}:`,e.current},vM=(e,t,n)=>{let r=()=>{if(!e)return;let n=t();if(typeof e==`function`){let t=e(n);return typeof t==`function`?t:()=>e(null)}return e.current=n,()=>{e.current=null}};n==null?Aj(r):Aj(r,[...n,e])},yM=N.default;function bM(e){let t=(0,N.useRef)(e);return(0,N.useInsertionEffect)(()=>{t.current=e}),(0,N.useCallback)(((...e)=>t.current(...e)),[])}var xM=yM.useEffectEvent??bM,SM=()=>dj()!==null,CM=N.default,wM=e=>SM()?oM(e):CM.useState(e),TM=(e,t,n)=>SM()?rM(e,t,n):CM.useReducer(e,t,n),Y=e=>SM()?Pj(e):CM.useRef(e),EM=(e,t)=>SM()?Nj(e,t):CM.useMemo(e,t),DM=(e,t)=>SM()?sM(e,t):CM.useCallback(e,t),X=(e,t)=>SM()?Aj(e,t):CM.useEffect(e,t),OM=(e,t)=>SM()?Aj(e,t):CM.useLayoutEffect(e,t),kM=e=>SM()?cM(e):xM(e),AM=(e,t,n)=>SM()?mM(e,t,n):CM.useSyncExternalStore(e,t,n),jM=(e,t)=>SM()?void 0:CM.useDebugValue(e,t),MM=(e,t)=>SM()?Aj(e,t):CM.useInsertionEffect(e,t),NM=()=>SM()?_M():CM.useId(),PM=(e,t,n)=>SM()?vM(e,t,n):CM.useImperativeHandle(e,t,n),Z=e=>CM.forwardRef(e),FM=(e,t)=>CM.memo(e,t),IM=CM.Fragment,LM=(...e)=>CM.createElement(...e),RM=(...e)=>CM.cloneElement(...e),zM=e=>CM.isValidElement(e);CM.Children,CM.Suspense;var BM=e=>{let t=CM.createContext(e);return Vj(t,e),t},VM=e=>SM()&&Wj(e)?fM(e):CM.use(e),HM=e=>SM()&&Wj(e)?fM(e):CM.useContext(e);function UM(e){return(...t)=>({hook:e,args:t})}function WM(e,t,n){return typeof t==`function`?(...n)=>WM(e,t(...n)):n?{...t,key:e,deps:n}:{...t,key:e}}var GM=(e,t)=>{if(e.length!==0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,t)}},KM=50,qM={schedulers:new Set,isScheduled:!1},JM=null,YM=[],XM=class{_isDirty=!1;_task;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){if(JM&&(JM.get(this)??0)>=KM)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);this._isDirty=!0,qM.schedulers.add(this),$M()}runTask(){JM?.set(this,(JM.get(this)??0)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}},ZM=[];new XM(()=>{let e=ZM.splice(0),t=[];for(let n of e)try{n()}catch(e){t.push(e)}GM(t,`Errors occurred while running scheduled tasks`)});var QM=e=>{if(JM!==null){YM.push(e);return}e()},$M=()=>{qM.isScheduled||(qM.isScheduled=!0,tN())},eN=()=>{let e=JM;JM=new Map;let t=[];try{for(let e of qM.schedulers)if(qM.schedulers.delete(e),e.isDirty)try{e.runTask()}catch(e){t.push(e)}}finally{if(JM=e,qM.schedulers.clear(),qM.isScheduled=!1,JM===null)for(;YM.length>0;)try{YM.shift()()}catch(e){t.push(e)}}GM(t,`Errors occurred during flushSync`)},tN=(()=>{if(typeof MessageChannel<`u`){let e=null,t;return()=>{if(!e){let n=new MessageChannel;n.port1.onmessage=()=>{e?.unref?.(),eN()},e=n.port1,t=n.port2}e.ref?.(),t.postMessage(null)}}return()=>setTimeout(eN,0)})(),nN=e=>{if(JM!==null)return fj&&console.warn(`flushTapSync was called from inside a render or commit. The flush is deferred until the current pass completes.`),e();let t=qM;qM={schedulers:new Set,isScheduled:!0};try{let t=e();return eN(),t}finally{let e=qM.schedulers;if(qM=t,e.size>0){for(let t of e)qM.schedulers.add(t);$M()}}};function rN(e){let t=[];for(let n=0;n<e.length;n++)try{e[n]()}catch(e){t.push(e)}GM(t,`Errors during commit`)}function iN(e){let t=e.setup,n=e.setupDeps,r=e.generation,i;try{let e=t();if(e!==void 0&&typeof e!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof e}`);i=e}finally{e.generation===r?(e.cleanup=i,e.deps=n):i?.()}}var aN=e=>e.setup===void 0?!1:e.deps===null||e.setupDeps===void 0||!jj(e.deps,e.setupDeps);function oN(e){let t=[],n=[];for(let t of e.effectCells)aN(t)&&n.push(t);for(let e of n)if(e.deps=null,e.cleanup!==void 0)try{e.cleanup()}catch(e){t.push(e)}finally{e.cleanup=void 0}for(let e of n)try{iN(e)}catch(e){t.push(e)}GM(t,`Errors during commit`)}function sN(e){let t=[];for(let n of e.effectCells)if(n.deps=null,n.cleanup)try{n.cleanup?.()}catch(e){t.push(e)}finally{n.cleanup=void 0}GM(t,`Errors during cleanup`)}var cN={useState:oM,useReducer:rM,useRef:Pj,useMemo:Nj,useCallback:sM,useEffect:Aj,useLayoutEffect:Aj,useInsertionEffect:Aj,useEffectEvent:cM,useContext:Jj,use:fM,useSyncExternalStore:mM,useDebugValue:hM,useId:_M,useImperativeHandle:vM,useMemoCache:Cj},lN=N.default,uN=lN.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??lN.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,dN=uN==null?null:`H`in uN?{get current(){return uN.H},set current(e){uN.H=e}}:`ReactCurrentDispatcher`in uN?{get current(){return uN.ReactCurrentDispatcher.current},set current(e){uN.ReactCurrentDispatcher.current=e}}:null;function fN(e){if(!dN)return e();let t=dN.current;dN.current=cN;try{return e()}finally{dN.current=t}}function pN(e,t,n=void 0,r){return{hook:e,root:t,markDirty:n,devStrictMode:r,cells:[],effectCells:[],contextDeps:null,wipContextDeps:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function mN(e){e.wipCommitCallbacks=null,e.wipContextDeps=null,e.memoCache.workInProgress=null}function hN(e){e.isMounted&&(e.isMounted=!1,sN(e))}function gN(e,t){if(e.renderPendingCells!==null){for(let t of e.renderPendingCells)t.renderQueue=null;e.renderPendingCells.clear()}let n=0,r;try{do{if(++n>25)throw Error(`Too many re-renders. tap limits the number of renders to prevent an infinite loop.`);e.memoCache.index=0,lj(e,()=>{r=fN(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0)}catch(t){throw mN(e),t}return Zj(e),r}function _N(e){let t=e.wipCommitCallbacks;e.wipCommitCallbacks=null;let n=fj&&!e.isMounted&&e.devStrictMode===`root`;e.isMounted=!0,e.isNeverMounted=!1,t!==null&&(e.contextDeps=e.wipContextDeps,mj(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),rN(t)),n&&(oN(e),sN(e)),oN(e)}var vN=()=>{let e=uj();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},yN=()=>`child`,bN=()=>null,xN=()=>{if(!fj)return bN;let e=Y(0);return wM(()=>e.current++),e.current===2?yN:bN},SN=()=>dj()?vN:xN(),CN=e=>e(),wN=e=>{let t=[];for(let n of e)try{n()}catch(e){t.push(e)}GM(t,`Errors occurred while notifying Tap root subscribers`)},TN=(e,t,n)=>{let r=new XM(()=>s.handleUpdate()),i=[],a=pj((e,t)=>{(i.length!==0||e())&&(i.push(t),r.markDirty())}),o=pN(CN,a,void 0,t),s={scheduler:r,queue:i,fiber:o,subscribers:new Set,pendingHostRender:!1,isMounted:!1,hasRendered:!1,committedRender:e,context:new Map,value:void 0,applyQueue:()=>{hj(a,a.committedVersion);for(let e of i)fj&&o.devStrictMode&&e(),e();return hj(a,a.committedVersion+a.changelog.length),i.length},publish:(e,t)=>{r.isDirty||a.committedVersion!==t||s.value===e||(s.value=e,QM(()=>wN(s.subscribers)))},finishFlush:(e,t,n)=>{mj(a),i.splice(0,n),s.pendingHostRender=!1,i.length===0&&r.settle(),s.isMounted&&_N(o),s.publish(e,t)},handleUpdate:()=>{let e=s.applyQueue(),t;try{fj&&o.devStrictMode&&Bj(s.context,()=>gN(o,[s.committedRender])),t=Bj(s.context,()=>gN(o,[s.committedRender]))}catch(e){if(hj(a,a.committedVersion),lM(e)){let t=()=>{s.isMounted&&r.markDirty()};e.then(t,t);return}if(s.isMounted){s.pendingHostRender=!0,n(e=>e+1);return}throw e}if(r.isDirty)throw Error(`Scheduler is dirty, this should never happen`);s.finishFlush(t,a.version,e)}};return s},EN=e=>{let[,t]=wM(0),n=SN(),r=Y(null),i=r.current??=TN(e,n(),t),a=zj(),o=i.scheduler.isDirty||i.pendingHostRender?i.applyQueue():0,s=Bj(a,()=>gN(i.fiber,[e])),c={render:e,context:a,value:s,drained:o,wip:i.fiber.wipCommitCallbacks,version:i.fiber.root.version,processed:!1};return i.hasRendered||(i.hasRendered=!0,i.committedRender=e,i.context=a,i.value=s),X(()=>(i.isMounted=!0,()=>{i.isMounted=!1,hN(i.fiber)}),[i]),X(()=>{if(c.processed){i.fiber.isMounted||(_N(i.fiber),i.queue.length&&!i.scheduler.isDirty&&i.scheduler.markDirty());return}if(c.processed=!0,i.committedRender=c.render,i.context=c.context,i.fiber.wipCommitCallbacks!==c.wip){i.scheduler.isDirty||i.handleUpdate();return}if(c.drained>0&&i.fiber.root.version===c.version){i.finishFlush(c.value,c.version,c.drained);return}_N(i.fiber),i.publish(c.value,c.version)}),EM(()=>({getValue:()=>i.value,subscribe:e=>(i.subscribers.add(e),()=>i.subscribers.delete(e))}),[i])},DN=()=>{let e=Y(0),t=e.current,n=uj();return{version:t,markDirty:EM(()=>()=>{e.current++,n.markDirty?.()},[n]),root:n.root}},ON=()=>{let[e]=wM(()=>pj((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(t)})),[t,n]=TM((t,n)=>(hj(e,t),t+ +!!n()),0),[,r]=wM(0);return hj(e,t),{root:e,version:t,markDirty:void 0}},kN=()=>{let e=SN(),{root:t,version:n,markDirty:r}=dj()?DN():ON();return{version:n,createFiber:DM((n,i,a)=>pN(n,t,a?()=>{a(),r?.()}:r,e()),[])}},AN=(e,t,n)=>{let r=Y(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,X(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&jj(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)};function jN(e){let{version:t,createFiber:n}=kN(),r=EM(()=>n(e.hook,e.key),[e.hook,e.key,n]),i=AN(()=>({value:gN(r,e.args)}),[r,t,e.args],$j(r));return X(()=>()=>hN(r),[r]),X(()=>{_N(r)},[r,i]),i.value}var MN=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},NN=(e,t)=>!e.isDirty&&!$j(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&jj(e.committedDeps,t),PN=e=>{if(!Qj())return!1;for(let{fiber:t}of e.values())if($j(t))return!0;return!1};function FN(e){let[t]=wM(()=>new Map),{version:n,createFiber:r}=kN(),i=PN(t),a=AN(()=>{let n=new Set,i=[],a=0;for(let o=0;o<e.length;o++){let s=e[o],c=s.key;if(c===void 0)throw Error(`useResources did not provide a key for array at index ${o}`);if(n.has(c))throw Error(`Duplicate key ${c} in useResources`);n.add(c);let l=t.get(c);if(!l){let e=r(s.hook,s.key,()=>MN(t,c));l={fiber:e,next:{value:gN(e,s.args),deps:s.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},a++,t.set(c,l)}else if(l.fiber.hook!==s.hook){let e=r(s.hook,s.key,()=>MN(t,c)),n=gN(e,s.args);l.next={value:n,deps:s.deps,remount:e}}else if(NN(l,s.deps))typeof l.next==`object`&&mN(l.fiber),l.fiber.contextDeps&&Zj(l.fiber,l.fiber.contextDeps),l.next=`skip`;else{let e=gN(l.fiber,s.args);l.next={value:e,deps:s.deps}}i.push(typeof l.next==`object`?l.next.value:l.committedValue)}if(t.size>i.length-a)for(let e of t.keys())n.has(e)||(t.get(e).next=`delete`);return i},[e,t,r,n],i);return X(()=>()=>{for(let e of t.keys())hN(t.get(e).fiber)},[t]),X(()=>{for(let[e,n]of t.entries()){let r=n.next;r===`delete`?(hN(n.fiber),t.delete(e)):r===`skip`?!n.fiber.isNeverMounted&&!n.fiber.isMounted&&_N(n.fiber):(r.remount&&(hN(n.fiber),n.fiber=r.remount),_N(n.fiber),n.committedDeps=r.deps,n.committedValue=r.value,n.isDirty=!1,n.next=`skip`)}},[a,t]),a}var IN=e=>e(),LN=e=>{let{createFiber:t}=kN(),n=EM(()=>t(IN,void 0),[t]),r=gN(n,[e]);X(()=>()=>{hN(n)},[n]);let i=!1,a=()=>{i&&n.isMounted||(i=!0,_N(n))};return X(a),{value:r,effects:a}},RN=UM(()=>{let e=J(4),[t,n]=wM(zN),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>{let r=Ej(n.renderers);return r[e]=[...r[e]??[],t],{...n,renderers:r}}),()=>{n(n=>{let r=Ej(n.renderers),i=r[e]?.filter(e=>e!==t)??[];return i.length>0?r[e]=i:delete r[e],{...n,renderers:r}})}),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{n(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),e[1]=a):a=e[1];let o=a,s;return e[2]===t?s=e[3]:(s={getState:()=>t,setDataUI:i,setFallbackDataUI:o},e[2]=t,e[3]=s),s});function zN(){return{renderers:Ej(),fallbacks:[]}}var BN=e=>{if(!e.overwrite)return e;let{overwrite:t,...n}=e;return n},VN=e=>{let t=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)),n=Ej();return t.reduce((e,t)=>{let r=t.priority??0;if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[i,a]of Object.entries(t.tools)){let t=e.tools!==void 0&&Object.hasOwn(e.tools,i)?e.tools[i]:void 0;if(t&&t!==a){let o=n[i];if(o===r){if(!a.overwrite)throw Error(`You tried to define a tool with the name ${i}, but it already exists.`);e.tools[i]=BN(a);continue}let s=o>r?t:a,c=o>r?a:t;e.tools[i]=BN({...c,...s}),n[i]=Math.max(o,r);continue}e.tools||=Ej(),e.tools[i]=BN(a),Object.hasOwn(n,i)||(n[i]=r)}return t.config&&(e.config={...e.config,...t.config}),t.callSettings&&(e.callSettings={...e.callSettings,...t.callSettings}),t.unstable_composerMetadata&&(e.unstable_composerMetadata={...e.unstable_composerMetadata,...t.unstable_composerMetadata}),e},{})},HN=(e,t,n)=>{let r=e=>{console.error(`[assistant-ui] ${n} listener threw an error`,e)};for(let n of e)try{let e=n(typeof t==`function`?t():t);e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`&&Promise.resolve(e).catch(r)}catch(e){r(e)}},UN=e=>e,WN=new Set([`$$typeof`,`nodeType`,`then`,`__v_raw`,`__v_isRef`,`__v_isReactive`,`__v_isReadonly`,`__v_isShallow`,`__v_skip`]),GN=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!WN.has(e))return!1}},KN=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!0}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},qN=Symbol(`assistant-ui.store.clientId`),JN=Symbol(`assistant-ui.store.instanceTag`),YN=(e,t)=>{let n=new Proxy((()=>{}),{apply:()=>(t(),n),get:(n,r)=>r===`source`?e.source:r===`query`?e.query:r===`name`?e.name:r===qN?$N(t()):t()[r],has:(e,n)=>n===`source`||n===`query`||n===`name`||n===qN||n in t(),ownKeys:()=>Reflect.ownKeys(t()),getOwnPropertyDescriptor:(e,n)=>{if(typeof n!=`symbol`&&n in t())return{value:t()[n],writable:!1,enumerable:!0,configurable:!0}}});return n},XN=(e,t)=>{let n=()=>{throw Error(e)};return new Proxy((()=>{}),{apply:n,get:(e,r)=>{if(r===`source`||r===`query`)return null;if(r===`name`)return t;if(r===qN)return n();let i=GN(r,`AssistantClientAccessor`);return i===!1?n():i},has:(e,t)=>t===`source`||t===`query`||t===`name`,ownKeys:()=>[],getOwnPropertyDescriptor:()=>void 0})},ZN=e=>e?.source!=null,QN=e=>e?.source===null,$N=e=>e[qN]??e,eP=e=>e[JN]??$N(e),tP=e=>e===`optional`||e===`subscribe`||e===`on`||e===`__proto__`||typeof e==`symbol`,nP=e=>{let t=[];for(let n in e)tP(n)||t.push(n);return t},rP=class extends KN{#e;constructor(e){super(),this.#e=e}get(e,t){let n=GN(t,`OptionalAssistantClient`);if(n!==!1)return n;if(tP(t))return;let r=this.#e[t];return ZN(r)?r:void 0}ownKeys(){return nP(this.#e)}has(e,t){return!tP(t)&&t in this.#e}},iP=e=>new Proxy({},new rP(e)),aP=()=>()=>{},oP=`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`,sP=class extends KN{#e;#t;#n;#r;constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n=n}get(e,t){if(t===`subscribe`||t===`on`)return aP;if(t===`optional`)return this.#r??=iP(this.#n());let n=GN(t,this.#e);return n===!1?XN(this.#t(String(t)),String(t)):n}ownKeys(){return[`subscribe`,`on`,`optional`]}getOwnPropertyDescriptor(e,t){if(t!==`optional`)return super.getOwnPropertyDescriptor(e,t);let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!1,configurable:!0}}has(e,t){return t===`subscribe`||t===`on`||t===`optional`}},cP=((e,t)=>{let n=new Proxy({},new sP(e,t,()=>n));return n})(`DefaultAssistantClient`,()=>oP),lP=()=>new Proxy({},{get(e,t){let n=GN(t,`AssistantClient`);return n===!1?XN(`The current scope does not have a "${String(t)}" property.`,String(t)):n}}),uP=BM(cP),dP=()=>{},fP=new WeakMap,pP=e=>fP.get(e)??dP,mP=(e,t)=>{fP.set(e,t)},hP=()=>HM(uP),gP=(e,t)=>Kj(uP,e,t),_P=Symbol(`assistant-ui.transform-scopes`);function vP(e,t){let n=e;if(n[_P])throw Error(`transformScopes is already attached to this resource`);n[_P]=t}function yP(e){return e[_P]}var bP=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},xP=e=>{console.error(`NotificationManager: event listener error`,e)},SP=(e,t,n)=>{try{let r=e(t,n);r!==null&&(typeof r==`object`||typeof r==`function`)&&typeof r.then==`function`&&Promise.resolve(r).catch(xP)}catch(e){xP(e)}},CP=()=>{let e=new Map,t=new Set,n=new Set;return{on(n,r){let i=r;if(n===`*`)return t.add(i),()=>t.delete(i);let a=e.get(n);return a||(a=new Set,e.set(n,a)),a.add(i),()=>{a.delete(i),a.size===0&&e.get(n)===a&&e.delete(n)}},emit(n,r,i){(e.has(n)||t.size!==0)&&queueMicrotask(()=>{let a=e.get(n);if(a)for(let e of a)SP(e,r,i);if(t.size>0){let e={event:n,payload:r};for(let n of t)SP(n,e,i)}})},subscribe(e){return n.add(e),()=>n.delete(e)},notifySubscribers(){for(let e of n)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}}}},wP=()=>wM(CP)[0],TP=Symbol(`assistant-ui.store.clientIndex`),EP=e=>e[TP],DP=BM([]),OP=()=>VM(DP),kP=(e,t)=>{let n=J(3),r=OP(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],Kj(DP,i,t)},AP=BM(null),jP=Symbol(`aui.scope-effect-unapplied`),MP=(e,t)=>Kj(AP,e,t),NP=()=>{let e=VM(AP);if(!e)throw Error(`AssistantTapContext is not available`);return e},PP=()=>NP().clientRef,FP=(e,t,n)=>{let r=J(8),{clientRef:i}=NP(),a;r[0]!==i||r[1]!==t||r[2]!==e?(a=()=>{let n=i.current;if(n===null)throw Error(`useAssistantScopeEffect ran before the client was committed. This is likely an internal bug in assistant-ui.`);let r=()=>{let t=i.current?.[e];return t!==void 0&&ZN(t)?eP(t):void 0},a=jP,o,s=e=>{if(o?.(),o=void 0,a=jP,e!==void 0){let e=t();o=typeof e==`function`?e:void 0}a=e};s(r());let c=n.subscribe(()=>{let e=r();e!==a&&s(e)});return()=>{c(),o?.()}},r[0]=i,r[1]=t,r[2]=e,r[3]=a):a=r[3];let o;r[4]!==i||r[5]!==n||r[6]!==e?(o=[i,e,...n],r[4]=i,r[5]=n,r[6]=e,r[7]=o):o=r[7],X(a,o)},IP=()=>{let e=J(3),{emit:t}=NP(),n=OP(),r;return e[0]!==n||e[1]!==t?(r=(e,r)=>{t(e,r,n)},e[0]=n,e[1]=t,e[2]=r):r=e[2],kM(r)},LP=BM(void 0),RP=(e,t)=>{let n=VM(LP);return Kj(LP,e??n,t)},zP=()=>{let e=J(3),[t]=wM(BP),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>()=>queueMicrotask(()=>t.abort()),r=[t],e[0]=t,e[1]=n,e[2]=r),MM(n,r),t.signal};function BP(){return new AbortController}var VP=Symbol(`assistant-ui.store.getValue`),HP=e=>{let t=e[VP];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.`);return t.getState?.()},UP=new Map;function WP(e){let t=UP.get(e);return t||(t=function(...t){if(!this||typeof this!=`object`)throw Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);let n=this[VP];if(!n)throw Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);let r=n[e];if(!r)throw Error(`Method "${String(e)}" is not implemented.`);if(typeof r!=`function`)throw Error(`"${String(e)}" is not a function.`);return r(...t)},UP.set(e,t)),t}var GP=class extends KN{boundFns;cachedReceiver;outputRef;tagRef;index;constructor(e,t,n){super(),this.outputRef=e,this.tagRef=t,this.index=n}get(e,t,n){if(t===VP)return this.outputRef.current;if(t===TP)return this.index;if(t===JN)return this.tagRef.current;let r=GN(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){if(n===void 0)return i;(!this.boundFns||this.cachedReceiver!==n)&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=WP(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===VP||t===TP||t===JN||t in this.outputRef.current}},KP=e=>{let t=Y(null),n=Y(null),r=EM(()=>({}),[e.hook,e.key]),i=OP().length,a=EM(()=>new Proxy({},new GP(t,n,i)),[i]),o=kP(a,function(){return jN(e)});return t.current||(t.current=o,n.current=r),X(()=>{t.current=o,n.current=r}),{methods:a,state:o.getState?.(),key:e.key}},qP=UM(KP),JP=(e,t)=>{if(Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&Object.is(e[n],t[n]))},YP=e=>{let t=EM(()=>({}),[]);return t.v!==void 0&&JP(t.v,e)?t.v:(t.v=e,e)},XP=e=>{let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&JP(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r},ZP=(()=>{try{return!1}catch{return!1}})(),QP=(e,t)=>{let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(r.has(e.hook))continue;r.add(e.hook);let a=yP(e.hook);if(a){a(n,t),i=!0;break}}}return n},$P=e=>e.hook===SF,eF=e=>{if(!$P(e))return{source:`root`,query:{}};let t=e.args[0];return{source:t.source,query:t.query??{}}},tF=Symbol.for(`aui.event-receiver-ref`),nF=(e,t)=>{let n=e===cP?lP():e,r=Object.create(n);Object.assign(r,t);let i;return Object.defineProperty(r,"optional",{get:()=>i??=iP(r),enumerable:!1}),r},rF=({notifications:e,clientRef:t})=>EM(()=>({subscribe:e.subscribe,on:function(n,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=bP(n),o=n[tF];if(i!==`*`&&!o&&QN(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let s=e.on(a,(e,n)=>{if(i===`*`)return r(e);let a=((o??t).current??this)[i];if(!ZN(a))return;let s=$N(a);if(s===n[EP(s)])return r(e)});if(i!==`*`){if(o){if(t.parent===cP)return s}else if(QN(t.parent[i]))return s}let c=t.parent.on(n,r);return()=>{s(),c()}}}),[e,t]),iF=e=>{let t=J(5),n;t[0]===e?n=t[1]:(n=eF(e),t[0]=e,t[1]=n);let{source:r,query:i}=n,a=YP(i),o;return t[2]!==r||t[3]!==a?(o={source:r,query:a},t[2]=r,t[3]=a,t[4]=o):o=t[4],YP(o)},aF=(e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=t?e:qP(e),n[0]=t,n[1]=e,n[2]=r):r=n[2],jN(r)},oF=UM((e,t)=>{let n=hP(),r=$P(t),i=aF(t,r),a=r?i:i.methods,o=iF(t),s=EM(()=>YN({name:e,...o},()=>a),[e,o,a]);return n[e]=s,s}),sF=e=>{let t=J(2),n;return t[0]===e?n=t[1]:(n=e.map(_F),t[0]=e,t[1]=n),FN(n)},cF=(e,t)=>{let n=YP(t),r=EM(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=e),r.client},lF=({parent:e,entries:t,clientRef:n,notifications:r})=>{let i=nF(e,rF({notifications:r,clientRef:n}));return{client:cF(i,[e,...MP({clientRef:n,emit:r.emit},function(){return gP(i,function(){return sF(t)})})])}},uF=({parent:e,entries:t,destroySignal:n})=>{let r=Y({parent:e,current:null}).current,{value:i,effects:a}=LN(function(){let i=wP(),{client:a}=RP(n,function(){return lF({parent:e,entries:t,clientRef:r,notifications:i})});return X(()=>e.subscribe(i.notifySubscribers),[e,i]),X(()=>i.notifySubscribers()),a});return MM(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},dF=({parent:e,entries:t,destroySignal:n})=>{let r=Y({parent:e,current:null}).current,{value:i,effects:a}=LN(function(){let i=wP(),a=EN(function(){return RP(n,function(){return lF({parent:e,entries:t,clientRef:r,notifications:i})})}),o=AM(a.subscribe,()=>a.getValue().client,()=>a.getValue().client);return X(()=>{let t=()=>nN(()=>{r.current=a.getValue().client,i.notifySubscribers()}),n=a.subscribe(t),o=e.subscribe(t);return()=>{n(),o()}},[a,e,i]),o});return MM(()=>{r.parent=e,r.current=i},[i,e,r]),{client:i,effects:a}},fF=(e,t,n,r)=>{let{get:i}=r.args[0],a=AM(e.subscribe,()=>i(e),()=>i(e)),o=iF(r),s=EM(()=>YN({name:n,...o},()=>a),[n,o,a]);return t[n]=s,s},pF=(e,t)=>{if(ZP){let[e]=wM(()=>t.map(([e])=>e).join(`,`)),n=t.find(([,e])=>!$P(e));if(n)throw Error(`Scope "${n[0]}" is a root scope but this useAui mounted derived-only; remount with a new key to change scope kinds.`);let r=t.map(([e])=>e).join(`,`);if(r!==e)throw Error(`A derived-only config mounted scopes [${e}] but now has [${r}]; remount with a new key to change the scope set.`)}let n=Y({parent:e,current:null}).current,r=nF(e,{subscribe:e.subscribe,on:function(t,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=bP(t);if(i===`*`)return e.on(t,r);let o=t[tF];if(!o&&QN(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);return e.on({scope:i,event:a,[tF]:o??n},r)}}),i=cF(r,[e,...t.map(([t,n])=>fF(e,r,t,n))]);return MM(()=>{n.parent=e,n.current=i},[i,e,n]),i},mF=(e,t)=>{let n=J(8),r;n[0]!==t||n[1]!==e?(r=Object.entries(QP(t,e)),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i=r,a;n[3]===i?a=n[4]:(a=()=>i.length===0||i.some(vF),n[3]=i,n[4]=a);let[o]=wM(a),s;return n[5]!==i||n[6]!==o?(s={entries:i,rooted:o},n[5]=i,n[6]=o,n[7]=s):s=n[7],s},hF=(e,t,n,r)=>{let{entries:i,rooted:a}=mF(e,t);return a?n({parent:e,entries:i,destroySignal:r}):{client:pF(e,i)}},gF=(e,t,n)=>hF(e,t,uF,n);function Q(e){let t=hP();if(e){let{client:n,effects:r}=hF(t,e,dF,zP());return r&&mP(n,r),n}return t}function _F(e){let[t,n]=e;return WM(t,oF(t,n))}function vF(e){let[,t]=e;return!$P(t)}var yF=e=>{let t;class n extends KN{get(t,n){let r=GN(n,`OptionalAssistantState`);if(r!==!1)return r;let i=n;if(!tP(i)&&ZN(e[i]))return HP(e[i]())}ownKeys(){return nP(e)}has(t,n){return!tP(n)&&n in e}}class r extends KN{get(r,i){let a=GN(i,`AssistantState`);if(a!==!1)return a;if(i===`optional`)return t??=new Proxy({},new n);let o=i;if(!tP(o))return HP(e[o]())}ownKeys(){return[...nP(e),`optional`]}has(t,n){return n===`optional`||!tP(n)&&n in e}}return new Proxy({},new r)},bF=new WeakMap,xF=e=>{let t=bF.get(e);return t||(t=yF(e),bF.set(e,t)),t},$=e=>{let t=J(6),n=Q(),r;t[0]===n?r=t[1]:(r=xF(n),t[0]=n,t[1]=r);let i=r,a,o;t[2]!==i||t[3]!==e?(a=()=>e(i),o=()=>e(i),t[2]=i,t[3]=e,t[4]=a,t[5]=o):(a=t[4],o=t[5]);let s=AM(n.subscribe,a,o);if(typeof s==`object`&&s&&(s===i||s===i.optional))throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return jM(s),s},SF=e=>{let t=J(3),{get:n}=e,r=Q(),i;return t[0]!==r||t[1]!==n?(i=()=>n(r),t[0]=r,t[1]=n,t[2]=i):i=t[2],$(i)},CF=UM(SF),wF=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function TF(e){let t=J(12),n;t[0]===e?n=t[1]:(n=e.map(OF),t[0]=e,t[1]=n);let r=FN(n),i;t[2]===e?i=t[3]:(i=e.reduce(DF,Object.create(null)),t[2]=e,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.map(EF),t[4]=r,t[5]=o);let s=o,c;t[6]!==a||t[7]!==r?(c=e=>{if(`index`in e){if(e.index<0||e.index>=r.length)throw Error(`useClientLookup: index ${e.index} out of bounds (length: ${r.length}) (ignore if recovered)`);return r[e.index].methods}let t=a[e.key];if(t===void 0)throw Error(`useClientLookup: key "${e.key}" not found (ignore if recovered)`);return r[t].methods},t[6]=a,t[7]=r,t[8]=c):c=t[8];let l;return t[9]!==s||t[10]!==c?(l={state:s,get:c},t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function EF(e){return e.state}function DF(e,t,n){return e[wF(t)]=n,e}function OF(e){return WM(wF(e),qP(e),e.deps)}var kF=(e,t=0)=>t===0?Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight:e.scrollHeight-t-e.scrollTop-e.clientHeight<=1||e.scrollHeight-t<=e.clientHeight,AF=(e,t=0)=>t===0?e.scrollHeight>e.clientHeight+1:e.scrollHeight-t>e.clientHeight+1,jF=(e,t)=>e.scrollTop>t.scrollTop&&e.scrollHeight===t.scrollHeight,MF=Symbol(`skip-update`),NF=(e,...t)=>{let n=[];for(let r of e)try{r(...t)}catch(e){n.push(e)}if(n.length===1)throw n[0];if(n.length>1){for(let e of n)console.error(e);throw AggregateError(n)}},PF=e=>{NF(e)},FF=(e,t)=>e===void 0||t===void 0?e===t:JP(e,t),IF=class{_subscribers=new Set;subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{let t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){NF(this._subscribers)}},LF=class extends IF{_state;constructor(e){super(),this._state=e,this.subscribe=this.subscribe.bind(this),this.getState=this.getState.bind(this),this.getServerSnapshot=()=>e}getState(){return this._state}getServerSnapshot;setState(e){Object.is(e,this._state)||(this._state=e,this._notifySubscribers())}},RF=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e,t){if(t){HN(this._subscriptions,e,t);return}NF(this._subscriptions,e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else{let e=this._connection;this._connection=void 0,e?.()}}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},zF=class extends RF{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e;let t=e.getState();if(t===MF)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===MF||FF(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){let e=this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()});return this._syncState(),e}},BF=class extends RF{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==MF&&(this._previousState===void 0||!FF(e,this._previousState))&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){let e=this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()});return this._previousStateDirty=!0,e}},VF=class extends RF{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){let e=()=>{this.notifySubscribers()},t=this.binding.getState(),n=t?.subscribe(e),r=this.outerSubscribe(()=>{let r=this.binding.getState();if(r===t)return;t=r;let i=n;n=void 0;try{i?.()}finally{n=r?.subscribe(e),e()}});return()=>PF([()=>r?.(),()=>n?.()])}},HF=class extends RF{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=`Runtime event "${this.config.event}"`,t=t=>{this.notifySubscribers(t,e)},n=this.config.binding.getState(),r=n?.unstable_on(this.config.event,t),i=this.outerSubscribe(()=>{let e=this.config.binding.getState();if(e===n)return;n=e;let i=r;r=void 0;try{i?.()}finally{r=e?.unstable_on(this.config.event,t)}});return()=>PF([()=>i?.(),()=>r?.()])}},UF=class{_providers=new Map;_providerUnsubscribes=new Map;getModelContext(){return VN(new Set(this._providers.values()))}registerModelContextProvider(e){let t=Symbol();this._providers.set(t,e);let n;try{n=e.subscribe?.(()=>{this.notifySubscribers()})}catch(e){this._providers.delete(t);try{this.notifySubscribers()}catch(e){console.error(e)}throw e}this._providerUnsubscribes.set(t,n),this.notifySubscribers();let r=!1;return()=>{if(r)return;r=!0,this._providers.delete(t);let e=this._providerUnsubscribes.get(t);this._providerUnsubscribes.delete(t);let n=!1,i,a=e=>{try{e()}catch(e){n?console.error(e):(n=!0,i=e)}};if(e&&a(e),a(()=>this.notifySubscribers()),n)throw i}}_subscribers=new Set;notifySubscribers(){NF(this._subscribers)}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},WF=[],GF={modelName:void 0,toolNames:WF},KF=(e,t)=>e===t||JP(e,t),qF=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():WF,a=i.length?i:WF;return r===t.modelName&&KF(a,t.toolNames)?t:{modelName:r,toolNames:a}},JF=UM(()=>{let e=J(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new UF,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>qF(n,GF),e[1]=r):r=e[1];let[i,a]=wM(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>qF(n,e)),n.subscribe(()=>{a(e=>qF(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),X(o,s);let c;e[4]===i?c=e[5]:(c=()=>qF(n,i),e[4]=i,e[5]=c);let l,u,d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>n.getModelContext(),u=e=>n.subscribe(e),d=e=>n.registerModelContextProvider(e),e[6]=l,e[7]=u,e[8]=d):(l=e[6],u=e[7],d=e[8]);let f;return e[9]===c?f=e[10]:(f={getState:c,getModelContext:l,subscribe:u,register:d},e[9]=c,e[10]=f),f}),YF=(e,t)=>{if(t.status?.type!==`running`&&t.status?.type!==`requires-action`){let n=e.complete;return typeof n==`function`?n({args:t.args,result:t.result}):n??null}let n=e.running;return typeof n==`function`?n({args:t.args}):n??null},XF=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,ZF=e=>function(t){return YF(e,t)},QF=e=>{let t=J(16),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[WM(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=FN(i)[0],[o,s]=wM(eI),c;t[2]!==a||t[3]!==o?(c={toolUIs:o,mcpApp:a},t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=c,u=PP(),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(e,t,n)=>{let r={render:t,renderText:n?.renderText,standalone:n?.standalone??!1};return s(t=>{let n=Ej(t);return n[e]=[...n[e]??[],r],n}),()=>{s(t=>{let n=t[e]?.filter(e=>e!==r)??[],i=Ej(t);return n.length>0?(i[e]=n,i):(delete i[e],i)})}},t[5]=d):d=t[5];let f=d,p,m;t[6]===n?(p=t[7],m=t[8]):(p=()=>{if(!n)return;let e=[];for(let[t,r]of Object.entries(n)){let n=`render`in r?r.render:void 0,i=`renderText`in r?r.renderText:void 0,a=n??(i?ZF(i):void 0);a&&e.push(f(t,a,{standalone:XF(r),renderText:i}))}return()=>{e.forEach(tI)}},m=[n,f],t[6]=n,t[7]=p,t[8]=m),X(p,m);let h;t[9]!==u||t[10]!==n?(h=()=>{if(!n)return;let e=Object.entries(n).reduce(nI,Ej());return u.current.modelContext().register({getModelContext:()=>({tools:e})})},t[9]=u,t[10]=n,t[11]=h):h=t[11];let g;t[12]===n?g=t[13]:(g=[n],t[12]=n,t[13]=g),FP(`modelContext`,h,g);let _;return t[14]===l?_=t[15]:(_={getState:()=>l,setToolUI:f},t[14]=l,t[15]=_),_},$F=UM(QF);vP(QF,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=JF())});function eI(){return Ej()}function tI(e){return e()}function nI(e,t){let[n,r]=t;if(r.type===`mcp`)return e;let{display:i,render:a,renderText:o,...s}=r;return e[n]=s,e}var rI=e=>AM(e.subscribe,e.getState,e.getServerSnapshot),iI=Symbol.for(`assistant-ui.silent-runtime-action`),aI=e=>typeof e==`object`&&!!e&&iI in e,oI=(e,t)=>{let n=t();return n.catch(t=>{aI(t)||console.error(`[assistant-ui] ${e} failed:`,t)}),n},sI=UM(e=>{let t=J(9),{runtime:n}=e,r=rI(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o;t[2]===n?(a=t[3],o=t[4]):(a=()=>oI(`attachment remove`,n.remove),o=()=>n,t[2]=n,t[3]=a,t[4]=o);let s;return t[5]!==i||t[6]!==a||t[7]!==o?(s={getState:i,remove:a,__internal_getRuntime:o},t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),cI=UM(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=sI({runtime:a}),t[3]=a,t[4]=o),jN(o)}),lI=UM(({item:e,onMove:t,onRemove:n})=>({getState:()=>e,steer:()=>t({lane:`steer`,insertAfter:null}),move:t,remove:n})),uI=UM(e=>{let t=J(63),{threadIdRef:n,messageIdRef:r,runtime:i,isSuggestion:a}=e,o=rI(i),s=IP(),c=Y(!1),l,u;t[0]!==s||t[1]!==r||t[2]!==i||t[3]!==n?(l=()=>{let e=[],t=i.unstable_on(`send`,e=>{let t=c.current;c.current=!1,s(`composer.send`,{threadId:n.current,...r&&{messageId:r.current},chars:e.chars,attachments:e.attachments,...t?{suggestion:!0}:void 0})});e.push(t);let a=i.unstable_on(`attachmentAdd`,e=>{s(`composer.attachmentAdd`,{threadId:n.current,...r&&{messageId:r.current},...e.contentType?{contentType:e.contentType}:void 0})});return e.push(a),e.push(i.unstable_on(`attachmentAddError`,e=>{s(`composer.attachmentAddError`,{threadId:n.current,...r&&{messageId:r.current},...e.attachmentId&&{attachmentId:e.attachmentId},reason:e.reason,message:e.message,...e.contentType?{contentType:e.contentType}:void 0})})),()=>{for(let t of e)t()}},u=[i,s,n,r],t[0]=s,t[1]=r,t[2]=i,t[3]=n,t[4]=l,t[5]=u):(l=t[4],u=t[5]),X(l,u);let d;if(t[6]!==i||t[7]!==o.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>WM(e.id,cI({runtime:i,index:t}),[i,t]),t[9]=i,t[10]=e),d=o.attachments.map(e),t[6]=i,t[7]=o.attachments,t[8]=d}else d=t[8];let f=TF(d),p=o.queue,m;if(t[11]!==p||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>WM(e.id,lI({item:e,onMove:t=>i.moveQueueItem(e.id,t),onRemove:()=>i.removeQueueItem(e.id)})),t[14]=i,t[15]=e),m=p.map(e),t[11]=p,t[12]=i,t[13]=m}else m=t[13];let h=TF(m),g=o.type??`thread`,_;t[16]!==f.state||t[17]!==p||t[18]!==o.attachmentAccept||t[19]!==o.canCancel||t[20]!==o.canSend||t[21]!==o.dictation||t[22]!==o.isEditing||t[23]!==o.isEmpty||t[24]!==o.quote||t[25]!==o.role||t[26]!==o.runConfig||t[27]!==o.text||t[28]!==g?(_={text:o.text,role:o.role,attachments:f.state,runConfig:o.runConfig,isEditing:o.isEditing,canCancel:o.canCancel,canSend:o.canSend,attachmentAccept:o.attachmentAccept,isEmpty:o.isEmpty,type:g,dictation:o.dictation,quote:o.quote,queue:p},t[16]=f.state,t[17]=p,t[18]=o.attachmentAccept,t[19]=o.canCancel,t[20]=o.canSend,t[21]=o.dictation,t[22]=o.isEditing,t[23]=o.isEmpty,t[24]=o.quote,t[25]=o.role,t[26]=o.runConfig,t[27]=o.text,t[28]=g,t[29]=_):_=t[29];let v=_,y;t[30]===v?y=t[31]:(y=()=>v,t[30]=v,t[31]=y);let b;t[32]!==a||t[33]!==i?(b=e=>{let t=i.getState();c.current=t.canSend&&(a?.(t.text)??!1),i.send(e)},t[32]=a,t[33]=i,t[34]=b):b=t[34];let x;t[35]!==s||t[36]!==r||t[37]!==i||t[38]!==n?(x=()=>{!r&&i.getState().canCancel&&s(`composer.cancel`,{threadId:n.current}),i.cancel()},t[35]=s,t[36]=r,t[37]=i,t[38]=n,t[39]=x):x=t[39];let S=i.beginEdit??dI,C;t[40]===f?C=t[41]:(C=e=>`id`in e?f.get({key:e.id}):f.get(e),t[40]=f,t[41]=C);let w;t[42]===h?w=t[43]:(w=e=>`id`in e?h.get({key:e.id}):h.get(e),t[42]=h,t[43]=w);let T;t[44]===i?T=t[45]:(T=()=>i,t[44]=i,t[45]=T);let E;return t[46]!==i.addAttachment||t[47]!==i.clearAttachments||t[48]!==i.reset||t[49]!==i.setQuote||t[50]!==i.setRole||t[51]!==i.setRunConfig||t[52]!==i.setText||t[53]!==i.startDictation||t[54]!==i.stopDictation||t[55]!==S||t[56]!==C||t[57]!==w||t[58]!==T||t[59]!==y||t[60]!==b||t[61]!==x?(E={getState:y,setText:i.setText,setRole:i.setRole,setRunConfig:i.setRunConfig,addAttachment:i.addAttachment,reset:i.reset,clearAttachments:i.clearAttachments,send:b,cancel:x,beginEdit:S,startDictation:i.startDictation,stopDictation:i.stopDictation,setQuote:i.setQuote,attachment:C,queueItem:w,__internal_getRuntime:T},t[46]=i.addAttachment,t[47]=i.clearAttachments,t[48]=i.reset,t[49]=i.setQuote,t[50]=i.setRole,t[51]=i.setRunConfig,t[52]=i.setText,t[53]=i.startDictation,t[54]=i.stopDictation,t[55]=S,t[56]=C,t[57]=w,t[58]=T,t[59]=y,t[60]=b,t[61]=x,t[62]=E):E=t[62],E});function dI(){throw Error(`beginEdit is not supported in this runtime`)}var fI=e=>({get current(){return e()}}),pI=UM(e=>{let t=J(13),{runtime:n}=e,r=rI(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o,s,c;t[2]===n?(a=t[3],o=t[4],s=t[5],c=t[6]):(a=e=>n.addToolResult(e),o=e=>n.resumeToolCall(e),s=e=>n.respondToToolApproval(e),c=()=>n,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s||t[11]!==c?(l={getState:i,addToolResult:a,resumeToolCall:o,respondToToolApproval:s,__internal_getRuntime:c},t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}),mI=UM(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=sI({runtime:a}),t[3]=a,t[4]=o),jN(o)}),hI=UM(e=>{let t=J(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getMessagePartByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=pI({runtime:a}),t[3]=a,t[4]=o),jN(o)}),gI=UM(e=>{let t=J(74),{runtime:n,threadIdRef:r,threadId:i}=e,a=rI(n),o=IP(),[s,c]=wM(!1),[l,u]=wM(!1),d;t[0]===n?d=t[1]:(d=fI(()=>n.getState().id),t[0]=n,t[1]=d);let f=d,p=Y(a.status),m;t[2]!==o||t[3]!==n||t[4]!==i?(m=e=>{o(e,{threadId:i,messageId:n.getState().id})},t[2]=o,t[3]=n,t[4]=i,t[5]=m):m=t[5];let h=m,g,_;t[6]!==o||t[7]!==a.id||t[8]!==a.status||t[9]!==i?(g=()=>{let e=a.status,t=p.current;p.current=e,e?.type===`incomplete`&&e.reason===`error`&&(t?.type!==`incomplete`||t.reason!==`error`)&&o(`message.error`,{threadId:i,messageId:a.id,reason:`error`})},_=[a.status,a.id,o,i],t[6]=o,t[7]=a.id,t[8]=a.status,t[9]=i,t[10]=g,t[11]=_):(g=t[10],_=t[11]),X(g,_);let v;t[12]!==f||t[13]!==n.composer||t[14]!==r?(v=uI({runtime:n.composer,threadIdRef:r,messageIdRef:f}),t[12]=f,t[13]=n.composer,t[14]=r,t[15]=v):v=t[15];let y=KP(v),b;if(t[16]!==n||t[17]!==a.content){let e;t[19]===n?e=t[20]:(e=(e,t)=>WM(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,hI({runtime:n,index:t}),[n,t]),t[19]=n,t[20]=e),b=a.content.map(e),t[16]=n,t[17]=a.content,t[18]=b}else b=t[18];let x=TF(b),S;t[21]===a.attachments?S=t[22]:(S=a.attachments??[],t[21]=a.attachments,t[22]=S);let C;if(t[23]!==n||t[24]!==S){let e;t[26]===n?e=t[27]:(e=(e,t)=>WM(e.id,mI({runtime:n,index:t}),[n,t]),t[26]=n,t[27]=e),C=S.map(e),t[23]=n,t[24]=S,t[25]=C}else C=t[25];let w=TF(C),T=a,E;t[28]!==y.state||t[29]!==s||t[30]!==l||t[31]!==x.state||t[32]!==T?(E={...T,parts:x.state,composer:y.state,isCopied:s,isHovering:l},t[28]=y.state,t[29]=s,t[30]=l,t[31]=x.state,t[32]=T,t[33]=E):E=t[33];let D=E,O;t[34]===D?O=t[35]:(O=()=>D,t[34]=D,t[35]=O);let k;t[36]===y.methods?k=t[37]:(k=()=>y.methods,t[36]=y.methods,t[37]=k);let A;t[38]===n?A=t[39]:(A=()=>n.delete(),t[38]=n,t[39]=A);let j,M;t[40]!==h||t[41]!==n?(j=e=>(h(`message.reload`),n.reload(e)),M=()=>(h(`message.speak`),n.speak()),t[40]=h,t[41]=n,t[42]=j,t[43]=M):(j=t[42],M=t[43]);let ee,te;t[44]===n?(ee=t[45],te=t[46]):(ee=()=>n.stopSpeaking(),te=e=>n.submitFeedback(e),t[44]=n,t[45]=ee,t[46]=te);let ne;t[47]!==h||t[48]!==n?(ne=e=>(h(`message.branchSwitched`),n.switchToBranch(e)),t[47]=h,t[48]=n,t[49]=ne):ne=t[49];let re;t[50]===n?re=t[51]:(re=()=>n.unstable_getCopyText(),t[50]=n,t[51]=re);let ie;t[52]===x?ie=t[53]:(ie=e=>`index`in e?x.get({index:e.index}):x.get({key:`toolCallId-${e.toolCallId}`}),t[52]=x,t[53]=ie);let ae;t[54]===w?ae=t[55]:(ae=e=>`id`in e?w.get({key:e.id}):w.get(e),t[54]=w,t[55]=ae);let oe;t[56]===h?oe=t[57]:(oe=e=>{e&&h(`message.copied`),c(e)},t[56]=h,t[57]=oe);let se;t[58]===n?se=t[59]:(se=()=>n,t[58]=n,t[59]=se);let ce;return t[60]!==O||t[61]!==k||t[62]!==A||t[63]!==j||t[64]!==M||t[65]!==ee||t[66]!==te||t[67]!==ne||t[68]!==re||t[69]!==ie||t[70]!==ae||t[71]!==oe||t[72]!==se?(ce={getState:O,composer:k,delete:A,reload:j,speak:M,stopSpeaking:ee,submitFeedback:te,switchToBranch:ne,getCopyText:re,part:ie,attachment:ae,setIsCopied:oe,setIsHovering:u,__internal_getRuntime:se},t[60]=O,t[61]=k,t[62]=A,t[63]=j,t[64]=M,t[65]=ee,t[66]=te,t[67]=ne,t[68]=re,t[69]=ie,t[70]=ae,t[71]=oe,t[72]=se,t[73]=ce):ce=t[73],ce}),_I=e=>{let t=EM(()=>({}),[]),n=t.state,r=[];e.suggestions.forEach(e=>{let t=n?.suggestions[r.length];r.push(t&&JP(t,e)?t:e)});let i=n&&JP(r,n.suggestions)?n:{suggestions:r};return t.state=i,i},vI=UM(e=>({getState:()=>e})),yI=e=>{let t=J(9),n=_I(e),r;t[0]===n.suggestions?r=t[1]:(r=n.suggestions.map(xI),t[0]=n.suggestions,t[1]=r);let i=TF(r),a;t[2]===n?a=t[3]:(a=()=>n,t[2]=n,t[3]=a);let o;t[4]===i?o=t[5]:(o=e=>{let{index:t}=e;return i.get({index:t})},t[4]=i,t[5]=o);let s;return t[6]!==a||t[7]!==o?(s={getState:a,suggestion:o},t[6]=a,t[7]=o,t[8]=s):s=t[8],s},bI=UM(e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=e.map(SI),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r={suggestions:n},t[2]=n,t[3]=r),yI(r)});function xI(e,t){return WM(t,vI(e),[e])}function SI(e){return{title:e.title??e.prompt,label:e.label??``,prompt:e.prompt}}var CI=Object.freeze({type:`complete`}),wI=Object.freeze({type:`running`}),TI=Object.freeze({cancelled:Object.freeze({type:`incomplete`,reason:`cancelled`}),length:Object.freeze({type:`incomplete`,reason:`length`}),"content-filter":Object.freeze({type:`incomplete`,reason:`content-filter`}),other:Object.freeze({type:`incomplete`,reason:`other`}),error:Object.freeze({type:`incomplete`,reason:`error`})}),EI=e=>{let t=e.status;if(!t||typeof t!=`object`)return;let{type:n}=t;if(n===`running`)return wI;if(n===`complete`)return CI;if(n!==`incomplete`)return;let{reason:r}=t;return TI[r===`cancelled`||r===`length`||r===`content-filter`||r===`other`||r===`error`?r:`other`]},DI=(e,t,n)=>{if(e.role!==`assistant`)return CI;if(n.type===`tool-call`)return n.result===void 0?e.status:CI;if(e.status.type===`running`){let e=EI(n);if(e)return e}let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?CI:r?e.status:CI},OI=e=>`reason`in e?e.reason:void 0,kI=e=>`error`in e?e.error:void 0,AI=32,jI=new WeakMap,MI=e=>jI.get(e)??e.id,NI=(e,t,n)=>`status`in e&&e.status?DI(e,t,n):CI,PI=()=>{let e=[],t=new Map;return n=>{let r=[],i=new Map,a=!0,o=(e,n,s,c)=>{if(!(s>AI))for(let[l,u]of e.entries())for(let[e,d]of u.content.entries()){if(d.type!==`tool-call`||d.messages===void 0)continue;let f=d.messages,p=NI(u,e,d),m=OI(p),h=kI(p),g=`${c}${l}.${e}`,_=t.get(g),v=_?.part===d&&_.statusType===p.type&&_.statusReason===m&&Object.is(_.statusError,h)&&_.messages===f&&_.task.messageId===u.id&&_.task.parentTaskId===n&&_.task.depth===s?_.task:{id:d.toolCallId,toolName:d.toolName,args:d.args,result:d.result,...d.isError===void 0?void 0:{isError:d.isError},status:p,timing:d.timing,messageId:u.id,parentTaskId:n,depth:s,messages:f};v!==_?.task&&(a=!1,jI.set(v,g)),r.push(v),i.set(g,{task:v,part:d,statusType:p.type,statusReason:m,statusError:h,messages:f}),o(f,v.id,s+1,`${g}.`)}};o(n,null,0,``);let s=a&&r.length===e.length&&r.every((t,n)=>t===e[n])?e:r;return e=s,t=i,s}},FI=UM(({task:e})=>({getState:()=>e})),II=UM(e=>{let t=J(7),{runtime:n,id:r,threadIdRef:i,threadId:a}=e,o;t[0]!==r||t[1]!==n?(o=n.getMessageById(r),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;return t[3]!==s||t[4]!==a||t[5]!==i?(c=gI({runtime:s,threadIdRef:i,threadId:a}),t[3]=s,t[4]=a,t[5]=i,t[6]=c):c=t[6],jN(c)}),LI=UM(e=>{let t=J(93),{runtime:n}=e,r=rI(n),i=IP(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let r=n.unstable_on(t,()=>{let e=n.getState()?.threadId||`unknown`;i(`thread.${t}`,{threadId:e})});e.push(r)}return e.push(n.unstable_on(`toolApprovalAnswered`,e=>{let t=n.getState()?.threadId||`unknown`;i(`thread.toolApprovalAnswered`,{threadId:t,...e})})),()=>{for(let t of e)t()}},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),X(a,o);let s;t[4]===n?s=t[5]:(s=fI(()=>n.getState().threadId),t[4]=n,t[5]=s);let c=s,l;t[6]!==i||t[7]!==n?(l=e=>{i(e,{threadId:n.getState().threadId})},t[6]=i,t[7]=n,t[8]=l):l=t[8];let u=l,d;t[9]===n?d=t[10]:(d=e=>n.getState().suggestions.some(t=>t.prompt===e),t[9]=n,t[10]=d);let f=d,p;t[11]!==f||t[12]!==n.composer||t[13]!==c?(p=uI({runtime:n.composer,threadIdRef:c,isSuggestion:f}),t[11]=f,t[12]=n.composer,t[13]=c,t[14]=p):p=t[14];let m=KP(p),h;t[15]===r.suggestions?h=t[16]:(h=bI(r.suggestions),t[15]=r.suggestions,t[16]=h);let g=KP(h),_;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(_=PI(),t[17]=_):_=t[17];let v=_,y;t[18]===r.messages?y=t[19]:(y=v(r.messages),t[18]=r.messages,t[19]=y);let b=y,x;t[20]===b?x=t[21]:(x=b.map(RI),t[20]=b,t[21]=x);let S=TF(x),C;if(t[22]!==n||t[23]!==r.messages||t[24]!==r.threadId||t[25]!==c){let e;t[27]!==n||t[28]!==r.threadId||t[29]!==c?(e=e=>WM(e.id,II({runtime:n,id:e.id,threadIdRef:c,threadId:r.threadId}),[n,e.id,c,r.threadId]),t[27]=n,t[28]=r.threadId,t[29]=c,t[30]=e):e=t[30],C=r.messages.map(e),t[22]=n,t[23]=r.messages,t[24]=r.threadId,t[25]=c,t[26]=C}else C=t[26];let w=TF(C),T=w.state.length===0&&!r.isLoading,E;t[31]!==m.state||t[32]!==w.state||t[33]!==r.capabilities||t[34]!==r.extras||t[35]!==r.isDisabled||t[36]!==r.isLoading||t[37]!==r.isRunning||t[38]!==r.speech||t[39]!==r.state||t[40]!==r.suggestions||t[41]!==r.voice||t[42]!==T||t[43]!==b?(E={isEmpty:T,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:m.state,messages:w.state,tasks:b},t[31]=m.state,t[32]=w.state,t[33]=r.capabilities,t[34]=r.extras,t[35]=r.isDisabled,t[36]=r.isLoading,t[37]=r.isRunning,t[38]=r.speech,t[39]=r.state,t[40]=r.suggestions,t[41]=r.voice,t[42]=T,t[43]=b,t[44]=E):E=t[44];let D=E,O;t[45]===D?O=t[46]:(O=()=>D,t[45]=D,t[46]=O);let k;t[47]===m.methods?k=t[48]:(k=()=>m.methods,t[47]=m.methods,t[48]=k);let A;t[49]===g?A=t[50]:(A=()=>g.methods,t[49]=g,t[50]=A);let j;t[51]!==S||t[52]!==b?(j=e=>{if(`id`in e){let t=b.find(t=>t.id===e.id);return S.get({key:t?MI(t):e.id})}return S.get(e)},t[51]=S,t[52]=b,t[53]=j):j=t[53];let M;t[54]!==i||t[55]!==f||t[56]!==n?(M=e=>{let t=typeof e==`string`?{content:[{type:`text`,text:e}]}:e;if((t.role??`user`)===`user`){let e=t.content.map(zI).join(``);i(`composer.send`,{threadId:n.getState().threadId,chars:e.length,attachments:t.attachments?.length??0,...f(e)?{suggestion:!0}:void 0})}n.append(e)},t[54]=i,t[55]=f,t[56]=n,t[57]=M):M=t[57];let ee;t[58]!==u||t[59]!==n||t[60]!==r.isRunning?(ee=()=>{r.isRunning&&u(`thread.cancelRun`),n.cancelRun()},t[58]=u,t[59]=n,t[60]=r.isRunning,t[61]=ee):ee=t[61];let te;t[62]!==u||t[63]!==n?(te=()=>{n.connectVoice(),u(`thread.voiceStarted`)},t[62]=u,t[63]=n,t[64]=te):te=t[64];let ne;t[65]===w?ne=t[66]:(ne=e=>`id`in e?w.get({key:e.id}):w.get(e),t[65]=w,t[66]=ne);let re;t[67]===n?re=t[68]:(re=()=>n,t[67]=n,t[68]=re);let ie;return t[69]!==n.deleteMessage||t[70]!==n.disconnectVoice||t[71]!==n.export||t[72]!==n.getModelContext||t[73]!==n.getVoiceVolume||t[74]!==n.import||t[75]!==n.importExternalState||t[76]!==n.muteVoice||t[77]!==n.reset||t[78]!==n.resumeRun||t[79]!==n.startRun||t[80]!==n.stopSpeaking||t[81]!==n.subscribeVoiceVolume||t[82]!==n.unmuteVoice||t[83]!==O||t[84]!==k||t[85]!==A||t[86]!==j||t[87]!==M||t[88]!==ee||t[89]!==te||t[90]!==ne||t[91]!==re?(ie={getState:O,composer:k,suggestions:A,task:j,append:M,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,importExternalState:n.importExternalState,cancelRun:ee,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:te,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:ne,__internal_getRuntime:re},t[69]=n.deleteMessage,t[70]=n.disconnectVoice,t[71]=n.export,t[72]=n.getModelContext,t[73]=n.getVoiceVolume,t[74]=n.import,t[75]=n.importExternalState,t[76]=n.muteVoice,t[77]=n.reset,t[78]=n.resumeRun,t[79]=n.startRun,t[80]=n.stopSpeaking,t[81]=n.subscribeVoiceVolume,t[82]=n.unmuteVoice,t[83]=O,t[84]=k,t[85]=A,t[86]=j,t[87]=M,t[88]=ee,t[89]=te,t[90]=ne,t[91]=re,t[92]=ie):ie=t[92],ie});function RI(e){return WM(MI(e),FI({task:e}),[e])}function zI(e){return e.type===`text`?e.text:``}var BI=(e,t)=>oI(`thread list ${e}`,t),VI=UM(e=>{let t=J(35),{runtime:n,mainThreadIsRunning:r}=e,i=r!==void 0&&r,a=rI(n),o;bb0:{let e=a.isRunning||a.isMain&&i;if(e===a.isRunning){o=a;break bb0}let n;t[0]!==e||t[1]!==a?(n={...a,isRunning:e},t[0]=e,t[1]=a,t[2]=n):n=t[2],o=n}let s=o,c=IP(),{isMain:l,id:u}=a,d;t[3]!==l||t[4]!==u?(d={isMain:l,threadId:u},t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=Y(d),p,m;t[6]!==c||t[7]!==l||t[8]!==u?(p=()=>{let e=f.current;(e.isMain!==l||e.threadId!==u)&&(f.current={isMain:l,threadId:u},c(l?`threadListItem.switchedTo`:`threadListItem.switchedAway`,{threadId:u}))},m=[l,u,c],t[6]=c,t[7]=l,t[8]=u,t[9]=p,t[10]=m):(p=t[9],m=t[10]),X(p,m);let h;t[11]===s?h=t[12]:(h=()=>s,t[11]=s,t[12]=h);let g,_,v,y,b,x,S;t[13]===n?(g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20]):(b=e=>BI(`switch`,()=>n.switchTo(e)),x=e=>BI(`rename`,()=>n.rename(e)),S=e=>BI(`update custom metadata`,()=>n.updateCustom(e)),g=()=>BI(`archive`,()=>n.archive()),_=()=>BI(`unarchive`,()=>n.unarchive()),v=()=>BI(`delete`,()=>n.delete()),y=e=>BI(`generate title`,()=>n.generateTitle(e)),t[13]=n,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S);let C;t[21]===n?C=t[22]:(C=()=>n,t[21]=n,t[22]=C);let w;return t[23]!==n.detach||t[24]!==n.initialize||t[25]!==g||t[26]!==_||t[27]!==v||t[28]!==y||t[29]!==C||t[30]!==h||t[31]!==b||t[32]!==x||t[33]!==S?(w={getState:h,switchTo:b,rename:x,updateCustom:S,archive:g,unarchive:_,delete:v,generateTitle:y,initialize:n.initialize,detach:n.detach,__internal_getRuntime:C},t[23]=n.detach,t[24]=n.initialize,t[25]=g,t[26]=_,t[27]=v,t[28]=y,t[29]=C,t[30]=h,t[31]=b,t[32]=x,t[33]=S,t[34]=w):w=t[34],w}),HI=e=>{let t=J(4),n=IP(),r=Y(e),i,a;t[0]!==n||t[1]!==e?(i=()=>{let t=r.current;t!==e&&(r.current=e,n(`threads.selectionChanged`,{threadId:e,previousThreadId:t}))},a=[e,n],t[0]=n,t[1]=e,t[2]=i,t[3]=a):(i=t[2],a=t[3]),X(i,a)},UI=UM(e=>{let t=J(6),{runtime:n,id:r,mainThreadIsRunning:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getItemById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==i||t[4]!==o?(s=VI({runtime:o,mainThreadIsRunning:i}),t[3]=i,t[4]=o,t[5]=s):s=t[5],jN(s)}),WI=UM(e=>{let t=J(48),{runtime:n,__internal_assistantRuntime:r}=e,i=rI(n);HI(i.mainThreadId);let a=IP(),o,s;t[0]!==a||t[1]!==n?(o=()=>n.unstable_subscribeThreadEvents(e=>{let{threadId:t,type:r}=e;t!==n.getState().mainThreadId&&a(`thread.${r}`,{threadId:t})}),s=[n,a],t[0]=a,t[1]=n,t[2]=o,t[3]=s):(o=t[2],s=t[3]),X(o,s);let c;t[4]===n.main?c=t[5]:(c=LI({runtime:n.main}),t[4]=n.main,t[5]=c);let l=KP(c),u;t[6]!==l.state||t[7]!==n||t[8]!==i.threadItems?(u=Object.keys(i.threadItems).map(e=>WM(e,UI({runtime:n,id:e,mainThreadIsRunning:l.state.isRunning}),[n,e,l.state.isRunning])),t[6]=l.state,t[7]=n,t[8]=i.threadItems,t[9]=u):u=t[9];let d=TF(u),f=i.newThreadId??null,p;t[10]!==l.state||t[11]!==i.archivedThreadIds||t[12]!==i.hasMore||t[13]!==i.isLoading||t[14]!==i.isLoadingMore||t[15]!==i.loadError||t[16]!==i.mainThreadId||t[17]!==i.threadIds||t[18]!==f||t[19]!==d.state?(p={mainThreadId:i.mainThreadId,newThreadId:f,isLoading:i.isLoading,loadError:i.loadError,isLoadingMore:i.isLoadingMore,hasMore:i.hasMore,threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadItems:d.state,main:l.state},t[10]=l.state,t[11]=i.archivedThreadIds,t[12]=i.hasMore,t[13]=i.isLoading,t[14]=i.isLoadingMore,t[15]=i.loadError,t[16]=i.mainThreadId,t[17]=i.threadIds,t[18]=f,t[19]=d.state,t[20]=p):p=t[20];let m=p,h;t[21]===m?h=t[22]:(h=()=>m,t[21]=m,t[22]=h);let g;t[23]===l.methods?g=t[24]:(g=()=>l.methods,t[23]=l.methods,t[24]=g);let _;t[25]!==m||t[26]!==d?(_=e=>{if(e===`main`)return d.get({key:m.mainThreadId});if(`id`in e)return d.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?m.archivedThreadIds[t]:m.threadIds[t];return d.get({key:r})},t[25]=m,t[26]=d,t[27]=_):_=t[27];let v,y,b,x,S,C;t[28]===n?(v=t[29],y=t[30],b=t[31],x=t[32],S=t[33],C=t[34]):(v=(e,t)=>BI(`switch`,()=>n.switchToThread(e,t)),y=()=>BI(`create`,()=>n.switchToNewThread()),b=()=>n.getLoadThreadsPromise(),x=()=>n.reload(),S=()=>n.reloadMainThread(),C=()=>n.loadMore(),t[28]=n,t[29]=v,t[30]=y,t[31]=b,t[32]=x,t[33]=S,t[34]=C);let w;t[35]===r?w=t[36]:(w=()=>r,t[35]=r,t[36]=w);let T;return t[37]!==v||t[38]!==y||t[39]!==b||t[40]!==x||t[41]!==S||t[42]!==C||t[43]!==w||t[44]!==h||t[45]!==g||t[46]!==_?(T={getState:h,thread:g,item:_,switchToThread:v,switchToNewThread:y,getLoadThreadsPromise:b,reload:x,reloadMainThread:S,loadMore:C,__internal_getAssistantRuntime:w},t[37]=v,t[38]=y,t[39]=b,t[40]=x,t[41]=S,t[42]=C,t[43]=w,t[44]=h,t[45]=g,t[46]=_,t[47]=T):T=t[47],T}),GI=(e,t)=>{e.thread??=CF({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)}),e.threadListItem??=CF({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)}),e.composer??=CF({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=JF()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=CF({source:`thread`,query:{},get:e=>e.thread.suggestions()}))},KI=e=>{let t=J(7),n=PP(),r;t[0]!==n||t[1]!==e?(r=()=>e.registerModelContextProvider(n.current.modelContext()),t[0]=n,t[1]=e,t[2]=r):r=t[2];let i;t[3]===e?i=t[4]:(i=[e],t[3]=e,t[4]=i),FP(`modelContext`,r,i);let a;return t[5]===e?a=t[6]:(a=WI({runtime:e.threads,__internal_assistantRuntime:e}),t[5]=e,t[6]=a),jN(a)},qI=UM(KI);vP(KI,(e,t)=>{GI(e,t),!e.tools&&t.tools.source===null&&(e.tools=$F({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=RN())});var JI=e=>{let{children:t,condition:n}=e;return $(n)?t:null};JI.displayName=`AuiIf`;var YI=UN({}),XI=({effects:e})=>{"use no memo";return OM(e),null},ZI=Z(function(e,t){"use no memo";let{config:n,children:r}=e,i=`extends`in e,a=`value`in e,o=hP();if(ZP){if(i&&a)throw Error("AuiProvider: pass either `extends` or `value`, not both.");if(i&&e.extends===void 0)throw Error("AuiProvider: `extends` must be a client or null, not undefined.");if(i&&!n)throw Error("AuiProvider: `extends` requires a `config`.");if(a&&n)throw Error("AuiProvider: pass either `value` or `config`, not both.");if(!a&&!n)throw Error("AuiProvider: a `config` is required.");if(!i&&!a&&o!==cP)throw Error(`A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.`)}let s=i?e.extends??cP:a?e.value??cP:o,c=zP(),{client:l,effects:u}=gF(s,n??YI,c);return PM(t,()=>l,[l]),(0,P.jsx)(LP.Provider,{value:c,children:(0,P.jsxs)(uP.Provider,{value:l,children:[(0,P.jsx)(XI,{effects:pP(s)}),u&&(0,P.jsx)(XI,{effects:u}),r]})})}),QI=e=>{let t=Q(),n=Y(!1),r=n.current?null:e(t);return $(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},$I=Object.freeze({});function eL(e){let t=J(3),{getItemState:n,children:r}=e,i=QI(n),a;return t[0]!==r||t[1]!==i?(a=r(i),t[0]=r,t[1]=i,t[2]=a):a=t[2],tL(a)}var tL=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return EM(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?$I:t?.props])??e},nL=(e,t)=>{let n=J(11),r=Q(),i=kM(t),a;n[0]===e?a=n[1]:(a=bP(e),n[0]=e,n[1]=a);let{scope:o,event:s}=a,c;n[2]!==r||n[3]!==i||n[4]!==s||n[5]!==o?(c=()=>r.on({scope:o,event:s},i),n[2]=r,n[3]=i,n[4]=s,n[5]=o,n[6]=c):c=n[6];let l;n[7]!==r||n[8]!==s||n[9]!==o?(l=[r,o,s],n[7]=r,n[8]=s,n[9]=o,n[10]=l):l=n[10],X(c,l)},rL=e=>e._core?.RenderComponent,iL=({runtime:e,aui:t,config:n,children:r})=>{"use no memo";let i=rL(e),a=UN({...n,threads:qI(e)});return(0,P.jsxs)(ZI,{extends:t,config:a,children:[i&&(0,P.jsx)(i,{}),r]})},aL=FM(e=>{let t=J(5),{runtime:n,aui:r,config:i,children:a}=e,o=r===void 0?null:r,s;return t[0]!==o||t[1]!==a||t[2]!==i||t[3]!==n?(s=(0,P.jsx)(iL,{runtime:n,aui:o,config:i,children:a}),t[0]=o,t[1]=a,t[2]=i,t[3]=n,t[4]=s):s=t[4],s});function oL(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function sL(e,t=0){return t>100?!1:e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(e=>sL(e,t+1)):oL(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&sL(n,t+1)):!1}var cL=100,lL=(e,t,n)=>{if(e===t)return!0;if(n>cL||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>lL(e,t[r],n+1));if(Array.isArray(t)||!oL(e)||!oL(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&lL(e[r],t[r],n+1))},uL=(e,t)=>!sL(e)||!sL(t)?!1:lL(e,t,0),dL=Symbol.for(`aui.tool-response`),fL=`<no result>`,pL=class e{get[dL](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact);let t=e.result;this.result=t===void 0?fL:t,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&dL in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?fL:t})}},mL=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});if(!e||!t)throw Error(`Failed to create promise`);return{promise:n,resolve:e,reject:t}},hL=()=>{let e=[],t=!1,n=!1,r=!1,i,a,o=0,s,c,l=()=>(a=void 0,c??=Promise.all(e.splice(0).map(async e=>{try{await e.reader.cancel().catch(()=>void 0),await e.pipeTask}finally{e.reader.releaseLock()}})).then(()=>void 0),c),u=e=>{n||r||(r=!0,console.error(e),l(),i.error(e),s?.reject(e),s=void 0)},d=a=>{a.promise||=a.reader.read().then(({done:c,value:l})=>{a.promise=void 0,!(n||r)&&(c?(e.splice(e.indexOf(a),1),a.reader.releaseLock(),t&&e.length===0&&o===0&&i.close()):i.enqueue(l),s?.resolve(),s=void 0)}).catch(u)},f=new ReadableStream({start(e){i=e},pull(){return s=mL(),e.forEach(e=>{d(e)}),s.promise},async cancel(){n=!0;let e=l();s?.resolve(),s=void 0,await e}}),p=c=>{if(e.length>0&&(a=void 0),!a){let c=[];a=c,o++,Promise.resolve().then(()=>{if(o--,a===c&&(a=void 0),!(n||r)){for(let e of c)i.enqueue(e);t&&e.length===0&&o===0&&i.close(),s?.resolve(),s=void 0}}).catch(u)}a.push(c)};return{readable:f,isSealed(){return t},isCancelled(){return n},isErrored(){return r},seal(){t||n||r||(t=!0,e.length===0&&o===0&&i.close())},addStream:(i,o)=>{let s=o?.catch(()=>void 0);if(n||r){i.cancel().catch(()=>void 0);return}if(t)throw i.cancel().catch(()=>void 0),Error(`Cannot add streams after the run callback has settled.`);a=void 0;let c={reader:i.getReader(),pipeTask:s};e.push(c),d(c)},enqueue(e){if(!(n||r)){if(t)throw Error(`Cannot add streams after the run callback has settled.`);p(e)}}}},gL=e=>e instanceof TypeError,_L=(e,t,n)=>{try{e.enqueue(t)}catch(e){if(!gL(e))throw e;n?.(e)}},vL=e=>{try{e.close()}catch(e){if(!gL(e))throw e}},yL=(e,t)=>new ReadableStream({start(n){return e.start?.(t(n))},pull(n){return e.pull?.(t(n))},cancel(t){return e.cancel?.(t)}}),bL=(e,t)=>{let n;return[yL({start(e){n=e},cancel(e){return t?.(n,e)}},e),n]},xL=class{_controller;_strict;_isClosed=!1;_warnedDropped=!1;constructor(e,t={}){this._controller=e,this._strict=t.strict??!0}append(e){let t={type:`text-delta`,path:[],textDelta:e};if(this._isClosed){if(this._strict)throw TypeError(`Cannot append to a closed TextStreamController`);return _L(this._controller,t,this._warnDroppedAfterClose),this}return _L(this._controller,t),this}_warnDroppedAfterClose=e=>{this._warnedDropped||(this._warnedDropped=!0,console.error(`Dropped text delta for closed stream: ${String(e)}`))};close(){this._isClosed||(this._isClosed=!0,_L(this._controller,{type:`part-finish`,path:[]}),vL(this._controller))}},SL=(e,t={})=>yL(e,e=>new xL(e,t)),CL=(e={})=>bL(t=>new xL(t,e)),wL=class{_isClosed=!1;_mergeTask;_controller;constructor(e,t={}){this._controller=e;let n=SL({start:e=>{this._argsTextController=e}},t),r=!1;this._mergeTask=n.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:r=!0,_L(this._controller,e);break;case`part-finish`:r||_L(this._controller,{type:`text-delta`,textDelta:`{}`,path:[]}),_L(this._controller,{type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){if(this._isClosed)return;let t=e.result;_L(this._controller,{type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:t===void 0?fL:t,isError:e.isError??!1,...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}}),await this.close()}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,_L(this._controller,{type:`part-finish`,path:[]}),vL(this._controller))}},TL=(e={})=>bL(t=>new wL(t,e)),EL=class{value=-1;up(){return++this.value}},DL=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var OL=class extends TransformStream{constructor(e){let t=new EL,n=new Map;super({transform(r,i){r.type===`part-start`&&r.path.length===0&&n.set(t.up(),e.up());let[a,...o]=r.path;if(a===void 0){i.enqueue(r);return}let s=n.get(a);if(s===void 0)throw Error(`Path not found`);i.enqueue({...r,path:[s,...o]})}})}},kL=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},AL=kL(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),jL=class e{_state;_parentId;constructor(e,t={}){this._state=e||{strict:t.strict??!0,merger:hL(),contentCounter:new EL}}get __internal_isClosed(){return this._state.merger.isSealed()||this._state.merger.isCancelled()||this._state.merger.isErrored()}get __internal_isCancelled(){return this._state.merger.isCancelled()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addTransformedStream(e,t){if(e.locked)throw TypeError(`Cannot merge a stream that is already locked to a reader.`);let n=e.pipeTo(t.writable).catch(async e=>{throw await t.writable.abort(e).catch(()=>void 0),e});this._state.merger.addStream(t.readable,n)}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._addTransformedStream(t,new DL(this._state.contentCounter.value))}merge(e){this._addTransformedStream(e,new OL(this._state.contentCounter))}appendText(e){(this._state.append?.kind!==`text`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`text`,parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e,t){(t!==void 0||this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart(t)}),(t===void 0||e.length!==0)&&this._state.append.controller.append(e)}addTextPart(){let[e,t]=CL({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(e){let[t,n]=CL({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`reasoning`,...e}),t),n}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??AL(),[i,a]=TL({strict:this._state.strict});return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type===`part-start`&&e.path.length===0&&this._state.contentCounter.up()}withParentId(t){let n=new e(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function ML(e,t={}){let n=new jL(void 0,t);return(async()=>{try{await e(n)}catch(e){n.__internal_isClosed?n.__internal_isCancelled||console.error(e):n.enqueue({type:`error`,path:[],error:String(e)})}finally{n.__internal_isClosed||n.close()}})(),n.__internal_getReadable()}function NL(e={}){let{resolve:t,promise:n}=mL(),r;return[ML(e=>(r=e,r.__internal_subscribeToClose(t),n),e),r]}var PL=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},FL=r(((e,t)=>{var n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o})),IL=class extends TransformStream{constructor(){let e=[];super({transform(t,n){if(t.type===`part-start`){if(t.path.length!==0){n.error(Error(`Nested parts are not supported`));return}e.push(t.part),n.enqueue(t);return}if(t.type===`text-delta`||t.type===`result`||t.type===`part-finish`||t.type===`tool-call-args-text-finish`){if(t.path.length!==1){n.error(Error(`${t.type} chunks must have a path of length 1`));return}let r=t.path[0];if(r<0||r>=e.length){n.error(Error(`Invalid path index: ${r}`));return}let i=e[r];n.enqueue({...t,meta:i});return}n.enqueue(t)}})}},LL=/[0-9a-fA-F]/;function RL(e){let t=[`ROOT`],n=-1,r=null,i=0,a=[],o;function s(){o!==void 0&&(a.push(JSON.parse(`"${o}"`)),o=void 0)}function c(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),s();break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),s();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),s()}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),o=a.pop()}}function u(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=r,t.pop(),o=a.pop()}}for(let s=0;s<e.length;s++){let d=e[s];switch(t[t.length-1]){case`ROOT`:c(d,s,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``;break;case`}`:n=s,t.pop(),o=a.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:d===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``);break;case`INSIDE_OBJECT_KEY`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),o+=d;break;default:o+=d}break;case`INSIDE_OBJECT_AFTER_KEY`:d===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:c(d,s,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:l(d,s);break;case`INSIDE_STRING`:switch(d){case`"`:t.pop(),n=s,o=a.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=s}break;case`INSIDE_ARRAY_START`:switch(d){case`]`:n=s,t.pop(),o=a.pop();break;default:o=`0`,c(d,s,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(d){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=s,t.pop(),o=a.pop();break;default:n=s}break;case`INSIDE_ARRAY_AFTER_COMMA`:c(d,s,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:{t.pop();let e=t[t.length-1];d===`u`?(t.push(`INSIDE_STRING_UNICODE_ESCAPE`),i=0):e===`INSIDE_STRING`&&(n=s),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_STRING_UNICODE_ESCAPE`:{let e=t[t.length-2];if(!LL.test(d)){t.pop(),s--;break}i++,i===4&&(t.pop(),e===`INSIDE_STRING`&&(n=s)),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_NUMBER`:switch(d){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=s;break;case`e`:case`E`:case`-`:case`+`:case`.`:break;case`,`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`}`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`]`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s);break;default:t.pop(),o=a.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,s+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?l(d,s):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s)):n=s;break}}}let d=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:d+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:d+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:d+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?d+=`true`.slice(t.length):`false`.startsWith(t)?d+=`false`.slice(t.length):`null`.startsWith(t)&&(d+=`null`.slice(t.length))}}return[d,a]}var zL=n(FL(),1),BL=Symbol(`aui.parse-partial-json-object.meta`),VL=e=>e?.[BL],HL=e=>{if(e.length===0)return{[BL]:{state:`partial`,partialPath:[]}};try{let t=zL.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[BL]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=RL(e),r=zL.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[BL]={state:`partial`,partialPath:n},r}catch{return}}},UL=(e,t,n)=>{if(typeof e!=`object`||!e)return t.state;if(t.state===`complete`)return`complete`;if(n.length===0)return t.state;let[r,...i]=n;if(!Object.hasOwn(e,r))return`partial`;let[a,...o]=t.partialPath;if(r!==a)return`complete`;let s=e[r];return UL(s,{state:`partial`,partialPath:o},i)},WL=(e,t)=>{let n=VL(e);if(!n)throw Error(`unable to determine object state`);return UL(e,n,t.map(String))},GL=new Set([`__proto__`,`constructor`,`prototype`]);function KL(e){if(GL.has(e))throw Error(`Unsafe gorp path segment: ${e}`)}var qL=class{_state;_strict;_logged=new Set;_warnedClamp=!1;constructor(e=null,t={}){this._state=e,this._strict=t.strict??!0}get state(){return this._state}logOnce(e,t){this._logged.has(e)||this._logged.size>=20||(this._logged.add(e),t())}append(e){this._state=e.reduce((e,t)=>{if(this._strict)return this.apply(e,t);try{return this.apply(e,t)}catch(n){return this.logOnce(`skip:${String(n)}`,()=>console.error(`Skipped unappliable gorp operation: ${String(n)}`,t)),e}},this._state)}apply(e,t){let n=t.type;switch(n){case`set`:return this.updatePath(e,t.path,()=>t.value);case`append-text`:return this.updatePath(e,t.path,e=>{if(typeof e!=`string`)throw Error(`Expected string at path [${t.path.join(`, `)}]`);return e+t.value});default:throw Error(`Invalid operation type: ${n}`)}}updatePath(e,t,n){if(t.length===0)return n(e);let r=[],i=e;for(let e=0;e<t.length;e++){if(i??={},typeof i!=`object`)throw Error(`Invalid path: [${t.slice(e).join(`, `)}]`);let n=t[e];if(KL(n),Array.isArray(i)){let a=Number(n);if(!Number.isInteger(a)||String(a)!==String(n))throw Error(`Expected array index at [${t.slice(e).join(`, `)}]`);if(a<0)throw Error(`Insert array index out of bounds`);if(a>i.length){if(this._strict)throw Error(`Insert array index out of bounds`);this._warnedClamp||(this._warnedClamp=!0,console.warn(`Clamped out-of-bounds gorp array index ${a} to ${i.length}`)),a=i.length}r.push({kind:`array`,state:i,key:a}),i=Object.hasOwn(i,a)?i[a]:void 0}else{let e=i;r.push({kind:`object`,state:e,key:n}),i=Object.hasOwn(e,n)?e[n]:void 0}}let a=n(i);for(let e=r.length-1;e>=0;e--){let t=r[e];if(t.kind===`array`){let e=[...t.state];e[t.key]=a,a=e}else{let e={...t.state};e[t.key]=a,a=e}}return a}},JL=class{_streamStartTime;_firstTokenTime;_totalChunks=0;_toolCallIds=new Set;constructor(){this._streamStartTime=Date.now()}recordChunk(){this._totalChunks++}recordFirstToken(){this._firstTokenTime===void 0&&(this._firstTokenTime=Date.now())}recordToolCallStart(e){this._toolCallIds.add(e)}getTiming(e,t){let n=Date.now()-this._streamStartTime,r=e&&e>0?e:t?Math.ceil(t.length/4):void 0,i=r&&n>0?r/n*1e3:void 0;return{streamStartTime:this._streamStartTime,...this._firstTokenTime===void 0?void 0:{firstTokenTime:this._firstTokenTime-this._streamStartTime},totalStreamTime:n,...r===void 0?void 0:{tokenCount:r},...i===void 0?void 0:{tokensPerSecond:i},totalChunks:this._totalChunks,toolCallCount:this._toolCallIds.size}}},YL=(e,t)=>({...e,parts:t,get content(){return this.parts}}),XL=(e,t)=>YL(e,[...e.parts,t]),ZL=({unstable_state:e=null}={})=>({role:`assistant`,status:{type:`running`},parts:[],get content(){return this.parts},metadata:{unstable_state:e,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),QL=16,$L=(e,t,n,r)=>{let i=t.path.length===1?e.parts[t.path[0]]:void 0;if(i===void 0)return n(`no-part:${t.type}`,`Dropped ${t.type} chunk: no part at path [${t.path.join(`, `)}]`),e;let a=t.path[0],o=r(i);return o===i?e:YL(e,[...e.parts.slice(0,a),o,...e.parts.slice(a+1)])},eR=(e,t,n)=>{let r=t.part;if(r.type===`text`||r.type===`reasoning`)return XL(e,{type:r.type,text:``,status:{type:`running`},...r.type===`reasoning`&&r.unstable_summary!==void 0?{unstable_summary:r.unstable_summary}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`tool-call`)return XL(e,{type:`tool-call`,state:`partial-call`,status:{type:`running`,isArgsComplete:!1},toolCallId:r.toolCallId,toolName:r.toolName,argsText:``,args:{},timing:{startedAt:Date.now()},...r.parentId&&{parentId:r.parentId}});if(r.type===`source`)return XL(e,{type:`source`,sourceType:r.sourceType,id:r.id,url:r.url,...r.title?{title:r.title}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`file`)return XL(e,{type:`file`,mimeType:r.mimeType,data:r.data,...r.parentId&&{parentId:r.parentId}});if(r.type===`data`)return XL(e,{type:`data`,name:r.name,data:r.data,...r.parentId&&{parentId:r.parentId}});{let t=String(r.type);return n(`unsupported-part-start:${t}`,`Unsupported part-start type ${t}: inserting an empty reasoning part to preserve part indices`),XL(e,{type:`reasoning`,text:``,status:{type:`running`}})}},tR=(e,t,n)=>$L(e,t,n,e=>e.type===`tool-call`?e.state===`partial-call`?{...e,state:`call`,status:e.status.type===`running`?{type:`running`,isArgsComplete:!0}:e.status}:e:(n(`wrong-part:tool-call-args-text-finish`,`Dropped tool-call-args-text-finish chunk: part is not a tool-call`),e)),nR=(e,t,n)=>$L(e,t,n,e=>({...e,status:{type:`complete`,reason:`unknown`}})),rR=(e,t,n)=>$L(e,t,n,e=>{if(e.type===`text`||e.type===`reasoning`)return{...e,text:e.text+t.textDelta};if(e.type===`tool-call`){let n=e.argsText+t.textDelta,r=HL(n)??e.args;return{...e,argsText:n,args:r}}return n(`wrong-part:text-delta`,`Dropped text-delta chunk: part is neither text nor tool-call`),e}),iR=(e,t,n)=>$L(e,t,n,e=>e.type===`tool-call`?{...e,state:`result`,...e.timing===void 0?{}:{timing:{...e.timing,completedAt:e.timing.completedAt??Date.now()}},...t.artifact===void 0?{}:{artifact:t.artifact},result:t.result,isError:t.isError??!1,...t.modelContent===void 0?{}:{modelContent:t.modelContent},...t.messages===void 0?{}:{messages:t.messages},status:{type:`complete`,reason:`stop`}}:(n(`wrong-part:result`,`Dropped result chunk: part is not a tool-call`),e)),aR=(e,t)=>{if(e.status?.type===`incomplete`&&e.status?.reason===`error`)return e;let n=oR(t);return{...e,status:n}},oR=e=>e.finishReason===`tool-calls`?{type:`requires-action`,reason:`tool-calls`}:e.finishReason===`stop`||e.finishReason===`unknown`?{type:`complete`,reason:e.finishReason}:{type:`incomplete`,reason:e.finishReason},sR=(e,t)=>({...e,metadata:{...e.metadata,unstable_annotations:[...e.metadata.unstable_annotations,...t.annotations]}}),cR=(e,t)=>({...e,metadata:{...e.metadata,unstable_data:[...e.metadata.unstable_data,...t.data]}}),lR=(e,t)=>({...e,metadata:{...e.metadata,steps:[...e.metadata.steps,{state:`started`,messageId:t.messageId}]}}),uR=(e,t)=>{let n=e.metadata.steps.slice(),r=n.length-1;return n.length>0&&n[r]?.state===`started`?n[r]={...n[r],state:`finished`,finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}:n.push({state:`finished`,messageId:AL(),finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}),{...e,metadata:{...e.metadata,steps:n}}},dR=(e,t)=>{let n=t.severity===`critical`||t.severity===`warning`||t.severity===`info`?t.severity:void 0;return{...e,status:{type:`incomplete`,reason:`error`,error:{code:t.code??`unknown`,message:t.error??`unknown error`,...n!==void 0&&{severity:n}}}}},fR=(e,t,n)=>(n.append(t.operations),{...e,metadata:{...e.metadata,unstable_state:n.state}}),pR=e=>{let t=0;for(let n of e.metadata.steps)n.state===`finished`&&n.usage&&(t+=n.usage.outputTokens);return t},mR=(e,t,n=0)=>{let r=n>0?n:pR(t);if(r>0)return e.getTiming(r);let i=``;for(let e of t.parts)(e.type===`text`||e.type===`reasoning`)&&(i+=e.text);return e.getTiming(void 0,i||void 0)},hR=e=>{let t=!1;return()=>{t||(t=!0,queueMicrotask(()=>{t=!1,e()}))}},gR=class extends TransformStream{constructor({initialMessage:e,throttle:t,onError:n,strict:r=!0}={}){let i=e??ZL(),a,o,s=new JL,c=new Set,l=(e,t)=>{c.has(e)||c.size>=QL||(c.add(e),console.warn(t))},u,d=t?hR(()=>{u?.enqueue(i)}):()=>{u?.enqueue(i)};super({start(e){u=e},transform(e){s.recordChunk();let t=e.type;switch(t){case`part-start`:i=eR(i,e,l),e.part.type===`tool-call`&&s.recordToolCallStart(e.part.toolCallId);break;case`tool-call-args-text-finish`:i=tR(i,e,l);break;case`part-finish`:i=nR(i,e,l);break;case`text-delta`:{let t=rR(i,e,l);t!==i&&s.recordFirstToken(),i=t;break}case`result`:i=iR(i,e,l);break;case`message-finish`:o=e.usage?.outputTokens,i=aR(i,e);break;case`annotations`:i=sR(i,e);break;case`data`:i=cR(i,e);break;case`step-start`:i=lR(i,e);break;case`step-finish`:i=uR(i,e);break;case`error`:i=dR(i,e),n?.(e.error);break;case`update-state`:a??=new qL(i.metadata.unstable_state,{strict:r}),i=fR(i,e,a);break;default:throw Error(`Unsupported chunk type: ${t}`)}i.status.type!==`running`&&(i={...i,metadata:{...i.metadata,timing:mR(s,i,o)}}),d()},flush(e){if(i.status?.type===`running`){let t=i.parts?.some(e=>e.type===`tool-call`&&(e.state===`call`||e.state===`partial-call`)&&e.result===void 0)??!1;i=aR(i,{type:`message-finish`,path:[],finishReason:t?`tool-calls`:`unknown`,usage:{inputTokens:0,outputTokens:0}}),i={...i,metadata:{...i.metadata,timing:mR(s,i,o)}},e.enqueue(i)}}})}};async function*_R(){let e=this.getReader(),t=!0;try{for(;;){let n;try{n=await e.read()}catch(e){throw t=!1,e}if(n.done){t=!1;break}let{value:r}=n;yield r}}finally{try{t&&await e.cancel()}finally{e.releaseLock()}}}function vR(e){return e[Symbol.asyncIterator]??=_R,e}var yR=class e{readable;constructor(e){this.readable=e}static fromAssistantStream(t){return new e(t.pipeThrough(new gR))}async unstable_result(){let e;for await(let t of this)e=t;return e||{role:`assistant`,status:{type:`complete`,reason:`unknown`},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}}[Symbol.asyncIterator](){return vR(this.readable)[Symbol.asyncIterator]()}tee(){let[t,n]=this.readable.tee();return[new e(t),new e(n)]}};function bR(e,t,n){try{let r=e();if(typeof r==`object`&&r&&`then`in r)return r.then(t,n);t(r)}catch(e){n(e)}}function xR(e,t){let n=e;for(let e of t){if(n==null||!Object.hasOwn(n,e))return;n=n[e]}return n}var SR=class{resolve;reject;disposed=!1;fieldPath;get isDisposed(){return this.disposed}constructor(e,t,n){this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(WL(e,this.fieldPath)===`complete`){let t=xR(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(e){if(!this.disposed)try{let t=xR(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},CR=class{controller;disposed=!1;fieldPath;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=xR(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),WL(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},wR=class{controller;disposed=!1;fieldPath;lastValue=void 0;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=xR(e,this.fieldPath);if(t!==void 0&&typeof t==`string`){let e=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(e)}WL(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},TR=class{controller;disposed=!1;fieldPath;nextIndex=0;get isDisposed(){return this.disposed}constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=xR(e,this.fieldPath);if(!Array.isArray(t))return;for(;this.nextIndex<t.length&&WL(e,[...this.fieldPath,this.nextIndex])===`complete`;this.nextIndex++)this.controller.enqueue(t[this.nextIndex]);WL(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},ER=class{argTextDeltas;handles=new Set;accumulatedText=``;parsedTextLength=-1;args=void 0;finished=!1;constructor(e){this.argTextDeltas=e,this.processStream()}async processStream(){try{let e=this.argTextDeltas.getReader();for(;;){let{value:t,done:n}=await e.read();if(n)break;this.accumulatedText+=t,this.handles.size!==0&&this.parseCurrentArgs()&&this.updateHandles()}}catch(e){console.error(`Error processing argument stream:`,e)}finally{this.finished=!0;for(let e of this.handles)e.end(this.args);this.handles.clear()}}parseCurrentArgs(){if(this.parsedTextLength===this.accumulatedText.length)return!1;let e=HL(this.accumulatedText);return this.parsedTextLength=this.accumulatedText.length,e===void 0?(this.args??=HL(``),!1):(this.args=e,!0)}updateHandles(){for(let e of this.handles)e.update(this.args),e.isDisposed&&this.handles.delete(e)}activateHandle(e){if(this.parseCurrentArgs(),e.update(this.args),!e.isDisposed){if(this.finished){e.end(this.args);return}this.handles.add(e)}}get(...e){return new Promise((t,n)=>{let r=new SR(t,n,e);this.activateHandle(r)})}streamValues(...e){let t=e,n;return vR(new ReadableStream({start:e=>{n=new CR(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){let t=e,n;return vR(new ReadableStream({start:e=>{n=new wR(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){let t=e,n;return vR(new ReadableStream({start:e=>{n=new TR(e,t),this.activateHandle(n)},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},DR=class{promise;constructor(e){this.promise=e}get(){return this.promise}},OR=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new ER(e.readable);let{promise:t,resolve:n}=mL();this.resolve=n,this.response=new DR(t)}async appendArgsTextDelta(e){let t=this.writable.getWriter();try{await t.write(e)}catch(e){console.warn(e)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){let e=this.writable.getWriter();try{await e.close()}catch(e){console.warn(e)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}result={get:async()=>(await this.response.get()).result}},kR=Symbol.for(`assistant-stream.tool-execution-id`),AR=(e,t,n,r,i)=>{try{let a=t?.(n,r,i);Promise.resolve(a).catch(t=>{console.error(`[assistant-stream] ${e} callback threw an error`,t)})}catch(t){console.error(`[assistant-stream] ${e} callback threw an error`,t)}},jR=e=>e.join(`,`),MR=(e,t)=>{let n={...e};return Object.defineProperty(n,kR,{value:t,enumerable:!0}),n},NR=class extends PL{constructor(e){let t=e,n=new Map,r=new Map,i=new Set,a=new Map,o=0;super(e=>{let s=new TransformStream({async transform(e,s){let c=a.get(jR(e.path));switch((e.type!==`part-finish`||e.meta.type!==`tool-call`)&&s.enqueue(c?MR(e,c):e),e.type){case`part-start`:{let n=o;if(o+=1,e.part.type===`tool-call`){let i=new OR,o=Symbol();a.set(String(n),o),r.set(o,i),t.streamCall({reader:i,toolCallId:e.part.toolCallId,toolName:e.part.toolName,executionId:o})}break}case`text-delta`:if(e.meta.type===`tool-call`){let t=a.get(jR(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);await n.appendArgsTextDelta(e.textDelta)}break;case`result`:{if(e.meta.type!==`tool-call`)break;let t=a.get(jR(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);n.setResponse(new pL({result:e.result,artifact:e.artifact,isError:e.isError,modelContent:e.modelContent,messages:e.messages})),i.add(t);break}case`tool-call-args-text-finish`:{if(e.meta.type!==`tool-call`)break;let{toolCallId:o,toolName:c}=e.meta,l=a.get(jR(e.path)),u=l?r.get(l):void 0;if(!u)throw Error(`No controller found for tool call`);if(await u.finishArgsText(),i.has(l))break;let d=!1,f=bR(()=>{let e;try{e=zL.default.parse(u.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=t.execute({toolCallId:o,toolName:c,args:e,executionId:l});return n!==void 0&&(d=!0,AR(`onExecutionStart`,t.onExecutionStart,o,c,l)),n},n=>{if(d&&AR(`onExecutionEnd`,t.onExecutionEnd,o,c,l),n===void 0)return;let r=new pL({artifact:n.artifact,result:n.result,isError:n.isError,messages:n.messages,modelContent:n.modelContent});u.setResponse(r),_L(s,MR({type:`result`,path:e.path,...r},l))},n=>{d&&AR(`onExecutionEnd`,t.onExecutionEnd,o,c,l);let r=new pL({result:String(n),isError:!0});u.setResponse(r),_L(s,MR({type:`result`,path:e.path,...r},l))});f&&n.set(l,f);break}case`part-finish`:{if(e.meta.type!==`tool-call`)break;let t=a.get(jR(e.path)),o=t?n.get(t):void 0,c=()=>{t&&(n.delete(t),r.delete(t),i.delete(t),a.delete(jR(e.path)))};o?o.then(()=>{c(),_L(s,e)}):(c(),s.enqueue(e))}}},async flush(){await Promise.all(n.values())}});return e.pipeThrough(new IL).pipeThrough(s)})}},PR=Symbol.for(`assistant-stream.tool-execution-id`),FR=Symbol(`assistant-stream.tool-aborted`),IR=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1,LR=e=>typeof e?.then==`function`,RR=async(e,t,n=!1)=>{let r,i=new Promise(e=>{r=()=>{n?queueMicrotask(()=>queueMicrotask(()=>e(FR))):e(FR)},t.aborted?r():t.addEventListener(`abort`,r,{once:!0})});try{return await Promise.race([e,i])}finally{t.removeEventListener(`abort`,r)}},zR=()=>new pL({result:`Tool execution was cancelled.`,isError:!0});function BR(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return zR();let a=e;if(IR(i.parameters)){let e=i.parameters[`~standard`].validate(n.args),r=LR(e)?await RR(e,t):e;if(r===FR)return zR();r.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(r.issues)}`)}))}if(t.aborted)return zR();let o=await RR((async()=>{let e={toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e,n.executionId),[PR]:n.executionId},o=await a(n.args,e),s=pL.toResponse(o);if(i.toModelOutput&&!s.isError&&s.modelContent===void 0)try{let e=await i.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:s.result});return new pL({result:s.result,artifact:s.artifact,isError:s.isError,messages:s.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return s})(),t,!0);return o===FR?zR():o})(i.execute):void 0}function VR(e,t,n,r,i){let a={toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e,r.executionId),[PR]:r.executionId};e?.[r.toolName]?.streamCall?.(n,a)}function HR(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t,o=r,s=n;return new NR({execute:e=>BR(i(),a(),e,s),streamCall:({reader:e,...t})=>VR(i(),a(),e,t,s),onExecutionStart:o?.onExecutionStart,onExecutionEnd:o?.onExecutionEnd})}function UR(e){let t=e.metadata;if(!t||typeof t!=`object`)return;let n=t.custom;if(!n||typeof n!=`object`)return;let r=n.interactables;return Array.isArray(r)?r:void 0}function WR(e){return`update_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}var GR=e=>{if(!oL(e))return;let t=e.id;return typeof t==`string`||typeof t==`number`?t:void 0};function KR(e,t,n){let r=Array.isArray(t.set)?[...t.set]:[...e];if(t.clear===!0&&(r=[]),Array.isArray(t.remove)&&t.remove.length>0){let e=new Set(t.remove);r=r.filter(t=>{let n=GR(t);return n===void 0?!e.has(t):!e.has(n)})}let i=t.update;if(Array.isArray(i)&&i.length>0){let e=new Map;for(let t of i){let n=GR(t);n!==void 0&&!Number.isNaN(n)&&!e.has(n)&&e.set(n,t)}r=r.map(t=>{let n=GR(t);if(n===void 0||!oL(t))return t;let r=e.get(n);return r?{...t,...r}:t})}if(Array.isArray(t.add)&&t.add.length>0){let e=n?t.add.map(e=>{if(!oL(e)||e.id!==void 0)return e;let t=n();return t===void 0?e:{...e,id:t}}):t.add;r=[...r,...e]}return r}function qR(e,t,n){if(!oL(e)||!oL(t))return t;let r=oL(n?.arrayBaseline)?n.arrayBaseline:e,i=Object.entries(e);for(let[e,a]of Object.entries(t)){let t=r[e];if(Array.isArray(t)&&oL(a)){let r=n?.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(e))?()=>n.idFactory?.(e):void 0;i.push([e,KR(t,a,r)])}else i.push([e,a])}return Object.fromEntries(i)}function JR(e,t){if(!oL(e)||!oL(t))return;for(let n of Object.keys(e))if(!Object.hasOwn(t,n))return;let n=[];for(let[r,i]of Object.entries(t))(!Object.hasOwn(e,r)||!uL(e[r],i))&&n.push([r,i]);let r=n.length;if(r!==0&&r!==Object.keys(t).length)return Object.fromEntries(n)}var YR=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`tool-call`?t:void 0},XR=(e,t)=>{if(!e.args||typeof e.args!=`object`)return!1;let n=oL(e.result)?e.result:void 0;if(n?.success===!1)return!1;if(typeof n?.id==`string`)return n.id===t;let r=e.args.id;return r===t||r===void 0},ZR=e=>{let t=oL(e)?e.addedItemIds:void 0;if(!oL(t))return;let n=new Map;for(let[e,r]of Object.entries(t)){if(!Array.isArray(r))continue;let t=r.filter(e=>typeof e==`string`);t.length>0&&n.set(e,t)}if(n.size!==0)return e=>n.get(e)?.shift()},QR=new WeakMap;function $R(e,t,n){let r=QR.get(e);r||(r=new Map,QR.set(e,r));let i=r.get(n);i||(i=new Map,r.set(n,i));let a=i.get(t);if(a)return a;let o=WR(n),s=[],c=()=>s[s.length-1];for(let r of e){if(r.role===`user`){let e=UR(r)?.find(e=>e.id===t);if(!e)continue;if(e.partial){let t=c();t&&s.push({state:qR(t.state,e.state),origin:`user-edit`})}else s.push({state:e.state,origin:`user-edit`});continue}if(r.role===`assistant`)for(let e of r.content??[]){let r=YR(e);if(r){if(r.toolCallId===t&&r.toolName===n)r.args&&typeof r.args==`object`&&s.push({state:r.args,origin:`create`,toolCallId:t});else if(r.toolName===o&&XR(r,t)){let e=c();if(e){let{id:t,...n}=r.args,i=ZR(r.result);s.push({state:i?qR(e.state,n,{idFactory:i}):qR(e.state,n),origin:`update`,toolCallId:r.toolCallId})}}}}}return i.set(t,s),s}function ez(e,t,n){let r=$R(e,t,n),i=r[r.length-1];return i?{state:i.state}:void 0}function tz(e,t){if(!e)return;let{interactables:n,...r}=e,i={...r};if(Array.isArray(n)){let e=[];for(let r of n){let n=ez(t,r.id,r.name);if(!n){e.push({id:r.id,name:r.name,state:r.state});continue}if(uL(r.state,n.state))continue;let i=JR(n.state,r.state);e.push(i?{id:r.id,name:r.name,state:i,partial:!0}:{id:r.id,name:r.name,state:r.state})}e.length&&(i.interactables=e)}return Object.keys(i).length?i:void 0}var nz=BM(null),rz=(e,t)=>Kj(nz,e,t),iz=()=>HM(nz),az={},oz=e=>{let t=YP(e??az);return e==null?null:t},sz=Symbol(`innerMessage`),cz=Symbol(`innerMessages`),lz=[],uz=(e,t)=>{sz in e||(e[sz]=t)},dz=e=>{let t=`messages`in e?e.messages:e,n=t[cz]||t[sz];return n?Array.isArray(n)?n:(t[cz]=[n],t[cz]):lz},fz=`__external_store_fallback_`,pz=kL(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7);function mz(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}var hz=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},gz=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>typeof e==`string`?mz(e)?.mimeType.startsWith(`image/`)||/^(https:\/\/|blob:)/i.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null):null;if(r!==`user`&&o?.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:return e.text?.trim()?e:null;case`reasoning`:return!e.text?.trim()&&!e.unstable_summary?.trim()?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId||`tool-${pz()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:HL(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=hz(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=hz(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>hz(e.type,e.data)??e)})),metadata:{custom:c?.custom??{},...c?.isOptimistic&&{isOptimistic:!0},...c?.modality&&{modality:c.modality}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},_z=e=>e.type===`tool-call`&&e.result===void 0,vz=e=>{if(e.type!==`tool-call`||e.result!==void 0)return!1;let t=e.messages?.at(-1);return t?.role===`assistant`&&t.status.type===`running`},yz=e=>e.type!==`tool-call`||e.result!==void 0?!1:e.interrupt!=null||e.approval!=null&&e.approval.approved===void 0&&e.approval.resolution===void 0,bz=Symbol(`autoStatus`),xz=Object.freeze(Object.assign({type:`running`},{[bz]:!0})),Sz=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[bz]:!0})),Cz=Object.freeze(Object.assign({type:`incomplete`,reason:`cancelled`},{[bz]:!0})),wz=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[bz]:!0})),Tz=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[bz]:!0})),Ez=e=>e[bz]===!0,Dz=(e,t,n,r,i,a,o)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[bz]:!0}):e&&t?xz:n?Tz:o&&!a?xz:r?wz:a?Cz:Sz,Oz=e=>Dz(!1,!1,typeof e!=`string`&&e.some(yz),typeof e!=`string`&&e.some(_z)),kz=(e,t,n)=>Dz(t,n,typeof e!=`string`&&e.some(yz),typeof e!=`string`&&e.some(_z),void 0,void 0,typeof e!=`string`&&e.some(vz)),Az=class{cache=new WeakMap;convertMessages(e,t){return e.map((e,n)=>{let r=t(this.cache.get(e),e,n);return this.cache.set(e,r),r})}},jz=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},Mz=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=UN({attachment:CF({source:`message`,query:{type:`index`,index:n},get:e=>e.message.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(ZI,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Nz=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=UN({attachment:CF({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(ZI,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Pz=e=>{let t=J(6),{runtime:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=UN({threadListItem:VI({runtime:n})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(ZI,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Fz=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=UN({message:CF({source:`thread`,query:{type:`index`,index:n},get:e=>e.thread.message({index:n})}),composer:CF({source:`message`,query:{},get:e=>e.thread.message({index:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(ZI,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Iz=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=UN({part:CF({source:`message`,query:{type:`index`,index:n},get:e=>e.message.part({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(ZI,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Lz=UM(e=>{let t=J(7),{text:n,isRunning:r}=e,i;t[0]===r?i=t[1]:(i=r?{type:`running`}:{type:`complete`},t[0]=r,t[1]=i);let a;t[2]!==i||t[3]!==n?(a={type:`text`,text:n,status:i},t[2]=i,t[3]=n,t[4]=a):a=t[4];let o=a,s;return t[5]===o?s=t[6]:(s={getState:()=>o,addToolResult:zz,resumeToolCall:Bz,respondToToolApproval:Vz},t[5]=o,t[6]=s),s}),Rz=e=>{let t=J(7),{text:n,isRunning:r,children:i}=e,a=r!==void 0&&r,o=Q(),s;t[0]!==a||t[1]!==n?(s=UN({part:Lz({text:n,isRunning:a})}),t[0]=a,t[1]=n,t[2]=s):s=t[2];let c=s,l;return t[3]!==o||t[4]!==i||t[5]!==c?(l=(0,P.jsx)(ZI,{extends:o,config:c,children:i}),t[3]=o,t[4]=i,t[5]=c,t[6]=l):l=t[6],l};function zz(){throw Error(`Not supported`)}function Bz(){throw Error(`Not supported`)}function Vz(){throw Error(`Not supported`)}var Hz=e=>{for(let t of e)if(t?.status.type===`running`)return wI;return e.at(-1)?.status??CI},Uz=(e,t)=>{let n={running:0,complete:0,incomplete:0,requiresAction:0},r=CI,i=!1;for(let a of t)switch(r=e[a]?.status??CI,r.type){case`running`:n.running++,i=!0;break;case`complete`:n.complete++;break;case`incomplete`:n.incomplete++;break;case`requires-action`:n.requiresAction++}return{status:i?wI:r,counts:n}},Wz=UM(e=>{let t=J(11),{parts:n,getMessagePart:r}=e,[i,a]=wM(!0),o;t[0]===n?o=t[1]:(o=Hz(n),t[0]=n,t[1]=o);let s=o,c;t[2]!==i||t[3]!==n||t[4]!==s?(c={parts:n,collapsed:i,status:s},t[2]=i,t[3]=n,t[4]=s,t[5]=c):c=t[5];let l=c,u;t[6]===l?u=t[7]:(u=()=>l,t[6]=l,t[7]=u);let d;return t[8]!==r||t[9]!==u?(d={getState:u,setCollapsed:a,part:r},t[8]=r,t[9]=u,t[10]=d):d=t[10],d}),Gz=e=>{let t=J(4),{startIndex:n,endIndex:r,children:i}=e,a=$(Kz).slice(n,r+1),o=Q(),s=UN({chainOfThought:Wz({parts:a,getMessagePart:e=>{let{index:t}=e;if(t<0||t>=a.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${a.length-1})`);return o.message.part({index:n+t})}})}),c;return t[0]!==i||t[1]!==s||t[2]!==o?(c=(0,P.jsx)(ZI,{extends:o,config:s,children:i}),t[0]=i,t[1]=s,t[2]=o,t[3]=c):c=t[3],c};function Kz(e){return e.message.parts}var qz=e=>{let t=J(7),{index:n,archived:r,children:i}=e,a=Q(),o;t[0]!==r||t[1]!==n?(o=UN({threadListItem:CF({source:`threads`,query:{type:`index`,index:n,archived:r},get:e=>e.threads.item({index:n,archived:r})})}),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s=o,c;return t[3]!==a||t[4]!==i||t[5]!==s?(c=(0,P.jsx)(ZI,{extends:a,config:s,children:i}),t[3]=a,t[4]=i,t[5]=s,t[6]=c):c=t[6],c},Jz=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=UN({suggestion:CF({source:`suggestions`,query:{index:n},get:e=>e.suggestions.suggestion({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(ZI,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Yz=e=>{let t=J(6),{index:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=UN({queueItem:CF({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.queueItem({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(ZI,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Xz=Symbol.for(`assistant-ui.message-not-sent`),Zz=e=>typeof e==`object`&&!!e&&Xz in e,Qz=class{get path(){return this._core.path}_core;constructor(e){this._core=e,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},$z=class extends Qz{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},eB=class extends $z{get source(){return`thread-composer`}},tB=class extends $z{get source(){return`edit-composer`}},nB=class extends Qz{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},rB=Object.freeze([]),iB=Object.freeze({}),aB=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??rB,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??iB,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??rB,value:e?.text??``}),oB=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??rB,runConfig:e?.runConfig??iB,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??rB,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),sB=class{get path(){return this._core.path}_core;constructor(e){this._core=e}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.moveQueueItem=this.moveQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}steerQueueItem(e){this.moveQueueItem(e,{lane:`steer`,insertAfter:null})}moveQueueItem(e,t){let n=this._core.getState();if(!n)throw Error(`Composer is not available`);n.moveQueueItem(e,t)}removeQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.removeQueueItem(e)}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new HF({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},cB=class extends sB{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new BF({path:e.path,getState:()=>aB(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new eB(new zF({path:{...this.path,attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`thread-composer`}:MF},subscribe:e=>this._core.subscribe(e)}),this._core)}},lB=class extends sB{get path(){return this._core.path}get type(){return`edit`}_getState;_beginEdit;constructor(e,t){let n=new BF({path:e.path,getState:()=>oB(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new tB(new zF({path:{...this.path,attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`edit-composer`}:MF},subscribe:e=>this._core.subscribe(e)}),this._core)}},uB=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
91
|
+
|
|
92
|
+
`),dB=`ui://`,fB=e=>!!e?.startsWith(dB),pB=e=>e.display===`text`||e.allowFreeform===!0,mB={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},hB=(e,t)=>{let n=t.text;if(n!==void 0&&!pB(e))throw Error(`Tool approval "${e.id}" does not accept a free-form answer; the request must declare display "text" or allowFreeform`);let r,i;if(`optionId`in t){let n=e.options?.find(e=>e.id===t.optionId);if(!n)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)r=t.approved;else{if(!Object.hasOwn(mB,n.kind))throw Error(`Tool approval option "${n.id}" has a custom kind "${n.kind}"; respond with an explicit approved value instead`);r=mB[n.kind]}i=n.id}else if(`approved`in t)r=t.approved;else{if(e.display!==`text`&&e.display!==`select`)throw Error(`Tool approval "${e.id}" is a decision, not a question; respond with an explicit approved value, optionally alongside the answer`);r=!0}return{approvalId:e.id,approved:r,...i!==void 0&&{optionId:i},...n!==void 0&&{text:n},...t.reason!=null&&{reason:t.reason}}},gB=class{get path(){return this.contentBinding.path}contentBinding;messageApi;threadApi;constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=pL.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,isError:a.isError,...a.artifact!==void 0&&{artifact:a.artifact},...a.modelContent!==void 0&&{modelContent:a.modelContent}})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0||t.approval.resolution!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);return this.threadApi.getState().respondToToolApproval(hB(t.approval,e))}subscribe(e){return this.contentBinding.subscribe(e)}},_B=(e,t)=>{let n=e.content[t];if(!n)return MF;let r=DI(e,t,n);return Object.freeze({...n,[sz]:n[sz],status:r})},vB=class{get path(){return this._core.path}_core;_threadBinding;constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new lB(new VF({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`edit`},getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}delete(){let e=this._core.getState();return this._threadBinding.getState().deleteMessage(e.id)}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i})}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e,comment:t}){let n=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:n.id,type:e,...t===void 0?void 0:{comment:t}})}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return uB(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new gB(new zF({path:{...this.path,ref:`${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>_B(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new gB(new zF({path:{...this.path,ref:`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}},getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?MF:_B(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new nB(new zF({path:{...this.path,ref:`${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:MF},subscribe:e=>this._core.subscribe(e)}))}},yB=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),bB=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),xB=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId===void 0?e.at(-1)?.id??null:t.parentId,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},SB=e=>{if(e.isRunning!==void 0)return e.isRunning;let t=e.messages.at(-1);return t?.role===`assistant`&&t.status.type===`running`},CB=(e,t)=>Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:SB(e),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice}),wB=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;_stateBinding;constructor(e,t){let n=new zF({path:e.path,getState:()=>CB(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>PF([r,i])}});this._stateBinding=n,this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new cB(new VF({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`thread`},getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.unstable_notifySessionReset=this.unstable_notifySessionReset.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(e){let t=this._threadBinding.getState().append(xB(this._threadBinding.getState().messages,e));Promise.resolve(t).catch(e=>{if(!Zz(e))throw e})}deleteMessage(e){return this._threadBinding.getState().deleteMessage(e)}subscribe(e){return this._stateBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(bB(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(yB(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}unstable_notifySessionReset(){this._threadBinding.getState().unstable_notifySessionReset()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw Error(`Message index must be >= 0`);return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:`messageId`,messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new vB(new zF({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return MF;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[sz]:e[sz],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new HF({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},TB=(e,t)=>({attachments:[],attachmentAccept:`*`,async addAttachment(){throw e},async removeAttachment(){throw e},isEditing:t,canCancel:!1,canSend:!1,isEmpty:!0,text:``,setText(){throw e},role:`user`,setRole(){throw e},runConfig:{},setRunConfig(){throw e},async reset(){},async clearAttachments(){},send(){throw e},cancel(){},queue:[],moveQueueItem(){},removeQueueItem(){},dictation:void 0,startDictation(){throw e},stopDictation(){},quote:void 0,setQuote(){throw e},subscribe(){return()=>{}},unstable_on(){return()=>{}}}),EB=class extends IF{switchToBranch(){throw this.error}append(){throw this.error}deleteMessage(){throw this.error}startRun(){throw this.error}resumeRun(){throw this.error}cancelRun(){throw this.error}unstable_notifySessionReset(){throw this.error}addToolResult(){throw this.error}resumeToolCall(){throw this.error}respondToToolApproval(){throw this.error}speak(){throw this.error}stopSpeaking(){throw this.error}connectVoice(){throw this.error}disconnectVoice(){throw this.error}muteVoice(){throw this.error}unmuteVoice(){throw this.error}submitFeedback(){throw this.error}exportExternalState(){throw this.error}importExternalState(){throw this.error}beginEdit(){throw this.error}import(){throw this.error}reset(){throw this.error}getModelContext(){return{}}getEditComposer(){}getVoiceVolume=()=>0;subscribeVoiceVolume=()=>()=>{};speech=void 0;voice=void 0;capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};isDisabled=!1;isSendDisabled=!1;state=null;suggestions=[];extras=void 0;unstable_on(){return()=>{}}},DB=e=>{let t=J(6),{adapters:n,children:r}=e,i=HM(nz),a;t[0]!==n||t[1]!==i?(a={...i,...n},t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a,s;return t[3]!==r||t[4]!==o?(s=(0,P.jsx)(nz.Provider,{value:o,children:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s},OB=class{get path(){return this._core.path}_core;_threadListBinding;constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(e){let t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){let t=this._core.getState();if(!this._threadListBinding.updateCustom)throw Error(`Thread list runtime does not support updating custom metadata`);return this._threadListBinding.updateCustom(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(e){let t=this._core.getState();return this._threadListBinding.generateTitle(t.id,e)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;(n!==a||r!==o)&&(n=a,r=o,(e!==`switchedTo`||a)&&(e===`switchedAway`&&a||HN([t],{},`Thread list item "${e}"`)))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},kB=Promise.resolve(),AB=()=>{},jB=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,loadError:e.loadError,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),MB=(e,t)=>{if(t===void 0)return MF;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,lastMessageAt:n.lastMessageAt,custom:n.custom,isMain:n.id===e.mainThreadId,isRunning:e.unstable_isThreadRunning?.(n.id)??!1}:MF},NB=class{_getState;_stateBinding;_core;_runtimeFactory;constructor(e,t=wB){this._core=e,this._runtimeFactory=t;let n=new BF({path:{},getState:()=>jB(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new OB(new zF({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>MB(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new VF({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.unstable_subscribeThreadEvents=this.unstable_subscribeThreadEvents.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.reloadMainThread=this.reloadMainThread.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}unstable_subscribeThreadEvents(e){return this._core.unstable_subscribeThreadEvents?.(e)??AB}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??kB}reloadMainThread(){return this._core.reloadMainThread?.()??kB}loadMore(){return this._core.loadMore?.()??kB}getState(){return this._getState()}subscribe(e){return this._stateBinding.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}_createItemStateBinding(e){return new zF({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>MB(this._core,e),subscribe:e=>this._core.subscribe(e)})}getById(e){return new this._runtimeFactory(new VF({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this._createItemStateBinding(e))}getItemByIndex(e){return new OB(new zF({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>MB(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new OB(new zF({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>MB(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new OB(this._createItemStateBinding(e),this._core)}},PB=class{threads;_thread;_core;constructor(e){this._core=e,this.threads=new NB(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},FB=new WeakMap,IB=e=>FB.get(e)??0,LB=(e,t)=>IB(e)===t,RB=e=>{FB.set(e,IB(e)+1)},zB=class{_contextProvider=new UF;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},BB=Object.freeze([]),VB=`DEFAULT_THREAD_ID`,HB=Object.freeze([VB]),UB=Object.freeze({id:VB,remoteId:void 0,externalId:void 0,status:`regular`}),WB=Promise.resolve(),GB=Object.freeze(Ej({[VB]:UB})),KB=class extends IF{_mainThreadId=VB;_threads=HB;_archivedThreads=BB;_threadData=GB;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return WB}_mainThread;get mainThreadId(){return this._mainThreadId}threadFactory;constructor(e={},t){super(),this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return Object.hasOwn(this._threadData,e)?this._threadData[e]:void 0}__internal_setAdapter(e,t=!1){let n=this.adapter;this.adapter=e;let r=e.threadId??VB,i=e.threads??BB,a=e.archivedThreads??BB,o=n.threadId??VB,s=n.threads??BB,c=n.archivedThreads??BB;(t||(n.isLoading??!1)!==(e.isLoading??!1)||o!==r||s!==i||c!==a)&&((s!==i||c!==a||o!==r)&&(this._threadData=Ej(GB,Object.fromEntries(e.threads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`regular`}])??[]),Object.fromEntries(e.archivedThreads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`archived`}])??[]))),s!==i&&(this._threads=this.adapter.threads?.map(e=>e.id)??BB),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??BB),(t||o!==r)&&(t||RB(this._mainThread),this._mainThreadId=r,this._mainThread=this.threadFactory()),Object.hasOwn(this._threadData,this._mainThreadId)||(this._threadData=Ej(this._threadData,{[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}})),this._notifySubscribers())}async reloadMainThread(){this._mainThread.unstable_refetchThread&&await this._mainThread.unstable_refetchThread()}async switchToThread(e,t){if(this._mainThreadId===e)return;let n=this.adapter.onSwitchToThread;if(!n)throw Error(`External store adapter does not support switching to thread`);await n(e)}async switchToNewThread(){let e=this.adapter.onSwitchToNewThread;if(!e)throw Error(`External store adapter does not support switching to new thread`);await e()}async rename(e,t){let n=this.adapter.onRename;if(!n)throw Error(`External store adapter does not support renaming`);await n(e,t)}async updateCustom(e,t){let n=this.adapter.onUpdateCustom;if(!n)throw Error(`External store adapter does not support updating custom metadata`);await n(e,t)}async detach(){}async archive(e){let t=this.adapter.onArchive;if(!t)throw Error(`External store adapter does not support archiving`);await t(e)}async unarchive(e){let t=this.adapter.onUnarchive;if(!t)throw Error(`External store adapter does not support unarchiving`);await t(e)}async delete(e){let t=this.adapter.onDelete;if(!t)throw Error(`External store adapter does not support deleting`);await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}},qB={fromArray:e=>{let t=e.map(e=>gz(e,pz(),Oz(e.content)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>({...t?.headId===void 0?void 0:{headId:t.headId},messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:gz(e,e.id,Oz(e.content))}})})},JB=e=>{let t=e;for(;t.next;)t=t.next;return`current`in t?t:null},YB=class{_value=null;func;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},XB=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){let n=[{message:e,level:t}];for(;n.length>0;){let e=n.pop();e.message.level=e.level;for(let t of e.message.children){let r=this.messages.get(t);r&&n.push({message:r,level:e.level+1})}}}selectPathTo(e){for(let t=e;t;t=t.prev)(t.prev??this.root).next=t}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(n!==`relink`||r!==i){if(n===`relink`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/relink): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.`)}if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);r.next=t}if(n!==`cut`){i.children=[...i.children,t.current.id],t.prev=e,JB(t)===this.head?this.selectPathTo(t):i.next===null&&(i.next=t,this.head===i&&(this.head=JB(t)));let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new YB(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}get canonicalHeadId(){let e=this.head;for(;e?.current.metadata?.isOptimistic;)e=e.prev;return e?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){n.current=t,this.performOp(r,n,`relink`),this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=JB(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;let n=new Set;for(let e=t;e;e=e.prev)n.add(e.current.id);let r=[];for(let t=e;t&&!n.has(t.current.id);t=t.prev)t.current.metadata?.isOptimistic&&r.push(t.current.id);for(let e of r)this.messages.has(e)&&this.deleteMessage(e)}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;this.selectPathTo(t),this.head=JB(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=[...t.children];for(;e.length>0;){let t=e.pop(),n=this.messages.get(t);if(n){for(let t of n.children)e.push(t);this.messages.delete(t)}}t.children=[],t.next=null}this.head=t,this.selectPathTo(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[],t=[...this.root.children].reverse();for(;t.length>0;){let n=this.messages.get(t.pop());if(!n)continue;for(let e=n.children.length-1;e>=0;e--)t.push(n.children[e]);if(n.current.metadata?.isOptimistic)continue;let r=n.prev;for(;r&&r.current.metadata?.isOptimistic;)r=r.prev;e.push({message:n.current,parentId:r?.current.id??null})}return{headId:this.canonicalHeadId,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}},ZB=Object.freeze([]);function*QB(e){for(let t of e)if(t?.role===`assistant`&&Array.isArray(t.content))for(let e of t.content)e&&e.type===`tool-call`&&(yield{part:e,messageId:t.id},e.messages?.length&&(yield*QB(e.messages)))}function $B(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=e.name.toLowerCase(),i=e.type.split(`;`,1)[0].trim().toLowerCase();for(let e of n){if(e.startsWith(`.`)&&r.endsWith(e)||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function eV(e){let t=pz();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function tV(e){let t=[];for(let n of e)n.type!==`text`&&t.push(eV(n));return t}var nV=e=>`content`in e&&!(`lastModified`in e),rV=e=>e.status.type===`complete`,iV=class{operations=new Set;start(){let e={cancelled:!1,attachmentIds:new Set};return this.operations.add(e),e}accept(e,t){return!e.cancelled&&(e.attachmentIds.add(t),!0)}finish(e){this.operations.delete(e)}isCancelled(e){return e.cancelled}cancel(e){for(let t of[...this.operations])t.attachmentIds.has(e)&&(t.cancelled=!0,this.operations.delete(t))}cancelAll(){for(let e of this.operations)e.cancelled=!0;this.operations.clear()}},aV=async(e,t)=>{if(Symbol.asyncIterator in e){for await(let n of e)if(!t(n))break}else t(await e)},oV=class extends IF{isEditing=!0;enrichWithComposerMetadata(e,t){return t?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...t}}}:e}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){this._text!==e&&(this._text=e,this._rebaseDictation(e),this._notifySubscribers())}_rebaseDictation(e){if(!this._dictation)return;this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_isSending=!1;_removedDuringSend=new Set;_sendGeneration=0;_attachmentAddOperations=new iV;_cancelAttachmentAdd(e){this._attachmentAddOperations.cancel(e)}_cancelAllAttachmentAdds(){this._attachmentAddOperations.cancelAll()}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._rebaseDictation(``),this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!rV(e));await Promise.all(t.map(async t=>e.remove(t)))}}async reset(){if(this._cancelAllAttachmentAdds(),this._sendGeneration++,this._isSending=!1,this._removedDuringSend.clear(),this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){if(this._cancelAllAttachmentAdds(),this._isSending)for(let e of this._attachments)this._removedDuringSend.add(e.id);let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend||this._isSending)return;if(this._dictationSession)try{this._dictationSession.cancel()}catch(e){console.error(`[assistant-ui] Dictation session cancel threw`,e)}finally{this._cleanupDictation()}let t=this.getAttachmentAdapter(),n=this.attachments.map(async e=>{if(rV(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)}),r=this.attachments,i=this.text,a=this._quote,o=this.role,s=this.runConfig;this._quote=void 0,this._text=``,this._isSending=!0;let c=++this._sendGeneration;this._notifySubscribers();let l;try{l=await Promise.all(n)}catch(e){throw c===this._sendGeneration&&(!this.text.trim()&&this._quote===void 0&&(this._text=i,this._rebaseDictation(i),this._quote=a,this._notifySubscribers()),Promise.allSettled(n).then(()=>{c===this._sendGeneration&&(this._removedDuringSend.clear(),this._isSending=!1,this._notifySubscribers())})),e}if(c!==this._sendGeneration)return;let u=new Set(r.map(e=>e.id));this._attachments=this._attachments.filter(e=>!u.has(e.id)),this._isSending=!1,this._notifySubscribers();let d=l.filter(e=>!this._removedDuringSend.has(e.id));this._removedDuringSend.clear();let f={createdAt:new Date,role:o,content:i?[{type:`text`,text:i}]:[],attachments:d,runConfig:s,metadata:{custom:{...a?{quote:a}:{}}}},p={text:i,quote:a,attachments:d},m;try{m=this.handleSend(f,e)}catch(e){throw this._restoreUnsentDraft(e,c,p),e}m&&m.catch(e=>{this._restoreUnsentDraft(e,c,p)}),this._notifyEventSubscribers(`send`,{chars:i.length,attachments:d.length})}restoreDraft(e){return this._text.trim()||this._quote!==void 0||this._attachments.length>0?!1:(this._text=e.text,this._rebaseDictation(e.text),this._quote=e.quote,this._attachments=e.attachments??[],this._notifySubscribers(),!0)}retractDraft(e){let t=e.attachments===void 0?this._attachments.length===0:this._attachments===e.attachments;this._text===e.text&&this._quote===e.quote&&t&&(this._text=``,this._rebaseDictation(``),this._quote=void 0,this._attachments=[],this._notifySubscribers())}_restoreUnsentDraft(e,t,n){Zz(e)&&t===this._sendGeneration&&this.restoreDraft(n)}cancel(){this.handleCancel()}get queue(){return ZB}moveQueueItem(e,t){}removeQueueItem(e){}async addAttachment(e){if(nV(e)){let t=this.getAttachmentAdapter();if(t&&!$B({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.contentType),r}let n={id:e.id??pz(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{...n.contentType?{contentType:n.contentType}:void 0});return}let t=this.getAttachmentAdapter();if(!t){let t=`Attachments are not supported`,n=Error(t);throw this._safeEmitAttachmentAddError(`no-adapter`,t,void 0,n,e.type),n}if(!$B({name:e.name,type:e.type},t.accept)){let n=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r,e.type),r}let n=this._attachmentAddOperations.start(),r=e=>{if(!this._attachmentAddOperations.accept(n,e.id))return!1;let t=this._attachments.findIndex(t=>t.id===e.id);return this._attachments=t===-1?[...this._attachments,e]:[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers(),!0},i;try{await aV(t.add({file:e}),e=>(i=e,r(e)))}catch(t){if(this._attachmentAddOperations.isCancelled(n))return;throw i&&r({...i,status:{type:`incomplete`,reason:`error`,message:t instanceof Error?t.message:String(t)}}),this._safeEmitAttachmentAddError(`adapter-error`,t instanceof Error?t.message:String(t),i?.id,t instanceof Error?t:void 0,i?.contentType||e.type),t}finally{this._attachmentAddOperations.finish(n)}this._attachmentAddOperations.isCancelled(n)||(i?.status.type===`incomplete`&&i.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,i.status.message??`Attachment upload did not complete successfully.`,i.id,void 0,i.contentType||e.type):this._notifyEventSubscribers(`attachmentAdd`,{...i?.contentType?{contentType:i.contentType}:e.type?{contentType:e.type}:void 0}))}_safeEmitAttachmentAddError(e,t,n,r,i){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r},...i?{contentType:i}:void 0})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(this._cancelAttachmentAdd(e),this._isSending&&this._removedDuringSend.add(e),!rV(n)){let t=this.getAttachmentAdapter();if(!t)throw Error(`Attachments are not supported`);try{await t.remove(n)}catch(t){let n=t instanceof Error?t.message:String(t);throw this._attachments=this._attachments.map(t=>t.id===e&&!rV(t)?{...t,status:{type:`incomplete`,reason:`error`,message:n}}:t),this._notifySubscribers(),t}}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);let t=this._dictationSession!==void 0;if(this._dictationSession){let e=this._dictationSession;this._cleanupDictation({notify:!1}),this._stopDictationSession(e)}let n=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let r;try{r=e.listen()}catch(e){if(t)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Dictation replacement rollback notification threw`,e)}throw e}this._dictationSession=r;let i=++this._dictationSessionIdCounter;this._activeDictationSessionId=i,this._dictation={status:r.status,inputDisabled:n},this._notifySubscribers();let a=r.onSpeech(e=>{if(!this._isActiveSession(i,r))return;let t=e.isFinal!==!1,n=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+n+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=n+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(a);let o=r.onSpeechStart(()=>{this._isActiveSession(i,r)&&(this._dictation={status:{type:`running`},inputDisabled:n,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(o);let s=r.onSpeechEnd(()=>{this._cleanupDictation({sessionId:i})});this._dictationUnsubscribes.push(s);let c=setInterval(()=>{this._isActiveSession(i,r)&&r.status.type===`ended`&&this._cleanupDictation({sessionId:i})},100);this._dictationUnsubscribes.push(()=>clearInterval(c))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId;this._stopDictationSession(e,()=>this._cleanupDictation({sessionId:t}))}_stopDictationSession(e,t=()=>{}){let n;try{n=e.stop()}catch(e){console.error(`[assistant-ui] Dictation session stop threw`,e),t();return}n.then(t,e=>{console.error(`[assistant-ui] Dictation session stop rejected`,e),t()})}_cleanupDictation(e){if(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)return;this._isCleaningDictation=!0;let t=e=>{try{e()}catch(e){console.error(`[assistant-ui] Dictation cleanup threw`,e)}};try{let n=this._dictationUnsubscribes;this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``;for(let e of n)t(e);e?.notify!==!1&&t(()=>this._notifySubscribers())}finally{this._isCleaningDictation=!1}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&HN(n,t,`Composer runtime "${e}"`)}unstable_on(e,t){let n=t,r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),()=>{this._eventSubscribers.get(e)?.delete(n)}}},sV=e=>e.capabilities?.cancel?SB(e):!1,cV=class extends oV{get canCancel(){return sV(this.runtime)}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled&&!this.runtime.voice&&!this._isSending}_queueCache;get queue(){let e=this.runtime.getSteerQueueItems?.()??ZB,t=this.runtime.getQueueItems?.()??ZB,n=this._queueCache;if(n&&n.steer===e&&n.queue===t)return n.flat;let r=e.length===0?t:t.length===0?e:[...e,...t];return this._queueCache={steer:e,queue:t,flat:r},r}moveQueueItem(e,t){this.runtime.moveQueueItem?.(e,t)}removeQueueItem(e){this.runtime.removeQueueItem?.(e)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}runtime;constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=!1,t=this.runtime.isSendDisabled,n=this.runtime.voice!==void 0,r=this.queue;return this.runtime.subscribe(()=>{let i=!1,a=this.canCancel;e!==a&&(e=a,i=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,i=!0);let o=this.runtime.voice!==void 0;n!==o&&(n=o,i=!0),r!==this.queue&&(r=this.queue,i=!0),i&&this._notifySubscribers()})}async handleSend(e,t){return this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun,steer:t?.steer})}async handleCancel(){this.runtime.cancelRun()}},lV=class extends oV{get canCancel(){return!0}get canSend(){return!this.isEmpty&&!this.runtime.voice&&!this._isSending}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_nonTextPassthrough;_parentId;_sourceId;runtime;endEditCallback;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e;let i=e.voice!==void 0,a=e.subscribe(()=>{let t=e.voice!==void 0;t!==i&&(i=t,this._notifySubscribers())});this.endEditCallback=()=>{a(),t()},this._parentId=n,this._sourceId=r.id,this.setText(uB(r)),this.setRole(r.role);let o;r.role===`user`?(o=[...r.attachments??[],...tV(r.content)],this._nonTextPassthrough=[]):(o=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(o),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content,r=this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun});return this.handleCancel(),r}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},uV=class extends IF{_isInitialized=!1;repository=new XB;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}_commitVoiceMessage(e){}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();if(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e){let t=new Set(e.map(e=>e.id));this._cachedMergedMessages=[...e,...this._voiceMessages.filter(e=>!t.has(e.id))],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e}return this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new cV(this);_contextProvider;constructor(e){super(),this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}enrichAppendMetadata(e,t=e.parentId){if(e.role!==`user`)return e;let n=this.messages,r=t===null?-1:n.findIndex(e=>e.id===t),i=tz(this.getModelContext().unstable_composerMetadata,n.slice(0,r+1));return i?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...i}}}:e}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}_isVoiceMessage(e){return e!==null&&this._voiceMessages.some(t=>t.id===e)}_resolveAppendParent(e){return this._isVoiceMessage(e)?this._getBaseMessages().at(-1)?.id??null:e}beginEdit(e){if(this.voice)throw Error(`Cannot edit a message while a voice session is connected`);if(this._isVoiceMessage(e))throw Error(`Voice transcript messages cannot be edited`);if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new lV(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&HN(n,t,`Thread runtime "${e}"`)}_notifyToolApprovalAnswered(e,t,n,r){this._notifyEventSubscribers(`toolApprovalAnswered`,{messageId:e,toolCallId:t,toolName:n,approved:r})}submitFeedback({messageId:e,type:t,comment:n}){let r=this.adapters?.feedback,i=this.getMessageById(e);if(!i)throw Error(`Message not found: ${e}`);let{message:a,parentId:o}=i,s=n?.trim(),c={type:t,...s?{comment:s}:void 0};if(r?.submit({message:a,...c}),a.role===`assistant`){let t={...a,metadata:{...a.metadata,submittedFeedback:c}},n=this._voiceMessages.findIndex(t=>t.id===e);n===-1?this.repository.addOrUpdateMessage(o,t):(this._voiceMessages[n]=t,this._currentAssistantMsg===a&&(this._currentAssistantMsg=t),this._markVoiceMessagesDirty())}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let n=this.getMessageById(e);if(!n)throw Error(`Message not found: ${e}`);let{message:r}=n,i=this._stopSpeaking,a;try{i?.(),a=t.speak(uB(r))}catch(e){if(i&&!this._stopSpeaking)try{this._notifySubscribers()}catch(e){console.error(`[assistant-ui] Speech rollback notification threw`,e)}throw e}let o,s=()=>{this._stopSpeaking=void 0,this.speech=void 0;let e=o;o=void 0,e?.()},c=()=>{if(this._stopSpeaking===c)try{s()}finally{a.cancel()}},l=()=>{this._stopSpeaking===c&&(a.status.type===`ended`?NF([s,()=>this._notifySubscribers()]):(this.speech={messageId:e,status:a.status},this._notifySubscribers()))};this._stopSpeaking=c;try{if(o=a.subscribe(l),this._stopSpeaking!==c){o();return}l()}catch(e){if(this._stopSpeaking===c)try{NF([c,()=>this._notifySubscribers()])}catch(e){console.error(`[assistant-ui] Speech rollback cleanup threw`,e)}throw e}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);NF([this._stopSpeaking,()=>this._notifySubscribers()])}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));_onVoiceConnected(){}_onVoiceDisconnected(){}_isRunActive(){if(this.isRunning)return!0;let e=this._getBaseMessages().at(-1);return e?.role===`assistant`&&(e.status.type===`running`||e.status.type===`requires-action`)}connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);if(this._isRunActive())throw Error(`Cannot start a voice session while a run is in progress or paused on a pending tool action`);let t=this._voiceSession!==void 0;try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice cleanup threw before reconnect`,e)}let n;try{n=e.connect({})}catch(e){throw t&&this._voiceSession===void 0&&this._onVoiceDisconnected(),e}this._voiceSession=n;let r=[];this._voiceUnsubs=r;let i=()=>{if(this._voiceSession===n&&this._voiceUnsubs===r)return!1;try{NF(r.splice(0))}catch(e){console.error(`[assistant-ui] Detached voice setup cleanup threw`,e)}return!0};try{let e=`listening`;if(this.voice={status:n.status,isMuted:n.isMuted,mode:e},this._voiceVolume=0,this._notifySubscribers(),i()||(r.push(n.onStatusChange(t=>{this._voiceSession===n&&(t.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0,this._onVoiceDisconnected()):this.voice={status:t,isMuted:n.isMuted,mode:e},this._notifySubscribers())})),i())||(r.push(n.onModeChange(t=>{e=t,this.voice&&(this.voice={...this.voice,mode:t},this._notifySubscribers())})),i())||(r.push(n.onVolumeChange(e=>{this._voiceVolume=e,HN(this._voiceVolumeSubscribers,void 0,`Voice volume`)})),i()))return;r.push(n.onTranscript(e=>{this._handleVoiceTranscript(e)})),i()||this._onVoiceConnected()}catch(e){if(this._voiceSession===n&&this._voiceUnsubs===r){try{this._disconnectVoice(!1)}catch(e){console.error(`[assistant-ui] Voice rollback cleanup threw`,e)}t&&this._voiceSession===void 0&&this._onVoiceDisconnected()}else i();throw e}}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`){if(this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal){let t={id:pz(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{modality:`voice`,custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]};this._voiceMessages.push(t),this._commitVoiceMessage(t),this._markVoiceMessagesDirty(),this._notifySubscribers()}}else{let t=e.isFinal?{type:`complete`,reason:`stop`}:{type:`running`};if(!this._currentAssistantMsg)this._currentAssistantMsg={id:pz(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],modality:`voice`,custom:{}},status:t,createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let n=this._voiceMessages.indexOf(this._currentAssistantMsg);if(n===-1)return;let r={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],status:t};this._voiceMessages[n]=r,this._currentAssistantMsg=r}e.isFinal&&(this._commitVoiceMessage(this._currentAssistantMsg),this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(e=!0){let t=this._voiceMessages.at(-1);if(t?.role===`assistant`&&t.status.type===`running`){let n=this._voiceMessages.length-1;this._voiceMessages[n]={...t,status:{type:`complete`,reason:`stop`}},this._commitVoiceMessage(this._voiceMessages[n]),this._currentAssistantMsg=null,this._markVoiceMessagesDirty(),e&&this._notifySubscribers()}}disconnectVoice(){this._disconnectVoice(!0)}_disconnectVoice(e){this._finishVoiceAssistantMessage(!1),this._currentAssistantMsg=null;let t=this._voiceUnsubs.splice(0);this._voiceUnsubs=[];let n=this._voiceSession;this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;let r=this.speech&&this._isVoiceMessage(this.speech.messageId)?this._stopSpeaking:void 0;this._voiceMessages=[],this._markVoiceMessagesDirty();try{NF([...t,...r?[r]:[],...n?[()=>n.disconnect()]:[],()=>HN(this._voiceVolumeSubscribers,void 0,`Voice volume`),()=>this._notifySubscribers()])}finally{e&&n&&this._voiceSession===void 0&&this._onVoiceDisconnected()}}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(qB.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>HN([n],{},`Thread runtime "${e}"`))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&HN([n],{},`Thread runtime "${e}"`)}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},dV=Symbol.for(`assistant-stream.tool-execution-id`),fV=e=>{try{return JSON.parse(e),!0}catch{return!1}},pV=e=>{try{return JSON.parse(e)}catch{return}},mV=(e,t)=>{let n=pV(e),r=pV(t);return n===void 0||r===void 0?!1:uL(n,r)},hV=e=>e[dV],gV=class{_getTools;_callbacks;_isClientToolCall;_entries=new Map;_humanInput=new Map;_executing=new Set;_discardedToolCallIds=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t,n){this._getTools=e,this._callbacks=t,this._isClientToolCall=n,this._initPipeline()}_initPipeline(){let[e,t]=NL();this._controller=t;let n=HR(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t,n)=>this._onHumanInput(e,t,n),{onExecutionStart:(e,t,n)=>this._onExecutionStart(e,n),onExecutionEnd:(e,t,n)=>this._onExecutionEnd(e,n)});e.pipeThrough(n).pipeThrough(new IL).pipeTo(new WritableStream({write:e=>{try{if(e.type!==`result`)return;this._handleResultChunk(e)}catch(e){console.error(`[ToolInvocationTracker] result chunk handling failed`,e)}}})).catch(e=>{console.error(`[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState`,e),this._pipelineDead=!0})}setState(e){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);let t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(e){throw this._isRunning=t,e}this._lastSnapshot=e,this._pendingRestore=!1}catch(e){console.error(`[ToolInvocationTracker] setState failed; snapshot dropped`,e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._discardedToolCallIds.clear(),this._lastSnapshot=null,this.abort(),this._statuses.size>0&&(this._statuses=new Map,this._invokeOnStatusesChange())}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(e){try{if(this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),e?.discardPending)for(let[e,t]of this._entries)t.controller&&(t.argsComplete||t.hasResult||(this._discardedToolCallIds.add(e),t.skipExecute=!0));if(this._ac.abort(),this._ac=new AbortController,this._executing.size===0)return Promise.resolve();let t=new Set(this._executing);return new Promise(e=>{this._settledResolvers.push({executionIds:t,resolve:e})})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),n.resolve(t),!0):!1}catch(e){return console.error(`[ToolInvocationTracker] resume failed`,e),!1}}getStatuses(){return this._statuses}_getWrappedTools(){let e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.execute,r=t.streamCall;return n===void 0&&r===void 0?[e,t]:[e,{...t,...n!==void 0&&{execute:(...[e,t])=>{let r=hV(t),i=this._captureExecution(t.toolCallId,r);return!i||i.skipExecute?new Promise(()=>{}):n(e,t)}},...r!==void 0&&{streamCall:(...[e,t])=>{let n=hV(t);if(this._captureExecution(t.toolCallId,n))return r(e,t)}}}]}))}_captureExecution(e,t){if(t===void 0)return;let n=this._entries.get(e);if(n?.controller)return n.executionId===void 0&&(n.executionId=t),n.executionId===t?n:void 0}_onHumanInput(e,t,n){return new Promise((r,i)=>{let a=this._entries.get(e);if(!a?.controller||a.executionId!==n){i(Error(`Tool execution aborted`));return}let o=this._humanInput.get(e);if(o)try{o.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{executionId:n,resolve:r,reject:i}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e,t){this._captureExecution(e,t)&&(this._entries.get(e).skipExecute||(this._executing.add(t),this._humanInput.get(e)?.executionId!==t&&this._setStatus(e,{type:`executing`})))}_onExecutionEnd(e,t){if(t===void 0||!this._executing.delete(t))return;this._entries.get(e)?.executionId===t&&this._deleteStatus(e);let n=[];this._settledResolvers.forEach(({executionIds:e,resolve:t})=>{if([...e].some(e=>this._executing.has(e))){n.push({executionIds:e,resolve:t});return}try{t()}catch{}}),this._settledResolvers.length=0,this._settledResolvers.push(...n)}_handleResultChunk(e){let t=e.meta.toolCallId,n=hV(e),r=this._entries.get(t);r&&r.executionId===n&&(r?.hasResult||r.skipExecute||this._invokeOnResult({type:`add-tool-result`,toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(e){console.error(`[ToolInvocationTracker] onResult callback threw; result dropped`,e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error(`[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated`,e)}}_setStatus(e,t){let n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;let t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_warnProviderOwnedSkip(e,t){}_shouldCloseArgsStream({argsText:e,hasResult:t,clientOwned:n}){return t?!0:fV(e)?n||!this._isRunning:!1}_startActiveEntry(e,t,n,r){let i={toolName:t,controller:this._controller.addToolCallPart({toolName:t,toolCallId:e}),argsText:``,hasResult:!1,skipExecute:n,argsComplete:!1,clientOwned:r};return this._entries.set(e,i),i}_demoteEntriesToRestored(){for(let[e,t]of this._entries)if(t.controller){if(!t.argsComplete&&!t.hasResult){this._entries.delete(e);continue}this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}}_processArgsText(e,t){if(!e.controller)return;let n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)mV(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText)){if(fV(e.argsText)&&fV(t.argsText)&&mV(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1}if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({argsText:e.argsText,hasResult:n,clientOwned:e.clientOwned})&&(e.controller.argsText.close(),e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let{part:n}of QB(e)){let e=this._entries.get(n.toolCallId);if(t){e?.controller||this._entries.set(n.toolCallId,{toolName:n.toolName,argsText:n.argsText,hasResult:n.result!==void 0});continue}let r=e;if(n.result!==void 0&&this._discardedToolCallIds.delete(n.toolCallId),r&&!r.controller){if(r.hasResult||(n.argsText===r.argsText||fV(r.argsText)&&fV(n.argsText)&&mV(r.argsText,n.argsText))&&n.result===void 0)continue;this._entries.delete(n.toolCallId),r=void 0}if(!r){let e=this._isClientToolCall?.(n),t=n.result===void 0&&e===!1;t&&this._warnProviderOwnedSkip(n.toolName,n.toolCallId),r=this._startActiveEntry(n.toolCallId,n.toolName,n.result!==void 0||t||this._discardedToolCallIds.has(n.toolCallId),e===!0)}if(n.approval!==void 0&&(r.skipExecute=!0),this._processArgsText(r,n),n.result!==void 0&&!r.hasResult){let{controller:e}=r;if(!e)continue;r.hasResult=!0,r.argsComplete=!0,e.setResponse(new pL({result:n.result,artifact:n.artifact,isError:n.isError,...n.modelContent===void 0?{}:{modelContent:n.modelContent}})),e.close()}}}},_V=Object.freeze([]),vV=(e,t)=>{Promise.resolve(t).catch(t=>{console.error(`[ExternalStoreThreadRuntimeCore] ${e} callback rejected`,t)})},yV=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,bV=class extends uV{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._hasExecutingTools(this._store)?!0:this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}get unstable_refetchThread(){if(this._store.onRefetchThread)return()=>this._store.onRefetchThread()}suggestions=[];extras=void 0;_converter=new Az;_pendingDeleteEvictions=new Set;_optimistic=null;_store;_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}_transformedQueue;_toolInvocations=null;_toolStatuses=new Map;_effectiveIsRunning=!1;_inTrackerUpdate=!1;_pendingRunningRefresh=!1;_runTrackerUpdate(e){this._inTrackerUpdate=!0;try{e()}finally{this._inTrackerUpdate=!1}this._pendingRunningRefresh&&(this._pendingRunningRefresh=!1,this._refreshEffectiveIsRunning())}_refreshEffectiveIsRunning(){let e=this._getEffectiveIsRunning(this._store);this._effectiveIsRunning!==e&&(this._effectiveIsRunning=e,this._notifyEventSubscribers(e?`runStart`:`runEnd`,{}),this._notifySubscribers())}_hasExecutingTools(e){if(e.unstable_enableToolInvocations!==!0||this._toolInvocations===null)return!1;for(let e of this._toolStatuses.values())if(e.type===`executing`)return!0;return!1}_getEffectiveIsRunning(e){return(e.isRunning??!1)||this._hasExecutingTools(e)}beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){this._store!==e&&this._updateStoreSnapshot(e)}_updateStoreSnapshot(e){let t=this._effectiveIsRunning;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e;let r=this._getEffectiveIsRunning(e),i=e.unstable_messageRepositoryInstance,a=i!==void 0&&i!==this.repository;a&&(this.repository=i,this._pendingDeleteEvictions.clear()),n?.queue!==e.queue&&(this._transformedQueue=void 0,e.queue?.__internal_setDispatchTransform?.(e=>{let t=this.messages.at(-1)?.id??null;return this.enrichAppendMetadata({...e,parentId:t},t)}),e.queue?.__internal_setDispatchTransform&&(this._transformedQueue=e.queue)),this.extras!==e.extras&&(this.extras=e.extras);let o=e.suggestions??_V;JP(this.suggestions,o)||(this.suggestions=o);let s={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,refetchThread:this._store.onRefetchThread!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:this._store.queue!==void 0};JP(this._capabilities,s)||(this._capabilities=s);let c;if(e.messageRepository){if(n&&!a&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository&&t===r){this._notifySubscribers();return}let i=e.messageRepository.messages,o=e.messageRepository.headId??i.at(-1)?.message.id??null;if(n&&!a&&n.messageRepository===e.messageRepository)this.repository.resetHead(o),c=this.repository.getMessages();else{let e=new Set(i.map(({message:e})=>e.id));for(let{message:e,parentId:t}of i)this.repository.addOrUpdateMessage(t,e);for(let{message:t}of this.repository.export().messages)e.has(t.id)||this.repository.deleteMessage(t.id);this._pendingDeleteEvictions.clear(),this.repository.resetHead(o),c=this.repository.getMessages()}}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new Az;else if(!a&&n.isRunning===e.isRunning&&n.messages===e.messages&&t===r){this._notifySubscribers();return}}c=e.convertMessage?this._converter.convertMessages(e.messages,(t,n,i)=>{if(!e.convertMessage)return n;let a=i===(e.messages?.length??0)-1,o=`${fz}${i}`;if(t&&(t.role!==`assistant`||!Ez(t.status)||t.status===kz(t.content,a,r))){if(t.id.startsWith(`__external_store_fallback_`)&&t.id!==o){let e={...t,id:o};return uz(e,n),e}return t}let s=e.convertMessage(n,i),c=gz(s,o,kz(s.content,a,r));return uz(c,n),c}):e.messages;let i=new Set,o=[];for(let e=c.length-1;e>=0;e--){let t=c[e];if(i.has(t.id)){console.warn(`ExternalStoreThreadRuntimeCore: duplicate message id "${t.id}" in the provided messages array; keeping the last occurrence.`);continue}i.add(t.id),o.push(t)}o.length!==c.length&&(c=o.reverse());for(let e=0;e<c.length;e++){let t=c[e],n=c[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}if(this._pendingDeleteEvictions.size>0){let e=new Set(c.map(e=>e.id));for(let t of this._pendingDeleteEvictions)if(this._pendingDeleteEvictions.delete(t),!e.has(t)){try{this.repository.getMessage(t)}catch{continue}this.repository.deleteMessage(t)}}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);c.length>0&&this.ensureInitialized(),this._effectiveIsRunning=r,t!==r&&(r?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let l=null;if(yV(r,c)){let e=c.at(-1)?.id??null;this._optimistic?.parentId!==e&&(this._optimistic={id:pz(),parentId:e}),l=this._optimistic.id,this.repository.addOrUpdateMessage(e,gz({role:`assistant`,content:[],metadata:{isOptimistic:!0}},l,{type:`running`}))}l===null&&(this._optimistic=null),this.repository.resetHead(l??c.at(-1)?.id??null);let u=this.repository.getMessages();if((!this._messages||!jz(this._messages,u))&&(this._messages=u),this._voiceMessages.length>0){let e=new Set(this._messages.map(e=>e.id)),t=this._voiceMessages.filter(t=>!e.has(t.id));t.length!==this._voiceMessages.length&&(this._voiceMessages=t,this._markVoiceMessagesDirty())}a&&this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._runTrackerUpdate(()=>this._driveToolInvocations()),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._toolStatuses=new Map,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new gV(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;vV(`onAddToolResult`,this._store.onAddToolResult?.({messageId:t,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}catch(e){console.error(`[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed`,e)}},onStatusesChange:e=>{let t=this._hasExecutingTools(this._store);this._toolStatuses=e;try{this._store.setToolStatuses?.(Object.fromEntries(e))}finally{t!==this._hasExecutingTools(this._store)&&(this._inTrackerUpdate?this._pendingRunningRefresh=!0:this._updateStoreSnapshot(this._store))}}},e=>this._store.unstable_isClientToolCall?.(e)),this._toolInvocations.setState({messages:this._messages,isRunning:this._getEffectiveIsRunning(this._store),...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();for(let{part:e,messageId:t}of QB(this._messages))this._toolCallToMessageId.set(e.toolCallId,t);this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);if(this._getEffectiveIsRunning(this._store))return;let t=this._store.unstable_onBranchChange,n=t?this.repository.canonicalHeadId:null;this.repository.switchToBranch(e),this._pendingDeleteEvictions.clear(),this.updateMessages(this.repository.getMessages()),t&&this._notifyBranchChange(n,t)}_notifyBranchChange(e,t){let n=this.repository.canonicalHeadId;n!==e&&t({headId:n,visibleMessageIds:this.repository.getMessages().map(e=>e.id)})}async append(e){let t={...e,parentId:this._resolveAppendParent(e.parentId)};if(this.voice)throw Error(`Cannot send a text message while a voice session is connected`);if(this._isVoiceMessage(t.sourceId))throw Error(`Voice transcript messages cannot be edited`);let n=t.sourceId!=null||t.parentId!==(this._getBaseMessages().at(-1)?.id??null);t=!n&&this._store.queue&&this._store.queue===this._transformedQueue?t:this.enrichAppendMetadata(t);let r=IB(this);this.ensureInitialized();let i=this._getInitializePromise?.();if(!n&&this._store.queue){if(i&&await i,!LB(this,r))return;t.steer??this._getEffectiveIsRunning(this._store)?this._store.queue.steer(t):this._store.queue.enqueue(t);return}if(i?.catch(()=>{}),(t.startRun??t.role===`user`)&&await this._toolInvocations?.abort({discardPending:!0}),LB(this,r)){if(n){if(!this._store.onEdit)throw Error(`Runtime does not support editing messages.`);this._pendingDeleteEvictions.clear(),await this._store.onEdit(t)}else await this._store.onNew(t)}}_commitVoiceMessage(e){this._store.onVoiceTranscript?.(e)}async deleteMessage(e){if(this._store.onDelete){this.repository.getMessages().some(t=>t.id===e)&&this._pendingDeleteEvictions.add(e);try{await this._store.onDelete(e)}catch(t){throw this._pendingDeleteEvictions.delete(e),t}return}if(!this._store.setMessages)throw Error(`Runtime does not support deleting messages.`);this._getEffectiveIsRunning(this._store)&&await this._toolInvocations?.abort();let t=this.repository.getMessages();if(t.findIndex(t=>t.id===e)===-1)throw Error(`Message not found.`);this._pendingDeleteEvictions.clear(),this.updateMessages(t.filter(t=>t.id!==e)),this._evictDeletedMessage(e)}_evictDeletedMessage(e){if(!e.startsWith(`__external_store_fallback_`)){try{this.repository.getMessage(e)}catch{return}this.repository.deleteMessage(e),this._publishRepositoryMessages()}}_publishRepositoryMessages(){let e=this.repository.getMessages();jz(this._messages,e)||(this._messages=e),this._notifySubscribers()}getQueueItems(){return this._store?.queue?.items??ZB}getSteerQueueItems(){return this._store?.queue?.steerItems??ZB}moveQueueItem(e,t){this._store?.queue?.move(e,t)}removeQueueItem(e){this._store?.queue?.remove(e)}async startRun(e){if(!this._store.onReload)throw Error(`Runtime does not support reloading messages.`);if(this.voice)throw Error(`Cannot start a run while a voice session is connected`);if(this._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);this._pendingDeleteEvictions.clear(),await this._toolInvocations?.abort({discardPending:!0}),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw Error(`Runtime does not support resuming runs.`);if(this.voice)throw Error(`Cannot start a run while a voice session is connected`);if(this._isVoiceMessage(e.sourceId))throw Error(`Voice transcript messages cannot be reloaded`);await this._store.onResume(e)}exportExternalState(){if(!this._store.onExportExternalState)throw Error(`Runtime does not support exporting external states.`);return this._store.onExportExternalState()}importExternalState(e){if(!this._store.onLoadExternalState)throw Error(`Runtime does not support importing external states.`);this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.onLoadExternalState(e)}unstable_notifySessionReset(){this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.queue?.__internal_notifyCancelled?.()}cancelRun(){if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);let e=IB(this);this._toolInvocations?.abort({discardPending:!0}),this._store.queue?.__internal_notifyCancelled?.(),vV(`onCancel`,this._store.onCancel()),this.dropEmptyOptimisticHead();let t=this.repository.getMessages(),n=t[t.length-1],r=this._store.setMessages!==void 0&&n?.role===`user`&&n.id===t.at(-1)?.id&&n.content.every(e=>e.type===`text`)?n:void 0,i;if(r){let e={text:uB(r),attachments:r.attachments,quote:r.metadata.custom.quote};this.composer.restoreDraft(e)&&(this.repository.deleteMessage(r.id),i={id:r.id,draft:e})}this._publishRepositoryMessages(),setTimeout(()=>{if(LB(this,e)){if(this.dropEmptyOptimisticHead(),i){let e=this.repository.getMessages();e.at(-1)?.id===i.id?this.repository.deleteMessage(i.id):e.some(e=>e.id===i.id)&&this.composer.retractDraft(i.draft)}this._publishRepositoryMessages(),this.updateMessages(this._messages)}},0)}dropEmptyOptimisticHead(){let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);vV(`onAddToolResult`,this._store.onAddToolResult(e))}resumeToolCall(e){if(!(this._toolInvocations?.resume(e.toolCallId,e.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}throw Error(`Tool call ${e.toolCallId} is not waiting for resume.`)}}respondToToolApproval(e){if(!this._store.onRespondToToolApproval)throw Error(`Runtime does not support tool approvals.`);let t=this.messages.findLast(t=>t.role===`assistant`&&t.content.some(t=>t.type===`tool-call`&&t.approval?.id===e.approvalId)),n=t?.content.find(t=>t.type===`tool-call`&&t.approval?.id===e.approvalId);try{return Promise.resolve(this._store.onRespondToToolApproval(e)).then(()=>{t&&n?.type===`tool-call`&&this._notifyToolApprovalAnswered(t.id,n.toolCallId,n.toolName,e.approved)})}catch(e){return Promise.reject(e)}}reset(e){let t=new XB;t.import(qB.fromArray(e??[])),this.updateMessages(t.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=e=>{this._store.convertMessage===void 0?this._store.setMessages?.(e):this._store.setMessages?.(e.flatMap(dz))}},xV=e=>e.adapters?.threadList??{},SV=class extends zB{threads;constructor(e){super(),this.threads=new KB(xV(e),()=>new bV(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(xV(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},CV=e=>{let t=J(21),{modelContext:n,feedback:r}=iz()??{},i;bb0:{if(!r||e.adapters?.feedback){i=e;break bb0}let n;t[0]!==r||t[1]!==e.adapters?(n={...e.adapters,feedback:r},t[0]=r,t[1]=e.adapters,t[2]=n):n=t[2];let a;t[3]!==e||t[4]!==n?(a={...e,adapters:n},t[3]=e,t[4]=n,t[5]=a):a=t[5],i=a}let a=i,o;t[6]===a?o=t[7]:(o=()=>new SV(a),t[6]=a,t[7]=o);let[s]=wM(o),c;t[8]===s.threads?c=t[9]:(c=()=>()=>{RB(s.threads.getMainThreadRuntimeCore())},t[8]=s.threads,t[9]=c);let l;t[10]===s?l=t[11]:(l=[s],t[10]=s,t[11]=l),X(c,l);let u;t[12]!==a||t[13]!==s?(u=()=>{s.setAdapter(a)},t[12]=a,t[13]=s,t[14]=u):u=t[14],X(u);let d,f;t[15]!==n||t[16]!==s?(d=()=>{if(n)return s.registerModelContextProvider(n)},f=[n,s],t[15]=n,t[16]=s,t[17]=d,t[18]=f):(d=t[17],f=t[18]),X(d,f);let p;return t[19]===s?p=t[20]:(p=new PB(s),t[19]=s,t[20]=p),p},wV=e=>e.status?.type!==`running`,TV=async(e,t)=>{let n=yR.fromAssistantStream(e);for await(let e of n){let n=e.parts.filter(e=>e.type===`text`)[0]?.text;n?.trim()&&await t(n)}},EV=(e,t)=>{let n=()=>void t.generateTitle({automatic:!0}).catch(e=>{aI(e)||console.error(`[assistant-ui] Thread title generation failed`,e)}),r=()=>e.getState().messages.some(wV);if(r())return n(),()=>{};let i=e.subscribe(()=>{r()&&(i(),n())});return i},DV=({threadId:e,generation:t,runtimeHook:n,publish:r,itemRuntime:i})=>{let a=n(),o=a?.thread?.__internal_threadBinding,s=DM(()=>{o&&r(e,o.getState(),t)},[e,t,o,r]),c=Y(!1);c.current||s(),X(()=>{if(o)return c.current=!0,s(),o.outerSubscribe(s)},[o,s]);let l=Y(void 0),u=Y(!1),d=Y(void 0),f=Y(!1),p=kM(()=>{if(u.current||i.getState().status!==`new`)return;u.current=!0;let e=i.initialize();l.current=e,e.then(()=>{f.current&&(d.current?.(),d.current=EV(a.thread,i))},()=>{l.current===e&&(l.current=void 0,u.current=!1)})}),m=kM(()=>(p(),l.current));return X(()=>{if(!o)return;let e=o.getState(),t=e.__internal_setGetInitializePromise;typeof t==`function`&&t.call(e,m)},[o]),X(()=>{if(!a?.threads?.main)return;u.current=!1,f.current=!0;let e=a.threads.main.unstable_on(`initialize`,p);return()=>{f.current=!1,e(),d.current?.(),d.current=void 0}},[a]),a},OV=UM(({threadId:e,generation:t,parentList:n,runtimeHook:r,parentClient:i,adapters:a,publish:o,destroySignal:s})=>{let c=EM(()=>new OB(new zF({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>{let t=n.getItemById(e);return t?{id:t.id,remoteId:t.remoteId,externalId:t.externalId,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,status:t.status,isMain:t.id===n.mainThreadId,isRunning:n.unstable_isThreadRunning?.(t.id)??!1}:MF},subscribe:e=>n.subscribe(e)}),n),[n,e]),{client:l}=gF(i,{threadListItem:VI({runtime:c})});return RP(s,function(){return gP(l,function(){return rz(a,function(){return DV({threadId:e,generation:t,runtimeHook:r,publish:o,itemRuntime:c})})})})}),kV=[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`],AV=e=>{let t=J(3),{detectorRef:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{n.current=!0},i=[n],t[0]=n,t[1]=r,t[2]=i),OM(r,i),null},jV=class extends IF{runtimeHook;adapterStore=new LF({defaultAdapters:null,threadAdapters:new Map});hostStore=new LF({threads:[],hookEpoch:0});pendingThreadAdapters=new Map;instances=new Map;nextGeneration=0;parent;constructor(e,t){super(),this.parent=t,this.runtimeHook=e}_whenRuntimeAttached(e){return new Promise((t,n)=>{let r=()=>{let r=this.instances.get(e);if(!r)i(),n(Error(`Thread was deleted before runtime was started`));else if(!r.runtime||r.publishedGeneration!==r.generation)return;else i(),t(r.runtime)},i=this.subscribe(r);r()})}startThreadRuntime(e){if(!this.instances.has(e)){let t=this.nextGeneration++;this.instances.set(e,{generation:t,isRunning:!1,destroy:new AbortController}),this._syncHostThreads()}return this._whenRuntimeAttached(e)}__internal_restartThreadRuntime(e){let t=this.instances.get(e);return t?(t.runtime&&RB(t.runtime),t.unsubscribeRunning?.(),t.unsubscribeRunning=void 0,t.destroy.abort(),t.destroy=new AbortController,t.generation=this.nextGeneration++,this._syncHostThreads(),this._notifySubscribers(),this._whenRuntimeAttached(e)):this.startThreadRuntime(e)}getThreadRuntimeCore(e){let t=this.instances.get(e);if(t)return t.runtime}__internal_isThreadRunning(e){return this.instances.get(e)?.isRunning??!1}runningSubscribers=new Set;__internal_subscribeRunningChanged(e){return this.runningSubscribers.add(e),()=>this.runningSubscribers.delete(e)}threadEventSubscribers=new Set;__internal_subscribeThreadEvents(e){return this.threadEventSubscribers.add(e),()=>this.threadEventSubscribers.delete(e)}_publish=(e,t,n)=>{this._publishThreadRuntime(e,t,n)};_publishThreadRuntime(e,t,n){let r=this.instances.get(e);if(!r||r.generation!==n)return;let i=r.runtime;r.runtime=t,r.publishedGeneration=n,i!==t&&this._trackRunning(e,r),this._notifySubscribers(),i!==void 0&&i!==t&&NF(this.replacedSubscribers)}replacedSubscribers=new Set;__internal_subscribeRuntimeReplaced(e){return this.replacedSubscribers.add(e),()=>this.replacedSubscribers.delete(e)}_trackRunning(e,t){t.unsubscribeRunning?.();let n=t.runtime;if(!n){t.unsubscribeRunning=void 0,this._setRunning(t,!1);return}this._setRunning(t,SB(n));let r=[n.subscribe(()=>{this._setRunning(t,SB(n))}),...kV.map(t=>n.unstable_on(t,()=>{HN(this.threadEventSubscribers,{threadId:e,type:t},`Thread event "${t}"`)}))];t.unsubscribeRunning=()=>{for(let e of r)e()}}_setRunning(e,t){e.isRunning!==t&&(e.isRunning=t,NF(this.runningSubscribers))}stopThreadRuntime(e){let t=this.instances.get(e);t?.runtime&&RB(t.runtime),t?.unsubscribeRunning?.(),t?.destroy.abort(),this.instances.delete(e),this.pendingThreadAdapters.delete(e),this._syncHostThreads(),this._notifySubscribers()}setRuntimeHook(e){if(this.runtimeHook===e)return;this.runtimeHook=e;let t=this.hostStore.getState();this.hostStore.setState({...t,hookEpoch:t.hookEpoch+1})}__internal_setDefaultAdapters(e){let t=this.adapterStore.getState();t.defaultAdapters!==e&&this.adapterStore.setState({...t,defaultAdapters:e})}__internal_setThreadAdapters(e,t){let n=this.adapterStore.getState(),r=new Map(n.threadAdapters);t===null?r.delete(e):r.set(e,t),this.adapterStore.setState({...n,threadAdapters:r})}__internal_dispose(){for(let e of[...this.instances.keys()])this.stopThreadRuntime(e)}_syncHostThreads(){let e=this.hostStore.getState();this.hostStore.setState({...e,threads:Array.from(this.instances.entries()).map(([e,{generation:t,destroy:n}])=>({id:e,generation:t,destroySignal:n.signal}))})}_threadElements(e,{threads:t,hookEpoch:n},r){let i=this.runtimeHook;return t.map(({id:t,generation:a,destroySignal:o})=>{let s=this.pendingThreadAdapters.has(t)?this.pendingThreadAdapters.get(t):r.threadAdapters.get(t)??r.defaultAdapters;return WM(`${t}:${a}:${n}`,OV({threadId:t,generation:a,parentList:this.parent,runtimeHook:i,parentClient:e,adapters:s,publish:this._publish,destroySignal:o}))})}__internal_useHost(e){let t=rI(this.hostStore),n=rI(this.adapterStore);return FN(this._threadElements(e,t,n))}__internal_RenderThreadRuntimes=({provider:e})=>(rI(this.hostStore),Array.from(this.instances.entries()).map(([t,{generation:n}])=>(0,P.jsx)(this._OuterActiveThreadProvider,{threadId:t,provider:e},`${t}:${n}`)));__internal_Host=({parentClient:e})=>{let t=rI(this.hostStore),n=rI(this.adapterStore),r=this._threadElements(e,t,n),{effects:i}=LN(function(){return FN(r)});return OM(i),null};_OuterActiveThreadProvider=FM(({threadId:e,provider:t})=>{let n=EM(()=>new NB(this.parent).getItemById(e),[e]),r=Y(!1);return X(()=>{},[t]),(0,P.jsx)(Pz,{runtime:n,children:(0,P.jsx)(t,{children:(0,P.jsx)(this._AdapterSink,{threadId:e,detectorRef:r})})})});_AdapterSink=({threadId:e,detectorRef:t})=>{let n=iz();return this.pendingThreadAdapters.set(e,n),OM(()=>(this.__internal_setThreadAdapters(e,n),()=>{this.pendingThreadAdapters.get(e)===n&&this.pendingThreadAdapters.delete(e),this.__internal_setThreadAdapters(e,null)}),[e,n]),(0,P.jsx)(AV,{detectorRef:t})}};function MV(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch{}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var NV=(e,t,n)=>n.reduce((e,n)=>n?.(e,t)??e,e),PV=class extends IF{_pendingTransforms=[];_completedOptimistics=[];_nextTransformOrder=0;_epoch=0;_baseValue;_cachedValue;constructor(e){super(),this._baseValue=e,this._cachedValue=e}_updateState(){let e=[...this._pendingTransforms.map(e=>({order:e.order,apply:t=>NV(t,e.task,[e.loading,e.optimistic])})),...this._completedOptimistics.map(({order:e,optimistic:t})=>({order:e,apply:t}))].sort((e,t)=>e.order-t.order);this._cachedValue=e.reduce((e,t)=>t.apply(e),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(e){this._baseValue=e,this._updateState()}reset(e){this._epoch++,this._pendingTransforms.length=0,this._completedOptimistics.length=0,this._baseValue=e,this._cachedValue=e,this._notifySubscribers()}async optimisticUpdate(e){let t=this._epoch,n=this._nextTransformOrder++,r=e.execute(),i={...e,order:n,task:r};try{this._pendingTransforms.push(i),this._updateState();let n=await r;if(t!==this._epoch)return n;this._baseValue=NV(this._baseValue,n,[e.optimistic,e.then]);for(let t of this._completedOptimistics)(e.then||t.order>i.order)&&(this._baseValue=t.optimistic(this._baseValue));return e.optimistic&&(this._completedOptimistics.push({order:i.order,optimistic:e.optimistic}),this._completedOptimistics.sort((e,t)=>e.order-t.order)),n}finally{let e=this._pendingTransforms.indexOf(i);e>-1&&this._pendingTransforms.splice(e,1),this._pendingTransforms.length===0&&(this._completedOptimistics.length=0),this._updateState()}}},FV=Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead."),IV=new class extends EB{get error(){return FV}messages=[];composer=TB(FV,!0);isLoading=!0;getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject(FV)}};function LV(e){return e}var RV=`__LOCALID_`,zV=e=>e||void 0,BV=(e,t)=>{let n=[...t.threadIds],r=[...t.archivedThreadIds],i=Ej(t.threadIdMap),a=Ej(t.threadData),o=new Set([...n,...r]);for(let t of e){switch(t.status){case`regular`:case`archived`:break;default:{let e=t.status;throw Error(`Unsupported state: ${e}`)}}let e=i[t.remoteId],s=e===void 0?void 0:a[e],c=s?.id??t.remoteId,l=e??LV(c),u=s!==void 0&&s.status!==`new`?s.initializeTask:void 0;o.has(c)?s!==void 0&&s.status!==t.status&&(t.status===`regular`?(r=r.filter(e=>e!==c),n.push(c)):(n=n.filter(e=>e!==c),r.push(c))):(o.add(c),t.status===`regular`?n.push(c):r.push(c)),i[c]=l,i[t.remoteId]=l,a[l]={...s?.localOrigin===!0?{localOrigin:!0}:{},id:c,remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,initializeTask:u??Promise.resolve({remoteId:t.remoteId,externalId:t.externalId})}}return{threadIds:n,archivedThreadIds:r,threadIdMap:i,threadData:a}},VV=()=>({isLoading:!0,loadError:void 0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:Ej(),threadData:Ej()}),HV=e=>{let t;do t=`${RV}${pz()}`;while(e.threadIdMap[t]);let n=LV(t);return{id:t,state:{...e,newThreadId:t,threadIdMap:Ej(e.threadIdMap,{[t]:n}),threadData:Ej(e.threadData,{[n]:{status:`new`,id:t,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0,localOrigin:!0}})}}},UV=(e,t,n)=>{let r=new Set(e.threadIds),i=new Set(e.archivedThreadIds),a=[],o=[],s=(e,t)=>e.has(t.id)||t.remoteId!==void 0&&e.has(t.remoteId);for(let t of Object.values(e.threadData)){let e=n.get(t.id);(e===void 0||e===`new`)&&(e!==void 0||t.localOrigin===!0)&&(t.status===`regular`&&!s(r,t)?(a.push(t),r.add(t.id)):t.status===`archived`&&!s(i,t)&&(o.push(t),i.add(t.id)))}if(a.length===0&&o.length===0)return e;let c=(e,t)=>{let n=e.indexOf(t.id);if(n!==-1)return n;let r=t.remoteId===void 0?-1:e.indexOf(t.remoteId);return r===-1?2**53-1:r};return a.sort((e,n)=>c(t.threadIds,e)-c(t.threadIds,n)),o.sort((e,n)=>c(t.archivedThreadIds,e)-c(t.archivedThreadIds,n)),{...e,threadIds:[...a.map(e=>e.id),...e.threadIds],archivedThreadIds:[...o.map(e=>e.id),...e.archivedThreadIds]}},WV=e=>new Map(Object.values(e.threadData).map(e=>[e.id,e.status])),GV=(e,t)=>{let n=Object.hasOwn(e.threadIdMap,t)?e.threadIdMap[t]:void 0;if(n!==void 0)return Object.hasOwn(e.threadData,n)?e.threadData[n]:void 0},KV=(e,t,n,r,i)=>{let a=LV(t),o=Object.hasOwn(e.threadData,a)?e.threadData[a]:void 0;if(!o)return{state:e,removedMappingId:void 0,survivorMappingId:a};let s=Object.hasOwn(e.threadIdMap,n)?e.threadIdMap[n]:void 0,c=s!==void 0&&s!==a&&Object.hasOwn(e.threadData,s)?e.threadData[s]:void 0,l=s!==void 0&&c!==void 0?{mappingId:s,data:c}:void 0,u=i!==void 0&&Object.hasOwn(e.threadIdMap,i)?e.threadIdMap[i]:void 0,d=l!==void 0&&u===l.mappingId?l.mappingId:a,f=l===void 0?void 0:d===a?l.mappingId:a,p=r??l?.data.externalId,m=Ej(e.threadData);f!==void 0&&delete m[f];let h={...o,id:d,initializeTask:Promise.resolve({remoteId:n,externalId:p}),remoteId:n,externalId:p};m[d]={...l?.data,...h,title:o.title??l?.data.title,lastMessageAt:(`lastMessageAt`in o?o.lastMessageAt:void 0)??(l&&`lastMessageAt`in l.data?l.data.lastMessageAt:void 0),custom:o.custom??l?.data.custom};let g=Ej(e.threadIdMap);if(f!==void 0)for(let[e,t]of Object.entries(g))t===f&&(g[e]=d);g[t]=d,g[n]=d;let _=e=>l===void 0?e:e.filter(e=>e!==l.data.id).map(e=>e===o.id?d:e);return{state:{...e,threadIds:_(e.threadIds),archivedThreadIds:_(e.archivedThreadIds),threadIdMap:g,threadData:m},removedMappingId:f,survivorMappingId:d}},qV=(e,t,n,r)=>{let i=GV(e,t);if(!i)return e;let{id:a,status:o}=i;if(o===n)return e;let s;if(n!==`deleted`){if(i.status===`new`){if(r===void 0)return e;s={...i,initializeTask:r,status:n}}else s={...i,status:n}}let c={...e};switch(o){case`new`:c.newThreadId=void 0;break;case`regular`:c.threadIds=c.threadIds.filter(e=>e!==a);break;case`archived`:c.archivedThreadIds=c.archivedThreadIds.filter(e=>e!==a);break;default:throw Error(`Unsupported state: ${o}`)}switch(n){case`regular`:c.threadIds=[a,...c.threadIds];break;case`archived`:c.archivedThreadIds=[a,...c.archivedThreadIds];break;case`deleted`:{let n=e.threadIdMap[t],r=Ej(c.threadData);delete r[n],c.threadData=r;let i=Ej(c.threadIdMap);for(let[e,t]of Object.entries(i))t===n&&delete i[e];c.threadIdMap=i;break}default:throw Error(`Unsupported state: ${n}`)}return s!==void 0&&(c.threadData={...c.threadData,[a]:s}),c},JV=(e,t,n)=>qV(e,t,n,void 0),YV=(e,t,n)=>qV(e,t,`regular`,n),XV=class extends Error{[iI]=!0;constructor(){super(`Thread list adapter changed while an operation was pending.`),this.name=`ThreadListAdapterChangedError`}};function ZV(e,t){let n=e.get(t);return n===void 0&&(n={generations:new Set,pendingClaim:null,inFlightClaims:new Set,manualTitle:void 0,latestExplicit:null,nextOrder:0},e.set(t,n)),n}function QV(e,t,n){n.generations.size===0&&n.pendingClaim===null&&n.inFlightClaims.size===0&&n.manualTitle===void 0&&e.get(t)===n&&e.delete(t)}function $V(e,t){return!t.superseded&&(e.latestExplicit?.order??0)<=t.order}function eH(e,t){return(e.latestExplicit?.order??0)<t.order}function tH(e,t,n){let r=ZV(e,t),i,a=new Promise(e=>{i=e}),o={title:n,order:++r.nextOrder,settled:a,settle:i};r.pendingClaim=o,r.inFlightClaims.add(o);for(let e of r.generations)e.order<o.order&&(e.claim=o);return o}function nH(e,t,n,r){n.settle(r);let i=e.get(t);i!==void 0&&(i.inFlightClaims.delete(n),i.pendingClaim===n&&(i.pendingClaim=null,r&&(i.manualTitle=n.title)),QV(e,t,i))}function rH(e,t,n){let r=n.manualTitle;if(r!==void 0)return n.manualTitle=void 0,QV(e,t,n),r}function iH(e,t){e.delete(t)}function aH(e,t,n){let r=ZV(e,t);if(n&&r.pendingClaim===null&&rH(e,t,r)!==void 0)return null;let i,a=new Promise(e=>{i=e}),o={automatic:n,order:++r.nextOrder,claim:n?r.pendingClaim:null,beforeGenerationClaims:n?[]:[...r.inFlightClaims],superseded:!1,persisted:a,settlePersisted:i};if(!n){r.pendingClaim=null,r.manualTitle=void 0,r.latestExplicit=o;for(let e of r.generations)e.automatic&&(e.superseded=!0)}return r.generations.add(o),o}async function oH({states:e,threadId:t,automatic:n,generate:r,rename:i,applyTitle:a}){let o=ZV(e,t),s=aH(e,t,n);if(s===null)return;let c,l=s.order,u=async e=>{let t=await e.settled;if(s.claim===e)return t||(s.claim=null,o.pendingClaim===e&&(o.pendingClaim=null)),t},d=()=>n&&rH(e,t,o)!==void 0,f=async()=>{if(c!==void 0)for(;;){let e=s.claim;if(e!==null&&e.order>l&&eH(o,e)){await u(e)===!0&&(c=e.title,l=e.order,await i(e.title));continue}let t=o.latestExplicit;if(t===null||t.order<=l)return;let n=await t.persisted;if(o.latestExplicit===t){if(l=t.order,n===void 0||n===c)return;c=n,await i(n)}}},p=async()=>{if(s.beforeGenerationClaims.length>0&&await Promise.all(s.beforeGenerationClaims.map(e=>e.settled)),s.claim!==null){let e=await u(s.claim);if(e===!0){s.superseded=!0;return}if(e===!1&&d())return}if(!$V(o,s))return;let e=!1,t;for(await r(async n=>{e=!0,t=n,n!==void 0&&(c=n);let r=s.claim;if(r!==null){if(await u(r)!==!1)return;if(d()){s.superseded=!0;return}}$V(o,s)&&await a(t)});;){let n=s.claim;if(n===null)return;let r=await u(n);if(r!==void 0){if(r===!1){if(d())return;e&&$V(o,s)&&await a(t);return}if(!eH(o,n))return;if(await i(n.title),c=n.title,l=n.order,s.claim===n){if(!$V(o,s))return;await a(n.title),s.superseded=!0;return}}}};try{await p(),await f()}finally{s.settlePersisted(c),o.generations.delete(s),QV(e,t,o)}}var sH=(e,t)=>Error(`Thread "${e}" not found while ${t}.`),cH=(e,t,n)=>Error(`Thread "${e}" has status "${t}", so it cannot ${n}.`),lH=VV(),uH=class extends IF{_options;_hookManager;_runtimeAdapters;_loadThreadsPromise;_loadMorePromise;_loadGeneration=0;_adapterGeneration=0;_replaceListOnNextLoad=!1;_staleThreadIdsOnReplace;_switchGeneration=0;_switchTask;_titleStates=new Map;_mainThreadId;_state=new PV(lH);_useAdaptersProvider=({children:e})=>{let t=this._options.adapter.unstable_useAdapters;return t===void 0?e:(0,P.jsx)(this._SynthesizedAdapters,{useAdapters:t,children:e})};_SynthesizedAdapters=({useAdapters:e,children:t})=>{let n=oz(e());return n==null?t:(0,P.jsx)(DB,{adapters:n,children:t})};resolveProvider(e){return e.unstable_Provider===void 0?e.unstable_useAdapters===void 0?IM:this._useAdaptersProvider:e.unstable_Provider}get threadItems(){return this._state.value.threadData}getLoadThreadsPromise(){if(!this._loadThreadsPromise){let e=this._loadGeneration,t=!1,n=WV(this._state.baseValue);this._loadThreadsPromise=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:t=>e===this._loadGeneration?{...t,isLoading:!0,loadError:void 0}:t,then:(r,i)=>{if(e!==this._loadGeneration)return r;if(this._replaceListOnNextLoad)return this._replaceListOnNextLoad=!1,t=!0,this._replaceWithThreads({...r,loadError:void 0},i.threads,zV(i.nextCursor));let a=BV(i.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:{...r.threadIdMap},threadData:{...r.threadData}});return UV({...r,isLoading:!1,loadError:void 0,cursor:zV(i.nextCursor),threadIds:a.threadIds,archivedThreadIds:a.archivedThreadIds,threadIdMap:a.threadIdMap,threadData:a.threadData},r,n)}}).catch(n=>{if(e===this._loadGeneration){if(console.error(`[assistant-ui] thread list load failed:`,n),this._loadThreadsPromise=void 0,!this._replaceListOnNextLoad){this._state.update({...this._state.baseValue,isLoading:!1,loadError:n});return}this._replaceListOnNextLoad=!1,t=!0,this._state.update(this._replaceWithThreads({...this._state.baseValue,loadError:n},[],void 0))}}).then(()=>{if(!t)return;let e=this._options.threadId;e!==void 0&&this.getItemById(e)?.id!==this._mainThreadId&&this._switchToThreadFromProp(e).catch(()=>{})})}return this._loadThreadsPromise}loadMore(){if(this._loadMorePromise)return this._loadMorePromise;let e=this._state.value;if(e.cursor===void 0||e.isLoading)return Promise.resolve();let t=this._loadGeneration,n=this._options.adapter,r=e.cursor,i=this._state.optimisticUpdate({execute:()=>n.list({after:r}),loading:e=>t===this._loadGeneration?{...e,isLoadingMore:!0}:e,then:(e,r)=>{if(t!==this._loadGeneration||n!==this._options.adapter)return e;let i=BV(r.threads,{threadIds:[...e.threadIds],archivedThreadIds:[...e.archivedThreadIds],threadIdMap:{...e.threadIdMap},threadData:{...e.threadData}});return{...e,isLoadingMore:!1,cursor:zV(r.nextCursor),threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadIdMap:i.threadIdMap,threadData:i.threadData}}}).catch(e=>{t===this._loadGeneration&&console.error(`[assistant-ui] thread list loadMore failed:`,e)}).then(()=>{this._loadMorePromise===i&&(this._loadMorePromise=void 0)});return this._loadMorePromise=i,i}constructor(e,t){super(),this._state.subscribe(()=>{this._notifySubscribers(),this._notifyThreadIdChange()}),this._runtimeAdapters={modelContext:t},this._hookManager=new jV(e.runtimeHook,this),this._hookManager.__internal_setDefaultAdapters(this._runtimeAdapters),this._hookManager.__internal_subscribeRunningChanged(()=>this._notifySubscribers()),this._hookManager.__internal_subscribeRuntimeReplaced(()=>{queueMicrotask(()=>this._notifySubscribers())}),this.providerStore=new LF(this.resolveProvider(e.adapter)),this.__internal_setOptions(e),this.switchToNewThread()}_initialThreadLoaded=!1;providerStore;__internal_setOptions(e){if(this._options===e)return;let t=this._options!==void 0&&this._options.adapter!==e.adapter,n=this._initialThreadLoaded&&this._options!==void 0&&this._options.threadId!==e.threadId;this._options=e,this.providerStore.setState(this.resolveProvider(e.adapter)),this._hookManager.setRuntimeHook(e.runtimeHook),t&&(this._loadGeneration++,this._adapterGeneration++,this._switchGeneration++,this._switchTask=void 0,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._replaceListOnNextLoad=!0,this._staleThreadIdsOnReplace=new Set(Object.values(this._state.baseValue.threadData).filter(e=>e.status!==`new`).map(e=>e.id)),this._state.update({...this._state.baseValue,cursor:void 0,loadError:void 0}),this._titleStates.clear()),n&&this._switchToThreadFromProp(e.threadId).catch(()=>{})}_requireAdapterGeneration(e){if(e!==this._adapterGeneration)throw new XV}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new XV}_replaceWithThreads(e,t,n){let r=[];if(e.newThreadId){let t=Object.hasOwn(e.threadIdMap,e.newThreadId)?e.threadIdMap[e.newThreadId]:void 0,n=t&&Object.hasOwn(e.threadData,t)?e.threadData[t]:void 0;n?.status===`new`&&r.push(n)}let i=this._staleThreadIdsOnReplace;if(i)for(let t of Object.values(e.threadData))i.has(t.id)||(t.status===`new`||t.remoteId!==void 0)&&r.push(t);this._staleThreadIdsOnReplace=void 0;let a={threadIds:[],archivedThreadIds:[],threadIdMap:Ej(),threadData:Ej()};for(let e of r){let t=LV(e.id);Object.hasOwn(a.threadData,t)||(a.threadIdMap[e.id]=t,e.remoteId!==void 0&&(a.threadIdMap[e.remoteId]=t),a.threadData[t]=e)}let{threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l}=BV(t,a);for(let e of r){if(e.remoteId===void 0)continue;let t=LV(e.id),n=Object.hasOwn(l,t)?l[t]:void 0;n!==void 0&&(n.status===`regular`&&!o.includes(n.id)?o.push(n.id):n.status===`archived`&&!s.includes(n.id)&&s.push(n.id))}let u={...e,isLoading:!1,cursor:n,threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l,newThreadId:e.newThreadId!==void 0&&!Object.hasOwn(c,e.newThreadId)?void 0:e.newThreadId};if(GV(u,this._mainThreadId)===void 0){let e=u.newThreadId;if(e!==void 0)this._mainThreadId=e;else{let e=HV(u);this._mainThreadId=e.id,u=e.state}this._options.threadId===void 0?this._notifyThreadIdChange():this._lastNotifiedThreadId=void 0}let d=new Set(Object.values(u.threadData).map(e=>e.id));for(let t of Object.values(e.threadData))d.has(t.id)||this._hookManager.stopThreadRuntime(t.id);return this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>void 0),u}__internal_load(){if(this.getLoadThreadsPromise(),this._initialThreadLoaded)return;this._initialThreadLoaded=!0;let e=this._options.threadId??this._options.initialThreadId;e!==void 0&&(this._options.threadId===void 0?this.switchToThread(e):this._switchToThreadFromProp(e)).catch(()=>{})}async reloadMainThread(){let e=this._mainThreadId;if(e===void 0||this.getItemById(e)?.status===`new`)return;let t=this._hookManager.getThreadRuntimeCore(e);try{t?.unstable_refetchThread?await t.unstable_refetchThread():await this._hookManager.__internal_restartThreadRuntime(e)}catch(t){if(e!==this._mainThreadId)return;throw t}e===this._mainThreadId&&this._notifySubscribers()}reload(){return this._loadGeneration++,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._state.update({...this._state.baseValue,cursor:void 0}),this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get loadError(){return this._state.value.loadError}get isLoadingMore(){return this._state.value.isLoadingMore}get hasMore(){return this._state.value.cursor!==void 0}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}get _mainThreadRemoteId(){if(this._mainThreadId!==void 0)return GV(this._state.value,this._mainThreadId)?.remoteId}_lastNotifiedThreadId=void 0;_notifyThreadIdChange(e=!0){let t=this._mainThreadRemoteId;this._lastNotifiedThreadId!==t&&(this._lastNotifiedThreadId=t,e&&MV(`assistant-ui`,`onThreadIdChange`,this._options.onThreadIdChange,t))}getMainThreadRuntimeCore(){return this._hookManager.getThreadRuntimeCore(this._mainThreadId)||IV}getThreadRuntimeCore(e){let t=this.getItemById(e);if(!t)throw sH(e,`getting its runtime`);let n=this._hookManager.getThreadRuntimeCore(t.id);if(!n)throw Error(`Runtime for thread "${e}" not found while getting its runtime.`);return n}unstable_isThreadRunning(e){let t=this.getItemById(e);return t?this._hookManager.__internal_isThreadRunning(t.id):!1}unstable_subscribeThreadEvents(e){return this._hookManager.__internal_subscribeThreadEvents(e)}getItemById(e){return GV(this._state.value,e)}switchToThread(e,t){return this._startSwitchToThread(e,t,!0)}_startSwitchToThread(e,t,n){let r=++this._switchGeneration,i=this._switchToThread(e,t,r,n);return this._switchTask=i,i}async _switchToThread(e,t,n,r){if(this._replaceListOnNextLoad&&e!==this._state.value.newThreadId)throw new XV;let i=this.getItemById(e);if(!i){let t=await this._options.adapter.fetch(e);if(n!==this._switchGeneration)return;let r=this._state.value,a=LV(t.remoteId),o={...r.threadData,[a]:{id:a,initializeTask:Promise.resolve({remoteId:t.remoteId,externalId:t.externalId}),remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom}},s={...r.threadIdMap,[t.remoteId]:a},c=t.remoteId,l=t.status===`regular`?r.threadIds.includes(c):r.archivedThreadIds.includes(c),u=r.threadIds.filter(e=>e!==c),d=r.archivedThreadIds.filter(e=>e!==c),f=t.status===`regular`?l?r.threadIds:[...u,c]:u,p=t.status===`archived`?l?r.archivedThreadIds:[...d,c]:d;this._state.update({...r,threadIds:f,archivedThreadIds:p,threadIdMap:s,threadData:o}),i=this.getItemById(e)}if(!i)throw sH(e,`switching to it`);if(this._mainThreadId===i.id)return;let a=this._hookManager.startThreadRuntime(i.id);if(this.mainThreadId===void 0?a.then(()=>this._notifySubscribers(),()=>void 0):await a,n!==this._switchGeneration)return;let o=this.getItemById(i.id);o?.id===i.id&&(o.status===`archived`&&t?.unarchive!==!1&&(await o.initializeTask,n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)||o.status===`archived`&&(await this.unarchive(o.id),n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)))||(this._mainThreadId=o.id,this._notifySubscribers(),this._notifyThreadIdChange(r)))}switchToNewThread(){return this._startSwitchToNewThread(!0)}_switchToThreadFromProp(e){return e===void 0?this._startSwitchToNewThread(!1):this._startSwitchToThread(e,void 0,!1)}_startSwitchToNewThread(e){let t=++this._switchGeneration,n=this._switchToNewThread(t,e);return this._switchTask=n,n}async _switchToNewThread(e,t){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)if(await this._state.waitForUpdate(),e!==this._switchGeneration)return;let n=this._state.baseValue,r=this._state.value.newThreadId;if(r===void 0){let e=HV(n);r=e.id,this._state.update(e.state)}return this._switchToThread(r,void 0,e,t)}initialize=async e=>{let t=this._options.adapter,n=this._adapterGeneration;if(this._state.value.newThreadId!==e){this._requireAdapterSettled();let t=this.getItemById(e);if(!t)throw sH(e,`initializing it`);if(t.status===`new`)throw cH(e,t.status,`be initialized here`);let{remoteId:r,externalId:i}=await t.initializeTask;return this._requireAdapterGeneration(n),{remoteId:r,externalId:i}}this._requireAdapterGeneration(n);let r=t.initialize(e),i,{remoteId:a,externalId:o}=await this._state.optimisticUpdate({execute:()=>r,optimistic:t=>YV(t,e,r),then:(t,{remoteId:r,externalId:a})=>{if(n!==this._adapterGeneration)return t;let o=KV(t,e,r,a,e);return i=o.removedMappingId,i===this._mainThreadId&&(this._mainThreadId=o.survivorMappingId),o.state}});return this._requireAdapterGeneration(n),i!==void 0&&this._hookManager.stopThreadRuntime(i),{remoteId:a,externalId:o}};generateTitle=async(e,t)=>{this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw sH(e,`generating its title`);if(i.status===`new`)throw cH(e,i.status,`generate a title`);let{remoteId:a}=await i.initializeTask;this._requireAdapterGeneration(r);let o=this._hookManager.getThreadRuntimeCore(i.id);if(!o)return;let s=o.messages.filter(wV);await oH({states:this._titleStates,threadId:i.id,automatic:t?.automatic===!0,generate:async e=>{let t=await n.generateTitle(a,s);this._requireAdapterGeneration(r),await TV(t,e)},rename:async e=>{this._requireAdapterGeneration(r),await n.rename(a,e)},applyTitle:async e=>{await this._state.optimisticUpdate({execute:async()=>{},optimistic:t=>{if(r!==this._adapterGeneration)return t;let n=GV(t,i.id);return n?{...t,threadData:{...t.threadData,[n.id]:{...n,title:e}}}:t}})}})};async rename(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw sH(e,`renaming it`);if(i.status===`new`)throw cH(e,i.status,`be renamed`);let a=tH(this._titleStates,i.id,t);try{let o=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;return this._requireAdapterGeneration(r),n.rename(e,t)},optimistic:n=>{let r=GV(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,title:t}}}:n}});return nH(this._titleStates,i.id,a,!0),o}catch(e){throw nH(this._titleStates,i.id,a,!1),e}}async updateCustom(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw sH(e,`updating its custom metadata`);if(i.status===`new`)throw cH(e,i.status,`update custom metadata`);if(!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;if(this._requireAdapterGeneration(r),!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return n.updateCustom(e,t)},optimistic:n=>{let r=GV(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,custom:t}}}:n}})}async _ensureThreadIsNotMain(e){if(e===this.newThreadId)throw Error(`Cannot ensure new thread is not main`);let t;for(;e===this._mainThreadId;){let e=this._switchTask,n=!e||e===t;n&&(e=this.switchToNewThread()),t=e;try{await e}catch(t){if(n&&this._switchTask===e)throw t}}}async archive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw sH(e,`archiving it`);if(r.status!==`regular`)throw cH(e,r.status,`be archived`);return await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),t.archive(e)},optimistic:e=>JV(e,r.id,`archived`)})}async unarchive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw sH(e,`unarchiving it`);if(r.status!==`archived`)throw cH(e,r.status,`be unarchived`);return this._state.optimisticUpdate({execute:async()=>{try{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.unarchive(e)}catch(e){throw n===this._adapterGeneration&&await this._ensureThreadIsNotMain(r.id),e}},optimistic:e=>JV(e,r.id,`regular`)})}async delete(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw sH(e,`deleting it`);if(r.status!==`regular`&&r.status!==`archived`)throw cH(e,r.status,`be deleted`);await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n);let i=await this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.delete(e)},optimistic:e=>JV(e,r.id,`deleted`)});return this._hookManager.stopThreadRuntime(r.id),iH(this._titleStates,r.id),i}__internal_dispose(){this._hookManager.__internal_dispose()}async detach(e){let t=this._adapterGeneration,n=this.getItemById(e);if(!n)throw sH(e,`detaching it`);if(n.status!==`regular`&&n.status!==`archived`)throw cH(e,n.status,`be detached`);await this._ensureThreadIsNotMain(n.id),this._requireAdapterGeneration(t),this._hookManager.stopThreadRuntime(n.id)}boundIdsStore=new LF([]);__internal_RenderComponent=()=>{let e=NM();X(()=>(this.boundIdsStore.setState([...this.boundIdsStore.getState(),e]),()=>{this.boundIdsStore.setState(this.boundIdsStore.getState().filter(t=>t!==e))}),[e]);let t=rI(this.boundIdsStore),n=rI(this.providerStore),r=Q();return(t.length===0||t[0]===e)&&(0,P.jsxs)(DB,{adapters:this._runtimeAdapters,children:[(0,P.jsx)(this._hookManager.__internal_RenderThreadRuntimes,{provider:n}),(0,P.jsx)(this._hookManager.__internal_Host,{parentClient:r})]})}},dH=class extends zB{threads;constructor(e){super(),this.threads=new uH(e,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},fH=e=>{let t=J(18),n;t[0]===e?n=t[1]:(n=()=>new dH(e),t[0]=e,t[1]=n);let[r]=wM(n),i;t[2]===r.threads?i=t[3]:(i=()=>()=>queueMicrotask(()=>r.threads.__internal_dispose()),t[2]=r.threads,t[3]=i);let a;t[4]===r?a=t[5]:(a=[r],t[4]=r,t[5]=a),MM(i,a);let o;t[6]!==e||t[7]!==r.threads?(o=()=>{r.threads.__internal_setOptions(e),r.threads.__internal_load()},t[6]=e,t[7]=r.threads,t[8]=o):o=t[8];let s;t[9]!==e||t[10]!==r?(s=[r,e],t[9]=e,t[10]=r,t[11]=s):s=t[11],X(o,s);let c;t[12]===r.threads?c=t[13]:(c=()=>{if(typeof window>`u`||typeof document>`u`)return;let e=()=>{r.threads.loadError!==void 0&&r.threads.reload()},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`online`,e),document.removeEventListener(`visibilitychange`,t)}},t[12]=r.threads,t[13]=c);let l;t[14]===r?l=t[15]:(l=[r],t[14]=r,t[15]=l),X(c,l);let u;return t[16]===r?u=t[17]:(u=new PB(r),t[16]=r,t[17]=u),u},pH=e=>{let[t]=wM(()=>new LF(e.runtimeHook));OM(()=>{t.setState(e.runtimeHook)},[t,e.runtimeHook]);let n=Y(e.initialThreadId),r=DM(function(){return rI({subscribe:t.subscribe,getState:t.getState,getServerSnapshot:t.getState})()},[t]),i=kM(t=>e.onThreadIdChange?.(t)),a=EM(()=>({adapter:e.adapter,allowNesting:e.allowNesting,threadId:e.threadId,initialThreadId:n.current,runtimeHook:r,onThreadIdChange:i}),[e.adapter,e.allowNesting,e.threadId,r]);if(Q().threadListItem.source!==null){if(!a.allowNesting)throw Error(`useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).`);return e.runtimeHook()}return fH(a)},mH=e=>{let t=J(6),{id:n,children:r}=e,i=Q(),a;t[0]===n?a=t[1]:(a=UN({message:CF({source:`thread`,query:{type:`id`,id:n},get:e=>e.thread.message({id:n})}),composer:CF({source:`message`,query:{},get:e=>e.thread.message({id:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,P.jsx)(ZI,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},hH=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,gH=()=>null,_H=new WeakMap,vH=(e,t)=>{let n=_H.get(e);return n||(n=new Set(e.map(e=>e.id)),_H.set(e,n)),n.has(t)},yH=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message??gH:e.SystemMessage??e.Message??gH;default:throw Error(`Unknown message role: ${t}`)}},bH=e=>{let t=J(6),{components:n}=e,r=$(EH),i=$(DH),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=yH(n,r,i),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3];let o=a,s;return t[4]===o?s=t[5]:(s=(0,P.jsx)(o,{}),t[4]=o,t[5]=s),s},xH=FM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(bH,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(Fz,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&hH(e.components,t.components));xH.displayName=`ThreadPrimitive.MessageByIndex`;var SH=FM(e=>{let t=J(7),{messageId:n,components:r}=e,i;if(t[0]===n?i=t[1]:(i=e=>vH(e.thread.messages,n),t[0]=n,t[1]=i),!$(i))return null;let a;t[2]===r?a=t[3]:(a=(0,P.jsx)(bH,{components:r}),t[2]=r,t[3]=a);let o;return t[4]!==n||t[5]!==a?(o=(0,P.jsx)(mH,{id:n,children:a}),t[4]=n,t[5]=a,t[6]=o):o=t[6],o},(e,t)=>e.messageId===t.messageId&&hH(e.components,t.components));SH.displayName=`ThreadPrimitive.Unstable_MessageById`;var CH=({children:e})=>{let t=$(XP(e=>e.thread.messages.map(e=>e.id)));return EM(()=>t.length===0?null:t.map((t,n)=>(0,P.jsx)(Fz,{index:n,children:(0,P.jsx)(eL,{getItemState:e=>e.thread.message({index:n}).getState(),children:t=>e({get message(){return t()}})})},t)),[t,e])},wH=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(CH,{children:()=>(0,P.jsx)(bH,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(CH,{children:r}),t[2]=r,t[3]=i),i};wH.displayName=`ThreadPrimitive.Messages`;var TH=FM(wH,(e,t)=>e.children||t.children?e.children===t.children:hH(e.components,t.components));function EH(e){return e.message.role}function DH(e){return e.message.composer.isEditing}var OH=e=>{let t=e.message.metadata;if(t&&typeof t==`object`)return t.custom?.quote},kH=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},AH=e=>typeof e==`object`&&!!e,jH=e=>e==null?[]:Array.isArray(e)?e:[e],MH=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!AH(e)||!(`component`in e)||typeof e.component!=`string`)return null;let{component:i,props:a,children:o,key:s}=e,c=t[i];if(!c){if(n)return(0,P.jsx)(n,{component:i,props:a},s??r);throw new kH(i)}return LM(c,{...a??{},key:s??r},...jH(o).map((e,i)=>MH(e,t,n,`${r}/${i}`)))},NH=e=>{let t=J(11),{spec:n,components:r,Fallback:i}=e,a=n?.root,o;t[0]===a?o=t[1]:(o=jH(a),t[0]=a,t[1]=o);let s=o,c;if(t[2]!==i||t[3]!==r||t[4]!==s){let e;t[6]!==i||t[7]!==r?(e=(e,t)=>MH(e,r,i,`${t}`),t[6]=i,t[7]=r,t[8]=e):e=t[8],c=s.map(e),t[2]=i,t[3]=r,t[4]=s,t[5]=c}else c=t[5];let l;return t[9]===c?l=t[10]:(l=(0,P.jsx)(P.Fragment,{children:c}),t[9]=c,t[10]=l),l};NH.displayName=`GenerativeUIRender`;var PH=e=>{let t=J(4),{components:n,spec:r,Fallback:i}=e,a=$(FH),o=r??a;if(!o)return null;let s;return t[0]!==i||t[1]!==n||t[2]!==o?(s=(0,P.jsx)(NH,{spec:o,components:n,Fallback:i}),t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3],s};PH.displayName=`MessagePrimitive.GenerativeUI`;function FH(e){let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}var IH=e=>{let t=-1;return{startGroup:e=>{t===-1&&(t=e)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},LH=(e,t,n)=>{let r=[];if(t){let t=IH(`chainOfThoughtGroup`);for(let n=0;n<e.length;n++){let i=e[n];i===`tool-call`||i===`reasoning`?t.startGroup(n):(t.endGroup(n-1,r),r.push({type:`single`,index:n}))}t.finalize(e.length-1,r)}else{let t=IH(`toolGroup`),n=IH(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(n.endGroup(i-1,r),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,r),n.startGroup(i)):(t.endGroup(i-1,r),n.endGroup(i-1,r),r.push({type:`single`,index:i}))}t.finalize(e.length-1,r),n.finalize(e.length-1,r)}if(n){let e=new Set;for(let t of r){if(t.type===`single`)continue;let r=n[t.startIndex];r!==void 0&&!e.has(r)&&(e.add(r),t.idKey=`id:${r}`)}}return r},RH=e=>{let t=J(10),n=$(XP(cU)),r=$(XP(uU)),i;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n={ranges:e,partIds:r},t[1]=r,t[2]=n),i=n;break bb0}let a;t[3]!==n||t[4]!==r||t[5]!==e?(a=LH(n,e,r),t[3]=n,t[4]=r,t[5]=e,t[6]=a):a=t[6];let o;t[7]!==r||t[8]!==a?(o={ranges:a,partIds:r},t[7]=r,t[8]=a,t[9]=o):o=t[9],i=o}return i},zH=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},BH=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),VH=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>BH(e.dataRenderers,r.name,n),t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},HH={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},UH=e=>{let t=J(41),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d,generativeUI:f}=r,p=i===void 0?HH.Text:i,m=a===void 0?HH.Reasoning:a,h=o===void 0?HH.Image:o,g=s===void 0?HH.Source:s,_=c===void 0?HH.File:c,v=l===void 0?HH.Unstable_Audio:l,y;t[2]===u?y=t[3]:(y=u===void 0?{}:u,t[2]=u,t[3]=y);let b=y,x=Q(),S=$(dU),C=S.type;if(C===`tool-call`){let e=x.part.addToolResult,n=x.part.resumeToolCall,r=x.part.respondToToolApproval;if(`Override`in b){let i;return t[4]!==e||t[5]!==S||t[6]!==r||t[7]!==n||t[8]!==b.Override?(i=(0,P.jsx)(b.Override,{...S,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=S,t[6]=r,t[7]=n,t[8]=b.Override,t[9]=i):i=t[9],i}let i=b.by_name?.[S.toolName]??b.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==S||t[13]!==r||t[14]!==n?(a=(0,P.jsx)(zH,{...S,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=S,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(S.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(C){case`text`:{let e;return t[16]!==p||t[17]!==S?(e=(0,P.jsx)(p,{...S}),t[16]=p,t[17]=S,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==m||t[20]!==S?(e=(0,P.jsx)(m,{...S}),t[19]=m,t[20]=S,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==g||t[23]!==S?(e=(0,P.jsx)(g,{...S}),t[22]=g,t[23]=S,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==h||t[26]!==S?(e=(0,P.jsx)(h,{...S}),t[25]=h,t[26]=S,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==_||t[29]!==S?(e=(0,P.jsx)(_,{...S}),t[28]=_,t[29]=S,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==v||t[32]!==S?(e=(0,P.jsx)(v,{...S}),t[31]=v,t[32]=S,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[S.name]??d?.Fallback,n;return t[34]!==e||t[35]!==S?(n=(0,P.jsx)(VH,{...S,Fallback:e}),t[34]=e,t[35]=S,t[36]=n):n=t[36],n}case`generative-ui`:{if(!f?.components)return null;let e=S,n;return t[37]!==f.Fallback||t[38]!==f.components||t[39]!==e.spec?(n=(0,P.jsx)(NH,{spec:e.spec,components:f.components,Fallback:f.Fallback}),t[37]=f.Fallback,t[38]=f.components,t[39]=e.spec,t[40]=n):n=t[40],n}default:return console.warn(`Unknown message part type: ${C}`),null}},WH=FM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(UH,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(Iz,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);WH.displayName=`MessagePrimitive.PartByIndex`;var GH=e=>{let t=J(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,P.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,P.jsx)(Rz,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},KH=Object.freeze({type:`complete`}),qH=Object.freeze({type:`running`}),JH=FM(e=>{let t=J(6),{components:n}=e,r=$(fU);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,P.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}if(r.type!==`running`)return null;let i=n?.Text??HH.Text,a;return t[3]!==r||t[4]!==i?(a=(0,P.jsx)(GH,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),YH=FM(e=>{let t=J(4),{components:n,enabled:r}=e,i;if(t[0]===r?i=t[1]:(i=e=>{if(!r||e.message.parts.length===0)return!1;let t=e.message.parts[e.message.parts.length-1];return t?.type!==`text`&&t?.type!==`reasoning`},t[0]=r,t[1]=i),!$(i))return null;let a;return t[2]===n?a=t[3]:(a=(0,P.jsx)(JH,{components:n}),t[2]=n,t[3]=a),a},(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),XH=FM(e=>{let t=J(4),{Quote:n}=e,r=$(OH);if(!r)return null;let i;return t[0]!==n||t[1]!==r.messageId||t[2]!==r.text?(i=(0,P.jsx)(n,{text:r.text,messageId:r.messageId}),t[0]=n,t[1]=r.messageId,t[2]=r.text,t[3]=i):i=t[3],i});function ZH(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(fB(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var QH=()=>{let e=J(6),t=Q(),n=$(pU),r=$(mU);if(!r||n.type!==`tool-call`)return null;let i;return e[0]!==r||e[1]!==t.part.addToolResult||e[2]!==t.part.respondToToolApproval||e[3]!==t.part.resumeToolCall||e[4]!==n?(i=(0,P.jsx)(r,{...n,addResult:t.part.addToolResult,resume:t.part.resumeToolCall,respondToApproval:t.part.respondToToolApproval}),e[0]=r,e[1]=t.part.addToolResult,e[2]=t.part.respondToToolApproval,e[3]=t.part.resumeToolCall,e[4]=n,e[5]=i):i=e[5],i},$H=()=>{let e=J(3),t=$(hU),n=$(gU);if(!n||t.type!==`data`)return null;let r=t,i;return e[0]!==n||e[1]!==r?(i=(0,P.jsx)(n,{...r}),e[0]=n,e[1]=r,e[2]=i):i=e[2],i},eU=()=>{let e=J(2),t=$(_U);if(t===`tool-call`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(QH,{}),e[0]=t):t=e[0],t}if(t===`data`){let t;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)($H,{}),e[1]=t):t=e[1],t}return null},tU=Object.freeze({type:`text`,text:``,status:qH}),nU=({children:e})=>{let t=Q(),n=$(e=>e.dataRenderers);return(0,P.jsx)(eL,{getItemState:e=>e.part.getState(),children:r=>e({get part(){let e=r();if(e.type===`tool-call`){let n=ZH(t.tools.getState(),e)!==null,r=t.part;return{...e,toolUI:n?(0,P.jsx)(QH,{}):null,addResult:r.addToolResult,resume:r.resumeToolCall,respondToApproval:r.respondToToolApproval}}if(e.type===`data`){let t=BH(n,e.name,void 0)!==void 0;return{...e,dataRendererUI:t?(0,P.jsx)($H,{}):null}}return e}})})},rU=e=>{let t=J(5),{index:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(nU,{children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(Iz,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},iU=e=>{let t=J(9),{children:n}=e,r=$(vU),i=$(yU),a=r===0&&i;if(r===0){if(!a)return null;let e;t[0]===n?e=t[1]:(e=n({part:tU}),t[0]=n,t[1]=e);let r;return t[2]===e?r=t[3]:(r=(0,P.jsx)(Rz,{text:``,isRunning:!0,children:e}),t[2]=e,t[3]=r),r}let o;if(t[4]!==n||t[5]!==r){let e;t[7]===n?e=t[8]:(e=(e,t)=>(0,P.jsx)(rU,{index:t,children:e=>n(e)??(0,P.jsx)(eU,{})},t),t[7]=n,t[8]=e),o=(0,P.jsx)(P.Fragment,{children:Array.from({length:r},e)}),t[4]=n,t[5]=r,t[6]=o}else o=t[6];return o},aU=e=>{let t=J(5),{components:n,unstable_showEmptyOnNonTextEnd:r,children:i}=e,a=r===void 0||r;if(i){let e;return t[0]===i?e=t[1]:(e=(0,P.jsx)(iU,{children:i}),t[0]=i,t[1]=e),e}let o;return t[2]!==n||t[3]!==a?(o=(0,P.jsx)(oU,{components:n,unstable_showEmptyOnNonTextEnd:a}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o};aU.displayName=`MessagePrimitive.Parts`;var oU=e=>{let t=J(15),{components:n,unstable_showEmptyOnNonTextEnd:r}=e,i=$(bU),{ranges:a,partIds:o}=RH(!!n?.ChainOfThought),s;bb0:{if(i===0){let e;t[0]===n?e=t[1]:(e=(0,P.jsx)(JH,{components:n}),t[0]=n,t[1]=e),s=e;break bb0}let e;if(t[2]!==n||t[3]!==a||t[4]!==o){let r=new Set,i=e=>{let t=o[e];return t!==void 0&&!r.has(t)?(r.add(t),`part-id:${t}`):`part-${e}`};e=a.map(e=>{if(e.type===`single`)return(0,P.jsx)(WH,{index:e.index,components:n},e.index);if(e.type===`chainOfThoughtGroup`){let t=n?.ChainOfThought;return t?(0,P.jsx)(Gz,{startIndex:e.startIndex,endIndex:e.endIndex,children:(0,P.jsx)(t,{})},`chainOfThought-${e.idKey??e.startIndex}`):null}if(e.type===`toolGroup`){let t=n?.ToolGroup??HH.ToolGroup;return(0,P.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let a=e.startIndex+r;return(0,P.jsx)(WH,{index:a,components:n},i(a))})},`tool-${e.idKey??e.startIndex}`)}{let t=n?.ReasoningGroup??HH.ReasoningGroup;return(0,P.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let i=e.startIndex+r;return(0,P.jsx)(WH,{index:i,components:n},`part-${i}`)})},`reasoning-${e.startIndex}`)}}),t[2]=n,t[3]=a,t[4]=o,t[5]=e}else e=t[5];s=e}let c=s,l;t[6]===n?l=t[7]:(l=n?.Quote&&(0,P.jsx)(XH,{Quote:n.Quote}),t[6]=n,t[7]=l);let u;t[8]!==n||t[9]!==r?(u=(0,P.jsx)(YH,{components:n,enabled:r}),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==l||t[13]!==u?(d=(0,P.jsxs)(P.Fragment,{children:[l,c,u]}),t[11]=c,t[12]=l,t[13]=u,t[14]=d):d=t[14],d};function sU(e){return e.type}function cU(e){return e.message.parts.map(sU)}function lU(e){return e.type===`tool-call`?e.toolCallId:void 0}function uU(e){return e.message.parts.map(lU)}function dU(e){return e.part}function fU(e){return e.message.status??KH}function pU(e){return e.part}function mU(e){return e.part.type===`tool-call`?ZH(e.tools,e.part):null}function hU(e){return e.part}function gU(e){return e.part.type===`data`?BH(e.dataRenderers,e.part.name,void 0)??null:null}function _U(e){return e.part.type}function vU(e){return e.message.parts.length}function yU(e){return(e.message.status?.type??`complete`)===`running`}function bU(e){return e.message.parts.length}var xU=Symbol.for(`@assistant-ui/groupBy.memoKey`),SU=e=>{let t=e,n=((e,n)=>{if(e.type===`tool-call`){if((fB(e.mcp?.app?.resourceUri)||(n?.toolUIs?.[e.toolName]?.[0]?.standalone??!1))&&t[`standalone-tool-call`]!==void 0)return t[`standalone-tool-call`];let r=t[`tool-call:${e.toolName}`];return r===void 0?t[`tool-call`]??[]:r}return t[e.type]??[]}),r=Object.keys(e).sort().map(t=>[t,e[t]]);return n[xU]=`groupPartByType:${JSON.stringify(r)}`,n},CU=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},wU=(e,t)=>{if(!(t===void 0||e.claimed.has(t)))return e.claimed.add(t),`id:${t}`},TU=(e,t)=>{let n={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0,claimed:new Set},r=[n],i=()=>{let e=r.pop(),n=r[r.length-1];n.children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,idKey:wU(n,t?.[e.indices[0]]),indices:e.indices,children:e.children})};for(let n=0;n<e.length;n++){let a=e[n],o=0;for(;o<r.length-1&&o<a.length&&r[o+1].key===a[o];)o++;for(;r.length-1>o;)i();for(;r.length-1<a.length;){let e=r[r.length-1];r.push({key:a[r.length-1],nodeKey:CU(e),indices:[],children:[],nextChildIdx:0,claimed:new Set})}let s=r[r.length-1];s.children.push({type:`part`,index:n,nodeKey:CU(s),idKey:wU(s,t?.[n])});for(let e=1;e<r.length;e++)r[e].indices.push(n)}for(;r.length>1;)i();return n.children},EU=(e,t,n)=>{if(!n)return!1;switch(e){case`never`:return!1;case`always`:return!0;case`empty`:return t.length===0;case`no-text`:{let e=t[t.length-1];return e===void 0||e.type!==`text`&&e.type!==`reasoning`}}},DU=()=>{throw Error("MessagePrimitive.GroupedParts: rendered `children` under a leaf part. `children` is only meaningful for `group-…` cases — add a matching case for the part type or return `null` to skip it.")},OU=(e,t,n)=>{if(e.type===`part`)return(0,P.jsx)(rU,{index:e.index,children:({part:e})=>n({part:e,children:(0,P.jsx)(DU,{})})},e.idKey?`part-${e.idKey}`:`part-${e.index}`);let{status:r,counts:i}=Uz(t,e.indices),a={type:e.key,status:r,counts:i,indices:e.indices};return(0,P.jsx)(IM,{children:n({part:a,children:(0,P.jsx)(P.Fragment,{children:e.children.map(e=>OU(e,t,n))})})},e.idKey??e.nodeKey)},kU=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=$(XP(e=>e.message.parts)),i=$(e=>e.tools.toolUIs),a=$(e=>t!==`never`&&e.message.status?.type===`running`),o=EM(()=>{let t={toolUIs:i};return TU(r.map(n=>e(n,t)??[]),r.map(e=>e.type===`tool-call`?e.toolCallId:void 0))},[r,e[xU]??e,i]);return(0,P.jsxs)(P.Fragment,{children:[o.map(e=>OU(e,r,n)),EU(t,r,a)&&n({part:{type:`indicator`},children:(0,P.jsx)(DU,{})})]})};kU.displayName=`MessagePrimitive.GroupedParts`;var AU=FM(e=>{let t=J(5),{children:n}=e,r=$(OH);if(!r)return null;let i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,P.jsx)(P.Fragment,{children:i}),t[3]=i,t[4]=a),a});AU.displayName=`MessagePrimitive.Quote`;var jU=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},MU=e=>{let t=J(5),{components:n}=e,r=$(IU);if(!r)return null;let i=r,a;t[0]!==n||t[1]!==i?(a=jU(n,i),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a;if(!o)return null;let s;return t[3]===o?s=t[4]:(s=(0,P.jsx)(o,{}),t[3]=o,t[4]=s),s},NU=FM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(MU,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(Mz,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);NU.displayName=`MessagePrimitive.AttachmentByIndex`;var PU=({children:e})=>{let t=$(XP(e=>e.message.role===`user`?(e.message.attachments??[]).map(e=>e.id):[]));return EM(()=>t.map((t,n)=>(0,P.jsx)(Mz,{index:n,children:(0,P.jsx)(eL,{getItemState:e=>e.message.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},FU=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(PU,{children:e=>{let{attachment:t}=e,r=jU(n,t);return r?(0,P.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(PU,{children:r}),t[2]=r,t[3]=i),i};FU.displayName=`MessagePrimitive.Attachments`;function IU(e){return e.attachment}var LU=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},RU=e=>{let t=J(5),{components:n}=e,r=$(HU);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=LU(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;return t[3]===a?o=t[4]:(o=(0,P.jsx)(a,{}),t[3]=a,t[4]=o),o},zU=FM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(RU,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(Nz,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);zU.displayName=`ComposerPrimitive.AttachmentByIndex`;var BU=({children:e})=>{let t=$(XP(e=>e.composer.attachments.map(e=>e.id)));return EM(()=>t.map((t,n)=>(0,P.jsx)(Nz,{index:n,children:(0,P.jsx)(eL,{getItemState:e=>e.composer.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},VU=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(BU,{children:e=>{let{attachment:t}=e,r=LU(n,t);return r?(0,P.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)(BU,{children:r}),t[2]=r,t[3]=i),i};VU.displayName=`ComposerPrimitive.Attachments`;function HU(e){return e.attachment}var UU=FM(({children:e})=>{let t=$(XP(e=>e.composer.queue.map(e=>e.id)));return EM(()=>t.map((t,n)=>(0,P.jsx)(Yz,{index:n,children:(0,P.jsx)(eL,{getItemState:e=>e.composer.queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},t)),[t,e])});UU.displayName=`ComposerPrimitive.Queue`;var WU=FM(e=>{let t=J(6),{index:n,archived:r,components:i}=e,a=r!==void 0&&r,o=i.ThreadListItem,s;t[0]===o?s=t[1]:(s=(0,P.jsx)(o,{}),t[0]=o,t[1]=s);let c;return t[2]!==a||t[3]!==n||t[4]!==s?(c=(0,P.jsx)(qz,{index:n,archived:a,children:s}),t[2]=a,t[3]=n,t[4]=s,t[5]=c):c=t[5],c},(e,t)=>e.index===t.index&&e.archived===t.archived&&e.components.ThreadListItem===t.components.ThreadListItem);WU.displayName=`ThreadListPrimitive.ItemByIndex`;var GU=({archived:e,children:t})=>{let n=$(XP(t=>e?t.threads.archivedThreadIds:t.threads.threadIds));return EM(()=>n.map((n,r)=>(0,P.jsx)(qz,{index:r,archived:e,children:(0,P.jsx)(eL,{getItemState:t=>t.threads.item({index:r,archived:e}).getState(),children:e=>t({get threadListItem(){return e()}})})},n)),[n,e,t])},KU=e=>{let t=J(8),{archived:n,components:r,children:i}=e,a=n!==void 0&&n;if(r){let e=r.ThreadListItem,n;t[0]===e?n=t[1]:(n=()=>(0,P.jsx)(e,{}),t[0]=e,t[1]=n);let i;return t[2]!==a||t[3]!==n?(i=(0,P.jsx)(GU,{archived:a,children:n}),t[2]=a,t[3]=n,t[4]=i):i=t[4],i}let o;return t[5]!==a||t[6]!==i?(o=(0,P.jsx)(GU,{archived:a,children:i}),t[5]=a,t[6]=i,t[7]=o):o=t[7],o};KU.displayName=`ThreadListPrimitive.Items`;var qU=e=>{let{children:t}=e;return $(JU)?t:null};qU.displayName=`MessagePartPrimitive.InProgress`;function JU(e){return e.part.status.type===`running`}var YU=e=>{let t=J(2),{fallback:n}=e,r=$(XU)||n,i;return t[0]===r?i=t[1]:(i=(0,P.jsx)(P.Fragment,{children:r}),t[0]=r,t[1]=i),i};YU.displayName=`ThreadListItemPrimitive.Title`;function XU(e){return e.threadListItem.title}var ZU=e=>{let t=J(2),{components:n}=e,r=n.Suggestion,i;return t[0]===r?i=t[1]:(i=(0,P.jsx)(r,{}),t[0]=r,t[1]=i),i},QU=FM(e=>{let t=J(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(ZU,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(Jz,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);QU.displayName=`ThreadPrimitive.SuggestionByIndex`;var $U=({children:e})=>{let t=$(e=>e.suggestions.suggestions.length);return EM(()=>t===0?null:Array.from({length:t},(t,n)=>(0,P.jsx)(Jz,{index:n,children:(0,P.jsx)(eL,{getItemState:e=>e.suggestions.suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},eW=e=>{let t=J(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)($U,{children:()=>(0,P.jsx)(ZU,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,P.jsx)($U,{children:r}),t[2]=r,t[3]=i),i};eW.displayName=`ThreadPrimitive.Suggestions`;var tW=FM(eW,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),nW=e=>{let t=J(3),n;return t[0]!==e.dictation||t[1]!==e.editing?(n=t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;let n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)},t[0]=e.dictation,t[1]=e.editing,t[2]=n):n=t[2],$(n)},rW=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),nW(r)?n:null};rW.displayName=`ComposerPrimitive.If`;var iW=e=>!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue,aW=e=>!e.composer.canCancel,oW=e=>e.composer.isEditing||e.optional.thread?.voice!==void 0||e.optional.thread?.capabilities.edit===!1,sW=e=>e.thread.isRunning||e.thread.isDisabled||e.thread.voice!==void 0||e.message.role!==`assistant`||!e.thread.capabilities.reload,cW=e=>e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(e=>e.type===`text`&&e.text.length>0),lW=e=>e.message.branchNumber<=1||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,uW=e=>e.message.branchNumber>=e.message.branchCount||!e.thread.capabilities.switchToBranch||e.thread.isRunning&&!e.thread.capabilities.switchBranchDuringRun,dW=(e,t)=>e.thread.isDisabled||t&&e.thread.isRunning&&!e.thread.capabilities.queue,fW=e=>{if(e.message.status?.type!==`incomplete`||e.message.status.reason!==`error`)return;let t=e.message.status.error;return typeof t==`string`?t:typeof t==`object`&&t&&`message`in t&&typeof t.message==`string`?t.message:t??`An error occurred`},pW=e=>!e.threads.hasMore||e.threads.isLoading||e.threads.isLoadingMore,mW=()=>{let e=J(5),t=Q(),n=$(iW),r;e[0]===t?r=e[1]:(r=e=>{t.composer.send(e)},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={send:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},hW=()=>{let e=J(5),t=Q(),n=$(aW),r;e[0]===t?r=e[1]:(r=()=>{t.composer.cancel()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={cancel:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a},gW=()=>{let e=J(5),t=Q(),n=$(_W),r;e[0]===t?r=e[1]:(r=()=>{t.composer.startDictation()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={startDictation:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function _W(e){return e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing}var vW=()=>{let e=J(5),t=Q(),n=$(yW),r;e[0]===t?r=e[1]:(r=e=>t.composer.addAttachment(e),e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={addAttachment:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function yW(e){return!e.composer.isEditing}var bW=e=>{let t=J(15),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r,copyToClipboard:i}=n,a=r===void 0?3e3:r,o=Q(),s=$(cW),c=$(xW),l=$(SW),u=$(CW),d=Y(void 0),f=Y(0),p,m;t[2]===o?(p=t[3],m=t[4]):(p=()=>()=>{f.current+=1,d.current!==void 0&&(clearTimeout(d.current),d.current=void 0,o.message.setIsCopied(!1))},m=[o],t[2]=o,t[3]=p,t[4]=m),X(p,m);let h;t[5]!==o||t[6]!==u||t[7]!==a||t[8]!==i||t[9]!==l?(h=()=>{if(!i)return;let e=l?u:o.message.getCopyText();if(!e)return;let t=f.current,n;try{n=i(e)}catch{return}Promise.resolve(n).then(()=>{t===f.current&&(d.current!==void 0&&clearTimeout(d.current),o.message.setIsCopied(!0),d.current=setTimeout(()=>{d.current=void 0,o.message.setIsCopied(!1)},a))},wW)},t[5]=o,t[6]=u,t[7]=a,t[8]=i,t[9]=l,t[10]=h):h=t[10];let g=h,_=s||!i,v;return t[11]!==g||t[12]!==c||t[13]!==_?(v={copy:g,disabled:_,isCopied:c},t[11]=g,t[12]=c,t[13]=_,t[14]=v):v=t[14],v};function xW(e){return e.message.isCopied}function SW(e){return e.composer.isEditing}function CW(e){return e.composer.text}function wW(){}var TW=()=>{let e=J(5),t=Q(),n=$(oW),r;e[0]===t?r=e[1]:(r=()=>{t.composer.beginEdit()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={edit:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},EW=()=>{let e=J(5),t=Q(),n=$(sW),r;e[0]===t?r=e[1]:(r=()=>{t.message.reload()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={reload:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},DW=()=>{let e=J(5),t=Q(),n=$(kW),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`positive`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},OW=()=>{let e=J(5),t=Q(),n=$(AW),r;e[0]===t?r=e[1]:(r=()=>{t.message.submitFeedback({type:`negative`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function kW(e){return e.message.metadata.submittedFeedback?.type===`positive`}function AW(e){return e.message.metadata.submittedFeedback?.type===`negative`}var jW=()=>{let e=J(5),t=Q(),n=$(NW),r;e[0]===t?r=e[1]:(r=async()=>{t.message.speak()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={speak:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function MW(e){return e.type===`text`&&e.text.length>0}function NW(e){return e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(MW)}var PW=()=>{let e=J(5),t=Q(),n=$(FW),r;e[0]===t?r=e[1]:(r=()=>{t.message.stopSpeaking()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={stopSpeaking:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function FW(e){return e.message.speech==null}var IW=()=>{let e=J(5),t=Q(),n=$(uW),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`next`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={next:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},LW=()=>{let e=J(5),t=Q(),n=$(lW),r;e[0]===t?r=e[1]:(r=()=>{t.message.switchToBranch({position:`previous`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={previous:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},RW=e=>{let t=J(10),{prompt:n,send:r,clearComposer:i}=e,a=i===void 0||i,o=Q(),s=r??!1,c;t[0]===s?c=t[1]:(c=e=>dW(e,s),t[0]=s,t[1]=c);let l=$(c),u;t[2]!==o||t[3]!==a||t[4]!==n||t[5]!==s?(u=()=>{if(s){let{isRunning:e,capabilities:t}=o.thread.getState();if(e&&!t.queue)return;o.thread.append({content:[{type:`text`,text:n}],runConfig:o.composer.getState().runConfig}),a&&!e&&o.composer.setText(``)}else if(a)o.composer.setText(n);else{let e=o.composer.getState().text;o.composer.setText([e,n].filter(zW).join(` `))}},t[2]=o,t[3]=a,t[4]=n,t[5]=s,t[6]=u):u=t[6];let d=u,f;return t[7]!==l||t[8]!==d?(f={trigger:d,disabled:l},t[7]=l,t[8]=d,t[9]=f):f=t[9],f};function zW(e){return e.trim()}var BW=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.archive()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={archive:r},e[2]=r,e[3]=i),i},VW=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.delete()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={delete:r},e[2]=r,e[3]=i),i},HW=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.unarchive()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={unarchive:r},e[2]=r,e[3]=i),i},UW=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threadListItem.switchTo()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchTo:r},e[2]=r,e[3]=i),i},WW=()=>{let e=J(4),t=Q(),n;e[0]===t?n=e[1]:(n=()=>{t.threads.switchToNewThread()},e[0]=t,e[1]=n);let r=n,i;return e[2]===r?i=e[3]:(i={switchToNewThread:r},e[2]=r,e[3]=i),i},GW=()=>{let e=J(5),t=Q(),n=$(pW),r;e[0]===t?r=e[1]:(r=()=>{t.threads.loadMore()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={loadMore:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},KW=()=>$(fW),qW=e=>{let{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,unstable_enableMessageQueue:o,unstable_queueClearOnRewind:s,unstable_queueClearOnCancel:c,...l}=e;return{localRuntimeOptions:{cloud:t,initialMessages:n,maxSteps:r,adapters:i,unstable_humanToolNames:a,unstable_enableMessageQueue:o,unstable_queueClearOnRewind:s,unstable_queueClearOnCancel:c},otherOptions:l}};function JW(e,t){function n(n){let r=HM(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function YW(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var XW=BM(null),{useThreadViewport:ZW,useThreadViewportStore:QW}=YW(JW(XW,`ThreadPrimitive.Viewport`),`useThreadViewport`),$W=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},eG=(e=>e?$W(e):$W),tG=e=>e;function nG(e,t=tG){let n=N.useSyncExternalStore(e.subscribe,N.useCallback(()=>t(e.getState()),[e,t]),N.useCallback(()=>t(e.getInitialState()),[e,t]));return N.useDebugValue(n),n}var rG=e=>{let t=eG(e),n=e=>nG(t,e);return Object.assign(n,t),n},iG=(e=>e?rG(e):rG),aG=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},oG=(e={})=>{let t=new Set,n=aG(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=aG(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=iG(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{HN(t,()=>({behavior:e}),`Thread viewport`)},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},sG=e=>e,cG=e=>{let t=J(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=QW(n),i;t[1]===e?i=t[2]:(i=()=>oG(e),t[1]=e,t[2]=i);let[a]=wM(i),o,s;t[3]!==r||t[4]!==a?(o=()=>r?.getState().onScrollToBottom(e=>{a.getState().scrollToBottom(e)}),s=[r,a],t[3]=r,t[4]=a,t[5]=o,t[6]=s):(o=t[5],s=t[6]),X(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&sG(r).setState({isAtBottom:e.isAtBottom})})},l=[a,r],t[7]=r,t[8]=a,t[9]=c,t[10]=l):(c=t[9],l=t[10]),X(c,l),a},lG=e=>{let t=J(7),{children:n,options:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?{}:r,t[0]=r,t[1]=i);let a=cG(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=wM(o),c;return t[4]!==n||t[5]!==s?(c=(0,P.jsx)(XW.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},uG=()=>{let e=J(3),t=Q(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),X(n,r),null},dG=FM(e=>{let t=J(8),{children:n,aui:r,config:i,runtime:a}=e,o=r??null,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,P.jsx)(uG,{}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,P.jsx)(lG,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==c?(l=(0,P.jsxs)(aL,{runtime:a,aui:o,config:i,children:[s,c]}),t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l):l=t[7],l}),fG=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,pG={serialize(e){let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let r of e.matchAll(fG)){r.index>n&&t.push({kind:`text`,text:e.slice(n,r.index)});let i=r[2];t.push({kind:`mention`,type:r[1],label:i,id:r[3]??i}),n=r.index+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}},mG=Object.defineProperty,hG=(e,t)=>mG(e,`name`,{value:t,configurable:!0});function gG(e,t=globalThis?.document){let n=on(e);N.useEffect(()=>{let e=hG(e=>{e.key===`Escape`&&n(e)},`handleKeyDown`);return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}hG(gG,`useEscapeKeydown`);var _G=f;_G.dispatchDiscreteCustomEvent=v,_G.Root=f;var vG=Object.defineProperty,yG=(e,t)=>{let n={};for(var r in e)vG(n,r,{get:e[r],enumerable:!0});return t||vG(n,Symbol.toStringTag,{value:`Module`}),n},bG=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function xG(e,t){return RM(e,void 0,t===void 0?e.props.children:t)}function SG(e,t,n){return(0,P.jsx)(c,{...n,children:xG(e,t)})}function CG(e){let t=Z((t,n)=>{let r=J(17),i,a,o,s;r[0]===t?(i=r[1],a=r[2],o=r[3],s=r[4]):({render:o,asChild:i,children:a,...s}=t,r[0]=t,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=e;if(o&&zM(o)){let e=s,t;r[5]!==a||r[6]!==o?(t=xG(o,a),r[5]=a,r[6]=o,r[7]=t):t=r[7];let i;return r[8]!==n||r[9]!==e||r[10]!==t?(i=(0,P.jsx)(c,{...e,asChild:!0,ref:n,children:t}),r[8]=n,r[9]=e,r[10]=t,r[11]=i):i=r[11],i}let l=s,u;return r[12]!==i||r[13]!==a||r[14]!==n||r[15]!==l?(u=(0,P.jsx)(c,{...l,asChild:i,ref:n,children:a}),r[12]=i,r[13]=a,r[14]=n,r[15]=l,r[16]=u):u=r[16],u});return t.displayName=typeof e==`string`?e:e.displayName??e.name??`Component`,t}function wG(e){let t=_G[e],n=CG(t);return n.displayName=`Primitive.${e}`,n}var TG=bG.reduce((e,t)=>(e[t]=wG(t),e),{}),EG={Hidden:`hidden`,Floating:`floating`,Normal:`normal`},DG=e=>{let t=J(5),{hideWhenRunning:n,autohide:r,autohideFloat:i,forceVisible:a}=e,o;return t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(o=e=>{if(n&&e.thread.isRunning)return EG.Hidden;let t=r===`always`||r===`not-last`&&!e.message.isLast,o=a||e.message.isHovering;return t?o?i===`always`||i===`single-branch`&&e.message.branchCount<=1?EG.Floating:EG.Normal:EG.Hidden:EG.Normal},t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=o):o=t[4],$(o)},OG=BM(null),kG=()=>HM(OG),AG=Z((e,t)=>{let n=J(18),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({hideWhenRunning:a,autohide:r,autohideFloat:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let[s,c]=wM(0),l;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=!1;return c(jG),()=>{e||(e=!0,c(MG))}},n[5]=l):l=n[5];let u=l,d;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(d={acquireInteractionLock:u},n[6]=d):d=n[6];let f=d,p=s>0,m;n[7]!==r||n[8]!==i||n[9]!==a||n[10]!==p?(m={hideWhenRunning:a,autohide:r,autohideFloat:i,forceVisible:p},n[7]=r,n[8]=i,n[9]=a,n[10]=p,n[11]=m):m=n[11];let h=DG(m);if(h===EG.Hidden)return null;let g;n[12]===h?g=n[13]:(g=h===EG.Floating?{"data-floating":`true`}:null,n[12]=h,n[13]=g);let _;return n[14]!==t||n[15]!==o||n[16]!==g?(_=(0,P.jsx)(OG.Provider,{value:f,children:(0,P.jsx)(TG.div,{...g,...o,ref:t})}),n[14]=t,n[15]=o,n[16]=g,n[17]=_):_=n[17],_});AG.displayName=`ActionBarPrimitive.Root`;function jG(e){return e+1}function MG(e){return Math.max(0,e-1)}var NG=e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r}=n,i=r===void 0?3e3:r,a;t[2]===i?a=t[3]:(a={copiedDuration:i,copyToClipboard:FG},t[2]=i,t[3]=a);let{copy:o,disabled:s}=bW(a);return s?null:o},PG=Z((e,t)=>{let n=J(20),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({copiedDuration:r,onClick:a,disabled:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=$(IG),c;n[5]===r?c=n[6]:(c={copiedDuration:r},n[5]=r,n[6]=c);let l=NG(c),u;n[7]===s?u=n[8]:(u=s?{"data-copied":`true`}:{},n[7]=s,n[8]=u);let d=i||!l,f;n[9]===l?f=n[10]:(f=()=>{l?.()},n[9]=l,n[10]=f);let p;n[11]!==a||n[12]!==f?(p=F(a,f),n[11]=a,n[12]=f,n[13]=p):p=n[13];let m;return n[14]!==t||n[15]!==o||n[16]!==u||n[17]!==d||n[18]!==p?(m=(0,P.jsx)(TG.button,{type:`button`,...u,...o,ref:t,disabled:d,onClick:p}),n[14]=t,n[15]=o,n[16]=u,n[17]=d,n[18]=p,n[19]=m):m=n[19],m});PG.displayName=`ActionBarPrimitive.Copy`;function FG(e){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API is unavailable`)):navigator.clipboard.writeText(e)}function IG(e){return e.message.isCopied}var LG=(e,t,n=[])=>{let r=Z((e,r)=>{let i=J(6),a={},o={};Object.keys(e).forEach(t=>{n.includes(t)?a[t]=e[t]:o[t]=e[t]});let s=t(a)??void 0,c=TG,l=o.disabled||!s,u=F(o.onClick,s),d;return i[0]!==r||i[1]!==o||i[2]!==c.button||i[3]!==l||i[4]!==u?(d=(0,P.jsx)(c.button,{type:`button`,...o,ref:r,disabled:l,onClick:u}),i[0]=r,i[1]=o,i[2]=c.button,i[3]=l,i[4]=u,i[5]=d):d=i[5],d});return r.displayName=e,r},RG=LG(`ActionBarPrimitive.Reload`,()=>{let{disabled:e,reload:t}=EW();return e?null:t}),zG=LG(`ActionBarPrimitive.Edit`,()=>{let{disabled:e,edit:t}=TW();return e?null:t}),BG=LG(`ActionBarPrimitive.Speak`,()=>{let{disabled:e,speak:t}=jW();return e?null:t}),VG=()=>{let{disabled:e,stopSpeaking:t}=PW();return e?null:t},HG=Z((e,t)=>{let n=J(10),r=VG(),i=!r,a;n[0]===r?a=n[1]:(a=()=>{r?.()},n[0]=r,n[1]=a);let o;n[2]!==e.onClick||n[3]!==a?(o=F(e.onClick,a),n[2]=e.onClick,n[3]=a,n[4]=o):o=n[4];let s;return n[5]!==e||n[6]!==t||n[7]!==i||n[8]!==o?(s=(0,P.jsx)(TG.button,{type:`button`,disabled:i,...e,ref:t,onClick:o}),n[5]=e,n[6]=t,n[7]=i,n[8]=o,n[9]=s):s=n[9],s});HG.displayName=`ActionBarPrimitive.StopSpeaking`;var UG=()=>{let{submit:e}=DW();return e},WG=Z((e,t)=>{let n=J(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(GG),s=UG(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=F(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,P.jsx)(TG.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});WG.displayName=`ActionBarPrimitive.FeedbackPositive`;function GG(e){return e.message.metadata.submittedFeedback?.type===`positive`}var KG=()=>{let{submit:e}=OW();return e},qG=Z((e,t)=>{let n=J(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(JG),s=KG(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=F(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,P.jsx)(TG.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});qG.displayName=`ActionBarPrimitive.FeedbackNegative`;function JG(e){return e.message.metadata.submittedFeedback?.type===`negative`}var YG=e=>{let t=J(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{filename:r,onExport:i}=n,a=Q(),o=$(QG),s;return t[2]!==a.message||t[3]!==r||t[4]!==i?(s=async()=>{let e=a.message.getCopyText();if(!e)return;if(i){await i(e);return}let t=new Blob([e],{type:`text/markdown`}),n=URL.createObjectURL(t),o=document.createElement(`a`);o.href=n,o.download=r??`message-${Date.now()}.md`,o.click(),setTimeout(()=>URL.revokeObjectURL(n),4e4)},t[2]=a.message,t[3]=r,t[4]=i,t[5]=s):s=t[5],o?s:null},XG=Z((e,t)=>{let n=J(19),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({filename:i,onExport:o,onClick:a,disabled:r,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let c;n[6]!==i||n[7]!==o?(c={filename:i,onExport:o},n[6]=i,n[7]=o,n[8]=c):c=n[8];let l=YG(c),u=r||!l,d;n[9]===l?d=n[10]:(d=()=>{l?.().catch($G)},n[9]=l,n[10]=d);let f;n[11]!==a||n[12]!==d?(f=F(a,d),n[11]=a,n[12]=d,n[13]=f):f=n[13];let p;return n[14]!==t||n[15]!==s||n[16]!==u||n[17]!==f?(p=(0,P.jsx)(TG.button,{type:`button`,...s,ref:t,disabled:u,onClick:f}),n[14]=t,n[15]=s,n[16]=u,n[17]=f,n[18]=p):p=n[18],p});XG.displayName=`ActionBarPrimitive.ExportMarkdown`;function ZG(e){return e.type===`text`&&e.text.length>0}function QG(e){return(e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(ZG)}function $G(e){console.error(`[assistant-ui] markdown export failed:`,e)}var eK=yG({Copy:()=>PG,Edit:()=>zG,ExportMarkdown:()=>XG,FeedbackNegative:()=>qG,FeedbackPositive:()=>WG,Reload:()=>RG,Root:()=>AG,Speak:()=>BG,StopSpeaking:()=>HG}),tK=nu(),nK=e=>{let t=J(25),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({__scopeActionBarMore:n,open:i,onOpenChange:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=tK(n),s=kG(),c=Y(null),l=i!==void 0,u;t[5]===s?u=t[6]:(u=e=>{if(e){if(c.current)return;c.current=s?.acquireInteractionLock()??null;return}c.current?.(),c.current=null},t[5]=s,t[6]=u);let d=u,f;t[7]!==l||t[8]!==r||t[9]!==d?(f=e=>{l||d(e),r?.(e)},t[7]=l,t[8]=r,t[9]=d,t[10]=f):f=t[10];let p=f,m,h;t[11]!==l||t[12]!==i||t[13]!==d?(m=()=>{l&&d(!!i)},h=[l,i,d],t[11]=l,t[12]=i,t[13]=d,t[14]=m,t[15]=h):(m=t[14],h=t[15]),X(m,h);let g,_;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>()=>{c.current?.(),c.current=null},_=[],t[16]=g,t[17]=_):(g=t[16],_=t[17]),X(g,_);let v;t[18]===i?v=t[19]:(v=i===void 0?null:{open:i},t[18]=i,t[19]=v);let y;return t[20]!==p||t[21]!==a||t[22]!==o||t[23]!==v?(y=(0,P.jsx)(wu,{...o,...a,...v,onOpenChange:p}),t[20]=p,t[21]=a,t[22]=o,t[23]=v,t[24]=y):y=t[24],y};nK.displayName=`ActionBarMorePrimitive.Root`;var rK=CG(Tu),iK=CG(Du),aK=CG(Au),oK=CG(Fu),sK=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=tK(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(rK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});sK.displayName=`ActionBarMorePrimitive.Trigger`;var cK=Z((e,t)=>{let n=J(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({__scopeActionBarMore:r,portalProps:i,sideOffset:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?4:o,c=tK(r),l;n[5]!==t||n[6]!==a||n[7]!==c||n[8]!==s?(l=(0,P.jsx)(iK,{...c,...a,ref:t,sideOffset:s}),n[5]=t,n[6]=a,n[7]=c,n[8]=s,n[9]=l):l=n[9];let u;return n[10]!==i||n[11]!==c||n[12]!==l?(u=(0,P.jsx)(Eu,{...c,...i,children:l}),n[10]=i,n[11]=c,n[12]=l,n[13]=u):u=n[13],u});cK.displayName=`ActionBarMorePrimitive.Content`;var lK=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=tK(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(aK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});lK.displayName=`ActionBarMorePrimitive.Item`;var uK=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=tK(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(oK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});uK.displayName=`ActionBarMorePrimitive.Separator`;var dK=yG({Content:()=>cK,Item:()=>lK,Root:()=>nK,Separator:()=>uK,Trigger:()=>sK}),fK=Z((e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=(0,P.jsx)(TG.div,{...e,ref:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});fK.displayName=`AttachmentPrimitive.Root`;var pK=Z((e,t)=>{let n=J(4),r=$(mK),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(TG.div,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});pK.displayName=`AttachmentPrimitive.unstable_Thumb`;function mK(e){let t=e.attachment.name,n=t.lastIndexOf(`.`);return n>0&&n<t.length-1?`.${t.slice(n+1)}`:e.attachment.type}var hK=()=>{let e=J(2),t=$(gK),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};hK.displayName=`AttachmentPrimitive.Name`;function gK(e){return e.attachment.name}var _K=LG(`AttachmentPrimitive.Remove`,()=>{let e=J(2),t=Q(),n;return e[0]===t.attachment?n=e[1]:(n=()=>{t.attachment.remove()},e[0]=t.attachment,e[1]=n),n}),vK=yG({Name:()=>hK,Remove:()=>_K,Root:()=>fK,unstable_Thumb:()=>pK}),yK=LG(`BranchPickerPrimitive.Next`,()=>{let{disabled:e,next:t}=IW();return e?null:t}),bK=LG(`BranchPickerPrimitive.Previous`,()=>{let{disabled:e,previous:t}=LW();return e?null:t}),xK=()=>$(CK),SK=()=>{let e=J(2),t=xK(),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};SK.displayName=`BranchPickerPrimitive.Count`;function CK(e){return e.message.branchCount}var wK=()=>$(EK),TK=()=>{let e=J(2),t=wK(),n;return e[0]===t?n=e[1]:(n=(0,P.jsx)(P.Fragment,{children:t}),e[0]=t,e[1]=n),n};TK.displayName=`BranchPickerPrimitive.Number`;function EK(e){return e.message.branchNumber}var DK=Z((e,t)=>{let n=J(11),r,i;n[0]===e?(r=n[1],i=n[2]):({hideWhenSingleBranch:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=e=>!r||e.message.branchCount>=2,n[3]=r,n[4]=a);let o;n[5]!==t||n[6]!==i?(o=(0,P.jsx)(TG.div,{...i,ref:t}),n[5]=t,n[6]=i,n[7]=o):o=n[7];let s;return n[8]!==a||n[9]!==o?(s=(0,P.jsx)(JI,{condition:a,children:o}),n[8]=a,n[9]=o,n[10]=s):s=n[10],s});DK.displayName=`BranchPickerPrimitive.Root`;var OK=yG({Count:()=>SK,Next:()=>yK,Number:()=>TK,Previous:()=>bK,Root:()=>DK}),kK=BM(null),AK=()=>HM(kK),jK=e=>{let t=J(8),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=Y(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let o=Y(a),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=Array.from(i.current.entries());e.sort(MK),o.current=e.map(NK)},t[2]=s):s=t[2];let c=s,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(e,t)=>{let n=t?.priority??0;return i.current.set(e,n),c(),()=>{i.current.delete(e),c()}},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={register:u,getPlugins:f},t[5]=p):p=t[5];let m=p,h;return t[6]===n?h=t[7]:(h=(0,P.jsx)(kK.Provider,{value:m,children:n}),t[6]=n,t[7]=h),h};function MK(e,t){return t[1]-e[1]}function NK(e){let[t]=e;return t}var PK=BM(null),FK=BM(null),IK=()=>{let e=HM(PK);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},LK=()=>HM(PK),RK=()=>{let e=HM(FK);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},zK=()=>{let e=IK();return AM(e.subscribe,e.getTriggers,e.getTriggers)},BK=new Map,VK=()=>()=>{},HK=()=>BK,UK=()=>{let e=LK();return AM(e?e.subscribe:VK,e?e.getTriggers:HK,e?e.getTriggers:HK)},WK=()=>null,GK=()=>{let e=LK();return AM(e?e.subscribeAria:VK,e?e.getActiveAria:WK,e?e.getActiveAria:WK)};function KK(){let e=J(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Set,e[0]=t):t=e[0];let n=Y(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{for(let e of n.current)e()},e[1]=r):r=e[1];let i=r,a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n.current.add(e),()=>{n.current.delete(e)}),e[2]=a):a=e[2];let o=a,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={notify:i,subscribe:o},e[3]=s):s=e[3],s}var qK=e=>{let t=J(21),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=Y(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,t[1]=a):a=t[1];let o=Y(a),{notify:s,subscribe:c}=KK(),l;t[2]===s?l=t[3]:(l=e=>{let{char:t}=e;if(i.current.has(t))return YK;let n=new Map(i.current);n.set(t,e),i.current=n,s();for(let t of o.current)t.added(e);return()=>{let e=new Map(i.current);e.delete(t),i.current=e,s();for(let e of o.current)e.removed(t)}},t[2]=s,t[3]=l);let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>i.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>(o.current.add(e),()=>{o.current.delete(e)}),t[5]=p):p=t[5];let m=p,h=Y(null),g=Y(null),{notify:_,subscribe:v}=KK(),y;t[6]===_?y=t[7]:(y=(e,t)=>{if(t===null){if(g.current!==e)return;h.current=null,g.current=null,_();return}let n=h.current;(g.current!==e||n===null||n.popoverId!==t.popoverId||n.highlightedItemId!==t.highlightedItemId)&&(h.current=t,g.current=e,_())},t[6]=_,t[7]=y);let b=y,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>h.current,t[8]=x):x=t[8];let S=x,C;t[9]!==u||t[10]!==c||t[11]!==v?(C={register:u,getTriggers:f,subscribe:c,subscribeLifecycle:m,getActiveAria:S,subscribeAria:v},t[9]=u,t[10]=c,t[11]=v,t[12]=C):C=t[12];let w=C,T;t[13]===b?T=t[14]:(T={setActiveAria:b},t[13]=b,t[14]=T);let E=T,D;t[15]!==E||t[16]!==n?(D=(0,P.jsx)(FK.Provider,{value:E,children:n}),t[15]=E,t[16]=n,t[17]=D):D=t[17];let O;return t[18]!==D||t[19]!==w?(O=(0,P.jsx)(PK.Provider,{value:w,children:D}),t[18]=D,t[19]=w,t[20]=O):O=t[20],O},JK=e=>{let t=J(4),{children:n}=e;if(AK()){let e;return t[0]===n?e=t[1]:(e=(0,P.jsx)(qK,{children:n}),t[0]=n,t[1]=e),e}let r;return t[2]===n?r=t[3]:(r=(0,P.jsx)(jK,{children:(0,P.jsx)(qK,{children:n})}),t[2]=n,t[3]=r),r};JK.displayName=`ComposerPrimitive.TriggerPopoverRoot`;function YK(){}var XK=/\s/u;function ZK(e,t,n,r){if(r===null)return null;let{query:i,offset:a,endOffset:o}=r;return a<0||a+t.length>n||!e.startsWith(t,a)||o<a+t.length||o>e.length?null:{query:i,offset:a,endOffset:o}}function QK(e,t,n,r){if(r)return ZK(e,t,n,r(e,t,n));let i=e.slice(0,n);for(let e=i.length-1;e>=0;e--){let r=i[e];if(XK.test(r))return null;if(i.startsWith(t,e)){if(e>0&&!XK.test(i[e-1]))continue;return{query:i.slice(e+t.length),offset:e,endOffset:n}}}return null}var $K=UM(e=>{let t=J(8),{text:n,triggerChar:r,matcher:i}=e,[a,o]=wM(n.length),s=Math.min(a,n.length),c;t[0]!==i||t[1]!==s||t[2]!==n||t[3]!==r?(c=QK(n,r,s,i),t[0]=i,t[1]=s,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l=c,u=l?.query??``,d;return t[5]!==u||t[6]!==l?(d={trigger:l,query:u,setCursorPosition:o},t[5]=u,t[6]=l,t[7]=d):d=t[7],d});function eq(e){return`type`in e}var tq=UM(e=>{let t=J(22),{navigableList:n,isSearchMode:r,activeCategoryId:i,query:a,popoverId:o,open:s,selectItem:c,selectCategory:l,goBack:u,close:d}=e,[f,p]=wM(0),m;t[0]!==i||t[1]!==r||t[2]!==n?(m={navigableList:n,isSearchMode:r,activeCategoryId:i},t[0]=i,t[1]=r,t[2]=n,t[3]=m):m=t[3];let[h,g]=wM(m);(h.navigableList!==n||h.isSearchMode!==r||h.activeCategoryId!==i)&&(g({navigableList:n,isSearchMode:r,activeCategoryId:i}),p(0));let _;t[4]!==f||t[5]!==n.length?(_=e=>{e<0||e>=n.length||e!==f&&p(e)},t[4]=f,t[5]=n.length,t[6]=_):_=t[6];let v=kM(_),y;t[7]!==i||t[8]!==d||t[9]!==u||t[10]!==f||t[11]!==n||t[12]!==s||t[13]!==a||t[14]!==l||t[15]!==c?(y=e=>{if(!s)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e<t-1?e+1:0}),!0;case`ArrowUp`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e>0?e-1:t-1}),!0;case`Enter`:case`Tab`:{if(e.shiftKey)return!1;e.preventDefault();let t=n[f];return t&&(eq(t)?c(t):l(t.id)),!0}case`Escape`:return e.preventDefault(),d(),!0;case`Backspace`:return i&&a===``?(e.preventDefault(),u(),!0):!1;default:return!1}},t[7]=i,t[8]=d,t[9]=u,t[10]=f,t[11]=n,t[12]=s,t[13]=a,t[14]=l,t[15]=c,t[16]=y):y=t[16];let b=kM(y),x=n[f],S=s&&x?`${o}-option-${x.id}`:void 0,C;return t[17]!==b||t[18]!==v||t[19]!==f||t[20]!==S?(C={highlightedIndex:f,highlightedItemId:S,highlightIndex:v,handleKeyDown:b},t[17]=b,t[18]=v,t[19]=f,t[20]=S,t[21]=C):C=t[21],C});function nq(e,t){return!t||e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var rq=UM(e=>{let t=J(35),{adapter:n,query:r,open:i}=e,[a,o]=wM(null),[s,c]=wM(i);s!==i&&(c(i),i||o(null));let l;bb0:{if(!i||!n){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],l=e;break bb0}let e;t[1]===n?e=t[2]:(e=n.categories(),t[1]=n,t[2]=e),l=e}let u=l,d=i?a:null,f;bb1:{if(!d||!n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],f=e;break bb1}let e;t[4]!==n||t[5]!==d?(e=n.categoryItems(d),t[4]=n,t[5]=d,t[6]=e):e=t[6],f=e}let p=f,m;bb2:{if(!i||!n||d){m=null;break bb2}if(!r&&u.length>0){m=null;break bb2}if(n.search){let e;t[7]!==n||t[8]!==r?(e=n.search(r),t[7]=n,t[8]=r,t[9]=e):e=t[9],m=e;break bb2}let e;if(t[10]!==n||t[11]!==u||t[12]!==r){e=[];let i=r.toLowerCase();for(let t of u)for(let r of n.categoryItems(t.id))nq(r,i)&&e.push(r);t[10]=n,t[11]=u,t[12]=r,t[13]=e}else e=t[13];m=e}let h=m,g=h!==null,_;bb3:{if(g){let e;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[14]=e):e=t[14],_=e;break bb3}if(!r){_=u;break bb3}let e;if(t[15]!==u||t[16]!==r){let n=r.toLowerCase();e=u.filter(e=>e.label.toLowerCase().includes(n)),t[15]=u,t[16]=r,t[17]=e}else e=t[17];_=e}let v=_,y;bb4:{if(g){let e;t[18]===h?e=t[19]:(e=h??[],t[18]=h,t[19]=e),y=e;break bb4}if(!r){y=p;break bb4}let e;if(t[20]!==p||t[21]!==r){let n=r.toLowerCase();e=p.filter(e=>nq(e,n)),t[20]=p,t[21]=r,t[22]=e}else e=t[22];y=e}let b=y,x;bb5:{if(g){let e;t[23]===h?e=t[24]:(e=h??[],t[23]=h,t[24]=e),x=e;break bb5}if(d){x=b;break bb5}x=v}let S=x,C;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{o(e)},t[25]=C):C=t[25];let w=kM(C),T;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{o(null)},t[26]=T):T=t[26];let E=kM(T),D;return t[27]!==d||t[28]!==v||t[29]!==b||t[30]!==E||t[31]!==g||t[32]!==S||t[33]!==w?(D={categories:v,items:b,isSearchMode:g,activeCategoryId:d,navigableList:S,selectCategory:w,goBack:E},t[27]=d,t[28]=v,t[29]=b,t[30]=E,t[31]=g,t[32]=S,t[33]=w,t[34]=D):D=t[34],D}),iq=UM(e=>{let t=J(15),{behavior:n,trigger:r,aui:i,setCursorPosition:a,onSelected:o}=e,s=Y(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>(s.current=e,()=>{s.current===e&&(s.current=null)}),t[0]=c):c=t[0];let l=kM(c),u;t[1]!==i||t[2]!==n||t[3]!==o||t[4]!==a||t[5]!==r?(u=e=>{if(!r||!n)return;if(s.current?.(e)){o();return}let t=i.composer.getState().text,c=t.slice(0,r.offset),l=t.slice(r.endOffset),u=()=>{let t=n.formatter.serialize(e);i.composer.setText(c+t+(l.startsWith(` `)?l:` ${l}`)),a(c.length+t.length+1)};n.kind===`directive`?(u(),n.onInserted?.(e)):(n.removeOnExecute?(i.composer.setText(c+(l.startsWith(` `)?l.slice(1):l)),a(c.length)):u(),n.onExecute(e)),o()},t[1]=i,t[2]=n,t[3]=o,t[4]=a,t[5]=r,t[6]=u):u=t[6];let d=kM(u),f;t[7]!==o||t[8]!==a||t[9]!==r?(f=()=>{o(),r&&a(r.offset)},t[7]=o,t[8]=a,t[9]=r,t[10]=f):f=t[10];let p=kM(f),m;return t[11]!==p||t[12]!==l||t[13]!==d?(m={selectItem:d,close:p,registerSelectItemOverride:l},t[11]=p,t[12]=l,t[13]=d,t[14]=m):m=t[14],m}),aq=UM(e=>{let t=J(47),{adapter:n,text:r,triggerChar:i,matcher:a,behavior:o,aui:s,popoverId:c,isLoading:l}=e,u;t[0]!==a||t[1]!==r||t[2]!==i?(u=$K({text:r,triggerChar:i,matcher:a}),t[0]=a,t[1]=r,t[2]=i,t[3]=u):u=t[3];let d=jN(u),f=d.trigger!==null&&n!==void 0&&o!==void 0,p;t[4]!==n||t[5]!==d.query||t[6]!==f?(p=rq({adapter:n,query:d.query,open:f}),t[4]=n,t[5]=d.query,t[6]=f,t[7]=p):p=t[7];let m=jN(p),h;t[8]===m?h=t[9]:(h=()=>{m.goBack()},t[8]=m,t[9]=h);let g=kM(h),_;t[10]!==s||t[11]!==o||t[12]!==d.setCursorPosition||t[13]!==d.trigger||t[14]!==g||t[15]!==i?(_=iq({behavior:o,trigger:d.trigger,aui:s,triggerChar:i,setCursorPosition:d.setCursorPosition,onSelected:g}),t[10]=s,t[11]=o,t[12]=d.setCursorPosition,t[13]=d.trigger,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v=jN(_),y;t[17]!==d.query||t[18]!==m.activeCategoryId||t[19]!==m.goBack||t[20]!==m.isSearchMode||t[21]!==m.navigableList||t[22]!==m.selectCategory||t[23]!==f||t[24]!==c||t[25]!==v.close||t[26]!==v.selectItem?(y=tq({navigableList:m.navigableList,isSearchMode:m.isSearchMode,activeCategoryId:m.activeCategoryId,query:d.query,popoverId:c,open:f,selectItem:v.selectItem,selectCategory:m.selectCategory,goBack:m.goBack,close:v.close}),t[17]=d.query,t[18]=m.activeCategoryId,t[19]=m.goBack,t[20]=m.isSearchMode,t[21]=m.navigableList,t[22]=m.selectCategory,t[23]=f,t[24]=c,t[25]=v.close,t[26]=v.selectItem,t[27]=y):y=t[27];let b=jN(y),x;return t[28]!==d.query||t[29]!==d.setCursorPosition||t[30]!==l||t[31]!==b.handleKeyDown||t[32]!==b.highlightIndex||t[33]!==b.highlightedIndex||t[34]!==b.highlightedItemId||t[35]!==m.activeCategoryId||t[36]!==m.categories||t[37]!==m.goBack||t[38]!==m.isSearchMode||t[39]!==m.items||t[40]!==m.selectCategory||t[41]!==f||t[42]!==c||t[43]!==v.close||t[44]!==v.registerSelectItemOverride||t[45]!==v.selectItem?(x={open:f,query:d.query,activeCategoryId:m.activeCategoryId,categories:m.categories,items:m.items,highlightedIndex:b.highlightedIndex,isSearchMode:m.isSearchMode,isLoading:l,popoverId:c,highlightedItemId:b.highlightedItemId,selectCategory:m.selectCategory,goBack:m.goBack,selectItem:v.selectItem,close:v.close,highlightIndex:b.highlightIndex,handleKeyDown:b.handleKeyDown,setCursorPosition:d.setCursorPosition,registerSelectItemOverride:v.registerSelectItemOverride},t[28]=d.query,t[29]=d.setCursorPosition,t[30]=l,t[31]=b.handleKeyDown,t[32]=b.highlightIndex,t[33]=b.highlightedIndex,t[34]=b.highlightedItemId,t[35]=m.activeCategoryId,t[36]=m.categories,t[37]=m.goBack,t[38]=m.isSearchMode,t[39]=m.items,t[40]=m.selectCategory,t[41]=f,t[42]=c,t[43]=v.close,t[44]=v.registerSelectItemOverride,t[45]=v.selectItem,t[46]=x):x=t[46],x}),oq=BM(null),sq=()=>{let e=HM(oq);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},cq=()=>HM(oq),lq=BM(null),uq=()=>{let e=HM(lq);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},dq=Z((e,t)=>{let n=J(69),r,i,a,o,s,c,l;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7]):({char:a,matcher:s,adapter:r,isLoading:l,"aria-label":i,children:o,...c}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c,n[7]=l);let u=l!==void 0&&l,d=Q(),f=$(fq),p=NM(),m=Y(s),h;n[8]===s?h=n[9]:(h=()=>{m.current=s},n[8]=s,n[9]=h),X(h);let g;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>(e,t,n)=>m.current(e,t,n),n[10]=g):g=n[10];let[_]=wM(g),v=s!==void 0,y=Y(null),[b,x]=wM(null),S=Y(0),C;n[11]===a?C=n[12]:(C=e=>(S.current+=1,y.current=e,x(e),()=>{S.current=Math.max(0,S.current-1),y.current===e&&(y.current=null,x(null))}),n[11]=a,n[12]=C);let w=C,T;n[13]===w?T=n[14]:(T={register:w},n[13]=w,n[14]=T);let E=T,D=b??void 0,O;n[15]!==r||n[16]!==d||n[17]!==a||n[18]!==u||n[19]!==s||n[20]!==p||n[21]!==D||n[22]!==f?(O=aq({adapter:r,text:f,triggerChar:a,matcher:s,behavior:D,aui:d,popoverId:p,isLoading:u}),n[15]=r,n[16]=d,n[17]=a,n[18]=u,n[19]=s,n[20]=p,n[21]=D,n[22]=f,n[23]=O):O=n[23];let k=jN(O),A;n[24]===k?A=n[25]:(A=()=>k,n[24]=k,n[25]=A);let j=kM(A),M=IK(),ee;n[26]!==b||n[27]!==a||n[28]!==j||n[29]!==v||n[30]!==_||n[31]!==M?(ee=()=>M.register({char:a,...v?{matcher:_}:{},...b?{behavior:b}:{},resource:j()}),n[26]=b,n[27]=a,n[28]=j,n[29]=v,n[30]=_,n[31]=M,n[32]=ee):ee=n[32];let te;n[33]!==b||n[34]!==a||n[35]!==v||n[36]!==M?(te=[M,a,v,b],n[33]=b,n[34]=a,n[35]=v,n[36]=M,n[37]=te):te=n[37],X(ee,te);let ne=AK(),re;n[38]!==j||n[39]!==ne?(re=()=>{if(ne)return ne.register(j())},n[38]=j,n[39]=ne,n[40]=re):re=n[40];let ie;n[41]===ne?ie=n[42]:(ie=[ne],n[41]=ne,n[42]=ie),X(re,ie);let ae=b!==null&&k.open,oe=RK(),se,ce;n[43]!==oe||n[44]!==a||n[45]!==ae?(se=()=>{if(ae)return()=>{oe.setActiveAria(a,null)}},ce=[oe,a,ae],n[43]=oe,n[44]=a,n[45]=ae,n[46]=se,n[47]=ce):(se=n[46],ce=n[47]),X(se,ce);let le,ue;n[48]!==oe||n[49]!==a||n[50]!==ae||n[51]!==p||n[52]!==k.highlightedItemId?(le=()=>{ae&&oe.setActiveAria(a,{popoverId:p,highlightedItemId:k.highlightedItemId})},ue=[oe,a,p,ae,k.highlightedItemId],n[48]=oe,n[49]=a,n[50]=ae,n[51]=p,n[52]=k.highlightedItemId,n[53]=le,n[54]=ue):(le=n[53],ue=n[54]),X(le,ue);let de;n[55]!==i||n[56]!==o||n[57]!==t||n[58]!==ae||n[59]!==p||n[60]!==c||n[61]!==k.highlightedItemId?(de=ae?(0,P.jsx)(TG.div,{role:`listbox`,id:p,"aria-label":i??`Suggestions`,"aria-activedescendant":k.highlightedItemId,"data-state":`open`,...c,ref:t,children:o}):o,n[55]=i,n[56]=o,n[57]=t,n[58]=ae,n[59]=p,n[60]=c,n[61]=k.highlightedItemId,n[62]=de):de=n[62];let fe;n[63]!==k||n[64]!==de?(fe=(0,P.jsx)(oq.Provider,{value:k,children:de}),n[63]=k,n[64]=de,n[65]=fe):fe=n[65];let pe;return n[66]!==E||n[67]!==fe?(pe=(0,P.jsx)(lq.Provider,{value:E,children:fe}),n[66]=E,n[67]=fe,n[68]=pe):pe=n[68],pe});dq.displayName=`ComposerPrimitive.TriggerPopover`;function fq(e){return e.composer.text}var pq=()=>{let e=J(2),{disabled:t,send:n}=mW(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r},mq=LG(`ComposerPrimitive.Send`,pq),hq=BM(null),gq=()=>HM(hq),_q=`[contenteditable]:not([contenteditable='false'])`,vq=`textarea:not(:disabled), ${_q}`,yq=[`a`,`audio[controls]`,`button`,`details`,`embed`,`iframe`,`input`,`label`,`select`,`summary`,`textarea`,`video[controls]`,_q,`[tabindex]`].join(`, `),bq=Z((e,t)=>{let n=J(24),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({onSubmit:a,onMouseDown:i,compact:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=pq(),[c,l]=wM(!1),u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={setMultiline:l},n[5]=u):u=n[5];let d=u,f;n[6]===r?f=n[7]:(f=e=>r?e.composer.attachments.length===0&&e.composer.quote==null&&e.composer.queue.length===0&&e.composer.dictation==null&&!e.composer.text.includes(`
|
|
93
|
+
`):!1,n[6]=r,n[7]=f);let p=$(f)&&!c,m;n[8]===s?m=n[9]:(m=e=>{e.preventDefault(),s&&s()},n[8]=s,n[9]=m);let h=m,g=xq,_=r?d:null,v=p?``:void 0,y;n[10]!==h||n[11]!==a?(y=F(a,h),n[10]=h,n[11]=a,n[12]=y):y=n[12];let b;n[13]===i?b=n[14]:(b=F(i,g),n[13]=i,n[14]=b);let x;n[15]!==t||n[16]!==o||n[17]!==v||n[18]!==y||n[19]!==b?(x=(0,P.jsx)(TG.form,{...o,"data-compact":v,ref:t,onSubmit:y,onMouseDown:b}),n[15]=t,n[16]=o,n[17]=v,n[18]=y,n[19]=b,n[20]=x):x=n[20];let S;return n[21]!==_||n[22]!==x?(S=(0,P.jsx)(hq.Provider,{value:_,children:x}),n[21]=_,n[22]=x,n[23]=S):S=n[23],S});bq.displayName=`ComposerPrimitive.Root`;function xq(e){if(e.button!==0)return;let t=e.target;if(!(t instanceof Element)||!e.currentTarget.contains(t))return;let n=t.closest(yq);if(n&&e.currentTarget.contains(n))return;let r=e.currentTarget.querySelector(vq);r&&(e.preventDefault(),r.focus())}var Sq=e=>{let t=J(4),n=on(e),r=ZW(Cq),i,a;t[0]!==n||t[1]!==r?(i=()=>r(n),a=[r,n],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),X(i,a)};function Cq(e){return e.onScrollToBottom}var wq=()=>!1,Tq=()=>{},Eq=e=>{let t=J(4),n;t[0]===e?n=t[1]:(n=t=>{if(typeof window>`u`||e===null||!window.matchMedia)return Tq;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},t[0]=e,t[1]=n);let r=n,i;return t[2]===e?i=t[3]:(i=()=>typeof window>`u`||e===null||!window.matchMedia?!1:window.matchMedia(e).matches,t[2]=e,t[3]=i),AM(r,i,wq)};function Dq(){return $(Oq)}function Oq(e){return e.composer.isEditing?e.composer.text:``}function kq(e){return!!$(Aq)||!!e}function Aq(e){return e.thread.isDisabled||e.composer.dictation?.inputDisabled}function jq(){let e=J(4),t=GK();if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={},e[0]=t):t=e[0],t}let n;return e[1]!==t.highlightedItemId||e[2]!==t.popoverId?(n={"aria-controls":t.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":t.highlightedItemId},e[1]=t.highlightedItemId,e[2]=t.popoverId,e[3]=n):n=e[3],n}function Mq(){return Mq=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Mq.apply(null,arguments)}function Nq(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Pq=N.useLayoutEffect,Fq=function(e){var t=N.useRef(e);return Pq(function(){t.current=e}),t},Iq=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},Lq=function(e,t){var n=N.useRef();return N.useCallback(function(r){e.current=r,n.current&&Iq(n.current,null),n.current=t,t&&Iq(t,r)},[t])},Rq={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},zq=function(e){Object.keys(Rq).forEach(function(t){e.style.setProperty(t,Rq[t],`important`)})},Bq=null,Vq=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function Hq(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),Bq||(Bq=document.createElement(`textarea`),Bq.setAttribute(`tabindex`,`-1`),Bq.setAttribute(`aria-hidden`,`true`),zq(Bq)),Bq.parentNode===null&&document.body.appendChild(Bq);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;Bq.style[t]=o[t]}),zq(Bq),Bq.value=t;var c=Vq(Bq,e);Bq.value=t,c=Vq(Bq,e),Bq.value=`x`;var l=Bq.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);var d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}var Uq=function(){},Wq=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},Gq=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],Kq=!!document.documentElement.currentStyle,qq=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=Wq(Gq,t),r=n.boxSizing;return r===``?null:(Kq&&r===`border-box`&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+`px`),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})};function Jq(e,t,n){var r=Fq(n);N.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var Yq=function(e,t){Jq(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},Xq=function(e){Jq(window,`resize`,e)},Zq=function(e){Jq(document.fonts,`loadingdone`,e)},Qq=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],$q=N.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?Uq:a,s=e.onHeightChange,c=s===void 0?Uq:s,l=Nq(e,Qq),u=l.value!==void 0,d=N.useRef(null),f=Lq(d,t),p=N.useRef(0),m=N.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:qq(e);if(t){m.current=t;var a=Hq(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return N.useLayoutEffect(h),Yq(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),Xq(h),Zq(h),N.createElement(`textarea`,Mq({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),eJ=`(pointer: coarse) and (not (any-pointer: fine))`,tJ=Z(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:s,submitOnEnter:l,submitMode:u,cancelOnEscape:f=!0,unstable_focusOnRunStart:p=!0,unstable_focusOnScrollToBottom:m=!0,unstable_focusOnThreadSwitched:h=!0,unstable_insertNewlineOnTouchEnter:g=!1,addAttachmentOnPaste:_=!0,onHeightChange:v,...y},b)=>{let x=Q(),S=AK(),C=gq(),w=u??(l===!1?`none`:`enter`),T=Eq(g?eJ:null),E=g&&T&&w===`enter`?`none`:w,D=Dq(),O=kq(r),k=Y(null),A=d(b,k),j=Y(!1);gG(e=>{if(!k.current?.contains(e.target)||e.isComposing)return;if(S){for(let t of S.getPlugins())if(t.handleKeyDown(e))return}if(!f)return;let t=x.composer;t.getState().canCancel&&(t.cancel(),e.preventDefault())});let M=e=>{if(!O&&!e.nativeEvent.isComposing){if(S){for(let t of S.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=x.thread.getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&w!==`none`&&x.composer.getState().canSend){e.preventDefault(),x.composer.send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;E===`ctrlEnter`?r=e.ctrlKey||e.metaKey:E===`enter`&&(r=!0),r&&(e.preventDefault(),k.current?.closest(`form`)?.requestSubmit())}}},ee=async e=>{if(!_)return;let t=x.thread.getState().capabilities,n=Array.from(e.clipboardData?.files||[]);t.attachments&&n.length>0&&(e.preventDefault(),await Promise.all(n.map(async e=>{try{await x.composer.addAttachment(e)}catch{}})))},te=(e,t)=>{if(v?.(e,t),!C)return;let n=k.current;if(!n||n.value===``)return;let r=getComputedStyle(n),i=r.boxSizing===`border-box`?e-parseFloat(r.paddingTop)-parseFloat(r.paddingBottom)-parseFloat(r.borderTopWidth)-parseFloat(r.borderBottomWidth):e;Math.round(i/t.rowHeight)>1&&C.setMultiline(!0)},ne=e&&!O,re=DM(()=>{let e=k.current;e&&ne&&(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[ne]);X(()=>re(),[re]),Sq(()=>{x.composer.getState().type===`thread`&&m&&re()}),X(()=>{if(x.composer.getState().type===`thread`&&p)return x.on(`thread.runStart`,re)},[p,re,x]),X(()=>{if(x.composer.getState().type===`thread`&&h)return x.on(`threads.selectionChanged`,re)},[h,re,x]),X(()=>{D===``&&C?.setMultiline(!1)},[D,C]);let ie=jq(),ae={name:`input`,value:D,...y,...ie,ref:A,disabled:O,onChange:F(i,e=>{if(!x.composer.getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;j.current&&!t&&(j.current=!1);let n=t||j.current;if(nN(()=>{x.composer.setText(e.target.value)}),n)return;let r=e.target.selectionStart??e.target.value.length;if(S)for(let e of S.getPlugins())e.setCursorPosition(r)}),onKeyDown:F(a,M),onCompositionStart:F(y.onCompositionStart,()=>{j.current=!0}),onCompositionEnd:F(y.onCompositionEnd,e=>{if(j.current=!1,!x.composer.getState().isEditing)return;let t=e.target;nN(()=>{x.composer.setText(t.value)});let n=t.selectionStart??t.value.length;if(S)for(let e of S.getPlugins())e.setCursorPosition(n)}),onSelect:F(s,e=>{if(j.current)return;let t=e.target,n=t.selectionStart??t.value.length;if(S)for(let e of S.getPlugins())e.setCursorPosition(n)}),onPaste:F(o,ee),...C?{onHeightChange:te}:v===void 0?{}:{onHeightChange:v}};if(n&&zM(n))return SG(n,y.children,ae);let oe=t?c:$q;return(0,P.jsx)(oe,{...ae})});tJ.displayName=`ComposerPrimitive.Input`;var nJ=LG(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=hW();return e?null:t}),rJ=LG(`ComposerPrimitive.AddAttachment`,e=>{let t=J(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{multiple:r}=n,i=r===void 0||r,{disabled:a,addAttachment:o}=vW(),s=Q(),c;return t[2]!==o||t[3]!==s.composer||t[4]!==i?(c=()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=i,e.hidden=!0;let t=s.composer.getState().attachmentAccept;t!==`*`&&(e.accept=t),document.body.appendChild(e),e.onchange=async t=>{let n=t.target.files;if(!n)return;let r=Array.from(n,async e=>{try{await o(e)}catch{}});document.body.removeChild(e),await Promise.all(r)},e.oncancel=()=>{(!e.files||e.files.length===0)&&document.body.removeChild(e)},e.click()},t[2]=o,t[3]=s.composer,t[4]=i,t[5]=c):c=t[5],a?null:c},[`multiple`]),iJ=Z(({disabled:e,asChild:t=!1,render:n,children:r,...i},a)=>{let[o,s]=wM(!1),l=Q(),u=DM(t=>{if(!e&&t.dataTransfer.types.includes(`Files`)){if(t.preventDefault(),!l.thread.getState().capabilities.attachments){t.dataTransfer.dropEffect=`none`;return}s(!0)}},[e,l]),d=DM(t=>{if(!e&&t.dataTransfer.types.includes(`Files`)){if(t.preventDefault(),!l.thread.getState().capabilities.attachments){t.dataTransfer.dropEffect=`none`;return}o||s(!0)}},[e,o,l]),f=DM(t=>{if(e)return;t.preventDefault();let n=t.relatedTarget;n&&t.currentTarget.contains(n)||s(!1)},[e]),p=DM(async t=>{if(e||(s(!1),!t.dataTransfer.types.includes(`Files`)))return;t.preventDefault();let n=Array.from(t.dataTransfer.files);l.thread.getState().capabilities.attachments&&n.length!==0&&await Promise.all(n.map(async e=>{try{await l.composer.addAttachment(e)}catch{}}))},[e,l]),m={...o?{"data-dragging":`true`}:null,...i,onDragEnterCapture:F(i.onDragEnterCapture,u),onDragOverCapture:F(i.onDragOverCapture,d),onDragLeaveCapture:F(i.onDragLeaveCapture,f),onDropCapture:F(i.onDropCapture,p),ref:a};if(n&&zM(n))return SG(n,r,m);let h=t?c:`div`;return(0,P.jsx)(h,{...m,children:r})});iJ.displayName=`ComposerPrimitive.AttachmentDropzone`;var aJ=LG(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=gW();return e?null:t}),oJ=LG(`ComposerPrimitive.StopDictation`,()=>{let e=J(2),t=Q(),n=$(sJ),r;return e[0]===t.composer?r=e[1]:(r=()=>{t.composer.stopDictation()},e[0]=t.composer,e[1]=r),n?r:null});function sJ(e){return e.composer.dictation!=null}var cJ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=$(lJ);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,P.jsx)(TG.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});cJ.displayName=`ComposerPrimitive.DictationTranscript`;function lJ(e){return e.composer.dictation?.transcript}var uJ=Z((e,t)=>{let n=J(3);if(!$(pJ))return null;let r;return n[0]!==t||n[1]!==e?(r=(0,P.jsx)(TG.div,{...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});uJ.displayName=`ComposerPrimitive.Quote`;var dJ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=$(mJ);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,P.jsx)(TG.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});dJ.displayName=`ComposerPrimitive.QuoteText`;var fJ=Z((e,t)=>{let n=J(12),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Q(),o;n[3]===a?o=n[4]:(o=()=>{a.composer.setQuote(void 0)},n[3]=a,n[4]=o);let s=o,c;n[5]!==s||n[6]!==r?(c=F(r,s),n[5]=s,n[6]=r,n[7]=c):c=n[7];let l;return n[8]!==t||n[9]!==i||n[10]!==c?(l=(0,P.jsx)(TG.button,{type:`button`,...i,ref:t,onClick:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});fJ.displayName=`ComposerPrimitive.QuoteDismiss`;function pJ(e){return e.composer.quote}function mJ(e){return e.composer.quote?.text}var hJ=Z((e,t)=>{let n=J(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{categories:o,activeCategoryId:s,isSearchMode:c,open:l}=sq();if(!l||s||c)return null;let u=r??`Categories`,d;n[4]!==o||n[5]!==i?(d=i(o),n[4]=o,n[5]=i,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,P.jsx)(TG.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});hJ.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var gJ=Z((e,t)=>{let n=J(30),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({categoryId:r,onClick:i,onMouseMove:a,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let{selectCategory:s,highlightIndex:c,categories:l,highlightedIndex:u,activeCategoryId:d,isSearchMode:f,popoverId:p}=sq(),m;n[5]!==r||n[6]!==s?(m=()=>{s(r)},n[5]=r,n[6]=s,n[7]=m):m=n[7];let h=m,g;if(n[8]!==l||n[9]!==r){let e;n[11]===r?e=n[12]:(e=e=>e.id===r,n[11]=r,n[12]=e),g=l.findIndex(e),n[8]=l,n[9]=r,n[10]=g}else g=n[10];let _=g,v=!d&&!f&&_===u,y;n[13]!==_||n[14]!==c?(y=()=>{c(_)},n[13]=_,n[14]=c,n[15]=y):y=n[15];let b=y,x=`${p}-option-${r}`,S=v?``:void 0,C;n[16]!==h||n[17]!==i?(C=F(i,h),n[16]=h,n[17]=i,n[18]=C):C=n[18];let w;n[19]!==b||n[20]!==a?(w=F(a,b),n[19]=b,n[20]=a,n[21]=w):w=n[21];let T;return n[22]!==t||n[23]!==v||n[24]!==o||n[25]!==x||n[26]!==S||n[27]!==C||n[28]!==w?(T=(0,P.jsx)(TG.button,{type:`button`,role:`option`,id:x,"aria-selected":v,"data-highlighted":S,...o,ref:t,onClick:C,onMouseMove:w}),n[22]=t,n[23]=v,n[24]=o,n[25]=x,n[26]=S,n[27]=C,n[28]=w,n[29]=T):T=n[29],T});gJ.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var _J=Z((e,t)=>{let n=J(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{items:o,activeCategoryId:s,isSearchMode:c,open:l}=sq();if(!l||!s&&!c)return null;let u=r??`Items`,d;n[4]!==i||n[5]!==o?(d=i(o),n[4]=i,n[5]=o,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,P.jsx)(TG.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});_J.displayName=`ComposerPrimitive.TriggerPopoverItems`;var vJ=Z((e,t)=>{let n=J(30),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({item:i,index:r,onClick:a,onMouseMove:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let{selectItem:c,highlightIndex:l,items:u,highlightedIndex:d,activeCategoryId:f,isSearchMode:p,popoverId:m}=sq(),h;n[6]!==i||n[7]!==c?(h=()=>{c(i)},n[6]=i,n[7]=c,n[8]=h):h=n[8];let g=h,_;n[9]!==r||n[10]!==i.id||n[11]!==u?(_=r??u.findIndex(e=>e.id===i.id),n[9]=r,n[10]=i.id,n[11]=u,n[12]=_):_=n[12];let v=_,y=(p||f!==null)&&v===d,b;n[13]!==l||n[14]!==v?(b=()=>{l(v)},n[13]=l,n[14]=v,n[15]=b):b=n[15];let x=b,S=`${m}-option-${i.id}`,C=y?``:void 0,w;n[16]!==g||n[17]!==a?(w=F(a,g),n[16]=g,n[17]=a,n[18]=w):w=n[18];let T;n[19]!==x||n[20]!==o?(T=F(o,x),n[19]=x,n[20]=o,n[21]=T):T=n[21];let E;return n[22]!==t||n[23]!==y||n[24]!==s||n[25]!==S||n[26]!==C||n[27]!==w||n[28]!==T?(E=(0,P.jsx)(TG.button,{type:`button`,role:`option`,id:S,"aria-selected":y,"data-highlighted":C,...s,ref:t,onClick:w,onMouseMove:T}),n[22]=t,n[23]=y,n[24]=s,n[25]=S,n[26]=C,n[27]=w,n[28]=T,n[29]=E):E=n[29],E});vJ.displayName=`ComposerPrimitive.TriggerPopoverItem`;var yJ=Z((e,t)=>{let n=J(10),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let{activeCategoryId:a,isSearchMode:o,goBack:s,open:c}=sq();if(!c||!a||o)return null;let l;n[3]!==s||n[4]!==r?(l=F(r,s),n[3]=s,n[4]=r,n[5]=l):l=n[5];let u;return n[6]!==t||n[7]!==i||n[8]!==l?(u=(0,P.jsx)(TG.button,{type:`button`,...i,ref:t,onClick:l}),n[6]=t,n[7]=i,n[8]=l,n[9]=u):u=n[9],u});yJ.displayName=`ComposerPrimitive.TriggerPopoverBack`;var bJ=e=>{let t=J(8),{formatter:n,onExecute:r,removeOnExecute:i}=e,{register:a}=uq(),o=Y(r),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>{o.current=r},c=[r],t[0]=r,t[1]=s,t[2]=c),MM(s,c);let l,u;return t[3]!==n||t[4]!==a||t[5]!==i?(l=()=>{let e={kind:`action`,formatter:n??pG,onExecute:e=>o.current(e),...i===void 0?{}:{removeOnExecute:i}};return a(e)},u=[a,n,i],t[3]=n,t[4]=a,t[5]=i,t[6]=l,t[7]=u):(l=t[6],u=t[7]),X(l,u),null};bJ.displayName=`ComposerPrimitive.TriggerPopoverAction`;var xJ=e=>{let t=J(7),{formatter:n,onInserted:r}=e,{register:i}=uq(),a=Y(r),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{a.current=r},s=[r],t[0]=r,t[1]=o,t[2]=s),MM(o,s);let c,l;return t[3]!==n||t[4]!==i?(c=()=>i({kind:`directive`,formatter:n??pG,onInserted:e=>a.current?.(e)}),l=[i,n],t[3]=n,t[4]=i,t[5]=c,t[6]=l):(c=t[5],l=t[6]),X(c,l),null};xJ.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var SJ=Object.assign(dq,{Directive:xJ,Action:bJ}),CJ=yG({AddAttachment:()=>rJ,AttachmentByIndex:()=>zU,AttachmentDropzone:()=>iJ,Attachments:()=>VU,Cancel:()=>nJ,Dictate:()=>aJ,DictationTranscript:()=>cJ,If:()=>rW,Input:()=>tJ,Queue:()=>UU,Quote:()=>uJ,QuoteDismiss:()=>fJ,QuoteText:()=>dJ,Root:()=>bq,Send:()=>mq,StopDictation:()=>oJ,Unstable_TriggerPopover:()=>SJ,Unstable_TriggerPopoverBack:()=>yJ,Unstable_TriggerPopoverCategories:()=>hJ,Unstable_TriggerPopoverCategoryItem:()=>gJ,Unstable_TriggerPopoverItem:()=>vJ,Unstable_TriggerPopoverItems:()=>_J,Unstable_TriggerPopoverRoot:()=>JK,unstable_useTriggerPopoverRootContext:()=>IK,unstable_useTriggerPopoverRootContextOptional:()=>LK,unstable_useTriggerPopoverScopeContext:()=>sq,unstable_useTriggerPopoverScopeContextOptional:()=>cq,unstable_useTriggerPopoverTriggers:()=>zK,unstable_useTriggerPopoverTriggersOptional:()=>UK}),wJ=Object.freeze({type:`complete`}),TJ=Object.freeze({type:`text`,text:``,status:wJ}),EJ=()=>$(DJ);function DJ(e){return e.part.type!==`text`&&e.part.type!==`reasoning`?TJ:e.part}var OJ=BM(null),kJ=e=>({useSmoothStatus:iG(()=>e)}),AJ=e=>{let t=J(6),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r={optional:!0},t[0]=r):r=t[0];let i=MJ(r),a=Q(),o;t[1]===a.part?o=t[2]:(o=()=>kJ(a.part.getState().status),t[1]=a.part,t[2]=o);let[s]=wM(o);if(i)return n;let c;return t[3]!==n||t[4]!==s?(c=(0,P.jsx)(OJ.Provider,{value:s,children:n}),t[3]=n,t[4]=s,t[5]=c):c=t[5],c},jJ=e=>{let t=Z((t,n)=>{let r=J(3),i=t,a;return r[0]!==n||r[1]!==i?(a=(0,P.jsx)(AJ,{children:(0,P.jsx)(e,{...i,ref:n})}),r[0]=n,r[1]=i,r[2]=a):a=r[2],a});return t.displayName=e.displayName,t};function MJ(e){let t=HM(OJ);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:NJ,useSmoothStatusStore:PJ}=YW(MJ,`useSmoothStatus`),FJ=250,IJ=5,LJ=class{animationFrameId=null;lastUpdateTime=Date.now();lastCommitTime=0;targetText=``;drainMs=FJ;maxCharIntervalMs=IJ;maxCharsPerFrame=1/0;minCommitMs=0;currentText;setText;constructor(e,t){this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(this.maxCharIntervalMs,this.drainMs/n),i=Math.min(n,this.maxCharsPerFrame),a=0;for(;t>=r&&a<i;)a++,t-=r;a===i&&i===this.maxCharsPerFrame&&(t=0),this.animationFrameId=a===n?null:requestAnimationFrame(this.animate),a!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+a),this.lastUpdateTime=e-t,(a===n||e-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=e,this.setText(this.currentText)))}},RJ=Object.freeze({type:`running`}),zJ=(e,t)=>e!==void 0&&e>0?e:t,BJ=(e,t=!1)=>{let{text:n}=e,r=Eq(`(prefers-reduced-motion: reduce)`),i=typeof t==`object`&&t?t:void 0,a=t!==!1&&t!==null&&!r,o=zJ(i?.drainMs,FJ),s=zJ(i?.maxCharIntervalMs,IJ),c=zJ(i?.maxCharsPerFrame,1/0),l=zJ(i?.minCommitMs,0),[u,d]=wM(e.status.type===`running`?``:n),f=Q(),p=$(()=>f.part),[m,h]=wM(p);(p!==m||!n.startsWith(u))&&(h(p),d(e.status.type===`running`?``:n));let g=PJ({optional:!0}),_=on(t=>{if(d(t),g){let n=u!==t||e.status.type===`running`?RJ:e.status;sG(g).setState(n,!0)}});X(()=>{if(g){let t=a&&(u!==n||e.status.type===`running`)?RJ:e.status;sG(g).setState(t,!0)}},[g,a,n,u,e.status]);let[v]=wM(new LJ(u,_));X(()=>{v.drainMs=o,v.maxCharIntervalMs=s,v.maxCharsPerFrame=c,v.minCommitMs=l},[v,o,s,c,l]);let y=Y(p);return X(()=>{if(!a){v.stop();return}let t=y.current!==p;if(y.current=p,t||!n.startsWith(v.targetText)){e.status.type===`running`?(v.currentText=``,v.targetText=n,v.lastCommitTime=0,v.start()):(v.currentText=n,v.targetText=n,v.stop(),_(n));return}if(v.targetText=n,e.status.type!==`running`){if(v.currentText===``){v.currentText=n,v.stop(),_(n);return}v.start();return}v.start()},[v,a,n,e.status.type,p,_]),X(()=>()=>{v.stop()},[v]),EM(()=>a?{...e,text:u,status:n===u?e.status:RJ}:e,[a,u,e,n])},VJ=Object.freeze({type:`complete`}),HJ=Object.freeze({type:`image`,image:``,status:VJ}),UJ=()=>$(WJ);function WJ(e){return e.part.type===`image`?e.part:HJ}var GJ=Z(({smooth:e=!0,component:t=TG.span,render:n,...r},i)=>{let{text:a,status:o}=BJ(EJ(),e),s={"data-status":o.type,...r,ref:i};return n&&zM(n)?SG(n,a,s):(0,P.jsx)(t,{...s,children:a})});GJ.displayName=`MessagePartPrimitive.Text`;var KJ=Z((e,t)=>{let n=J(4),{image:r}=UJ(),i;return n[0]!==t||n[1]!==r||n[2]!==e?(i=(0,P.jsx)(TG.img,{src:r,...e,ref:t}),n[0]=t,n[1]=r,n[2]=e,n[3]=i):i=n[3],i});KJ.displayName=`MessagePartPrimitive.Image`;var qJ=Z((e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=(0,P.jsx)(TG.div,{role:`alert`,...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});qJ.displayName=`ErrorPrimitive.Root`;var JJ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=KW();if(a===void 0)return null;let o=r??String(a),s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,P.jsx)(TG.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});JJ.displayName=`ErrorPrimitive.Message`;var YJ=yG({Message:()=>JJ,Root:()=>qJ}),XJ=e=>{let t=J(2),n=Y(void 0),r;return t[0]===e?r=t[1]:(r=t=>{n.current&&=(n.current(),void 0),t&&(n.current=e(t))},t[0]=e,t[1]=r),r},ZJ=(e,t)=>{let n=e.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return 1/0;let r=Number(n[1]),i=n[2];return i===`px`?r:i===`em`?r*(parseFloat(getComputedStyle(t).fontSize)||16):i===`rem`?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):1/0},QJ=e=>e.dataset.messageId,$J=()=>{let e=document.createElement(`div`);return e.dataset.auiTopAnchorReserve=``,e.style.height=`0px`,e.style.flexShrink=`0`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),e},eY=(e,t)=>{let n=`${t}px`;return e.style.height!==n&&(e.style.height=n,!0)},tY=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},nY=()=>{let e=J(4),t=Q(),n;e[0]===t.message?n=e[1]:(n=()=>t.message,e[0]=t.message,e[1]=n);let r=$(n),i;return e[2]===r?i=e[3]:(i=e=>{let t=()=>{r.setIsHovering(!0)},n=()=>{r.setIsHovering(!1)};return e.addEventListener(`mouseenter`,t),e.addEventListener(`mouseleave`,n),e.matches(`:hover`)&&queueMicrotask(()=>r.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,t),e.removeEventListener(`mouseleave`,n),r.setIsHovering(!1)}},e[2]=r,e[3]=i),XJ(i)},rY=()=>{let e=J(2),t=ZW(uY),n;return e[0]===t?n=e[1]:(n=e=>e.message.role===`user`&&e.message.index>0&&e.message.index===e.thread.messages.length-2&&e.thread.messages.at(-1)?.role===`assistant`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),$(n)},iY=()=>{let e=J(2),t=ZW(dY),n;return e[0]===t?n=e[1]:(n=e=>e.message.isLast&&e.message.role===`assistant`&&e.message.index>=1&&e.thread.messages.at(e.message.index-1)?.role===`user`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),$(n)},aY=(e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=n=>{if(e)return t.getState().registerAnchorElement(n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],XJ(r)},oY=e=>{let t=J(3),{active:n,threadViewportStore:r}=e,i;return t[0]!==n||t[1]!==r?(i=e=>{if(!n)return;let t=r.getState(),i=t.topAnchorMessageClamp;return t.registerAnchorTargetElement(e,{tallerThan:ZJ(i.tallerThan,e),visibleHeight:ZJ(i.visibleHeight,e)})},t[0]=n,t[1]=r,t[2]=i):i=t[2],XJ(i)},sY=e=>{let t=J(7),n,r;t[0]===e?(n=t[1],r=t[2]):({forwardedRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=nY(),a=d(n,i),o=$(fY),s;return t[3]!==o||t[4]!==r||t[5]!==a?(s=(0,P.jsx)(TG.div,{...r,ref:a,"data-message-id":o}),t[3]=o,t[4]=r,t[5]=a,t[6]=s):s=t[6],s},cY=e=>{let t=J(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({forwardedRef:n,threadViewportStore:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=nY(),o=rY(),s=iY(),c=aY(o,i),l;t[4]!==s||t[5]!==i?(l={active:s,threadViewportStore:i},t[4]=s,t[5]=i,t[6]=l):l=t[6];let u=oY(l),f=d(n,a,c,u),p=$(pY),m=o?``:void 0,h=s?``:void 0,g;return t[7]!==p||t[8]!==r||t[9]!==f||t[10]!==m||t[11]!==h?(g=(0,P.jsx)(TG.div,{...r,ref:f,"data-message-id":p,"data-aui-top-anchor-user":m,"data-aui-top-anchor-target":h}),t[7]=p,t[8]=r,t[9]=f,t[10]=m,t[11]=h,t[12]=g):g=t[12],g},lY=Z((e,t)=>{let n=J(7),r=QW();if(r.getState().turnAnchor===`top`){let i;return n[0]!==t||n[1]!==e||n[2]!==r?(i=(0,P.jsx)(cY,{...e,forwardedRef:t,threadViewportStore:r}),n[0]=t,n[1]=e,n[2]=r,n[3]=i):i=n[3],i}let i;return n[4]!==t||n[5]!==e?(i=(0,P.jsx)(sY,{...e,forwardedRef:t}),n[4]=t,n[5]=e,n[6]=i):i=n[6],i});lY.displayName=`MessagePrimitive.Root`;function uY(e){return e.topAnchorTurn?.anchorId}function dY(e){return e.topAnchorTurn?.targetId}function fY(e){return e.message.id}function pY(e){return e.message.id}var mY={...HH,Text:()=>(0,P.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,P.jsx)(GJ,{}),(0,P.jsx)(qU,{children:(0,P.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,P.jsx)(KJ,{})},hY=e=>{let t=J(10);if(`children`in e){let n;return t[0]===e.children?n=t[1]:(n=(0,P.jsx)(aU,{children:e.children}),t[0]=e.children,t[1]=n),n}let n,r;t[2]===e?(n=t[3],r=t[4]):({components:n,...r}=e,t[2]=e,t[3]=n,t[4]=r);let i;t[5]===n?i=t[6]:(i=n?{...n,Text:n.Text??mY.Text,Image:n.Image??mY.Image}:mY,t[5]=n,t[6]=i);let a=i,o;return t[7]!==r||t[8]!==a?(o=(0,P.jsx)(aU,{components:a,...r}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o};hY.displayName=`MessagePrimitive.Parts`;var gY=e=>{let t=J(12),n;return t[0]!==e.assistant||t[1]!==e.copied||t[2]!==e.hasAttachments||t[3]!==e.hasBranches||t[4]!==e.hasContent||t[5]!==e.last||t[6]!==e.lastOrHover||t[7]!==e.speaking||t[8]!==e.submittedFeedback||t[9]!==e.system||t[10]!==e.user?(n=t=>{let{role:n,attachments:r,parts:i,branchCount:a,isLast:o,speech:s,isCopied:c,isHovering:l}=t.message;return!(e.hasBranches===!0&&a<2||e.user&&n!==`user`||e.assistant&&n!==`assistant`||e.system&&n!==`system`||e.lastOrHover===!0&&!l&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!c||e.copied===!1&&c||e.speaking===!0&&s==null||e.speaking===!1&&s!=null||e.hasAttachments===!0&&(n!==`user`||!r?.length)||e.hasAttachments===!1&&n===`user`&&r?.length||e.hasContent===!0&&i.length===0||e.hasContent===!1&&i.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)},t[0]=e.assistant,t[1]=e.copied,t[2]=e.hasAttachments,t[3]=e.hasBranches,t[4]=e.hasContent,t[5]=e.last,t[6]=e.lastOrHover,t[7]=e.speaking,t[8]=e.submittedFeedback,t[9]=e.system,t[10]=e.user,t[11]=n):n=t[11],$(n)},_Y=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),gY(r)?n:null};_Y.displayName=`MessagePrimitive.If`;var vY=e=>{let{children:t}=e;return KW()===void 0?null:t};vY.displayName=`MessagePrimitive.Error`;var yY=e=>{let t=new Map;for(let n=0;n<e.length;n++){let r=e[n]?.parentId??n,i=t.get(r)??[];i.push(n),t.set(r,i)}let n=[];for(let[e,r]of t){let t=typeof e==`string`?e:void 0;n.push({groupKey:t,indices:r})}return n},bY=e=>{let t=J(4),n=$(jY),r;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],r=e;break bb0}let i;t[1]!==e||t[2]!==n?(i=e(n),t[1]=e,t[2]=n,t[3]=i):i=t[3],r=i}return r},xY=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},SY=e=>{let t=J(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>{let t=e.dataRenderers.renderers[r.name]??n;return Array.isArray(t)?t[0]??n:t},t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=$(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,P.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},CY={Text:()=>(0,P.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,P.jsx)(GJ,{}),(0,P.jsx)(qU,{children:(0,P.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,P.jsx)(KJ,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},wY=e=>{let t=J(37),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d}=r,f=i===void 0?CY.Text:i,p=a===void 0?CY.Reasoning:a,m=o===void 0?CY.Image:o,h=s===void 0?CY.Source:s,g=c===void 0?CY.File:c,_=l===void 0?CY.Unstable_Audio:l,v;t[2]===u?v=t[3]:(v=u===void 0?{}:u,t[2]=u,t[3]=v);let y=v,b=Q(),x=$(MY),S=x.type;if(S===`tool-call`){let e=b.part.addToolResult,n=b.part.resumeToolCall,r=b.part.respondToToolApproval;if(`Override`in y){let i;return t[4]!==e||t[5]!==x||t[6]!==r||t[7]!==n||t[8]!==y.Override?(i=(0,P.jsx)(y.Override,{...x,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=x,t[6]=r,t[7]=n,t[8]=y.Override,t[9]=i):i=t[9],i}let i=y.by_name?.[x.toolName]??y.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==x||t[13]!==r||t[14]!==n?(a=(0,P.jsx)(xY,{...x,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=x,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(x.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(S){case`text`:{let e;return t[16]!==f||t[17]!==x?(e=(0,P.jsx)(f,{...x}),t[16]=f,t[17]=x,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==p||t[20]!==x?(e=(0,P.jsx)(p,{...x}),t[19]=p,t[20]=x,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==h||t[23]!==x?(e=(0,P.jsx)(h,{...x}),t[22]=h,t[23]=x,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==m||t[26]!==x?(e=(0,P.jsx)(m,{...x}),t[25]=m,t[26]=x,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==g||t[29]!==x?(e=(0,P.jsx)(g,{...x}),t[28]=g,t[29]=x,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==_||t[32]!==x?(e=(0,P.jsx)(_,{...x}),t[31]=_,t[32]=x,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[x.name]??d?.Fallback,n;return t[34]!==e||t[35]!==x?(n=(0,P.jsx)(SY,{...x,Fallback:e}),t[34]=e,t[35]=x,t[36]=n):n=t[36],n}default:return console.warn(`Unknown message part type: ${S}`),null}},TY=FM(e=>{let t=J(5),{partIndex:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,P.jsx)(wY,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,P.jsx)(Iz,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),EY=e=>{let t=J(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,P.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,P.jsx)(Rz,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},DY=Object.freeze({type:`complete`}),OY=FM(e=>{let t=J(6),{components:n}=e,r=$(NY);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,P.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}let i=n?.Text??CY.Text,a;return t[3]!==r||t[4]!==i?(a=(0,P.jsx)(EY,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),kY=e=>{let t=J(9),{groupingFunction:n,components:r}=e,i=$(PY),a=bY(n),o;bb0:{if(i===0){let e;t[0]===r?e=t[1]:(e=(0,P.jsx)(OY,{components:r}),t[0]=r,t[1]=e),o=e;break bb0}let e;if(t[2]!==r||t[3]!==a){let n;t[5]===r?n=t[6]:(n=(e,t)=>{let n=r?.Group??CY.Group;return(0,P.jsx)(n,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,P.jsx)(TY,{partIndex:e,components:r},e))},`group-${t}-${e.groupKey??`ungrouped`}`)},t[5]=r,t[6]=n),e=a.map(n),t[2]=r,t[3]=a,t[4]=e}else e=t[4];o=e}let s=o,c;return t[7]===s?c=t[8]:(c=(0,P.jsx)(P.Fragment,{children:s}),t[7]=s,t[8]=c),c};kY.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var AY=e=>{let t=J(6),n,r;t[0]===e?(n=t[1],r=t[2]):({components:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,P.jsx)(kY,{...r,components:n,groupingFunction:yY}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};AY.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;function jY(e){return e.message.parts}function MY(e){return e.part}function NY(e){return e.message.status??DY}function PY(e){return e.message.parts.length}var FY=yG({AttachmentByIndex:()=>NU,Attachments:()=>FU,Content:()=>hY,Error:()=>vY,GenerativeUI:()=>PH,GroupedParts:()=>kU,If:()=>_Y,PartByIndex:()=>WH,Parts:()=>hY,Quote:()=>AU,Root:()=>lY,Unstable_PartsGrouped:()=>kY,Unstable_PartsGroupedByParentId:()=>AY}),IY=e=>{let t=J(2),n=on(e),r;return t[0]===n?r=t[1]:(r=e=>{let t=new ResizeObserver(()=>{n()}),r=new MutationObserver(e=>{e.some(LY)&&n()});return t.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{t.disconnect(),r.disconnect()}},t[0]=n,t[1]=r),XJ(r)};function LY(e){return e.type!==`attributes`||e.attributeName!==`style`}var RY=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=Y(null),a=$(e=>e.thread.messages.length>0),o=$(e=>e.thread.isRunning),s=Y(!1),c=Y(null),l=QW();e===void 0&&(e=l.getState().turnAnchor!==`top`);let u=Y(0),f=Y(0),p=Y(0),m=Y(0),h=Y(null),g=Y(e),_=Y(e);OM(()=>{let t=_.current;if(_.current=e,t||!e)return;let n=i.current;g.current=n!==null&&kF(n)},[e]);let v=DM(e=>{let t=i.current;t&&(g.current=!0,h.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),y=DM(()=>{c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)},[]),b=DM(e=>{h.current=e,y(),c.current=requestAnimationFrame(()=>{c.current=null,v(e)})},[y,v]);OM(()=>()=>y(),[y]);let x=DM(()=>{let e=l.getState();return e.turnAnchor===`top`&&e.element.viewport===i.current&&e.element.anchor!==null},[l]),S=()=>{let t=i.current;if(!t)return;let n=l.getState().isAtBottom,r=kF(t);if(!(!r&&u.current<t.scrollTop)){let i=jF({scrollTop:u.current,scrollHeight:f.current},t);r?(AF(t)&&(h.current=null),e&&(g.current=!0)):i&&(y(),h.current=null,g.current=!1),(r||h.current===null)&&r!==n&&sG(l).setState({isAtBottom:r})}u.current=t.scrollTop,f.current=t.scrollHeight},C=IY(()=>{let t=i.current;if(!t)return;let{scrollHeight:n,clientHeight:r}=t;if(n===p.current&&r===m.current)return;p.current=n,m.current=r;let a=h.current;a&&x()?h.current=null:a?v(a):e&&!(o&&x())&&g.current&&v(`instant`),S()}),w=XJ(e=>{let t=()=>{h.current=null};return e.addEventListener(`scroll`,S),e.addEventListener(`pointerdown`,t),()=>{e.removeEventListener(`scroll`,S),e.removeEventListener(`pointerdown`,t)}});return OM(()=>{if(n){if(!a){s.current=!1;return}s.current||(s.current=!0,h.current===null&&b(`instant`))}},[a,b,n]),Sq(({behavior:e})=>{v(e)}),nL(`thread.runStart`,()=>{t&&l.getState().turnAnchor!==`top`&&b(`auto`)}),nL(`threads.selectionChanged`,()=>{r&&b(`instant`)}),d(C,w,i)},zY=Z((e,t)=>{let n=J(6),r=Q(),i,a;n[0]===r?(i=n[1],a=n[2]):(i=()=>{let e=e=>{if(e.key===`Escape`&&!(e.defaultPrevented||r.thread.source===null)&&r.thread.getState().speech!=null){e.preventDefault();try{r.thread.stopSpeaking()}catch(e){let t=e;if(!(t instanceof Error)||t.message!==`No message is being spoken`)throw t}}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},a=[r],n[0]=r,n[1]=i,n[2]=a),X(i,a);let o;return n[3]!==e||n[4]!==t?(o=(0,P.jsx)(TG.div,{...e,ref:t}),n[3]=e,n[4]=t,n[5]=o):o=n[5],o});zY.displayName=`ThreadPrimitive.Root`;var BY=e=>{let{children:t}=e;return $(VY)?t:null};BY.displayName=`ThreadPrimitive.Empty`;function VY(e){return e.thread.isEmpty}var HY=e=>{let t=J(4),n;return t[0]!==e.disabled||t[1]!==e.empty||t[2]!==e.running?(n=t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled),t[0]=e.disabled,t[1]=e.empty,t[2]=e.running,t[3]=n):n=t[3],$(n)},UY=e=>{let t=J(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),HY(r)?n:null};UY.displayName=`ThreadPrimitive.If`;var WY=(e,t)=>{let n=J(3),r;return n[0]!==t||n[1]!==e?(r=n=>{if(!e)return;let r=e(),i=()=>{let e=t?t(n):n.offsetHeight;r.setHeight(e)},a=new ResizeObserver(i);return a.observe(n),i(),()=>{a.disconnect(),r.unregister()}},n[0]=t,n[1]=e,n[2]=r):r=n[2],XJ(r)},GY=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},KY=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:GY(e)-GY(t)},qY=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=KY(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},JY=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=qY(t)+n.clientHeight;return Math.max(0,r-e)},YY=({viewport:e,reserve:t,...n})=>JY({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),XY=e=>{let t=new ResizeObserver(e),n=new MutationObserver(e),r=null,i=null,a=null,o=()=>{t.disconnect(),n.disconnect(),r=null,i=null,a=null};return{target:(e,s,c)=>{(r!==e||i!==s||a!==c)&&(o(),t.observe(e),t.observe(s),t.observe(c),n.observe(c,{childList:!0,subtree:!0,characterData:!0}),r=e,i=s,a=c)},disconnect:o}},ZY=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},QY=e=>{let t=null,n;function r(){let r=e.getState(),{viewport:o,anchor:s,target:c}=r.element,l=r.targetConfig;if(r.turnAnchor!==`top`||!o){a.disconnect(),t&&(eY(t,0),t.remove());return}if(!s&&!c&&!l&&r.topAnchorTurn){a.disconnect(),t?.parentElement&&t.parentElement.lastElementChild!==t&&t.parentElement.append(t);return}if(!s||!c||!l){a.disconnect(),t&&(eY(t,0),t.remove());return}if(t??=$J(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),eY(t,YY({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=QJ(s);if(u!==void 0&&n===u)return;let d=tY(qY({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=ZY(r),a=XY(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},$Y=e=>{let t=J(4),n=QW(),r,i;t[0]!==e||t[1]!==n?(r=()=>{if(e)return QY(n)},i=[e,n],t[0]=e,t[1]=n,t[2]=r,t[3]=i):(r=t[2],i=t[3]),OM(r,i)},eX=(e,t)=>{if(!e)return!1;let n=t.findIndex(t=>t.id===e.targetId);return n<1?!1:t[n-1]?.id===e.anchorId&&t.slice(n+1).every(e=>e.role===`user`)},tX=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return r?.role!==`user`||n?.role!==`assistant`?null:{anchorId:r.id,targetId:n.id}},nX=e=>tX(e)?.anchorId,rX=e=>tX(e)?.targetId,iX=()=>WY(ZW(lX),uX),aX=()=>XJ(ZW(dX)),oX=e=>{let t=J(19),n=QW(),r;t[0]===e?r=t[1]:(r=t=>{if(e)return nX(t.thread)},t[0]=e,t[1]=r);let i=$(r),a;t[2]===e?a=t[3]:(a=t=>{if(e)return rX(t.thread)},t[2]=e,t[3]=a);let o=$(a),s=ZW(fX),c;bb0:{if(!i||!o){c=null;break bb0}let e;t[4]!==i||t[5]!==o?(e={anchorId:i,targetId:o},t[4]=i,t[5]=o,t[6]=e):e=t[6],c=e}let l=c,u;t[7]!==e||t[8]!==s?(u=t=>e&&!!s&&eX(s,t.thread.messages),t[7]=e,t[8]=s,t[9]=u):u=t[9];let d=$(u),f,p;t[10]!==n||t[11]!==s||t[12]!==d?(f=()=>{s&&!d&&n.getState().setTopAnchorTurn(null)},p=[n,s,d],t[10]=n,t[11]=s,t[12]=d,t[13]=f,t[14]=p):(f=t[13],p=t[14]),OM(f,p);let m,h;t[15]!==l||t[16]!==n?(m=()=>{if(!l)return;let e=n.getState(),t=e.topAnchorTurn;(t?.anchorId!==l.anchorId||t.targetId!==l.targetId)&&e.setTopAnchorTurn(l)},h=[l,n],t[15]=l,t[16]=n,t[17]=m,t[18]=h):(m=t[17],h=t[18]),OM(m,h)},sX=Z((e,t)=>{let n=J(18),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c,children:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l;n[7]!==r||n[8]!==o||n[9]!==s||n[10]!==c?(l={autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c},n[7]=r,n[8]=o,n[9]=s,n[10]=c,n[11]=l):l=n[11];let u=RY(l),f=iX(),p=aX(),m=QW(),h;n[12]===m?h=n[13]:(h=m.getState(),n[12]=m,n[13]=h);let g=h.turnAnchor===`top`;oX(g),$Y(g);let _=d(t,u,f,p),v;return n[14]!==i||n[15]!==_||n[16]!==a?(v=(0,P.jsx)(TG.div,{...a,ref:_,children:i}),n[14]=i,n[15]=_,n[16]=a,n[17]=v):v=n[17],v});sX.displayName=`ThreadPrimitive.ViewportScrollable`;var cX=Z((e,t)=>{let n=J(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({turnAnchor:a,topAnchorMessageClamp:i,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==i||n[5]!==a?(o={turnAnchor:a,topAnchorMessageClamp:i},n[4]=i,n[5]=a,n[6]=o):o=n[6];let s;n[7]!==r||n[8]!==t?(s=(0,P.jsx)(sX,{...r,ref:t}),n[7]=r,n[8]=t,n[9]=s):s=n[9];let c;return n[10]!==o||n[11]!==s?(c=(0,P.jsx)(lG,{options:o,children:s}),n[10]=o,n[11]=s,n[12]=c):c=n[12],c});cX.displayName=`ThreadPrimitive.Viewport`;function lX(e){return e.registerViewport}function uX(e){return e.clientHeight}function dX(e){return e.registerViewportElement}function fX(e){return e.topAnchorTurn}var pX=Z((e,t)=>{let n=J(3),r=WY(ZW(mX),hX),i=d(t,r),a;return n[0]!==e||n[1]!==i?(a=(0,P.jsx)(TG.div,{...e,ref:i}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});pX.displayName=`ThreadPrimitive.ViewportFooter`;function mX(e){return e.registerContentInset}function hX(e){let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t}var gX=LG(`ThreadPrimitive.ScrollToBottom`,e=>{let t=J(5),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{behavior:r}=n,i=ZW(_X),a=QW(),o;return t[2]!==r||t[3]!==a?(o=()=>{a.getState().scrollToBottom({behavior:r})},t[2]=r,t[3]=a,t[4]=o):o=t[4],i?null:o},[`behavior`]);function _X(e){return e.isAtBottom}var vX=LG(`ThreadPrimitive.Suggestion`,e=>{let t=J(4),{prompt:n,send:r,clearComposer:i,autoSend:a}=e,o=r??a??!1,s;t[0]!==i||t[1]!==n||t[2]!==o?(s={prompt:n,send:o,clearComposer:i},t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3];let{disabled:c,trigger:l}=RW(s);return c?null:l},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),yX=yG({Empty:()=>BY,If:()=>UY,MessageByIndex:()=>xH,Messages:()=>TH,Root:()=>zY,ScrollToBottom:()=>gX,Suggestion:()=>vX,SuggestionByIndex:()=>QU,Suggestions:()=>tW,Unstable_MessageById:()=>SH,Viewport:()=>cX,ViewportFooter:()=>pX,ViewportProvider:()=>lG}),bX=Z((e,t)=>{let n=J(4),r=$(xX),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(TG.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});bX.displayName=`SuggestionPrimitive.Title`;function xX(e){return e.suggestion.title}var SX=Z((e,t)=>{let n=J(4),r=$(CX),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,P.jsx)(TG.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});SX.displayName=`SuggestionPrimitive.Description`;function CX(e){return e.suggestion.label}var wX=LG(`SuggestionPrimitive.Trigger`,e=>{let t=J(4),{send:n,clearComposer:r}=e,i=$(TX),a;t[0]!==r||t[1]!==i||t[2]!==n?(a={prompt:i,send:n,clearComposer:r},t[0]=r,t[1]=i,t[2]=n,t[3]=a):a=t[3];let{trigger:o,disabled:s}=RW(a);return s?null:o},[`send`,`clearComposer`]);function TX(e){return e.suggestion.prompt}var EX=yG({Description:()=>SX,Title:()=>bX,Trigger:()=>wX}),DX=Z((e,t)=>{let n=J(15),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=$(OX),{switchToNewThread:s}=WW(),c;n[4]===o?c=n[5]:(c=o?{"data-active":`true`,"aria-current":`true`}:null,n[4]=o,n[5]=c);let l;n[6]!==i||n[7]!==s?(l=F(i,s),n[6]=i,n[7]=s,n[8]=l):l=n[8];let u;return n[9]!==r||n[10]!==t||n[11]!==a||n[12]!==c||n[13]!==l?(u=(0,P.jsx)(TG.button,{type:`button`,...c,...a,ref:t,disabled:r,onClick:l}),n[9]=r,n[10]=t,n[11]=a,n[12]=c,n[13]=l,n[14]=u):u=n[14],u});DX.displayName=`ThreadListPrimitive.New`;function OX(e){return e.threads.newThreadId===e.threads.mainThreadId}var kX=LG(`ThreadListPrimitive.LoadMore`,()=>{let{loadMore:e,disabled:t}=GW();return t?null:e}),[AX,jX]=Ke(`ThreadList`),MX=AX,NX=BM(null),PX=NX.Provider,FX=()=>HM(NX),IX=Z((e,t)=>{let n=J(3),r;return n[0]!==e||n[1]!==t?(r=(0,P.jsx)(MX.Provider,{scope:void 0,children:(0,P.jsx)(MX.Slot,{scope:void 0,children:(0,P.jsx)(TG.div,{...e,ref:t})})}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});IX.displayName=`ThreadListPrimitive.Root`;var LX=yG({ItemByIndex:()=>WU,Items:()=>KU,LoadMore:()=>kX,New:()=>DX,Root:()=>IX}),RX=Z((e,t)=>{let n=$(e=>e.threads.mainThreadId===e.threadListItem.id),r=Y(null),i=Y(null),a=EM(()=>({triggerRef:r,moreRef:i}),[]),o=jX(void 0),s=nn(),c=e=>{let t=s===`rtl`?`ArrowLeft`:`ArrowRight`,n=s===`rtl`?`ArrowRight`:`ArrowLeft`,a=r.current,c=i.current;if(a&&e.target===a){if(e.key===`ArrowDown`||e.key===`ArrowUp`){let t=o().map(e=>e.ref.current).filter(e=>e!==null),n=t[t.indexOf(a)+(e.key===`ArrowDown`?1:-1)];n&&(n.focus(),e.preventDefault())}else e.key===t&&c&&(c.focus(),e.preventDefault())}else c&&e.target===c&&e.key===n&&(a?.focus(),e.preventDefault())};return(0,P.jsx)(PX,{value:a,children:(0,P.jsx)(TG.div,{...n?{"data-active":`true`,"aria-current":`true`}:null,...e,onKeyDown:F(e.onKeyDown,c),ref:t})})});RX.displayName=`ThreadListItemPrimitive.Root`;var zX=LG(`ThreadListItemPrimitive.Archive`,()=>{let{archive:e}=BW();return e}),BX=LG(`ThreadListItemPrimitive.Unarchive`,()=>{let{unarchive:e}=HW();return e}),VX=LG(`ThreadListItemPrimitive.Delete`,()=>{let{delete:e}=VW();return e}),HX=LG(`ThreadListItemPrimitive.Trigger`,()=>{let{switchTo:e}=UW();return e}),UX=Z((e,t)=>{let n=J(3),r=FX(),i=d(t,r?.triggerRef),a;return n[0]!==e||n[1]!==i?(a=(0,P.jsx)(MX.ItemSlot,{scope:void 0,children:(0,P.jsx)(HX,{...e,ref:i})}),n[0]=e,n[1]=i,n[2]=a):a=n[2],a});UX.displayName=`ThreadListItemPrimitive.Trigger`;var WX=yG({Archive:()=>zX,Delete:()=>VX,Root:()=>RX,Title:()=>YU,Trigger:()=>UX,Unarchive:()=>BX}),GX=nu(),KX=BM(()=>{}),qX=()=>HM(KX),JX=BM(!1),YX=()=>HM(JX),XX=e=>{let t=J(26),n,r,i,a,o,s,c;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6],c=t[7]):({__scopeThreadListItemMore:n,open:o,defaultOpen:r,onOpenChange:a,sharedFocusGroup:c,modal:i,...s}=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);let l=c!==void 0&&c,u=l?!1:i??!0,d=GX(n),f=r??!1,p;t[8]===a?p=t[9]:(p=a?{onChange:a}:{},t[8]=a,t[9]=p);let m;t[10]!==o||t[11]!==f||t[12]!==p?(m={prop:o,defaultProp:f,caller:`ThreadListItemMorePrimitive.Root`,...p},t[10]=o,t[11]=f,t[12]=p,t[13]=m):m=t[13];let[h,g]=yt(m),_;t[14]!==u||t[15]!==h||t[16]!==s||t[17]!==d||t[18]!==g?(_=(0,P.jsx)(wu,{...d,...s,modal:u,open:h,onOpenChange:g}),t[14]=u,t[15]=h,t[16]=s,t[17]=d,t[18]=g,t[19]=_):_=t[19];let v;t[20]!==g||t[21]!==_?(v=(0,P.jsx)(KX.Provider,{value:g,children:_}),t[20]=g,t[21]=_,t[22]=v):v=t[22];let y;return t[23]!==l||t[24]!==v?(y=(0,P.jsx)(JX.Provider,{value:l,children:v}),t[23]=l,t[24]=v,t[25]=y):y=t[25],y};XX.displayName=`ThreadListItemMorePrimitive.Root`;var ZX=Z((e,t)=>{let n=J(10),{__scopeThreadListItemMore:r,...i}=e,a=GX(r),o=FX(),s=qX(),c=YX(),l=d(t,o?.moreRef),u=nn()===`rtl`?`ArrowLeft`:`ArrowRight`,f=rK,p;n[0]!==u||n[1]!==s||n[2]!==c?(p=e=>{c&&e.key===u&&(e.preventDefault(),s(!0))},n[0]=u,n[1]=s,n[2]=c,n[3]=p):p=n[3];let m=F(i.onKeyDown,p),h;return n[4]!==f||n[5]!==l||n[6]!==i||n[7]!==a||n[8]!==m?(h=(0,P.jsx)(f,{...a,...i,onKeyDown:m,ref:l}),n[4]=f,n[5]=l,n[6]=i,n[7]=a,n[8]=m,n[9]=h):h=n[9],h});ZX.displayName=`ThreadListItemMorePrimitive.Trigger`;var QX=Z((e,t)=>{let n=J(21),{__scopeThreadListItemMore:r,portalProps:i,sideOffset:a,...o}=e,s=a===void 0?4:a,c=GX(r),l=qX(),u=FX(),d=YX(),f=nn()===`rtl`?`ArrowRight`:`ArrowLeft`,p=Zl,m=iK,h;n[0]!==f||n[1]!==u?.moreRef||n[2]!==l||n[3]!==d?(h=e=>{d&&e.key===f&&(e.preventDefault(),l(!1),u?.moreRef.current?.focus())},n[0]=f,n[1]=u?.moreRef,n[2]=l,n[3]=d,n[4]=h):h=n[4];let g=F(o.onKeyDown,h),_;n[5]!==u?.moreRef||n[6]!==d?(_=()=>{d&&u?.moreRef.current?.focus()},n[5]=u?.moreRef,n[6]=d,n[7]=_):_=n[7];let v=F(o.onEscapeKeyDown,_),y;n[8]!==m||n[9]!==t||n[10]!==o||n[11]!==c||n[12]!==s||n[13]!==g||n[14]!==v?(y=(0,P.jsx)(m,{...c,...o,onKeyDown:g,onEscapeKeyDown:v,ref:t,sideOffset:s}),n[8]=m,n[9]=t,n[10]=o,n[11]=c,n[12]=s,n[13]=g,n[14]=v,n[15]=y):y=n[15];let b;return n[16]!==i||n[17]!==c||n[18]!==p.Portal||n[19]!==y?(b=(0,P.jsx)(p.Portal,{...c,...i,children:y}),n[16]=i,n[17]=c,n[18]=p.Portal,n[19]=y,n[20]=b):b=n[20],b});QX.displayName=`ThreadListItemMorePrimitive.Content`;var $X=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeThreadListItemMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=GX(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(aK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});$X.displayName=`ThreadListItemMorePrimitive.Item`;var eZ=Z((e,t)=>{let n=J(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeThreadListItemMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=GX(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,P.jsx)(oK,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});eZ.displayName=`ThreadListItemMorePrimitive.Separator`;var tZ=yG({Content:()=>QX,Item:()=>$X,Root:()=>XX,Separator:()=>eZ,Trigger:()=>ZX}),nZ=(e,t)=>{let n=J(5),r=Y(null),i=Y(null),a,o;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>()=>{i.current?.()},o=[],n[0]=a,n[1]=o):(a=n[0],o=n[1]),X(a,o);let s;return n[2]!==e||n[3]!==t?(s=()=>{i.current?.(),(function(){if(r.current||!e.current)return;let t=e.current;for(;t;){let{overflowY:e}=getComputedStyle(t);if(e===`scroll`||e===`auto`){r.current=t;break}t=t.parentElement}})();let n=r.current;if(!n)return;let a=n.scrollTop,o=n.style.scrollbarWidth,s=getComputedStyle(n),c=s.direction===`rtl`?`paddingLeft`:`paddingRight`,l=n.style[c],u=n.offsetWidth-n.clientWidth-parseFloat(s.borderLeftWidth)-parseFloat(s.borderRightWidth),d=n.ownerDocument,f=(n===d.documentElement||n===d.body)&&u<=0?(d.defaultView?.innerWidth??0)-d.documentElement.clientWidth:u;n.style.scrollbarWidth=`none`,f>0&&(n.style[c]=`${parseFloat(s[c])+f}px`);let p=()=>{n.style.scrollbarWidth=o,n.style[c]=l},m=()=>n.scrollTop=a;n.addEventListener(`scroll`,m);let h=setTimeout(()=>{n.removeEventListener(`scroll`,m),p(),i.current=null},t);i.current=()=>{clearTimeout(h),n.removeEventListener(`scroll`,m),p()}},n[2]=e,n[3]=t,n[4]=s):s=n[4],s},rZ=()=>{let e=J(3),t=$(iZ),n=$(aZ),r=t!==void 0&&t.completedAt===void 0&&n,[i,a]=wM(oZ),o,s;if(e[0]===r?(o=e[1],s=e[2]):(o=()=>{if(!r)return;a(Date.now());let e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},s=[r],e[0]=r,e[1]=o,e[2]=s),X(o,s),t!==void 0){if(t.completedAt!==void 0)return Math.max(0,t.completedAt-t.startedAt);if(r)return Math.max(0,i-t.startedAt)}};function iZ(e){let t=e.optional.part;return t?.type===`tool-call`?t.timing:void 0}function aZ(e){let t=e.optional.part;return t?.type===`tool-call`&&t.status.type===`running`}function oZ(){return Date.now()}var sZ=yG({AssistantRuntimeImpl:()=>PB,BaseAssistantRuntimeCore:()=>zB,CompositeContextProvider:()=>UF,DefaultThreadComposerRuntimeCore:()=>cV,MessageRepository:()=>XB,ThreadRuntimeImpl:()=>wB,getAutoStatus:()=>Dz,splitLocalRuntimeOptions:()=>qW,useComposerInputPluginRegistryOptional:()=>AK,useSmooth:()=>BJ,useSmoothStatus:()=>NJ,withSmoothContextProvider:()=>jJ}),cZ=(e,t)=>`${e}:${t}`,lZ=e=>({id:e,status:`idle`}),uZ=e=>({threadId:e,metadata:lZ(e),messages:[],streamingMessageIndex:void 0,toolExecutions:{},runStatus:`idle`,queue:{steering:[],followUp:[]},contextUsage:void 0,compaction:{active:!1},retry:{active:!1,attempt:0},hostUiRequests:[],readiness:void 0,lastError:void 0,loadState:`pending`,lastSeq:0}),dZ=e=>e?.role===`assistant`,fZ=(e,t)=>e.status===t?e:{...e,status:t},pZ=(e,t,n)=>e.compactionActive===t.active&&e.retryActive===n.active&&e.retryAttempt===n.attempt?e:{...e,compactionActive:t.active,retryActive:n.active,retryAttempt:n.attempt},mZ=(e,t)=>{let n=t.metadata.status===`running`?`running`:t.metadata.status===`failed`?`failed`:`idle`,r=n!==`running`,i=t.seq!==void 0&&t.seq<e.lastSeq,a=t.metadata.compactionActive??(!r&&e.compaction.active),o=t.metadata.retryActive??(!r&&e.retry.active),s=i?e.compaction:a?{...e.compaction,active:!0}:{active:!1},c=i?e.retry:o?{active:!0,attempt:t.metadata.retryAttempt??e.retry.attempt}:{active:!1,attempt:0};return{...e,metadata:pZ(t.metadata,s,c),messages:t.messages,streamingMessageIndex:void 0,toolExecutions:{},runStatus:n,compaction:s,retry:c,queue:{steering:(t.metadata.queuedMessages??[]).filter(e=>e.mode===`steer`).map(e=>e.content),followUp:(t.metadata.queuedMessages??[]).filter(e=>e.mode===`followUp`).map(e=>e.content)},contextUsage:t.metadata.contextUsage??e.contextUsage,hostUiRequests:t.hostUiRequests??[],readiness:t.readiness??e.readiness,lastError:t.lastError,loadState:`loaded`}},hZ=(e,t,n)=>{let r=e.slice();return r[t]=n,r},gZ=(e,t,n)=>({...e,toolExecutions:{...e.toolExecutions,[t]:{toolCallId:t,status:`running`,...e.toolExecutions[t],...n}}}),_Z=(e,t)=>e.hostUiRequests.some(e=>e.id===t)?{...e,hostUiRequests:e.hostUiRequests.filter(e=>e.id!==t)}:e,vZ=(e,t)=>{if(t.type!==`snapshot`&&t.type!==`error`&&t.seq<=e.lastSeq)return e;let n=n=>n===e&&t.seq<=e.lastSeq?n:{...n,lastSeq:Math.max(e.lastSeq,t.seq)};switch(t.type){case`snapshot`:return n(mZ(e,t.snapshot));case`agent_start`:return n({...e,runStatus:`running`,lastError:void 0,metadata:fZ(e.metadata,`running`)});case`agent_end`:{let r=t.willRetry===!0;return n({...e,runStatus:r?`running`:`idle`,streamingMessageIndex:void 0,metadata:fZ(e.metadata,r?`running`:`idle`)})}case`message_start`:{let r=[...e.messages,t.message];return n({...e,messages:r,streamingMessageIndex:dZ(t.message)?r.length-1:e.streamingMessageIndex})}case`message_update`:{if(e.streamingMessageIndex!==void 0&&e.streamingMessageIndex<e.messages.length)return n({...e,messages:hZ(e.messages,e.streamingMessageIndex,t.message)});let r=[...e.messages,t.message];return n({...e,messages:r,streamingMessageIndex:r.length-1})}case`message_end`:return e.streamingMessageIndex!==void 0&&e.streamingMessageIndex<e.messages.length?n({...e,messages:hZ(e.messages,e.streamingMessageIndex,t.message),streamingMessageIndex:void 0}):n({...e,streamingMessageIndex:void 0});case`tool_execution_start`:return n(gZ(e,t.toolCallId,{toolName:t.toolName,args:t.args,status:`running`}));case`tool_execution_update`:return n(gZ(e,t.toolCallId,{...t.toolName===void 0?{}:{toolName:t.toolName},partialResult:t.partialResult,status:`running`}));case`tool_execution_end`:return n(gZ(e,t.toolCallId,{partialResult:t.result,status:t.isError?`error`:`complete`}));case`queue_update`:return n({...e,queue:{steering:t.steering,followUp:t.followUp}});case`compaction_start`:{let r={active:!0,reason:t.reason};return n({...e,compaction:r,metadata:pZ(e.metadata,r,e.retry)})}case`compaction_end`:{let t={active:!1};return n({...e,compaction:t,metadata:pZ(e.metadata,t,e.retry)})}case`auto_retry_start`:{let r={active:!0,attempt:t.attempt};return n({...e,retry:r,metadata:pZ(e.metadata,e.compaction,r)})}case`auto_retry_end`:{let t={active:!1,attempt:0};return n({...e,retry:t,metadata:pZ(e.metadata,e.compaction,t)})}case`context_usage`:return n({...e,contextUsage:t.contextUsage});case`session_info_changed`:{let r={...e.metadata};return t.name===void 0?delete r.title:r.title=t.name,n({...e,metadata:r})}case`thinking_level_changed`:return n({...e,metadata:{...e.metadata,config:{...e.metadata.config,thinkingLevel:t.level}}});case`extension_ui_request`:return e.hostUiRequests.some(e=>e.id===t.request.id)?n(e):n({...e,hostUiRequests:[...e.hostUiRequests,t.request]});case`extension_ui_resolved`:return n(_Z(e,t.requestId));case`error`:return n({...e,lastError:t.error,runStatus:`failed`,metadata:fZ(e.metadata,`failed`)});case`agent_settled`:case`entry_appended`:return n(e);default:return n(e)}},yZ=e=>{let t=new Map,n=[];for(let r of e)r.toolCallId!==void 0&&xZ(r)?t.has(r.toolCallId)?n.push(r):t.set(r.toolCallId,r):n.push(r);return{toolAssociated:t,freeStanding:n}},bZ=(e,t)=>({requestId:e,confirmed:t}),xZ=e=>{switch(e.kind){case`confirm`:return{id:e.id,prompt:`${e.title}\n${e.message}`};case`select`:return e.options.length===0?void 0:{id:e.id,prompt:e.title,display:`select`,options:e.options.map((e,t)=>({id:String(t),kind:`_${t}`,label:e}))};case`input`:case`editor`:return{id:e.id,prompt:e.title,display:`text`}}},SZ=(e,t)=>{if(e.kind===`confirm`)return bZ(e.id,t.approved);if(!t.approved)return{requestId:e.id,dismissed:!0};let n=e.kind===`select`?e.options.find((e,n)=>String(n)===t.optionId):t.text;if(n===void 0)throw Error(`Pi ${e.kind} request "${e.id}" was not answered with ${e.kind===`select`?`one of its options`:`text`}`);return{requestId:e.id,value:n}},CZ=e=>{if(typeof e==`string`)return e;if(typeof e==`object`&&e){if(e.dismissed)return;if(typeof e.value==`string`)return e.value}},wZ=(e,t)=>{let n=CZ(t);return n===void 0?{requestId:e,dismissed:!0}:{requestId:e,value:n}};function TZ(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}function EZ(e,t,n,...r){if(!n)return;let i=n=>{try{console.error(`[${e}] ${t} callback threw an error`,n)}catch{}};try{let e=n(...r);if(e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`)return Promise.resolve(e).then(()=>void 0,e=>i(e))}catch(e){i(e)}}var DZ=e=>`pi-msg:${e}`,OZ=e=>`pi-step:${e}`,kZ=(e,t)=>/^data:/i.test(e)?e:`data:${t};base64,${e}`,AZ=e=>new Date(typeof e.timestamp==`number`?e.timestamp:0),jZ=e=>{if(!e)return{};let t=e.filter(e=>e.type===`text`).map(e=>e.text).join(``);return e.every(e=>e.type===`text`)?{result:t}:{result:t,modelContent:e.flatMap(e=>{if(e.type===`text`)return[{type:`text`,text:e.text}];let t=TZ(e.data);return[{type:`file`,data:t?.data??e.data,mediaType:t?.mimeType??e.mimeType}]})}},MZ=e=>{if(e==null)return;let t=e.content;if(Array.isArray(t))return t.filter(e=>typeof e==`object`&&!!e&&(e.type===`text`&&typeof e.text==`string`||e.type===`image`&&typeof e.data==`string`&&typeof e.mimeType==`string`))},NZ=e=>typeof e==`string`?[{type:`text`,text:e}]:e.map(e=>e.type===`image`?{type:`image`,image:kZ(e.data,e.mimeType)}:{type:`text`,text:e.text}),PZ=(e,t)=>({type:`data`,name:e,data:t}),FZ=e=>{let t=new Map;for(let n of e){if(n.role!==`toolResult`)continue;let e=n;t.set(e.toolCallId,{...jZ(MZ({content:e.content})),isError:e.isError,details:e.details})}return t},IZ=(e,t,n,r,i,a)=>{let o=OZ(n);e.lastAssistant=t,e.steps.push({messageId:o,usage:{inputTokens:t.usage?.input??0,outputTokens:t.usage?.output??0}});for(let n of t.content)if(n.type===`text`)e.parts.push({type:`text`,text:n.text,parentId:o});else if(n.type===`thinking`){let t=n.thinking||(n.redacted?`[reasoning redacted]`:``);e.parts.push({type:`reasoning`,text:t,parentId:o})}else if(n.type===`toolCall`){let t=i.get(n.id),s=r.toolExecutions[n.id],c=t??jZ(MZ(s?.partialResult)),l=t?.isError??s?.status===`error`,u=a.get(n.id),d=u&&xZ(u),f={type:`tool-call`,toolCallId:n.id,toolName:n.name,args:n.arguments??{},argsText:JSON.stringify(n.arguments??{}),parentId:o,...c.result===void 0?{}:{result:c.result},...c.modelContent===void 0?{}:{modelContent:c.modelContent},...l?{isError:!0}:{},...d?{approval:d}:{}};d&&(e.hasPendingHostUi=!0),e.parts.push(f)}},LZ=(e,t,n)=>{let r=e.lastAssistant,i=RZ(e,t,n);return{id:DZ(e.firstIndex),role:`assistant`,createdAt:AZ(r),content:e.parts,...i?{status:i}:{},metadata:{steps:e.steps,custom:{pi:{provider:r.provider,model:r.model,api:r.api,usage:r.usage,stopReason:r.stopReason,...r.errorMessage?{errorMessage:r.errorMessage}:{}}}}}},RZ=(e,t,n)=>{if(e.hasPendingHostUi)return{type:`requires-action`,reason:`interrupt`};let r=e.lastAssistant;return t.runStatus===`running`&&n&&r.stopReason!==`error`&&r.stopReason!==`aborted`?{type:`running`}:r.stopReason===`error`?{type:`incomplete`,reason:`error`,...r.errorMessage?{error:r.errorMessage}:{}}:r.stopReason===`aborted`?{type:`incomplete`,reason:`cancelled`}:r.stopReason===`length`?{type:`incomplete`,reason:`length`}:{type:`complete`,reason:`stop`}},zZ=e=>{let{messages:t}=e,n=FZ(t),r=yZ(e.hostUiRequests).toolAssociated,i=[],a=null,o=t=>{a&&=(i.push(LZ(a,e,t)),null)};return t.forEach((s,c)=>{let l=c===t.length-1;switch(s.role){case`assistant`:a||={firstIndex:c,parts:[],steps:[],lastAssistant:s,hasPendingHostUi:!1},IZ(a,s,c,e,n,r),l&&o(!0);break;case`toolResult`:break;case`user`:o(!1),i.push({id:DZ(c),role:`user`,createdAt:AZ(s),content:NZ(s.content)});break;case`bashExecution`:{o(!1);let e=s;i.push(BZ(c,e,`pi-bash-execution`,{command:e.command,output:e.output,exitCode:e.exitCode,cancelled:e.cancelled,truncated:e.truncated,fullOutputPath:e.fullOutputPath}));break}case`custom`:{o(!1);let e=s;if(!e.display)break;i.push({id:DZ(c),role:`assistant`,createdAt:AZ(e),content:[PZ(`pi-custom-message`,{customType:e.customType,details:e.details}),...NZ(e.content)]});break}case`branchSummary`:{o(!1);let e=s;i.push(BZ(c,e,`pi-branch-summary`,{summary:e.summary,fromId:e.fromId}));break}case`compactionSummary`:{o(!1);let e=s;i.push(BZ(c,e,`pi-compaction-summary`,{summary:e.summary,tokensBefore:e.tokensBefore}));break}default:o(!1),i.push(BZ(c,s,`pi-unsupported-message`,{role:s.role,message:s}))}}),o(!0),i},BZ=(e,t,n,r)=>({id:DZ(e),role:`assistant`,createdAt:AZ(t),content:[PZ(n,r)]}),VZ=(e,t)=>e instanceof Date&&t instanceof Date?e.getTime()===t.getTime():void 0,HZ=e=>typeof e==`object`&&!!e&&Object.getPrototypeOf(e)===Object.prototype,UZ=(e,t)=>{if(e===t)return!0;let n=VZ(e,t);if(n!==void 0)return n;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!UZ(e[n],t[n]))return!1;return!0}if(HZ(e)||HZ(t)){if(!HZ(e)||!HZ(t))return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!UZ(e[r],t[r]))return!1;return!0}return!1},WZ=(e,t)=>e.id===t.id&&e.role===t.role&&UZ(e.createdAt,t.createdAt)&&UZ(e.content,t.content)&&UZ(e.status,t.status)&&UZ(e.metadata,t.metadata),GZ=(e,t)=>{let n=e.length!==t.length,r=e.map((e,r)=>{let i=t[r];return i&&WZ(e,i)?i:(n=!0,e)});return n?r:t},KZ=(e,t)=>GZ(zZ(e),t),qZ={snapshot:!0,agent_start:!0,agent_end:!0,agent_settled:!0,turn_start:!0,turn_end:!0,message_start:!0,message_update:!0,message_end:!0,tool_execution_start:!0,tool_execution_update:!0,tool_execution_end:!0,queue_update:!0,compaction_start:!0,compaction_end:!0,entry_appended:!0,auto_retry_start:!0,auto_retry_end:!0,session_info_changed:!0,thinking_level_changed:!0,context_usage:!0,extension_ui_request:!0,extension_ui_resolved:!0,error:!0},JZ=e=>Object.prototype.hasOwnProperty.call(qZ,e),YZ=e=>e instanceof Error?e.message:String(e),XZ=e=>{if(typeof globalThis.requestAnimationFrame==`function`){globalThis.requestAnimationFrame(()=>e());return}setTimeout(e,16)},ZZ=e=>{for(let t of e)try{t()}catch(e){console.error(`[react-pi] Listener threw an error`,e)}},QZ=new Set([`snapshot`,`agent_start`,`agent_end`,`message_start`,`message_update`,`message_end`,`tool_execution_update`,`tool_execution_end`,`extension_ui_request`,`extension_ui_resolved`]),$Z=new Set([`message_update`,`tool_execution_update`]),eQ=new Set([`snapshot`,`agent_start`,`agent_end`,`queue_update`,`compaction_start`,`compaction_end`,`auto_retry_start`,`auto_retry_end`,`session_info_changed`,`thinking_level_changed`,`context_usage`,`extension_ui_request`,`extension_ui_resolved`,`error`]),tQ=e=>{let t=/^data:([^;,]+)(?:;base64)?,(.*)$/is.exec(e);return t?{type:`image`,mimeType:t[1].toLowerCase(),data:t[2]}:{type:`image`,mimeType:`image/png`,data:e}},nQ=e=>[...e.content,...e.attachments?.flatMap(e=>e.content??[])??[]],rQ=(e,t)=>{let n=nQ(e),r=[],i=[];for(let e of n)e.type===`text`?r.push(e.text):e.type===`image`&&i.push(tQ(e.image));return{content:r.join(`
|
|
94
|
+
|
|
95
|
+
`),...i.length>0?{attachments:i}:{},...t?{streamingBehavior:t}:{}}},iQ=e=>{let t=e.runConfig?.custom?.streamingBehavior;return t===`followUp`||t===`steer`?t:void 0},aQ=e=>({role:`user`,content:e.attachments&&e.attachments.length>0?[{type:`text`,text:e.content},...e.attachments]:e.content,timestamp:Date.now()}),oQ=e=>{if(e.role!==`user`)return null;let t=e.content;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
|
|
96
|
+
`):null},sQ=e=>e.runStatus===`running`&&e.metadata.status===`running`?e:{...e,runStatus:`running`,lastError:void 0,metadata:e.metadata.status===`running`?e.metadata:{...e.metadata,status:`running`}},cQ=class{state;stateSnapshot;projectedMessages=[];messageRepository=qB.fromArray([]);version=0;allListeners=new Set;metadataListeners=new Set;messageListeners=new Set;connectionRetainers=0;optimisticUserMessages=[];unsubscribeFromEvents=null;disconnectTimer=null;loadPromise=null;messageFlushScheduled=!1;localSnapshotSeq=0;client;threadId;options;constructor(e,t,n={}){this.client=e,this.threadId=t,this.options=n,this.state=uZ(t),this.stateSnapshot=this.state}getState(){return this.state}getStateSnapshot(){return this.stateSnapshot}getProjectedMessages(){return this.projectedMessages}getMessageRepository(){return this.messageRepository}getVersion(){return this.version}connect(){return this.connectionRetainers+=1,this.ensureEventSubscription({includeSnapshot:this.state.loadState!==`loaded`}),()=>{this.connectionRetainers=Math.max(0,this.connectionRetainers-1),this.maybeDisconnectFromEvents()}}subscribe(e){return this.allListeners.add(e),()=>{this.allListeners.delete(e),this.maybeDisconnectFromEvents()}}subscribeMetadata(e){return this.metadataListeners.add(e),()=>{this.metadataListeners.delete(e),this.maybeDisconnectFromEvents()}}subscribeMessages(e){return this.messageListeners.add(e),()=>{this.messageListeners.delete(e),this.maybeDisconnectFromEvents()}}dispose(){this.clearDisconnectTimer(),this.unsubscribeFromEvents?.(),this.unsubscribeFromEvents=null,this.allListeners.clear(),this.metadataListeners.clear(),this.messageListeners.clear()}ensureEventSubscription(e){this.clearDisconnectTimer(),!this.unsubscribeFromEvents&&(this.unsubscribeFromEvents=this.client.subscribe(this.threadId,e=>{e.threadId===this.threadId&&this.dispatch(e)},e))}hasConsumers(){return this.connectionRetainers>0||this.allListeners.size>0||this.metadataListeners.size>0||this.messageListeners.size>0}maybeDisconnectFromEvents(){this.hasConsumers()||(this.disconnectTimer||=setTimeout(()=>{this.disconnectTimer=null,!this.hasConsumers()&&(this.unsubscribeFromEvents?.(),this.unsubscribeFromEvents=null)},3e4))}clearDisconnectTimer(){this.disconnectTimer&&=(clearTimeout(this.disconnectTimer),null)}async load(e=!1){if(this.loadPromise&&!e)return this.loadPromise;this.setState({...this.state,loadState:`loading`});let t=this.client.getThread(this.threadId).then(e=>{this.loadPromise===t&&this.applySnapshot(e)}).catch(e=>{throw this.loadPromise===t&&this.setState({...this.state,loadState:`loaded`,lastError:YZ(e)}),e}).finally(()=>{this.loadPromise===t&&(this.loadPromise=null)});return this.loadPromise=t,t}refresh(){return this.load(!0)}refreshInBackground(){this.loadPromise||this.refresh().catch(()=>{})}async sendMessage(e,t){if(e.role!==`user`)throw Error(`Pi only supports sending user messages`);let n=this.state.runStatus===`running`,r=t?.streamingBehavior??iQ(e)??(n?`followUp`:void 0),i=rQ(e,r);if(this.ensureEventSubscription({includeSnapshot:!1}),n)return this.sendQueued(i,r??`followUp`);let a=aQ(i);this.optimisticUserMessages.push({message:a,baseMessageCount:this.state.messages.length}),this.setState(sQ(this.state)),this.recomputeProjectedMessagesAndNotify();try{await this.client.sendMessage(this.threadId,i)}catch(e){let t=this.optimisticUserMessages.findIndex(e=>e.message===a);throw t!==-1&&this.optimisticUserMessages.splice(t,1),this.recomputeProjectedMessagesAndNotify(),this.setState({...this.state,lastError:YZ(e),runStatus:`failed`,metadata:{...this.state.metadata,status:`failed`}}),e}}async sendQueued(e,t){let n=t===`steer`?`steering`:`followUp`,r={...this.state.queue,[n]:[...this.state.queue[n],e.content]};this.setState({...this.state,queue:r});try{await this.client.sendMessage(this.threadId,e)}catch(t){let i=this.state.queue!==r,a=this.state.queue[n],o=i?-1:a.lastIndexOf(e.content);throw this.setState({...this.state,lastError:YZ(t),...o===-1?{}:{queue:{...this.state.queue,[n]:a.filter((e,t)=>t!==o)}}}),t}}async clearQueue(){let e=this.state.queue,t=await this.client.clearQueue(this.threadId);return this.state.queue===e&&(e.steering.length>0||e.followUp.length>0)&&this.setState({...this.state,queue:{steering:[],followUp:[]}}),t}async cancel(){try{await this.client.cancelRun(this.threadId)}catch(e){throw this.setState({...this.state,lastError:YZ(e)}),e}}async setModel(e){try{await this.client.setModel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:YZ(e)}),e}await this.refresh()}async setThinkingLevel(e){try{await this.client.setThinkingLevel(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:YZ(e)}),e}await this.refresh()}async respondToToolApproval(e,t){let n=this.state.hostUiRequests.find(t=>t.id===e);await this.respond(n?SZ(n,{approvalId:e,approved:t}):bZ(e,t))}async resumeToolCall(e,t){let n=this.state.hostUiRequests.find(t=>t.toolCallId===e);if(!n)throw Error(`No pending host-UI request for tool call "${e}"`);n.kind===`confirm`?await this.respond(bZ(n.id,t===!0)):await this.respond(wZ(n.id,t))}async respondToHostUiRequest(e){await this.respond(e)}async respond(e){try{await this.client.respondToHostUiRequest(this.threadId,e)}catch(e){throw this.setState({...this.state,lastError:YZ(e)}),e}let t=_Z(this.state,e.requestId);t!==this.state&&(this.setState(t),this.recomputeProjectedMessagesAndNotify())}applySnapshot(e){this.dispatch({type:`snapshot`,snapshot:e,threadId:this.threadId,seq:this.localSnapshotSeq})}dispatch(e){let t=vZ(this.state,e),n=t!==this.state;n&&(this.state=t),this.reconcileOptimisticUserMessages(),n&&eQ.has(e.type)&&this.notifyMetadataListeners(),n&&QZ.has(e.type)&&($Z.has(e.type)?this.scheduleProjectedMessageFlush():this.recomputeProjectedMessagesAndNotify()),(!JZ(e.type)||e.type===`entry_appended`&&e.entry?.type!==`custom`)&&this.refreshInBackground()}setState(e){e!==this.state&&(this.state=e,this.notifyMetadataListeners())}projectedInputMessages(){return[...this.state.messages,...this.optimisticUserMessages.map(e=>e.message)]}reconcileOptimisticUserMessages(){if(this.optimisticUserMessages.length===0)return;let e=[];for(let t of this.optimisticUserMessages){let n=oQ(t.message);this.state.messages.slice(t.baseMessageCount).some(e=>oQ(e)===n)||e.push(t)}e.length!==this.optimisticUserMessages.length&&(this.optimisticUserMessages.length=0,this.optimisticUserMessages.push(...e))}projectMessages(){return KZ({messages:this.projectedInputMessages(),toolExecutions:this.state.toolExecutions,runStatus:this.state.runStatus,hostUiRequests:this.state.hostUiRequests},this.projectedMessages)}recomputeProjectedMessagesAndNotify(){let e=this.projectMessages();if(e===this.projectedMessages){this.state!==this.stateSnapshot&&this.publishState();return}this.projectedMessages=e,this.messageRepository=qB.fromArray(e),this.notifyMessageListeners()}scheduleProjectedMessageFlush(){this.messageFlushScheduled||(this.messageFlushScheduled=!0,(this.options.scheduleNotify??XZ)(()=>{this.messageFlushScheduled=!1,this.recomputeProjectedMessagesAndNotify()}))}bumpVersion(){this.version+=1}publishState(){this.stateSnapshot=this.state,this.bumpVersion(),ZZ(this.allListeners)}notifyMetadataListeners(){this.stateSnapshot=this.state,this.bumpVersion(),ZZ(this.metadataListeners),ZZ(this.allListeners)}notifyMessageListeners(){this.stateSnapshot=this.state,this.bumpVersion(),ZZ(this.messageListeners),ZZ(this.allListeners)}},lQ=e=>{let t=Symbol(`${e} extras`),n=e=>typeof e==`object`&&!!e&&t in e;return{provide:e=>(Object.defineProperty(e,t,{value:!0,enumerable:!1,configurable:!0}),e),is:n,tryGet:e=>n(e)?e:void 0,assert:t=>{if(!n(t))throw Error(`The current thread is not backed by the ${e} runtime.`);return t}}},uQ=e=>{let{provide:t,is:n,tryGet:r,assert:i}=e,a=e=>i(e.thread.getState().extras);function o(e,...t){let r=t.length>0,a=t[0];return $(t=>{let o=t.thread.extras;return n(o)?e?e(o):o:r?a:i(o)})}return{provide:t,is:n,tryGet:r,get:a,use:o}},dQ=(e=>uQ(lQ(e)))(`usePiRuntime`),fQ=uZ(`__pending__`),pQ=[],mQ=qB.fromArray([]),hQ=e=>{let t=new Map,n=!1;return{client:e,controllers:t,get disposed(){return n},activate(){n=!1},dispose(){n=!0;for(let e of t.values())e.dispose()}}},gQ=(e,t)=>{let n=e.controllers.get(t);if(n)return n;let r=new cQ(e.client,t);return e.controllers.set(t,r),r},_Q={getState:()=>fQ,getProjectedMessages:()=>pQ,getMessageRepository:()=>mQ,getVersion:()=>0,subscribe:()=>()=>{},subscribeMetadata:()=>()=>{},subscribeMessages:()=>()=>{},connect:()=>()=>{},load:async()=>{},refresh:async()=>{},sendMessage:async()=>{},cancel:async()=>{},clearQueue:async()=>({steering:[],followUp:[]}),setModel:async()=>{},setThinkingLevel:async()=>{},respondToToolApproval:async()=>{},resumeToolCall:async()=>{},respondToHostUiRequest:async()=>{},dispose:()=>{}},vQ=(e,t)=>{EZ(`react-pi`,`onError`,e,t)},yQ=(e,t)=>{let{freeStanding:n}=yZ(t.hostUiRequests);return dQ.provide({controller:e,state:t,metadata:t.metadata,status:t.runStatus===`failed`?`failed`:t.runStatus,readiness:t.readiness,contextUsage:t.contextUsage,hostUiRequests:n,allHostUiRequests:t.hostUiRequests,queue:t.queue,compaction:t.compaction,retry:t.retry,lastError:t.lastError,cancel:()=>e.cancel(),refresh:()=>e.refresh(),clearQueue:()=>e.clearQueue(),setModel:t=>e.setModel(t),setThinkingLevel:t=>e.setThinkingLevel(t),respondToHostUiRequest:t=>e.respondToHostUiRequest(t),respondToToolApproval:(t,n)=>e.respondToToolApproval(t,n),resumeToolCall:(t,n)=>e.resumeToolCall(t,n)})},bQ=yQ(_Q,fQ),xQ=e=>e.getStateSnapshot?.()??e.getState(),SQ=e=>{let t=(0,N.useCallback)(()=>xQ(e),[e]);return(0,N.useSyncExternalStore)((0,N.useCallback)(t=>e.subscribe(t),[e]),t,t)},CQ=e=>{let t=(0,N.useCallback)(()=>e.getMessageRepository(),[e]);return(0,N.useSyncExternalStore)((0,N.useCallback)(t=>e.subscribeMessages(t),[e]),t,t)},wQ=e=>e.runStatus===`running`||e.compaction.active||e.retry.active,TQ=(e,t)=>{let n=SQ(e),r=CQ(e),{adapters:i,isDisabled:a,isSendDisabled:o,onError:s,suggestions:c,unstable_capabilities:l}=t,u=n.loadState===`loading`,d=wQ(n),f=(0,N.useEffectEvent)(e=>{vQ(s,e)});(0,N.useEffect)(()=>{e!==_Q&&e.load().catch(f)},[e]),(0,N.useEffect)(()=>{if(e!==_Q&&d)return e.connect()},[e,d]);let p=(0,N.useMemo)(()=>yQ(e,n),[e,n]),m=(0,N.useMemo)(()=>({items:n.queue.followUp.map((e,t)=>({id:cZ(`followUp`,t),prompt:e,parts:[{type:`text`,text:e}]})),steerItems:n.queue.steering.map((e,t)=>({id:cZ(`steer`,t),prompt:e,parts:[{type:`text`,text:e}]})),enqueue:t=>{e.sendMessage(t).catch(e=>vQ(s,e))},steer:t=>{e.sendMessage(t,{streamingBehavior:`steer`}).catch(e=>vQ(s,e))},move:()=>{},edit:()=>{},remove:()=>{}}),[e,n.queue,s]);return(0,N.useMemo)(()=>({isDisabled:a,isSendDisabled:o,unstable_capabilities:l,suggestions:c,isLoading:u,isRunning:d,messageRepository:r,extras:p,queue:m,...i?{adapters:i}:{},onNew:async t=>{try{await e.sendMessage(t)}catch(e){throw vQ(s,e),e}},onCancel:async()=>{try{try{await e.clearQueue()}finally{await e.cancel()}}catch(e){throw vQ(s,e),e}},onRespondToToolApproval:async t=>{try{let n=e.getState().hostUiRequests.find(e=>e.id===t.approvalId);if(!n)throw Error(`No pending host-UI request "${t.approvalId}"`);await e.respondToHostUiRequest(SZ(n,t))}catch(e){throw vQ(s,e),e}},onResumeToolCall:({toolCallId:t,payload:n})=>{e.resumeToolCall(t,n).catch(e=>vQ(s,e))}}),[e,p,r,m,i,a,u,d,o,s,c,l])},EQ=(e,t)=>({id:`pi-new-user:${t}`,role:`user`,createdAt:new Date,content:nQ(e)}),DQ=(e,t)=>{let n=Q(),{adapters:r,isDisabled:i,isSendDisabled:a,onError:o,suggestions:s,unstable_capabilities:c}=t,[l,u]=(0,N.useState)([]),d=(0,N.useRef)(0),f=(0,N.useMemo)(()=>qB.fromArray(l),[l]);return(0,N.useMemo)(()=>({isDisabled:i??!1,isSendDisabled:a,unstable_capabilities:c,suggestions:s,isLoading:!1,isRunning:!1,messageRepository:f,extras:bQ,...r?{adapters:r}:{},onNew:async t=>{let r=EQ(t,d.current++);u(e=>[...e,r]);let i=()=>{u(e=>e.filter(e=>e!==r))};try{let{remoteId:r,externalId:a}=await n.threadListItem.initialize();if(e.disposed){i();return}await gQ(e,a??r).sendMessage(t),i()}catch(e){throw i(),vQ(o,e),e}}}),[n,f,e,r,i,a,o,s,c])},OQ=(e,t)=>{let n=$(e=>e.threadListItem),r=$(e=>e.threads.mainThreadId===e.threadListItem.id),i=n.externalId??n.remoteId,a=i?gQ(e,i):_Q,o=TQ(r?a:_Q,t),s=DQ(e,t);return CV(i?o:s)},kQ=e=>({status:e.archived?`archived`:`regular`,remoteId:e.id,externalId:e.id,...e.title===void 0?{}:{title:e.title},custom:{status:e.status,...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath},...e.sessionFile===void 0?{}:{sessionFile:e.sessionFile},...e.parentSessionPath===void 0?{}:{parentSessionPath:e.parentSessionPath}}}),AQ=e=>{let{client:t}=e,n=(0,N.useMemo)(()=>hQ(t),[t]);return(0,N.useEffect)(()=>(n.activate(),()=>n.dispose()),[n]),pH({allowNesting:!0,adapter:(0,N.useMemo)(()=>({list:async()=>({threads:(await t.listThreads({...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath},...e.includeArchived===void 0?{}:{includeArchived:e.includeArchived}})).map(kQ)}),rename:async(e,n)=>{await t.renameThread(e,n)},archive:async e=>{await t.archiveThread?.(e)},unarchive:async e=>{await t.unarchiveThread?.(e)},delete:async e=>{await t.deleteThread?.(e)},initialize:async()=>{let n=await t.createThread({...e.workspacePath===void 0?{}:{workspacePath:e.workspacePath}});return{remoteId:n.metadata.id,externalId:n.metadata.id}},generateTitle:async()=>new ReadableStream({start(e){e.close()}}),fetch:async e=>kQ((await t.getThread(e)).metadata)}),[t,e.workspacePath,e.includeArchived]),...e.initialThreadId===void 0?{}:{initialThreadId:e.initialThreadId},...e.threadId===void 0?{}:{threadId:e.threadId},...e.onThreadIdChange===void 0?{}:{onThreadIdChange:e.onThreadIdChange},runtimeHook:()=>OQ(n,e)})},jQ=()=>dQ.use(e=>e,bQ),MQ=()=>dQ.use(e=>e.metadata,null),NQ=()=>{let e=dQ.use(e=>e,void 0);return(0,N.useMemo)(()=>({requests:e?.hostUiRequests??[],respond:e?.respondToHostUiRequest??(async()=>{throw Error(`Pi runtime is not ready yet`)})}),[e])};function PQ({delayDuration:e=0,...t}){return(0,P.jsx)(yd,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function FQ({...e}){return(0,P.jsx)(bd,{"data-slot":`tooltip`,...e})}function IQ({...e}){return(0,P.jsx)(xd,{"data-slot":`tooltip-trigger`,...e})}function LQ({className:e,sideOffset:t=0,children:n,...r}){return(0,P.jsx)(Sd,{children:(0,P.jsxs)(Cd,{"data-slot":`tooltip-content`,sideOffset:t,className:a(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,P.jsx)(wd,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function RQ({...e}){return(0,P.jsx)(vi,{"data-slot":`dialog`,...e})}function zQ({...e}){return(0,P.jsx)(bi,{"data-slot":`dialog-trigger`,...e})}function BQ({...e}){return(0,P.jsx)(wi,{"data-slot":`dialog-portal`,...e})}function VQ({className:e,...t}){return(0,P.jsx)(Ei,{"data-slot":`dialog-overlay`,className:a(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function HQ({className:e,children:t,showCloseButton:n=!0,...r}){return(0,P.jsxs)(BQ,{"data-slot":`dialog-portal`,children:[(0,P.jsx)(VQ,{}),(0,P.jsxs)(Ai,{"data-slot":`dialog-content`,className:a(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,P.jsxs)(Li,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,P.jsx)(Pe,{}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function UQ({className:e,...t}){return(0,P.jsx)(Fi,{"data-slot":`dialog-title`,className:a(`text-lg leading-none font-semibold`,e),...t})}function WQ({className:e,size:t=`default`,...n}){return(0,P.jsx)(qi,{"data-slot":`avatar`,"data-size":t,className:a(`group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6`,e),...n})}function GQ({className:e,...t}){return(0,P.jsx)(Yi,{"data-slot":`avatar-image`,className:a(`aspect-square size-full`,e),...t})}function KQ({className:e,...t}){return(0,P.jsx)(Zi,{"data-slot":`avatar-fallback`,className:a(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}var qQ=(0,N.forwardRef)(({children:e,tooltip:t,side:n=`bottom`,className:r,...i},o)=>(0,P.jsx)(PQ,{delayDuration:0,children:(0,P.jsxs)(FQ,{children:[(0,P.jsx)(IQ,{asChild:!0,children:(0,P.jsxs)(s,{variant:`ghost`,size:`icon`,...i,className:a(`aui-button-icon size-6 p-1 active:scale-90`,r),ref:o,children:[(0,P.jsx)(l,{children:e}),(0,P.jsx)(`span`,{className:`aui-sr-only sr-only`,children:t})]})}),(0,P.jsx)(LQ,{side:n,children:t})]})}));qQ.displayName=`TooltipIconButton`;var JQ=e=>Symbol.iterator in e,YQ=e=>`entries`in e,XQ=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},ZQ=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function QQ(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:JQ(e)&&JQ(t)?YQ(e)&&YQ(t)?XQ(e,t):ZQ(e,t):XQ({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function $Q(e){let t=N.useRef(void 0);return n=>{let r=e(n);return QQ(t.current,r)?t.current:t.current=r}}var e$=e=>{let[t,n]=(0,N.useState)(void 0);return(0,N.useEffect)(()=>{if(!e){n(void 0);return}let t=URL.createObjectURL(e);return n({file:e,url:t}),()=>{URL.revokeObjectURL(t)}},[e]),t!==void 0&&t.file===e?t.url:void 0},t$=()=>{let{file:e,src:t}=$($Q(e=>{if(e.attachment.type!==`image`)return{};if(e.attachment.file)return{file:e.attachment.file};let t=e.attachment.content?.filter(e=>e.type===`image`)[0]?.image;return t?{src:t}:{}}));return e$(e)??t},n$=({src:e})=>{let[t,n]=(0,N.useState)(!1);return(0,P.jsx)(`img`,{src:e,alt:`Attachment preview`,className:a(`block h-auto max-h-[80vh] w-auto max-w-full rounded-sm object-contain transition-opacity duration-300 motion-reduce:transition-none`,t?`aui-attachment-preview-image-loaded opacity-100`:`aui-attachment-preview-image-loading opacity-0`),onLoad:()=>n(!0)})},r$=({children:e})=>{let t=t$();return t?(0,P.jsxs)(RQ,{children:[(0,P.jsx)(zQ,{className:`aui-attachment-preview-trigger cursor-zoom-in`,asChild:!0,children:(0,N.isValidElement)(e)?e:(0,P.jsx)(`button`,{type:`button`,children:e})}),(0,P.jsxs)(HQ,{className:`aui-attachment-preview-dialog-content [&>button]:bg-foreground/60 [&>button]:hover:bg-foreground/80 [&_svg]:text-background p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:ring-0!`,children:[(0,P.jsx)(UQ,{className:`aui-sr-only sr-only`,children:`Image Attachment Preview`}),(0,P.jsx)(`div`,{className:`aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden rounded-sm`,children:(0,P.jsx)(n$,{src:t})})]})]}):e},i$=()=>{let e=t$();return(0,P.jsxs)(WQ,{className:`aui-attachment-tile-avatar h-full w-full rounded-none`,children:[(0,P.jsx)(GQ,{src:e,alt:`Attachment preview`,className:`aui-attachment-tile-image rounded-none object-cover`}),(0,P.jsx)(KQ,{children:(0,P.jsx)(ce,{className:`aui-attachment-tile-fallback-icon text-muted-foreground/80 size-6 stroke-[1.5]`})})]})},a$=()=>{let e=Q().attachment.source!==`message`,t=$(e=>e.attachment.type===`image`),n=$(e=>{let t=e.attachment.type;switch(t){case`image`:return`Image`;case`document`:return`Document`;case`file`:return`File`;default:return t}}),r=$(e=>e.attachment.status.type===`running`?`uploading`:e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?`error`:void 0),i=r===`uploading`,o=r===`error`,s=$(e=>e.attachment.status.type===`incomplete`&&e.attachment.status.reason===`error`?e.attachment.status.message??`Upload failed`:void 0);return(0,P.jsx)(PQ,{children:(0,P.jsxs)(FQ,{children:[(0,P.jsxs)(vK.Root,{className:a(`aui-attachment-root relative`,e&&`animate-in fade-in-0 zoom-in-95 duration-200 motion-reduce:animate-none`,t&&!e&&`aui-attachment-root-message only:*:first:size-24`),children:[(0,P.jsx)(r$,{children:(0,P.jsx)(IQ,{asChild:!0,children:(0,P.jsxs)(`div`,{className:a(`aui-attachment-tile bg-muted hover:after:bg-foreground/10 focus-visible:ring-ring/50 relative size-14 cursor-pointer overflow-hidden rounded-[calc(var(--composer-radius,1rem)-var(--composer-padding,8px))] transition-transform outline-none after:pointer-events-none after:absolute after:inset-0 after:rounded-[inherit] after:ring-1 after:ring-black/10 after:transition-colors after:ring-inset focus-visible:ring-1 active:scale-[0.96] motion-reduce:transition-none dark:after:ring-white/10`,o&&`after:ring-destructive/60 dark:after:ring-destructive/60`),role:`button`,tabIndex:0,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault()},onKeyUp:e=>{e.key===` `&&e.currentTarget.click()},"aria-label":`${n} attachment${o?`, upload failed`:i?`, uploading`:``}`,children:[(0,P.jsx)(i$,{}),i&&(0,P.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-uploading bg-background/60 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,P.jsx)(pe,{className:`text-muted-foreground size-4 animate-spin`})}),o&&(0,P.jsx)(`div`,{"aria-hidden":`true`,className:`aui-attachment-tile-error bg-background/70 animate-in fade-in-0 absolute inset-0 flex items-center justify-center backdrop-blur-[2px] motion-reduce:animate-none`,children:(0,P.jsx)(te,{className:`text-destructive size-4`})})]})})}),e&&(0,P.jsx)(o$,{})]}),(0,P.jsxs)(LQ,{side:`top`,children:[(0,P.jsx)(vK.Name,{}),s&&(0,P.jsx)(`p`,{className:`aui-attachment-error-message`,children:s})]})]})})},o$=()=>(0,P.jsx)(vK.Remove,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Remove file`,className:`aui-attachment-tile-remove absolute end-1 top-1 size-5 rounded-full bg-black/50! text-white after:absolute after:-inset-1.5 hover:bg-black/70! hover:text-white! active:scale-[0.96] motion-reduce:transition-none`,side:`top`,children:(0,P.jsx)(Pe,{className:`aui-attachment-remove-icon size-3 stroke-[2.5]`})})}),s$=()=>(0,P.jsx)(`div`,{className:`aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2 empty:hidden`,children:(0,P.jsx)(FY.Attachments,{children:()=>(0,P.jsx)(a$,{})})}),c$=()=>(0,P.jsx)(`div`,{className:`aui-composer-attachments flex w-full flex-row items-center gap-2 overflow-x-auto empty:hidden`,children:(0,P.jsx)(CJ.Attachments,{children:()=>(0,P.jsx)(a$,{})})}),l$=()=>(0,P.jsx)(CJ.AddAttachment,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Add Attachment`,side:`bottom`,variant:`ghost`,size:`icon`,className:`aui-composer-add-attachment text-muted-foreground hover:text-foreground hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-7 rounded-full active:scale-[0.96] motion-reduce:transition-none`,"aria-label":`Add Attachment`,children:(0,P.jsx)(be,{className:`aui-attachment-add-icon size-4`})})}),u$=y(`aui-file-root inline-flex items-center gap-3 rounded-lg transition-colors`,{variants:{variant:{outline:`border-border hover:bg-muted/50 border`,ghost:`hover:bg-muted/50`,muted:`bg-muted/50 hover:bg-muted/70`},size:{sm:`px-2.5 py-1.5 text-xs`,default:`px-3 py-2 text-sm`,lg:`px-4 py-3 text-base`}},defaultVariants:{variant:`outline`,size:`default`}});function d$(e){let t=e.toLowerCase();return t.startsWith(`image/`)?de:t===`application/pdf`?ce:t===`application/json`?O:t.startsWith(`text/`)?ce:t.startsWith(`audio/`)?ge:t.startsWith(`video/`)?Me:le}function f$(e,t){return t===`url`&&/^data:/i.test(e)?`data-uri`:t||(/^data:/i.test(e)?`data-uri`:/^https?:\/\//i.test(e)?`url`:`base64`)}function p$(e){let t=e.endsWith(`==`)?2:+!!e.endsWith(`=`),n=e.search(/[^A-Za-z\d+/]/);return n!==-1&&n!==e.length-t||e.length%4==1||t>0&&e.length%4!=0?0:Math.floor(e.length*3/4)-t}function m$(e){return p$(/[\t\n\f\r ]/.test(e)?e.replace(/[\t\n\f\r ]/g,``):e)}function h$(e){let t=e.indexOf(`#`),n=t<0?e.length:t,r=e.indexOf(`,`);if(r<0||r>=n)return 0;let i=e.slice(r+1,n);return/;base64$/i.test(e.slice(0,r))?(/[%\t\n\f\r ]/.test(i)&&(i=i.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16))).replace(/[\t\n\f\r ]/g,``)),p$(i)):new TextEncoder().encode(i.replace(/%[\da-f]{2}/gi,`_`)).byteLength}function g$(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function _$({className:e,variant:t,size:n,children:r,...i}){return(0,P.jsx)(`div`,{"data-slot":`file-root`,"data-variant":t,"data-size":n,className:a(u$({variant:t,size:n,className:e})),...i,children:r})}function v$({mimeType:e,className:t,children:n,...r}){let i=e?d$(e):le;return(0,P.jsx)(`span`,{"data-slot":`file-icon`,className:a(`text-muted-foreground shrink-0`,t),...r,children:n??(0,P.jsx)(i,{className:`size-5`})})}function y$({className:e,children:t,...n}){return(0,P.jsx)(`span`,{"data-slot":`file-name`,className:a(`min-w-0 flex-1 truncate font-medium`,e),...n,children:t||`Unnamed file`})}function b$({bytes:e,className:t,...n}){return(0,P.jsx)(`span`,{"data-slot":`file-size`,className:a(`text-muted-foreground shrink-0`,t),...n,children:g$(e)})}function x$({data:e,mimeType:t,filename:n,sourceType:r,className:i,children:o,...s}){if(typeof e!=`string`)return null;let c=f$(e,r);if(c===`id`||c===`url`&&!/^(https?:\/\/|blob:)/i.test(e))return null;let l=c===`base64`?`data:${t};base64,${e}`:e;return(0,P.jsx)(`a`,{"data-slot":`file-download`,href:l,download:n||`download`,...c===`url`&&{target:`_blank`,rel:`noopener noreferrer`},className:a(`text-muted-foreground hover:bg-accent hover:text-accent-foreground shrink-0 rounded-md p-1 transition-colors`,i),"aria-label":o?void 0:`Download ${n||`file`}`,...s,children:o||(0,P.jsx)(ae,{className:`size-4`})})}var S$=(0,N.memo)(({filename:e,data:t,mimeType:n,sourceType:r})=>{let i=f$(t,r);return(0,P.jsxs)(_$,{children:[(0,P.jsx)(v$,{mimeType:n}),(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,P.jsx)(y$,{children:e}),typeof t==`string`&&(i===`base64`||i===`data-uri`)&&(0,P.jsx)(b$,{bytes:i===`data-uri`?h$(t):m$(t),className:`text-xs`})]}),(0,P.jsx)(x$,{data:t,mimeType:n,...e!==void 0&&{filename:e},...r!==void 0&&{sourceType:r}})]})});S$.displayName=`File`,S$.Root=_$,S$.Icon=v$,S$.Name=y$,S$.Size=b$,S$.Download=x$;var C$=()=>{let e=$(e=>e.thread.suggestions),t=(0,N.useRef)(null),n=(0,N.useRef)(null),[r,i]=(0,N.useState)({left:!1,right:!1}),a=(0,N.useCallback)(()=>{let e=t.current;if(!e)return;let r=e.scrollWidth-e.clientWidth,a=Math.abs(e.scrollLeft),[o,s]=(n.current??=getComputedStyle(e).direction===`rtl`)?[r-a,a]:[a,r-a];i(e=>{let t={left:o>1,right:s>1};return e.left===t.left&&e.right===t.right?e:t})},[]);(0,N.useEffect)(()=>{a();let e=t.current;if(!e?.firstElementChild)return;let n=new ResizeObserver(a);return n.observe(e),n.observe(e.firstElementChild),()=>n.disconnect()},[a]);let o=`linear-gradient(to right, ${r.left?`transparent, black 2rem`:`black`}, ${r.right?`black calc(100% - 2rem), transparent`:`black`})`;return(0,P.jsx)(`div`,{ref:t,onScroll:a,className:`aui-thread-followup-suggestions -my-1 w-full [scrollbar-width:none] overflow-x-auto py-1 [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden`,style:{maskImage:o,WebkitMaskImage:o},children:(0,P.jsx)(`div`,{className:`mx-auto flex min-h-8 w-max items-center gap-2 px-0.5`,children:e.map((e,t)=>(0,P.jsxs)(yX.Suggestion,{className:`aui-thread-followup-suggestion border-foreground/10 hover:bg-foreground/[0.03] hover:border-foreground/25 rounded-md border px-2.5 py-1 text-sm whitespace-nowrap transition-colors ease-in motion-reduce:transition-none`,prompt:e.prompt,send:!0,children:[e.title??e.prompt,e.label&&(0,P.jsx)(`span`,{className:`aui-thread-followup-suggestion-label text-muted-foreground ms-1`,children:e.label})]},t))})})},w$=()=>(0,P.jsx)(JI,{condition:e=>!e.thread.isEmpty&&!e.thread.isRunning&&e.thread.suggestions.length>0,children:(0,P.jsx)(C$,{})}),T$=e=>{switch(e){case`image/png`:return`png`;case`image/jpeg`:case`image/jpg`:return`jpg`;case`image/webp`:return`webp`;case`image/gif`:return`gif`;case`image/svg+xml`:return`svg`;default:return`png`}},E$=e=>{let t=e.indexOf(`,`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):``,i=n.match(/data:([^;]+)/i)?.[1]?.toLowerCase()??`application/octet-stream`;if(!/;base64/i.test(n)){let e=r.replace(/(?:%[0-9A-Fa-f]{2})+/g,e=>{try{return decodeURIComponent(e)}catch{return e}});return new Blob([e],{type:i})}let a;try{let e=r.replace(/%([\da-f]{2})/gi,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));a=atob(e)}catch{return null}let o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);return new Blob([o],{type:i})},D$=e=>e.match(/^data:([^;,]+)/i)?.[1]?.toLowerCase(),O$=e=>{if(typeof document>`u`)return;let t=T$(D$(e.image)),n=e.filename??`image.${t}`,r=/^data:/i.test(e.image),i=r?E$(e.image):null;if(r&&!i)return;let a=i?URL.createObjectURL(i):null,o=a??e.image,s=document.createElement(`a`);s.href=o,s.download=n,s.rel=`noopener`,document.body.appendChild(s),s.click(),document.body.removeChild(s),a&&setTimeout(()=>URL.revokeObjectURL(a),4e4)},k$=async e=>{if(typeof navigator>`u`||!navigator.clipboard||typeof ClipboardItem>`u`)throw Error(`Clipboard API is not available in this environment.`);let t=/^data:/i.test(e.image)?E$(e.image):await fetch(e.image).then(e=>e.blob());if(!t)return;let n=D$(e.image)??t.type??`image/png`;await navigator.clipboard.write([new ClipboardItem({[n]:t})])},A$=y(`aui-image-root relative overflow-hidden rounded-lg`,{variants:{variant:{outline:`border-border border`,ghost:``,muted:`bg-muted/50`},size:{sm:`max-w-64`,default:`max-w-96`,lg:`max-w-[512px]`,full:`w-full`}},defaultVariants:{variant:`outline`,size:`default`}});function j$({className:e,variant:t,size:n,children:r,...i}){return(0,P.jsx)(`div`,{"data-slot":`image-root`,"data-variant":t,"data-size":n,className:a(A$({variant:t,size:n,className:e})),...i,children:r})}function M$({className:e,containerClassName:t,onLoad:n,onError:r,alt:i=`Image content`,src:o,...s}){let c=(0,N.useRef)(null),[l,u]=(0,N.useState)(void 0),[d,f]=(0,N.useState)(void 0),p=l===o,m=d===o;return(0,N.useEffect)(()=>{let e=c.current;typeof o==`string`&&e?.complete&&(e.naturalWidth>0?u(o):f(o))},[o]),(0,P.jsxs)(`div`,{"data-slot":`image-preview`,className:a(`relative min-h-32`,t),children:[!p&&!m&&(0,P.jsx)(`div`,{"data-slot":`image-preview-loading`,className:`bg-muted/50 absolute inset-0 flex items-center justify-center`,children:(0,P.jsx)(de,{className:`text-muted-foreground size-8 animate-pulse`})}),m?(0,P.jsx)(`div`,{"data-slot":`image-preview-error`,className:`bg-muted/50 flex min-h-32 items-center justify-center p-4`,children:(0,P.jsx)(ue,{className:`text-muted-foreground size-8`})}):(0,P.jsx)(`img`,{ref:c,src:o,alt:i,className:a(`block h-auto w-full object-contain`,!p&&`invisible`,e),onLoad:e=>{typeof o==`string`&&u(o),n?.(e)},onError:e=>{typeof o==`string`&&f(o),r?.(e)},...s})]})}function N$({className:e,children:t,...n}){return t?(0,P.jsx)(`span`,{"data-slot":`image-filename`,className:a(`text-muted-foreground block truncate px-2 py-1.5 text-xs`,e),...n,children:t}):null}function P$({src:e,alt:t=`Image preview`,children:n}){let[r,i]=(0,N.useState)(!1),a=(0,N.useRef)(null),o=(0,N.useRef)(null),s=(0,N.useRef)(null),c=(0,N.useCallback)(()=>i(!0),[]),l=(0,N.useCallback)(()=>{i(!1),a.current?.focus()},[]);return(0,N.useEffect)(()=>{if(!r)return;let e=e=>{if(e.key===`Escape`){l();return}if(e.key!==`Tab`)return;let t=s.current?.querySelectorAll(`a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])`),n=t?.[0],r=t?.[t.length-1];n&&r&&(e.shiftKey&&document.activeElement===n?(e.preventDefault(),r.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n.focus()))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r,l]),(0,N.useEffect)(()=>{if(!r)return;let e=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=e}},[r]),(0,N.useEffect)(()=>{r&&o.current?.focus()},[r]),(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{ref:a,onClick:c,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),e.currentTarget.click()):e.key===` `&&e.preventDefault()},onKeyUp:e=>{e.key===` `&&e.currentTarget.click()},role:`button`,tabIndex:0,className:`aui-image-zoom-trigger cursor-zoom-in`,"aria-label":`Click to zoom image`,children:n}),r&&(0,Rn.createPortal)((0,P.jsxs)(`div`,{ref:s,"data-slot":`image-zoom-overlay`,role:`dialog`,"aria-modal":`true`,className:`aui-image-zoom-overlay fade-in animate-in fixed inset-0 z-50 flex items-center justify-center bg-black/80 duration-200`,onClick:l,"aria-label":`Zoomed image`,children:[(0,P.jsx)(`img`,{"data-slot":`image-zoom-content`,src:e,alt:t,className:`aui-image-zoom-content fade-in zoom-in-95 animate-in max-h-[90vh] max-w-[90vw] cursor-zoom-out object-contain duration-200`,onClick:e=>{e.stopPropagation(),l()}}),(0,P.jsx)(`button`,{ref:o,type:`button`,"aria-label":`Close zoomed image`,onClick:e=>{e.stopPropagation(),l()},className:`text-muted-foreground hover:text-foreground bg-background/80 absolute end-4 top-4 cursor-pointer rounded-md p-2`,children:(0,P.jsx)(Pe,{className:`size-5`})})]}),document.body)]})}function F$({className:e}){return(0,P.jsxs)(`div`,{"data-slot":`image-generating`,className:a(`bg-muted/50 flex min-h-32 items-center justify-center p-4`,e),children:[(0,P.jsx)(pe,{className:`text-muted-foreground size-8 animate-spin`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`Generating image…`})]})}function I$({className:e,reason:t}){return(0,P.jsxs)(`div`,{"data-slot":`image-content-filter-error`,className:a(`bg-muted/50 flex min-h-32 flex-col items-center justify-center gap-2 p-4 text-center`,e),children:[(0,P.jsx)(we,{className:`text-muted-foreground size-8`}),(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Image could not be generated`}),t&&(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:t})]})}function L$({onRegenerate:e}){let[t,n]=(0,N.useState)(!1);return(0,P.jsx)(`button`,{type:`button`,onClick:async()=>{n(!0);try{await e()}catch{}finally{n(!1)}},disabled:t,"data-slot":`image-regenerate`,"aria-label":`Regenerate image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded disabled:opacity-50`,children:(0,P.jsx)(xe,{className:a(`size-4`,t&&`animate-spin`)})})}function R$({part:e,onRegenerate:t,className:n}){return(0,P.jsxs)(`div`,{"data-slot":`image-actions`,className:a(`flex items-center gap-1 p-1`,n),children:[(0,P.jsx)(`button`,{type:`button`,onClick:()=>O$(e),"data-slot":`image-download`,"aria-label":`Download image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,P.jsx)(ae,{className:`size-4`})}),(0,P.jsx)(`button`,{type:`button`,onClick:()=>{k$(e).catch(()=>{})},"data-slot":`image-copy`,"aria-label":`Copy image`,className:`hover:bg-muted inline-flex size-7 items-center justify-center rounded`,children:(0,P.jsx)(ie,{className:`size-4`})}),t&&(0,P.jsx)(L$,{onRegenerate:t})]})}var z$=(0,N.memo)(e=>{let{image:t,filename:n,status:r}=e;return r?.type===`running`?(0,P.jsxs)(j$,{children:[(0,P.jsx)(F$,{}),(0,P.jsx)(N$,{children:n})]}):r?.type===`incomplete`&&r.reason===`content-filter`?(0,P.jsx)(j$,{children:(0,P.jsx)(I$,{reason:`The provider blocked this image.`})}):(0,P.jsxs)(j$,{children:[(0,P.jsx)(P$,{src:t,alt:n||`Image content`,children:(0,P.jsx)(M$,{src:t,alt:n||`Image content`})}),(0,P.jsx)(N$,{children:n})]})});z$.displayName=`Image`,z$.Root=j$,z$.Preview=M$,z$.Filename=N$,z$.Zoom=P$,z$.Actions=R$,z$.Generating=F$,z$.ContentFilterError=I$;var B$=(e,t)=>typeof e==`string`?e===t:JSON.stringify(e)===JSON.stringify(t),V$=(e,t)=>{if(!e||!t)return!1;let n=e=>{let{position:t,data:n,...r}=e||{};return r};return JSON.stringify(n(e.properties))===JSON.stringify(n(t.properties))&&B$(e.children,t.children)},H$=(e,t)=>V$(e.node,t.node),U$=(e={})=>Object.fromEntries(Object.entries(e??{}).map(([e,t])=>{if(!t)return[e,t];let n=t;return[e,(0,N.memo)(({node:e,...t})=>(0,P.jsx)(n,{...t}),H$)]})),W$=(0,N.createContext)(null),G$=()=>(0,N.useContext)(W$)!==null,K$=(0,N.memo)(({children:e,fallbackPre:t,...n})=>n.node?.children.some(e=>e.type===`element`&&e.tagName===`code`)??!0?(0,P.jsx)(W$.Provider,{value:n,children:e}):(0,P.jsx)(t,{...n,children:e}),(e,t)=>e.fallbackPre===t.fallbackPre&&H$(e,t)),q$=({node:e,...t})=>(0,P.jsx)(`pre`,{...t}),J$=({node:e,...t})=>(0,P.jsx)(`code`,{...t}),Y$=({node:e,components:{Pre:t,Code:n},code:r})=>(0,P.jsx)(t,{children:(0,P.jsx)(n,{node:e,children:r})}),X$=()=>null,Z$=e=>/language-([^\s]+)/.exec(e??``)?.[1]??``,Q$=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},language:a,code:o})=>{let s=(0,N.useMemo)(()=>({Pre:t,Code:n}),[t,n]);return(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(i,{node:e,language:a,code:o}),(0,P.jsx)(r,{node:e,components:s,language:a,code:o})]})},$$=n(r(((e,t)=>{(function(){var e={}.hasOwnProperty;function n(){for(var e=``,t=0;t<arguments.length;t++){var n=arguments[t];n&&(e=i(e,r(n)))}return e}function r(t){if(typeof t==`string`||typeof t==`number`)return t;if(typeof t!=`object`)return``;if(Array.isArray(t))return n.apply(null,t);if(t.toString!==Object.prototype.toString&&!t.toString.toString().includes(`[native code]`))return t.toString();var r=``;for(var a in t)e.call(t,a)&&t[a]&&(r=i(r,a));return r}function i(e,t){return t?e?e+` `+t:e+t:e}t!==void 0&&t.exports?(n.default=n,t.exports=n):typeof define==`function`&&typeof define.amd==`object`&&define.amd?define(`classnames`,[],function(){return n}):window.classNames=n})()}))(),1),e1=({className:e,...t})=>({className:n,...r})=>({className:(0,$$.default)(e,n),...t,...r});function t1(e){if(typeof e==`string`)return e;if(Array.isArray(e)){let t=``;for(let n of e)t+=t1(n);return t}return(0,N.isValidElement)(e)?t1(e.props.children):``}var n1=({node:e,components:{Pre:t,Code:n,SyntaxHighlighter:r,CodeHeader:i},componentsByLanguage:a={},children:o,...s})=>{let c=e1((0,N.useContext)(W$)),l=on(e=>(0,P.jsx)(t,{...c(e)})),u=e1(s),d=on(e=>(0,P.jsx)(n,{...u(e)})),f=Z$(s.className),p=a[f]?.SyntaxHighlighter??r,m=a[f]?.CodeHeader??i;return o!=null&&typeof o!=`string`?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(m,{node:e,language:f,code:t1(o)}),(0,P.jsx)(Y$,{node:e,components:{Pre:l,Code:d},code:o})]}):(0,P.jsx)(Q$,{node:e,components:{Pre:l,Code:d,SyntaxHighlighter:p,CodeHeader:m},language:f,code:o??``})},r1=({node:e,components:t,componentsByLanguage:n,...r})=>G$()?(0,P.jsx)(n1,{node:e,components:t,componentsByLanguage:n,...r}):(0,P.jsx)(t.Code,{...r}),i1=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let n=e[r],i=t[r];if(n!==i&&(!n||!i||n.SyntaxHighlighter!==i.SyntaxHighlighter||n.CodeHeader!==i.CodeHeader))return!1}return!0},a1=(0,N.memo)(r1,(e,t)=>e.components===t.components&&i1(e.componentsByLanguage,t.componentsByLanguage)&&H$(e,t)),{useSmooth:o1,useSmoothStatus:s1,withSmoothContextProvider:c1}=sZ,l1=(0,N.memo)(({text:e,overrideVersion:t,...n})=>(0,P.jsx)(WD,{...n,children:e}));l1.displayName=`MarkdownRenderer`;var u1=({text:e,...t})=>{let n=(0,N.useDeferredValue)(e);return(0,P.jsx)(l1,{text:n,...t})},d1=e=>typeof e==`object`&&!!e&&!Array.isArray(e),f1=(e,t,n=1)=>{if(Object.is(e,t))return!0;if(n<=0)return!1;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!f1(e[r],t[r],n-1))return!1;return!0}if(d1(e)&&d1(t)){let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(r=>Object.hasOwn(t,r)&&f1(e[r],t[r],n-1))}return!1};function p1(e,t){let n=(0,N.useRef)(e);return f1(e,n.current,t)||(n.current=e),n.current}function m1(e){let t=(0,N.useRef)(e),n=(e,t)=>e[t],r=Object.keys(e),i=Object.keys(t.current);return r.length===i.length&&r.every(r=>Object.hasOwn(t.current,r)&&f1(n(e,r),n(t.current,r)))||(t.current=e),t.current}var h1=({components:e,componentsByLanguage:t,smooth:n=!0,defer:r=!1,preprocess:i,...a})=>{let{text:o}=o1(EJ(),n),s=(0,N.useMemo)(()=>i?i(o):o,[i,o]),{pre:c=q$,code:l=J$,SyntaxHighlighter:u=Y$,CodeHeader:d=X$}=e??{},f=(0,N.useMemo)(()=>({Pre:c,Code:l,SyntaxHighlighter:u,CodeHeader:d}),[c,l,u,d]),p=on(e=>(0,P.jsx)(a1,{components:f,componentsByLanguage:t,...e})),m=on(e=>(0,P.jsx)(K$,{fallbackPre:c,...e})),h=m1((0,N.useMemo)(()=>{let{pre:t,code:n,SyntaxHighlighter:r,CodeHeader:i,...a}=e??{};return{...a,pre:m,code:p}},[p,m,e])),g=p1((0,N.useMemo)(()=>({components:f,componentsByLanguage:t}),[f,t]),3),_=r?u1:l1,v=m1(a);return(0,P.jsx)(_,{text:s,components:h,overrideVersion:g,...v})},g1=(0,N.forwardRef)(({className:e,containerProps:t,containerComponent:n=`div`,...r},i)=>{let a=s1();return(0,P.jsx)(n,{"data-status":a.type,...t,className:(0,$$.default)(e,t?.className),ref:i,children:(0,P.jsx)(h1,{...r})})});g1.displayName=`MarkdownTextPrimitive`;var _1=c1(g1),v1=({copiedDuration:e=3e3}={})=>{let[t,n]=(0,N.useState)(!1),r=(0,N.useRef)(void 0),i=(0,N.useRef)(0);return(0,N.useEffect)(()=>()=>{i.current+=1,r.current!==void 0&&(clearTimeout(r.current),r.current=void 0,n(!1))},[]),{isCopied:t,copyToClipboard:t=>{if(!t||typeof navigator>`u`||!navigator.clipboard)return;let a=i.current;navigator.clipboard.writeText(t).then(()=>{a===i.current&&(r.current!==void 0&&clearTimeout(r.current),n(!0),r.current=setTimeout(()=>{r.current=void 0,n(!1)},e))},()=>{})}}},y1=e=>{let t=(0,N.useRef)(e);if(e!==t.current){let n=t.current;e!==void 0&&n!==void 0&&Object.keys(n).length===Object.keys(e).length&&Object.keys(e).every(t=>n[t]===e[t])||(t.current=e)}return t.current},b1=(0,N.memo)(({components:e})=>{let t=y1(e),n=(0,N.useMemo)(()=>t?{...x1,...U$(t)}:x1,[t]);return(0,P.jsx)(_1,{remarkPlugins:[JA],className:`aui-md`,components:n,defer:!0})}),x1=U$({h1:({className:e,...t})=>(0,P.jsx)(`h1`,{className:a(`aui-md-h1 mt-5 mb-2 scroll-m-20 text-xl font-semibold first:mt-0 last:mb-0`,e),...t}),h2:({className:e,...t})=>(0,P.jsx)(`h2`,{className:a(`aui-md-h2 mt-5 mb-2 scroll-m-20 text-lg font-semibold first:mt-0 last:mb-0`,e),...t}),h3:({className:e,...t})=>(0,P.jsx)(`h3`,{className:a(`aui-md-h3 mt-4 mb-1.5 scroll-m-20 text-base font-semibold first:mt-0 last:mb-0`,e),...t}),h4:({className:e,...t})=>(0,P.jsx)(`h4`,{className:a(`aui-md-h4 mt-3.5 mb-1 scroll-m-20 text-base font-medium first:mt-0 last:mb-0`,e),...t}),h5:({className:e,...t})=>(0,P.jsx)(`h5`,{className:a(`aui-md-h5 mt-3 mb-1 text-sm font-semibold first:mt-0 last:mb-0`,e),...t}),h6:({className:e,...t})=>(0,P.jsx)(`h6`,{className:a(`aui-md-h6 mt-3 mb-1 text-sm font-medium first:mt-0 last:mb-0`,e),...t}),p:({className:e,...t})=>(0,P.jsx)(`p`,{className:a(`aui-md-p my-3 leading-relaxed first:mt-0 last:mb-0`,e),...t}),a:({className:e,...t})=>(0,P.jsx)(`a`,{className:a(`aui-md-a text-primary hover:text-primary/80 underline underline-offset-2`,e),...t}),blockquote:({className:e,...t})=>(0,P.jsx)(`blockquote`,{className:a(`aui-md-blockquote border-muted-foreground/30 text-muted-foreground my-3 border-s-2 ps-4`,e),...t}),ul:({className:e,...t})=>(0,P.jsx)(`ul`,{className:a(`aui-md-ul marker:text-muted-foreground my-3 ms-5 list-disc [&>li]:mt-1`,e),...t}),ol:({className:e,...t})=>(0,P.jsx)(`ol`,{className:a(`aui-md-ol marker:text-muted-foreground my-3 ms-5 list-decimal [&>li]:mt-1`,e),...t}),hr:({className:e,...t})=>(0,P.jsx)(`hr`,{className:a(`aui-md-hr border-muted-foreground/20 my-3`,e),...t}),table:({className:e,...t})=>(0,P.jsx)(`div`,{className:`aui-md-table-wrapper my-3 overflow-x-auto`,children:(0,P.jsx)(`table`,{className:a(`aui-md-table w-full border-separate border-spacing-0`,e),...t})}),th:({className:e,...t})=>(0,P.jsx)(`th`,{className:a(`aui-md-th bg-muted px-3 py-1.5 text-start font-medium first:rounded-ss-lg last:rounded-se-lg [[align=center]]:text-center [[align=right]]:text-right`,e),...t}),td:({className:e,...t})=>(0,P.jsx)(`td`,{className:a(`aui-md-td border-muted-foreground/20 border-s border-b px-3 py-1.5 text-start last:border-e [[align=center]]:text-center [[align=right]]:text-right`,e),...t}),tr:({className:e,...t})=>(0,P.jsx)(`tr`,{className:a(`aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-es-lg [&:last-child>td:last-child]:rounded-ee-lg`,e),...t}),li:({className:e,...t})=>(0,P.jsx)(`li`,{className:a(`aui-md-li leading-relaxed`,e),...t}),strong:({className:e,...t})=>(0,P.jsx)(`strong`,{className:a(`aui-md-strong font-semibold`,e),...t}),sup:({className:e,...t})=>(0,P.jsx)(`sup`,{className:a(`aui-md-sup [&>a]:text-xs [&>a]:no-underline`,e),...t}),pre:({className:e,...t})=>(0,P.jsx)(`pre`,{className:a(`aui-md-pre border-border/50 bg-muted/30 overflow-x-auto rounded-t-none rounded-b-xl border border-t-0 p-3.5 text-[13px] leading-relaxed`,e),...t}),code:function({className:e,...t}){let n=G$();return(0,P.jsx)(`code`,{className:a(!n&&`aui-md-inline-code bg-muted rounded-md px-1.5 py-0.5 font-mono text-[0.85em]`,e),...t})},CodeHeader:({language:e,code:t})=>{let{isCopied:n,copyToClipboard:r}=v1();return(0,P.jsxs)(`div`,{className:`aui-code-header-root border-border/50 bg-muted/50 mt-3 flex items-center justify-between rounded-t-xl border border-b-0 px-3.5 py-1.5 text-xs`,children:[(0,P.jsx)(`span`,{className:`aui-code-header-language text-muted-foreground font-medium lowercase`,children:e}),(0,P.jsxs)(qQ,{tooltip:`Copy`,onClick:()=>{t&&!n&&r(t)},children:[!n&&(0,P.jsx)(ie,{className:`animate-in zoom-in-75 fade-in duration-150`}),n&&(0,P.jsx)(A,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})]})]})}});function S1({...e}){return(0,P.jsx)(Qt,{"data-slot":`collapsible`,...e})}function C1({...e}){return(0,P.jsx)(qt,{"data-slot":`collapsible-trigger`,...e})}function w1({...e}){return(0,P.jsx)(Yt,{"data-slot":`collapsible-content`,...e})}var T1=(0,N.createContext)(!1),E1=y(`aui-reasoning-root mb-4 w-full`,{variants:{variant:{outline:`rounded-lg border px-3 py-2`,ghost:``,muted:`bg-muted/50 rounded-lg px-3 py-2`}},defaultVariants:{variant:`outline`}});function D1({className:e,variant:t,open:n,onOpenChange:r,defaultOpen:i=!1,streaming:o,onAnimationStart:s,children:c,...l}){let[u]=(0,N.useState)(i),[d,f]=(0,N.useState)(null),p=n!==void 0,m=p?n:d??(o||u),h=o===!0&&m,g=(0,N.useRef)(o);(0,N.useLayoutEffect)(()=>{g.current!==o&&(g.current=o,!p&&d===null&&!u&&s?.())},[o,p,d,u,s]);let _=(0,N.useCallback)(e=>{s?.(),p||f(e),r?.(e)},[s,p,r]);return(0,P.jsx)(S1,{"data-slot":`reasoning-root`,"data-variant":t,open:m,onOpenChange:_,className:a(`group/reasoning-root`,E1({variant:t,className:e})),style:{"--animation-duration":`200ms`},...l,children:(0,P.jsx)(T1.Provider,{value:h,children:c})})}function O1({side:e=`bottom`,className:t,...n}){return e===`top`?(0,P.jsx)(`div`,{"data-slot":`reasoning-fade`,className:a(`aui-reasoning-fade pointer-events-none absolute inset-x-0 top-0 z-10 h-8`,`bg-[linear-gradient(to_bottom,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_bottom,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,t),...n}):(0,P.jsx)(`div`,{"data-slot":`reasoning-fade`,className:a(`aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-8`,`bg-[linear-gradient(to_top,var(--color-background),transparent)]`,`group-data-[variant=muted]/reasoning-root:bg-[linear-gradient(to_top,color-mix(in_oklab,var(--color-muted)_50%,var(--color-background)),transparent)]`,`fade-in-0 animate-in`,`animation-duration-(--animation-duration)`,t),...n})}function k1({active:e,duration:t,className:n,...r}){let i=t?` (${t}s)`:``;return(0,P.jsxs)(C1,{"data-slot":`reasoning-trigger`,className:a(`aui-reasoning-trigger group/trigger text-muted-foreground hover:text-foreground flex max-w-[75%] origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]`,n),...r,children:[(0,P.jsx)(k,{"data-slot":`reasoning-trigger-icon`,className:`aui-reasoning-trigger-icon size-4 shrink-0`}),(0,P.jsxs)(`span`,{"data-slot":`reasoning-trigger-label`,className:a(`aui-reasoning-trigger-label-wrapper inline-block leading-none tabular-nums`,e&&`shimmer motion-reduce:animate-none`),children:[`Reasoning`,i]}),(0,P.jsx)(j,{"data-slot":`reasoning-trigger-chevron`,className:a(`aui-reasoning-trigger-chevron mt-0.5 size-4 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function A1({className:e,children:t,...n}){let r=(0,N.useContext)(T1);return(0,P.jsxs)(w1,{"data-slot":`reasoning-content`,className:a(`aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:[(0,P.jsx)(O1,{side:`top`}),t,r?(0,P.jsx)(O1,{}):null]})}function j1({className:e,children:t,...n}){let r=(0,N.useContext)(T1),i=(0,N.useRef)(null),o=(0,N.useRef)(null);return(0,N.useEffect)(()=>{if(!r)return;let e=i.current,t=o.current;if(!e||!t)return;let n=!0,a=e.scrollTop,s=e.scrollHeight,c=()=>Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight,l=()=>{n&&(e.scrollTop=e.scrollHeight)},u=()=>{c()?n=!0:e.scrollTop<a&&e.scrollHeight===s&&(n=!1),a=e.scrollTop,s=e.scrollHeight};l(),e.addEventListener(`scroll`,u);let d=new ResizeObserver(l);return d.observe(t),()=>{e.removeEventListener(`scroll`,u),d.disconnect()}},[r]),(0,P.jsx)(`div`,{ref:i,"data-slot":`reasoning-text`,className:a(`aui-reasoning-text relative z-0 max-h-64 overflow-y-auto ps-6 pt-2 pb-2 leading-relaxed text-pretty`,`transform-gpu transition-[transform,opacity] ease-[cubic-bezier(0.32,0.72,0,1)]`,`motion-reduce:animate-none`,`group-data-open/collapsible-content:animate-in`,`group-data-closed/collapsible-content:animate-out`,`group-data-open/collapsible-content:fade-in-0`,`group-data-closed/collapsible-content:fade-out-0`,`group-data-open/collapsible-content:slide-in-from-top-4`,`group-data-closed/collapsible-content:slide-out-to-top-4`,`group-data-open/collapsible-content:blur-in-[2px]`,`group-data-closed/collapsible-content:blur-out-[2px]`,`group-data-open/collapsible-content:animation-duration-(--animation-duration)`,`group-data-closed/collapsible-content:animation-duration-(--animation-duration)`,e),...n,children:(0,P.jsx)(`div`,{ref:o,className:`aui-reasoning-text-content space-y-4`,children:t})})}function M1({ref:e,onAnimationStart:t,...n}){let r=(0,N.useRef)(null),i=nZ(r,200),a=(0,N.useCallback)(()=>{i(),t?.()},[i,t]),o=(0,N.useCallback)(t=>{r.current=t,typeof e==`function`?e(t):e&&(e.current=t)},[e]);return(0,P.jsx)(D1,{ref:o,onAnimationStart:a,...n})}var N1=()=>(0,P.jsx)(b1,{}),P1=({children:e,startIndex:t,endIndex:n})=>{let r=$(e=>{if(e.message.status?.type!==`running`)return!1;for(let r=t;r<=n;r++)if(e.message.parts[r]?.status.type===`running`)return!0;return!1});return(0,P.jsxs)(M1,{streaming:r,children:[(0,P.jsx)(k1,{active:r}),(0,P.jsx)(A1,{"aria-busy":r,children:(0,P.jsx)(j1,{children:e})})]})},F1=(0,N.memo)(N1);F1.displayName=`Reasoning`,F1.Root=M1,F1.Trigger=k1,F1.Content=A1,F1.Text=j1,F1.Fade=O1;var I1=(0,N.memo)(P1);I1.displayName=`ReasoningGroup`;function L1({className:e,...t}){return(0,P.jsx)(`textarea`,{"data-slot":`textarea`,className:a(`flex field-sizing-content min-h-16 w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:ring-destructive/40`,e),...t})}var R1=200,z1=`active:scale-[0.98]`;function B1({className:e,open:t,onOpenChange:n,defaultOpen:r=!1,children:i,...o}){let s=(0,N.useRef)(null),[c,l]=(0,N.useState)(r),u=nZ(s,R1),d=t!==void 0,f=d?t:c,p=(0,N.useCallback)(e=>{u(),d||l(e),n?.(e)},[u,d,n]);return(0,P.jsx)(S1,{ref:s,"data-slot":`tool-fallback-root`,open:f,onOpenChange:p,className:a(`aui-tool-fallback-root group/tool-fallback-root w-full`,e),style:{"--animation-duration":`${R1}ms`},...o,children:i})}var V1={running:me,complete:A,incomplete:ne,"requires-action":te},H1=e=>{if(e<1e3)return`<1s`;let t=e/1e3;return t<10?`${(Math.floor(t*10)/10).toFixed(1)}s`:t<60?`${Math.floor(t)}s`:`${Math.floor(t/60)}m ${Math.floor(t%60)}s`};function U1({className:e,...t}){let n=rZ();return n===void 0?null:(0,P.jsx)(`span`,{"data-slot":`tool-fallback-duration`,className:a(`aui-tool-fallback-duration text-muted-foreground text-xs tabular-nums`,e),...t,children:H1(n)})}function W1({toolName:e,status:t,className:n,...r}){let i=t?.type??`complete`,o=i===`running`,s=t?.type===`incomplete`&&t.reason===`cancelled`,c=V1[i],l=s?`Cancelled tool`:`Used tool`;return(0,P.jsxs)(C1,{"data-slot":`tool-fallback-trigger`,className:a(`aui-tool-fallback-trigger group/trigger text-muted-foreground hover:text-foreground flex w-fit origin-left items-center gap-2 py-1.5 text-sm transition-[color,scale] active:scale-[0.98]`,n),...r,children:[(0,P.jsx)(c,{"data-slot":`tool-fallback-trigger-icon`,className:a(`aui-tool-fallback-trigger-icon size-4 shrink-0`,s&&`text-muted-foreground`,o&&`animate-spin [animation-duration:0.6s]`)}),(0,P.jsxs)(`span`,{"data-slot":`tool-fallback-trigger-label`,className:a(`aui-tool-fallback-trigger-label-wrapper inline-block text-start leading-none`,s&&`text-muted-foreground line-through`,o&&`shimmer motion-reduce:animate-none`),children:[l,`: `,(0,P.jsx)(`b`,{children:e})]}),(0,P.jsx)(U1,{}),(0,P.jsx)(j,{"data-slot":`tool-fallback-trigger-chevron`,className:a(`aui-tool-fallback-trigger-chevron size-4 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function G1({className:e,children:t,...n}){return(0,P.jsx)(w1,{"data-slot":`tool-fallback-content`,className:a(`aui-tool-fallback-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:(0,P.jsx)(`div`,{className:a(`flex flex-col gap-2 ps-6 pt-1 pb-2 ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`group-data-open/collapsible-content:animate-in group-data-open/collapsible-content:fade-in-0 group-data-open/collapsible-content:blur-in-[2px] group-data-open/collapsible-content:slide-in-from-top-1`,`group-data-closed/collapsible-content:animate-out group-data-closed/collapsible-content:fade-out-0 group-data-closed/collapsible-content:blur-out-[2px] group-data-closed/collapsible-content:slide-out-to-top-1`,`group-data-closed/collapsible-content:animation-duration-(--animation-duration) group-data-open/collapsible-content:animation-duration-(--animation-duration)`),children:t})})}function K1({argsText:e,className:t,...n}){return e?(0,P.jsx)(`div`,{"data-slot":`tool-fallback-args`,className:a(`aui-tool-fallback-args`,t),...n,children:(0,P.jsx)(`pre`,{className:`aui-tool-fallback-args-value bg-muted/50 text-foreground/90 rounded-md p-2.5 text-xs whitespace-pre-wrap`,children:e})}):null}var q1=(e,t)=>{if(typeof e==`string`)return e;try{if(e instanceof Error)return String(e);let n=JSON.stringify(e,null,t);if(n!==void 0)return n}catch{}try{return String(e)}catch{return`[Unserializable value]`}};function J1({result:e,className:t,...n}){return e===void 0?null:(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-result`,className:a(`aui-tool-fallback-result`,t),...n,children:[(0,P.jsx)(`p`,{className:`aui-tool-fallback-result-header text-muted-foreground text-xs font-medium`,children:`Result:`}),(0,P.jsx)(`pre`,{className:`aui-tool-fallback-result-content bg-muted/50 text-foreground/90 mt-1 rounded-md p-2.5 text-xs whitespace-pre-wrap`,children:q1(e,2)})]})}function Y1({status:e,className:t,...n}){if(e?.type!==`incomplete`)return null;let r=e.error,i=r==null?null:q1(r);if(!i)return null;let o=e.reason===`cancelled`?`Cancelled reason:`:`Error:`;return(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-error`,className:a(`aui-tool-fallback-error`,t),...n,children:[(0,P.jsx)(`p`,{className:`aui-tool-fallback-error-header text-muted-foreground font-semibold`,children:o}),(0,P.jsx)(`p`,{className:`aui-tool-fallback-error-reason text-muted-foreground whitespace-pre-line`,children:i})]})}var X1=`Approved by user`,Z1=`User denied tool execution`,Q1={"allow-once":`Allow`,"allow-always":`Always allow`,"reject-once":`Deny`,"reject-always":`Always deny`},$1=e=>Object.hasOwn(Q1,e),e0=e=>e===`allow-once`||e===`allow-always`,t0=e=>e.label??($1(e.kind)?Q1[e.kind]:void 0)??e.id,n0=e=>e?.display===`select`||e?.display===`text`,r0=(e,t,n)=>e?.type!==`requires-action`||e.reason!==`interrupt`||t!=null||n!=null;function i0({className:e,addResult:t,resume:n,interrupt:r,approval:i,respondToApproval:o,status:c,...l}){let[u,d]=(0,N.useState)(!1),f=$(e=>e.thread.voice!==void 0),p=u||f,[m,h]=(0,N.useState)(null),[g,_]=(0,N.useState)(``),[v,y]=(0,N.useState)(null);if(i!=null&&(i.approved!==void 0||i.resolution!==void 0)||!r0(c,i,r))return null;let b=o?i?.options:void 0,x=i!=null&&o!=null&&pB(i),S=e=>{d(!0),y(null),(async()=>{try{await e()}catch(e){d(!1),y(e instanceof Error?e.message:String(e))}})()},C=e=>{if(!p){if(i!=null&&i.approved===void 0&&o)S(()=>o({approved:e,...T()}));else if(r)S(()=>n?.({approved:e}));else if(c?.type===`requires-action`&&c.reason===`interrupt`)return;else S(()=>t?.(e?X1:Z1))}},w=e=>{p||(h(null),S(()=>o?.($1(e.kind)?{optionId:e.id,...T()}:{optionId:e.id,approved:!0,...T()})))},T=()=>g.trim()?{text:g}:{},E=()=>{p||S(()=>o?.({text:g}))},D=()=>{p||S(()=>o?.({approved:!1}))},O=e=>{e.confirm?h(e.id):w(e)},k=m==null?void 0:b?.find(e=>e.id===m),A=n0(i),j=A&&o!=null&&i?.dismissible===!0?(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:z1,onClick:D,disabled:p,children:`Dismiss`}):null,M=i?.prompt?(0,P.jsx)(`p`,{className:`aui-tool-fallback-approval-prompt text-foreground whitespace-pre-line`,children:i.prompt}):null,ee=v?(0,P.jsx)(`p`,{role:`alert`,className:`aui-tool-fallback-approval-error text-destructive text-xs whitespace-pre-line`,children:v}):null,te=x?(0,P.jsxs)(`div`,{className:`aui-tool-fallback-approval-answer flex flex-col items-start gap-2`,children:[(0,P.jsx)(L1,{value:g,onChange:e=>_(e.target.value),disabled:p,"aria-label":A?i?.prompt??`Answer`:`Note`,placeholder:A?`Type your answer`:`Add a note to your decision`}),A&&(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:z1,onClick:E,disabled:p,children:`Send`}),j]})]}):null;if(k){let t=typeof k.confirm==`object`?k.confirm:void 0,n=t?.description??k.description;return(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval-confirm`,className:a(`aui-tool-fallback-approval-confirm flex flex-col gap-2 pt-1`,e),...l,children:[(0,P.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-title font-semibold`,children:t?.title??`${t0(k)}?`}),n&&(0,P.jsx)(`p`,{className:`aui-tool-fallback-approval-confirm-description text-muted-foreground whitespace-pre-line`,children:n}),k.grants&&k.grants.length>0&&(0,P.jsx)(`ul`,{className:`aui-tool-fallback-approval-confirm-grants flex flex-col gap-1`,children:k.grants.map(e=>(0,P.jsx)(`li`,{children:(0,P.jsx)(`code`,{className:`aui-tool-fallback-approval-confirm-grant bg-muted rounded px-1.5 py-0.5 text-xs`,children:e})},e))}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:z1,onClick:()=>w(k),disabled:p,children:`Confirm`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:z1,onClick:()=>h(null),disabled:p,children:`Back`})]})]})}if(b&&b.length>0){let t=b.filter(e=>e0(e.kind)),n=b.filter(e=>!$1(e.kind)),r=b.filter(e=>$1(e.kind)&&!e0(e.kind));return(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[M,(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[[...t,...n,...r].map(e=>(0,P.jsx)(s,{size:`sm`,variant:e===t[0]?`default`:`outline`,className:z1,onClick:()=>O(e),disabled:p,children:t0(e)},e.id)),r.length===0&&!A&&(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:z1,onClick:()=>C(!1),disabled:p,children:`Deny`}),!x&&j]}),te,ee]})}return A?(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[M,te,!x&&j&&(0,P.jsx)(`div`,{className:`flex items-center gap-2`,children:j}),ee]}):(0,P.jsxs)(`div`,{"data-slot":`tool-fallback-approval`,className:a(`aui-tool-fallback-approval flex flex-col gap-2 pt-1`,e),...l,children:[M,(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(s,{size:`sm`,className:z1,onClick:()=>C(!0),disabled:p,children:`Allow`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,className:z1,onClick:()=>C(!1),disabled:p,children:`Deny`})]}),te,ee]})}var a0=(0,N.memo)(({toolName:e,argsText:t,result:n,status:r,addResult:i,resume:o,interrupt:s,approval:c,respondToApproval:l})=>{let u=r?.type===`incomplete`&&r.reason===`cancelled`,d=r?.type===`requires-action`,f=d&&r0(r,c,s),[p,m]=(0,N.useState)(d),[h,g]=(0,N.useState)(d);return d!==h&&(g(d),d&&m(!0)),(0,P.jsxs)(B1,{open:p,onOpenChange:m,children:[(0,P.jsx)(W1,{toolName:e,status:r}),(0,P.jsxs)(G1,{children:[(0,P.jsx)(Y1,{status:r}),(0,P.jsx)(K1,{argsText:t,className:a(u&&`opacity-60`)}),f&&(0,P.jsx)(i0,{addResult:i,resume:o,interrupt:s,approval:c,respondToApproval:l,status:r}),(0,P.jsx)(J1,{result:n})]})]})});a0.displayName=`ToolFallback`,a0.Root=B1,a0.Trigger=W1,a0.Content=G1,a0.Args=K1,a0.Result=J1,a0.Error=Y1,a0.Approval=i0;var o0=200,s0=y(`aui-tool-group-root group/tool-group w-full`,{variants:{variant:{outline:`rounded-lg border py-3`,ghost:``,muted:`border-muted-foreground/30 bg-muted/30 rounded-lg border py-3`}},defaultVariants:{variant:`outline`}});function c0({className:e,variant:t,open:n,onOpenChange:r,defaultOpen:i=!1,children:o,...s}){let c=(0,N.useRef)(null),[l,u]=(0,N.useState)(i),d=nZ(c,o0),f=n!==void 0,p=f?n:l,m=(0,N.useCallback)(e=>{d(),f||u(e),r?.(e)},[d,f,r]);return(0,P.jsx)(S1,{ref:c,"data-slot":`tool-group-root`,"data-variant":t??`outline`,open:p,onOpenChange:m,className:a(s0({variant:t}),`group/tool-group-root`,e),style:{"--animation-duration":`${o0}ms`},...s,children:o})}function l0({count:e,active:t=!1,className:n,...r}){let i=`${e} tool ${e===1?`call`:`calls`}`;return(0,P.jsxs)(C1,{"data-slot":`tool-group-trigger`,className:a(`aui-tool-group-trigger group/trigger flex origin-left items-center gap-2 text-sm transition-[color,scale] active:scale-[0.98]`,`group-data-[variant=ghost]/tool-group-root:text-muted-foreground group-data-[variant=ghost]/tool-group-root:hover:text-foreground group-data-[variant=ghost]/tool-group-root:py-1.5`,`group-data-[variant=outline]/tool-group-root:w-full group-data-[variant=outline]/tool-group-root:px-4`,`group-data-[variant=muted]/tool-group-root:w-full group-data-[variant=muted]/tool-group-root:px-4`,n),...r,children:[t&&(0,P.jsx)(me,{"data-slot":`tool-group-trigger-loader`,className:`aui-tool-group-trigger-loader size-3 shrink-0 animate-spin [animation-duration:0.6s]`}),(0,P.jsx)(`span`,{"data-slot":`tool-group-trigger-label`,className:a(`aui-tool-group-trigger-label-wrapper inline-block text-start text-xs leading-none font-medium`,`group-data-[variant=ghost]/tool-group-root:font-normal`,`group-data-[variant=outline]/tool-group-root:grow`,`group-data-[variant=muted]/tool-group-root:grow`,t&&`shimmer motion-reduce:animate-none`),children:i}),(0,P.jsx)(j,{"data-slot":`tool-group-trigger-chevron`,className:a(`aui-tool-group-trigger-chevron size-3 shrink-0`,`transition-transform duration-(--animation-duration) ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:transition-none`,`-rotate-90`,`group-data-open/trigger:rotate-0`,`group-data-panel-open/trigger:rotate-0`)})]})}function u0({className:e,children:t,...n}){return(0,P.jsx)(w1,{"data-slot":`tool-group-content`,className:a(`aui-tool-group-content relative overflow-hidden text-sm outline-none`,`group/collapsible-content ease-[cubic-bezier(0.32,0.72,0,1)] motion-reduce:animate-none`,`data-closed:animate-collapsible-up`,`data-open:animate-collapsible-down`,`data-closed:fill-mode-forwards`,`data-closed:pointer-events-none`,`[--tw-duration:var(--animation-duration)]`,e),...n,children:(0,P.jsx)(`div`,{className:a(`mt-2 flex flex-col gap-2`,`group-data-[variant=ghost]/tool-group-root:mt-1 group-data-[variant=ghost]/tool-group-root:gap-1`,`group-data-[variant=outline]/tool-group-root:mt-3 group-data-[variant=outline]/tool-group-root:border-t group-data-[variant=outline]/tool-group-root:px-4 group-data-[variant=outline]/tool-group-root:pt-3`,`group-data-[variant=muted]/tool-group-root:mt-3 group-data-[variant=muted]/tool-group-root:border-t group-data-[variant=muted]/tool-group-root:px-4 group-data-[variant=muted]/tool-group-root:pt-3`,`[&>*]:animate-in [&>*]:fade-in-0 [&>*]:blur-in-[2px] [&>*]:slide-in-from-top-1 [&>*]:animation-duration-(--animation-duration) [&>*]:ease-[cubic-bezier(0.32,0.72,0,1)]`,`[&>*]:motion-reduce:animate-none`,`[&>*:nth-child(2)]:[animation-delay:40ms]`,`[&>*:nth-child(3)]:[animation-delay:80ms]`,`[&>*:nth-child(4)]:[animation-delay:120ms]`,`[&>*:nth-child(n+5)]:[animation-delay:160ms]`),children:t})})}var d0=(0,N.memo)(({children:e,startIndex:t,endIndex:n})=>{let r=n-t+1;return(0,P.jsxs)(c0,{children:[(0,P.jsx)(l0,{count:r}),(0,P.jsx)(u0,{children:e})]})});d0.displayName=`ToolGroup`,d0.Root=c0,d0.Trigger=l0,d0.Content=u0;function f0({className:e,...t}){return(0,P.jsx)(`div`,{"data-slot":`skeleton`,className:a(`animate-pulse rounded-md bg-accent`,e),...t})}var p0=SU({reasoning:[`group-chainOfThought`,`group-reasoning`],"tool-call":[`group-chainOfThought`,`group-tool`],"standalone-tool-call":[]}),m0=[`group-chainOfThought`,`group-task`],h0=(e,t)=>{let n=p0(e,t);return e.type===`tool-call`&&e.messages!==void 0&&n.length>0&&!t?.toolUIs?.[e.toolName]?.length?m0:n},g0={},_0=(0,N.createContext)(g0),v0=e=>e.thread.messages.length===0&&(!e.thread.isLoading||e.threads.isLoading),y0=e=>e.thread.messages.length===0&&e.thread.isLoading&&!e.thread.isDisabled&&!e.threads.isLoading,b0=()=>(0,P.jsxs)(`div`,{"data-slot":`aui_thread-history-skeleton`,role:`status`,className:`animate-in fade-in fill-mode-both flex flex-col gap-y-6 [animation-delay:150ms] [animation-duration:200ms]`,children:[(0,P.jsx)(`span`,{className:`sr-only`,children:`Loading conversation`}),(0,P.jsx)(f0,{className:`ml-auto h-9 w-2/5 rounded-xl motion-reduce:animate-none`}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,P.jsx)(f0,{className:`h-4 w-11/12 motion-reduce:animate-none`}),(0,P.jsx)(f0,{className:`h-4 w-4/5 motion-reduce:animate-none`}),(0,P.jsx)(f0,{className:`h-4 w-3/5 motion-reduce:animate-none`})]}),(0,P.jsx)(f0,{className:`ml-auto h-9 w-1/3 rounded-xl motion-reduce:animate-none`}),(0,P.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,P.jsx)(f0,{className:`h-4 w-10/12 motion-reduce:animate-none`}),(0,P.jsx)(f0,{className:`h-4 w-2/3 motion-reduce:animate-none`})]})]}),x0=({components:e=g0,autoFocus:t=!0})=>{let n=$(v0);return(0,P.jsx)(_0.Provider,{value:e,children:(0,P.jsx)(S0,{isEmpty:n,autoFocus:t})})},S0=({isEmpty:e,autoFocus:t})=>{let{Welcome:n=k0}=(0,N.useContext)(_0);return(0,P.jsx)(yX.Root,{className:`aui-root aui-thread-root bg-background @container flex h-full flex-col`,style:{"--thread-max-width":`44rem`,"--composer-bg":`color-mix(in oklab, var(--color-muted) 30%, transparent)`,"--composer-radius":`1rem`,"--composer-padding":`8px`},children:(0,P.jsx)(yX.Viewport,{turnAnchor:`top`,"data-slot":`aui_thread-viewport`,className:`relative flex flex-1 flex-col overflow-x-auto overflow-y-scroll scroll-smooth`,children:(0,P.jsxs)(`div`,{className:a(`mx-auto flex w-full max-w-(--thread-max-width) flex-1 flex-col px-4 pt-4`,e&&`justify-center`),children:[(0,P.jsx)(JI,{condition:v0,children:(0,P.jsx)(n,{})}),(0,P.jsx)(JI,{condition:y0,children:(0,P.jsx)(b0,{})}),(0,P.jsx)(`div`,{"data-slot":`aui_message-group`,className:`mb-14 flex flex-col gap-y-6 empty:hidden`,children:(0,P.jsx)(yX.Messages,{children:()=>(0,P.jsx)(C0,{})})}),(0,P.jsxs)(yX.ViewportFooter,{className:a(`aui-thread-viewport-footer bg-background flex flex-col gap-4 overflow-visible pb-4 md:pb-6`,!e&&`sticky bottom-0 mt-auto rounded-t-(--composer-radius)`),children:[(0,P.jsx)(O0,{}),(0,P.jsx)(w$,{}),(0,P.jsx)(M0,{autoFocus:t}),(0,P.jsx)(JI,{condition:e=>v0(e)&&e.composer.isEmpty,children:(0,P.jsx)(A0,{})})]})]})})})},C0=()=>{let{AssistantMessage:e=F0}=(0,N.useContext)(_0),t=$(e=>e.message.role),n=$(e=>e.message.composer.isEditing),r=$(e=>e.message.metadata.modality===`voice`);return n?(0,P.jsx)(V0,{}):r?(0,P.jsx)(E0,{}):t===`user`?(0,P.jsx)(z0,{}):(0,P.jsx)(e,{})},w0=()=>$(e=>{let t=e.thread.messages[e.message.index-1]?.metadata.modality===`voice`,n=e.thread.messages[e.message.index+1]?.metadata.modality===`voice`;return t?n?`middle`:`end`:n?`start`:`single`}),T0=({text:e})=>(0,P.jsx)(`p`,{className:`aui-spoken-message-text m-0`,children:e}),E0=()=>{let e=$(e=>e.message.role),t=w0(),n=$(e=>e.message.role===`assistant`&&e.message.status?.type===`running`),r=t===`start`||t===`single`;return(0,P.jsxs)(FY.Root,{"data-slot":`aui_spoken-message-root`,"data-role":e,"data-voice-run":t,className:a(`aui-spoken-message bg-muted/40 mx-2 px-3 py-1.5 [contain-intrinsic-size:auto_48px] [content-visibility:auto]`,t===`single`&&`rounded-xl py-2`,t===`start`&&`rounded-t-xl pt-2`,t===`middle`&&`-mt-6`,t===`end`&&`-mt-6 rounded-b-xl pb-2`),children:[r&&(0,P.jsxs)(`div`,{"data-slot":`aui_spoken-exchange-header`,className:`text-muted-foreground mb-1.5 flex items-center gap-1.5 text-xs`,children:[(0,P.jsx)(ye,{className:`size-3`,"aria-hidden":!0}),(0,P.jsx)(`span`,{children:`Voice conversation`})]}),(0,P.jsxs)(`div`,{"data-slot":`aui_spoken-message-content`,className:`text-foreground flex items-start gap-2 text-sm leading-relaxed`,children:[(0,P.jsx)(`span`,{className:`text-muted-foreground mt-1 shrink-0`,"aria-hidden":!0,children:e===`user`?(0,P.jsx)(he,{className:`size-3.5`}):(0,P.jsx)(D,{className:`size-3.5`})}),(0,P.jsx)(`span`,{className:`sr-only`,children:e===`user`?`You said`:`Assistant said`}),(0,P.jsxs)(`div`,{className:`min-w-0 flex-1 wrap-break-word`,children:[(0,P.jsx)(FY.Parts,{components:{Text:T0}}),n&&(0,P.jsx)(`span`,{"data-slot":`aui_spoken-message-indicator`,role:`status`,className:`text-muted-foreground ms-1 animate-pulse font-sans`,"aria-label":`Assistant is speaking`,children:`●`})]}),(0,P.jsx)(D0,{})]})]})},D0=()=>(0,P.jsx)(eK.Root,{hideWhenRunning:!0,autohide:`always`,className:`aui-spoken-action-bar text-muted-foreground flex shrink-0 gap-1`,children:(0,P.jsx)(eK.Copy,{asChild:!0,children:(0,P.jsxs)(qQ,{tooltip:`Copy`,className:`size-6`,children:[(0,P.jsx)(JI,{condition:e=>e.message.isCopied,children:(0,P.jsx)(A,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,P.jsx)(JI,{condition:e=>!e.message.isCopied,children:(0,P.jsx)(ie,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})})}),O0=()=>(0,P.jsx)(yX.ScrollToBottom,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Scroll to bottom`,variant:`outline`,className:`aui-thread-scroll-to-bottom dark:border-border dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible`,children:(0,P.jsx)(C,{})})}),k0=()=>(0,P.jsx)(`div`,{className:`aui-thread-welcome-root mb-6 flex flex-col px-2`,children:(0,P.jsx)(`p`,{className:`aui-thread-welcome-message-inner fade-in slide-in-from-bottom-1 animate-in fill-mode-both text-2xl font-medium tracking-tight duration-200`,children:`How can I help you today?`})}),A0=()=>(0,P.jsx)(`div`,{className:`aui-thread-welcome-suggestions flex w-full flex-col`,children:(0,P.jsx)(yX.Suggestions,{children:()=>(0,P.jsx)(j0,{})})}),j0=()=>(0,P.jsx)(`div`,{className:`aui-thread-welcome-suggestion-display fade-in slide-in-from-bottom-2 animate-in fill-mode-both duration-200`,children:(0,P.jsx)(EX.Trigger,{send:!0,asChild:!0,children:(0,P.jsxs)(`button`,{type:`button`,className:`aui-thread-welcome-suggestion group hover:bg-foreground/[0.03] focus-visible:ring-ring/50 flex w-full items-baseline gap-2.5 rounded-md px-2 py-2 text-start text-sm transition-colors outline-none focus-visible:ring-1 motion-reduce:transition-none`,children:[(0,P.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-foreground/60 group-hover:text-foreground font-mono text-xs transition-colors motion-reduce:transition-none`,children:`>`}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[(0,P.jsx)(EX.Title,{className:`aui-thread-welcome-suggestion-text-1 text-foreground`}),` `,(0,P.jsx)(EX.Description,{className:`aui-thread-welcome-suggestion-text-2 text-muted-foreground empty:hidden`})]})]})})}),M0=({autoFocus:e})=>(0,P.jsx)(CJ.Root,{className:`aui-composer-root relative flex w-full flex-col`,children:(0,P.jsx)(CJ.AttachmentDropzone,{asChild:!0,children:(0,P.jsxs)(`div`,{"data-slot":`aui_composer-shell`,className:`border-foreground/10 focus-within:border-foreground/25 data-[dragging=true]:border-ring flex w-full cursor-text flex-col gap-2 rounded-(--composer-radius) border bg-(--composer-bg) p-(--composer-padding) transition-[border-color] data-[dragging=true]:border-dashed data-[dragging=true]:bg-[color-mix(in_oklab,var(--color-accent)_50%,var(--color-background))]`,children:[(0,P.jsx)(c$,{}),(0,P.jsx)(CJ.Input,{placeholder:`Send a message...`,className:`aui-composer-input caret-primary placeholder:text-muted-foreground/60 max-h-48 min-h-10 w-full resize-none bg-transparent px-2.5 py-1 text-base leading-6 outline-none`,rows:1,autoFocus:e,enterKeyHint:`send`,"aria-label":`Message input`}),(0,P.jsx)(N0,{})]})})}),N0=()=>(0,P.jsxs)(`div`,{className:`aui-composer-action-wrapper relative flex items-center justify-between`,children:[(0,P.jsx)(l$,{}),(0,P.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,P.jsxs)(JI,{condition:e=>e.thread.capabilities.dictation,children:[(0,P.jsx)(JI,{condition:e=>e.composer.dictation==null,children:(0,P.jsx)(CJ.Dictate,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Voice input`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-dictate text-muted-foreground hover:text-foreground size-7 rounded-full`,"aria-label":`Start voice input`,children:(0,P.jsx)(he,{className:`aui-composer-dictate-icon size-4`})})})}),(0,P.jsx)(JI,{condition:e=>e.composer.dictation!=null,children:(0,P.jsx)(CJ.StopDictation,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Stop dictation`,side:`bottom`,type:`button`,variant:`ghost`,size:`icon`,className:`aui-composer-stop-dictation text-destructive size-7 rounded-full`,"aria-label":`Stop voice input`,children:(0,P.jsx)(Ee,{className:`aui-composer-stop-dictation-icon size-3.5 animate-pulse fill-current`})})})})]}),(0,P.jsx)(JI,{condition:e=>!e.thread.isRunning||e.thread.voice!==void 0,children:(0,P.jsx)(CJ.Send,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Send message`,side:`bottom`,type:`button`,variant:`default`,size:`icon`,className:`aui-composer-send size-7 rounded-full`,"aria-label":`Send message`,children:(0,P.jsx)(E,{className:`aui-composer-send-icon size-4`})})})}),(0,P.jsx)(JI,{condition:e=>e.thread.isRunning&&e.thread.voice===void 0,children:(0,P.jsx)(CJ.Cancel,{asChild:!0,children:(0,P.jsx)(s,{type:`button`,variant:`default`,size:`icon`,className:`aui-composer-cancel size-7 rounded-full`,"aria-label":`Stop generating`,children:(0,P.jsx)(Ee,{className:`aui-composer-cancel-icon size-3.5 fill-current`})})})})]})]}),P0=()=>(0,P.jsx)(FY.Error,{children:(0,P.jsx)(YJ.Root,{className:`aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200`,children:(0,P.jsx)(YJ.Message,{className:`aui-message-error-message line-clamp-2`})})}),F0=()=>{let{ToolFallback:e=a0,ToolGroup:t,ReasoningGroup:n,TaskGroup:r}=(0,N.useContext)(_0),i=r?h0:p0;return(0,P.jsxs)(FY.Root,{"data-slot":`aui_assistant-message-root`,"data-role":`assistant`,className:`fade-in slide-in-from-bottom-1 animate-in relative -mb-7.5 pb-7.5 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:[(0,P.jsxs)(`div`,{"data-slot":`aui_assistant-message-content`,className:`text-foreground px-2 leading-relaxed wrap-break-word`,children:[(0,P.jsx)(FY.GroupedParts,{groupBy:i,children:({part:i,children:a})=>{switch(i.type){case`group-chainOfThought`:return(0,P.jsx)(`div`,{"data-slot":`aui_chain-of-thought`,children:a});case`group-task`:return r?(0,P.jsx)(r,{group:i}):null;case`group-tool`:return t?(0,P.jsx)(t,{group:i,children:a}):(0,P.jsxs)(c0,{variant:`ghost`,children:[(0,P.jsx)(l0,{count:i.indices.length,active:i.status.type===`running`}),(0,P.jsx)(u0,{children:a})]});case`group-reasoning`:{if(n)return(0,P.jsx)(n,{group:i,children:a});let e=i.status.type===`running`;return(0,P.jsxs)(M1,{streaming:e,children:[(0,P.jsx)(k1,{active:e}),(0,P.jsx)(A1,{"aria-busy":e,children:(0,P.jsx)(j1,{children:a})})]})}case`text`:return(0,P.jsx)(b1,{});case`reasoning`:return(0,P.jsx)(F1,{...i});case`tool-call`:return i.toolUI??(0,P.jsx)(e,{...i});case`data`:return i.dataRendererUI;case`file`:return(0,P.jsx)(`div`,{"data-slot":`aui_assistant-message-file`,className:`py-1`,children:(0,P.jsx)(S$,{...i})});case`image`:return(0,P.jsx)(`div`,{"data-slot":`aui_assistant-message-image`,className:`py-1`,children:(0,P.jsx)(z$,{...i})});case`indicator`:return(0,P.jsx)(`span`,{"data-slot":`aui_assistant-message-indicator`,className:`animate-pulse font-sans`,"aria-label":`Assistant is working`,children:`●`});default:return null}}}),(0,P.jsx)(P0,{})]}),(0,P.jsxs)(`div`,{"data-slot":`aui_assistant-message-footer`,className:a(`ms-2 flex items-center`,`min-h-7.5 pt-1.5`),children:[(0,P.jsx)(H0,{}),(0,P.jsx)(I0,{})]})]})},I0=()=>(0,P.jsxs)(eK.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-assistant-action-bar-root text-muted-foreground animate-in fade-in col-start-3 row-start-2 -ms-1 flex gap-1 duration-200`,children:[(0,P.jsx)(eK.Copy,{asChild:!0,children:(0,P.jsxs)(qQ,{tooltip:`Copy`,children:[(0,P.jsx)(JI,{condition:e=>e.message.isCopied,children:(0,P.jsx)(A,{className:`animate-in zoom-in-50 fade-in duration-200 ease-out`})}),(0,P.jsx)(JI,{condition:e=>!e.message.isCopied,children:(0,P.jsx)(ie,{className:`animate-in zoom-in-75 fade-in duration-150`})})]})}),(0,P.jsxs)(JI,{condition:e=>e.thread.capabilities.feedback,children:[(0,P.jsx)(eK.FeedbackPositive,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,P.jsx)(ke,{})})}),(0,P.jsx)(eK.FeedbackNegative,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Not helpful`,className:`data-[submitted=true]:bg-accent data-[submitted=true]:text-accent-foreground`,children:(0,P.jsx)(Oe,{})})})]}),(0,P.jsx)(eK.Reload,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Refresh`,children:(0,P.jsx)(xe,{})})}),(0,P.jsxs)(dK.Root,{children:[(0,P.jsx)(dK.Trigger,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`More`,className:`data-[state=open]:bg-accent`,children:(0,P.jsx)(oe,{})})}),(0,P.jsx)(dK.Content,{side:`bottom`,align:`start`,sideOffset:6,className:`aui-action-bar-more-content bg-popover text-popover-foreground data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] overflow-hidden rounded-xl border p-1.5`,children:(0,P.jsx)(eK.ExportMarkdown,{asChild:!0,children:(0,P.jsxs)(dK.Item,{className:`aui-action-bar-more-item hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(ae,{className:`size-4`}),`Export as Markdown`]})})})]})]}),L0=e=>(0,P.jsx)(`div`,{"data-slot":`aui_user-message-file`,className:`py-1`,children:(0,P.jsx)(S$,{...e})}),R0=e=>(0,P.jsx)(`div`,{"data-slot":`aui_user-message-image`,className:`py-1`,children:(0,P.jsx)(z$,{...e})}),z0=()=>(0,P.jsxs)(FY.Root,{"data-slot":`aui_user-message-root`,className:`fade-in slide-in-from-bottom-1 animate-in grid auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] content-start gap-y-2 px-2 duration-150 [contain-intrinsic-size:auto_200px] [content-visibility:auto] [&:where(>*)]:col-start-2`,"data-role":`user`,children:[(0,P.jsx)(s$,{}),(0,P.jsxs)(`div`,{className:`aui-user-message-content-wrapper relative col-start-2 min-w-0`,children:[(0,P.jsx)(`div`,{className:`aui-user-message-content peer bg-muted text-foreground rounded-(--composer-radius) px-4 py-2 wrap-break-word empty:hidden`,children:(0,P.jsx)(FY.Parts,{components:{File:L0,Image:R0}})}),(0,P.jsx)(`div`,{className:`aui-user-action-bar-wrapper absolute start-0 top-1/2 -translate-x-full -translate-y-1/2 pe-2 peer-empty:hidden rtl:translate-x-full`,children:(0,P.jsx)(B0,{})})]}),(0,P.jsx)(H0,{"data-slot":`aui_user-branch-picker`,className:`col-span-full col-start-1 -me-1 justify-end`})]}),B0=()=>(0,P.jsx)(eK.Root,{hideWhenRunning:!0,autohide:`not-last`,className:`aui-user-action-bar-root flex flex-col items-end`,children:(0,P.jsx)(eK.Edit,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Edit`,className:`aui-user-action-edit`,children:(0,P.jsx)(ve,{})})})}),V0=()=>(0,P.jsx)(FY.Root,{"data-slot":`aui_edit-composer-wrapper`,className:`flex flex-col px-2 [contain-intrinsic-size:auto_200px] [content-visibility:auto]`,children:(0,P.jsxs)(CJ.Root,{className:`aui-edit-composer-root border-foreground/10 focus-within:border-foreground/25 ms-auto flex w-full max-w-[85%] cursor-text flex-col rounded-(--composer-radius) border bg-(--composer-bg) transition-[border-color]`,children:[(0,P.jsx)(CJ.Input,{className:`aui-edit-composer-input text-foreground min-h-14 w-full resize-none bg-transparent px-4 pt-3 pb-1 text-base outline-none`,autoFocus:!0}),(0,P.jsxs)(`div`,{className:`aui-edit-composer-footer mx-2.5 mb-2.5 flex items-center gap-1.5 self-end`,children:[(0,P.jsx)(CJ.Cancel,{asChild:!0,children:(0,P.jsx)(s,{variant:`ghost`,size:`sm`,className:`h-8 px-3`,children:`Cancel`})}),(0,P.jsx)(CJ.Send,{asChild:!0,children:(0,P.jsx)(s,{size:`sm`,className:`h-8 px-3`,children:`Update`})})]})]})}),H0=({className:e,...t})=>(0,P.jsxs)(OK.Root,{hideWhenSingleBranch:!0,className:a(`aui-branch-picker-root text-muted-foreground -ms-2 me-2 inline-flex items-center text-xs`,e),...t,children:[(0,P.jsx)(OK.Previous,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Previous`,children:(0,P.jsx)(M,{})})}),(0,P.jsxs)(`span`,{className:`aui-branch-picker-state font-medium`,children:[(0,P.jsx)(OK.Number,{}),` / `,(0,P.jsx)(OK.Count,{})]}),(0,P.jsx)(OK.Next,{asChild:!0,children:(0,P.jsx)(qQ,{tooltip:`Next`,children:(0,P.jsx)(ee,{})})})]}),U0=()=>{let[e,t]=(0,N.useState)(``),n=$(e=>e.threads.threadIds.length>0);return(0,P.jsxs)(G0,{children:[(0,P.jsx)(Q0,{}),n&&(0,P.jsx)(W0,{value:e,onValueChange:t}),(0,P.jsx)(K0,{searchQuery:n?e:``})]})},W0=(0,N.forwardRef)(({className:e,value:t,onValueChange:n,...r},i)=>(0,P.jsxs)(`div`,{"data-slot":`aui_thread-list-search`,className:`relative px-0.5 py-1`,children:[(0,P.jsx)(Ce,{"data-slot":`aui_thread-list-search-icon`,className:`text-muted-foreground pointer-events-none absolute start-3 top-1/2 size-4 -translate-y-1/2`}),(0,P.jsx)(m,{ref:i,type:`search`,value:t,onChange:e=>n(e.target.value),"aria-label":`Search threads`,placeholder:`Search threads`,className:a(`h-8 ps-8 text-sm`,e),...r})]}));W0.displayName=`ThreadListSearch`;var G0=({className:e,...t})=>(0,P.jsx)(LX.Root,{"data-slot":`aui_thread-list-root`,className:a(`flex flex-col gap-0.5`,e),...t}),K0=({className:e,searchQuery:t=``,...n})=>(0,P.jsxs)(`div`,{"data-slot":`aui_thread-list-items`,className:a(`flex flex-col gap-0.5`,e),...n,children:[(0,P.jsx)(JI,{condition:e=>e.threads.isLoading,children:(0,P.jsx)($0,{})}),(0,P.jsx)(JI,{condition:e=>!e.threads.isLoading,children:(0,P.jsx)(X0,{searchQuery:t})})]}),q0=864e5,J0=(e,t)=>!e||e.getTime()>=t?`Today`:e.getTime()>=t-q0?`Yesterday`:`Earlier`,Y0=(e=``)=>{let t=$(e=>e.threads.threadIds),n=$(e=>e.threads.threadItems),r=e.trim().toLowerCase();return(0,N.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e])),i=t=>!r||(e.get(t)?.title||`New Chat`).toLowerCase().includes(r),a=t=>e.get(t)?.status===`archived`,o=t.map(t=>e.get(t)?.lastMessageAt),s=t.map((e,t)=>({id:e,index:t})).filter(({id:e})=>i(e)&&!a(e)).map(({index:e})=>e),c=t.map((e,t)=>({id:e,index:t})).filter(({id:e})=>i(e)&&a(e)).map(({index:e})=>e);if(!s.some(e=>o[e]))return{threadIds:t,filteredIndices:s,archivedIndices:c,groups:null};let l=new Date,u=new Date(l.getFullYear(),l.getMonth(),l.getDate()).getTime(),d=e=>o[e]?.getTime()??2**53-1,f=[...s].sort((e,t)=>d(t)-d(e)),p=[];for(let e of f){let t=J0(o[e],u),n=p[p.length-1];n?.label===t?n.indices.push(e):p.push({label:t,indices:[e]})}return{threadIds:t,filteredIndices:s,archivedIndices:c,groups:p}},[t,n,r])},X0=({searchQuery:e=``})=>{let{threadIds:t,filteredIndices:n,archivedIndices:r,groups:i}=Y0(e);return e.trim()&&n.length===0&&r.length===0?(0,P.jsx)(`div`,{"data-slot":`aui_thread-list-empty`,className:`text-muted-foreground px-2.5 py-4 text-sm`,children:`No threads found`}):i?(0,P.jsxs)(P.Fragment,{children:[i.map(e=>(0,P.jsxs)(N.Fragment,{children:[(0,P.jsx)(`div`,{"data-slot":`aui_thread-list-group-label`,className:`text-muted-foreground px-2.5 pt-3 pb-1 text-xs font-medium`,children:e.label}),e.indices.map(e=>(0,P.jsx)(LX.ItemByIndex,{index:e,components:{ThreadListItem:e2}},t[e]))]},e.label)),(0,P.jsx)(Z0,{threadIds:t,indices:r})]}):(0,P.jsxs)(P.Fragment,{children:[n.map(e=>(0,P.jsx)(LX.ItemByIndex,{index:e,components:{ThreadListItem:e2}},t[e])),(0,P.jsx)(Z0,{threadIds:t,indices:r})]})},Z0=({threadIds:e,indices:t})=>t.length?(0,P.jsxs)(N.Fragment,{children:[(0,P.jsx)(`div`,{"data-slot":`aui_thread-list-group-label`,className:`text-muted-foreground px-2.5 pt-3 pb-1 text-xs font-medium`,children:`Archived`}),t.map(t=>(0,P.jsx)(LX.ItemByIndex,{index:t,components:{ThreadListItem:e2}},e[t]))]}):null,Q0=(0,N.forwardRef)(({className:e,labelClassName:t,children:n,...r},i)=>(0,P.jsx)(LX.New,{asChild:!0,children:(0,P.jsx)(s,{ref:i,variant:`ghost`,"data-slot":`aui_thread-list-new`,className:a(`hover:bg-muted data-active:bg-muted h-8 justify-start gap-2 rounded-md px-2.5 text-sm font-normal`,e),...r,children:n??(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(be,{"data-slot":`aui_thread-list-new-icon`,className:`size-4 shrink-0`}),(0,P.jsx)(`span`,{"data-slot":`aui_thread-list-new-label`,className:a(`whitespace-nowrap`,t),children:`New Thread`})]})})}));Q0.displayName=`ThreadListNew`;var $0=()=>(0,P.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:Array.from({length:5},(e,t)=>(0,P.jsx)(`div`,{role:`status`,"aria-label":`Loading threads`,"data-slot":`aui_thread-list-skeleton-wrapper`,className:`flex h-8 items-center px-2.5`,children:(0,P.jsx)(f0,{"data-slot":`aui_thread-list-skeleton`,className:`h-3.5 w-full`})},t))}),e2=()=>{let e=$(e=>e.threadListItem.isRunning),t=$(e=>e.threadListItem.status)===`archived`,[n,r]=(0,N.useState)(!1),i=(0,N.useRef)(null),o=(0,N.useRef)(!1);return(0,N.useEffect)(()=>{!n&&o.current&&(o.current=!1,i.current?.focus())},[n]),(0,P.jsxs)(WX.Root,{"data-slot":`aui_thread-list-item`,"data-archived":t||void 0,className:a(`group hover:bg-muted focus-visible:bg-muted data-active:bg-muted has-focus-visible:bg-muted has-data-[state=open]:bg-muted relative flex h-8 items-center rounded-md transition-colors focus-visible:outline-none`,t&&`opacity-60`),children:[n?(0,P.jsx)(t2,{onDone:e=>{o.current=e,r(!1)}}):(0,P.jsxs)(WX.Trigger,{ref:i,"data-slot":`aui_thread-list-item-trigger`,className:`focus-visible:ring-ring/50 flex h-full min-w-0 flex-1 items-center rounded-md px-2.5 text-start text-sm outline-none group-hover:pe-9 group-has-focus-visible:pe-9 group-has-data-[state=open]:pe-9 group-data-active:pe-9 focus-visible:ring-1`,children:[e&&(0,P.jsx)(pe,{"aria-hidden":!0,"data-slot":`aui_thread-list-item-running`,className:`text-muted-foreground me-1.5 size-3.5 shrink-0 animate-spin`}),(0,P.jsx)(`span`,{"data-slot":`aui_thread-list-item-title`,className:`min-w-0 flex-1 truncate`,children:(0,P.jsx)(WX.Title,{fallback:`New Chat`})}),e&&(0,P.jsx)(`span`,{className:`sr-only`,children:`Running`})]}),(0,P.jsx)(n2,{archived:t,onRename:()=>r(!0)})]})},t2=({onDone:e})=>{let t=Q(),n=$(e=>e.threadListItem.title)??``,[r,i]=(0,N.useState)(n),a=(0,N.useRef)(null),o=(0,N.useRef)(!1);(0,N.useEffect)(()=>{a.current?.select()},[]);let s=i=>{if(o.current)return;o.current=!0;let s=r.trim();if(!s||s===n){e(i);return}Promise.resolve().then(()=>t.threadListItem.rename(s)).then(()=>e(i),()=>{o.current=!1,i&&a.current?.focus()})},c=()=>{o.current||(o.current=!0,e(!0))};return(0,P.jsx)(m,{ref:a,autoFocus:!0,"data-slot":`aui_thread-list-item-rename`,"aria-label":`Rename thread`,value:r,className:`h-7 min-w-0 flex-1 ps-2.5 pe-9 text-sm`,onChange:e=>i(e.target.value),onBlur:()=>s(!1),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),s(!0)):e.key===`Escape`&&(e.preventDefault(),c())}})},n2=({archived:e,onRename:t})=>(0,P.jsxs)(tZ.Root,{sharedFocusGroup:!0,children:[(0,P.jsx)(tZ.Trigger,{asChild:!0,children:(0,P.jsxs)(s,{variant:`ghost`,size:`icon`,"data-slot":`aui_thread-list-item-more`,className:`data-[state=open]:bg-accent absolute end-1.5 top-1/2 size-6 -translate-y-1/2 p-0 opacity-0 group-hover:opacity-100 group-has-focus-visible:opacity-100 group-data-active:opacity-100 data-[state=open]:opacity-100`,children:[(0,P.jsx)(oe,{className:`size-3.5`}),(0,P.jsx)(`span`,{className:`sr-only`,children:`More options`})]})}),(0,P.jsxs)(tZ.Content,{side:`right`,align:`start`,sideOffset:6,"data-slot":`aui_thread-list-item-more-content`,className:`bg-popover text-popover-foreground data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:animate-out data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-32 overflow-hidden rounded-xl border p-1.5`,children:[(0,P.jsxs)(tZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,onSelect:t,children:[(0,P.jsx)(ve,{className:`size-4`}),`Rename`]}),e?(0,P.jsx)(WX.Unarchive,{asChild:!0,children:(0,P.jsxs)(tZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(x,{className:`size-4`}),`Unarchive`]})}):(0,P.jsx)(WX.Archive,{asChild:!0,children:(0,P.jsxs)(tZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(S,{className:`size-4`}),`Archive`]})}),(0,P.jsx)(WX.Delete,{asChild:!0,children:(0,P.jsxs)(tZ.Item,{"data-slot":`aui_thread-list-item-more-item`,className:`text-destructive hover:bg-destructive/10 hover:text-destructive focus:bg-destructive/10 focus:text-destructive flex cursor-pointer items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm outline-none select-none`,children:[(0,P.jsx)(Ae,{className:`size-4`}),`Delete`]})})]})]}),r2=`bg-background border border-border/60 dark:bg-popover`;function i2({phase:e,attempt:t,resumedTokens:n,onRetry:r,className:i,...o}){return e===`online`?null:(0,P.jsxs)(`div`,{"data-slot":`connection-state`,className:a(r2,`fade-in slide-in-from-top-1 animate-in flex w-full max-w-sm items-center gap-2.5 rounded-2xl px-3.5 py-2.5 duration-300`,i),...o,children:[e===`dropped`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(re,{className:`size-3.5 shrink-0 text-amber-600 dark:text-amber-400`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Connection lost. The run kept going on the server.`}),(0,P.jsx)(`button`,{type:`button`,onClick:r,className:`text-foreground/70 hover:bg-foreground/[0.06] hover:text-foreground/95 shrink-0 rounded-full px-2.5 py-1 text-xs font-medium transition-[background-color,color,scale] duration-150 active:scale-[0.96]`,children:`Reconnect`})]}),e===`reconnecting`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(pe,{className:`text-foreground/40 size-3.5 shrink-0 animate-spin motion-reduce:animate-none`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Reconnecting`}),t!==void 0&&(0,P.jsxs)(`span`,{className:a(`font-mono text-[11px] tracking-tight`,`text-foreground/30 shrink-0 tabular-nums`),children:[`attempt `,t]})]}),e===`resumed`&&(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(A,{className:`size-3.5 shrink-0 text-emerald-500`}),(0,P.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px]`,children:`Picked the stream back up.`}),n!==void 0&&(0,P.jsxs)(`span`,{className:a(`font-mono text-[11px] tracking-tight`,`text-foreground/30 shrink-0 tabular-nums`),children:[`+`,n,` tokens`]})]})]})}function a2({request:e,respond:t}){let[n,r]=(0,N.useState)(e.kind===`editor`?e.prefill??``:``),i=e=>void t(e);return(0,P.jsxs)(`div`,{className:`bg-card grid gap-2 rounded-md border border-l-[3px] border-l-primary p-3`,role:`group`,"aria-label":`The agent is asking for approval`,children:[(0,P.jsxs)(`p`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,P.jsx)(Te,{className:`size-4 shrink-0 text-primary`,"aria-hidden":`true`}),e.title]}),e.kind===`confirm`?(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs break-words whitespace-pre-wrap`,children:e.message}):null,e.timeoutMs?(0,P.jsxs)(`p`,{className:`text-muted-foreground text-[0.7rem] tabular-nums`,children:[`Auto-dismisses after `,Math.round(e.timeoutMs/1e3),`s`]}):null,e.kind===`confirm`?(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(s,{size:`sm`,onClick:()=>i({requestId:e.id,confirmed:!0}),children:`Allow`}),(0,P.jsx)(s,{size:`sm`,variant:`outline`,onClick:()=>i({requestId:e.id,confirmed:!1}),children:`Deny`})]}):null,e.kind===`select`?(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[e.options.map(t=>(0,P.jsx)(s,{size:`sm`,variant:`outline`,onClick:()=>i({requestId:e.id,value:t}),children:t},t)),(0,P.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>i({requestId:e.id,dismissed:!0}),children:`Dismiss`})]}):null,e.kind===`input`||e.kind===`editor`?(0,P.jsxs)(`form`,{className:`grid gap-2`,onSubmit:t=>{t.preventDefault(),i({requestId:e.id,value:n})},children:[e.kind===`editor`?(0,P.jsx)(L1,{rows:6,value:n,onChange:e=>r(e.target.value)}):(0,P.jsx)(m,{value:n,placeholder:e.placeholder??``,onChange:e=>r(e.target.value)}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,P.jsx)(s,{size:`sm`,type:`submit`,children:`Submit`}),(0,P.jsx)(s,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>i({requestId:e.id,dismissed:!0}),children:`Dismiss`})]})]}):null]})}function o2(){let{requests:e,respond:t}=NQ();return e.length===0?null:(0,P.jsx)(`div`,{className:`grid gap-2 border-b px-3 py-2`,children:e.map(e=>(0,P.jsx)(a2,{request:e,respond:t},e.id))})}function s2({className:e,...t}){return(0,P.jsx)(`select`,{"data-slot":`native-select`,className:a(`border-input bg-background text-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive h-9 w-full min-w-0 cursor-pointer rounded-md border px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t})}var c2=6e4,l2=500,u2=1e4,d2=100,f2=new Set([`listThreads`,`getThread`,`getAvailableModels`]),p2=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchTransportError`}},m2=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`WorkbenchRpcError`}};function h2(){return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}/api/v1/workbench/ws`}function g2(e={}){let t=e.url??h2(),n=new Map,r=new Map,i=null,a=0,o,s=!1,c=!1,l=0;function u(t){e.onStatusChange?.(t)}function d(t){e.onError?.(t instanceof Error?t:Error(String(t)))}function f(e,t){let r=n.get(e);r&&(n.delete(e),clearTimeout(r.timer),r.reject(t))}function p(e,t=!1){return e.phase===`sent`?new p2(`OUTCOME_UNKNOWN`,`Confirmation for ${e.frame.method} was lost. The request may have been accepted. Reconnect and check the thread before retrying.`):new p2(t?`TIMEOUT_NOT_SENT`:`NOT_CONNECTED`,`The connection is unavailable. The request was not sent.`)}function m(e){if(i&&i.readyState===WebSocket.OPEN&&n.has(e.frame.id))try{i.send(JSON.stringify(e.frame)),e.phase=`sent`}catch{f(e.frame.id,new p2(`SEND_FAILED`,`The request could not be sent.`))}}function h(e){if(i&&i.readyState===WebSocket.OPEN)try{i.send(JSON.stringify(e))}catch(e){d(e),i.close()}}function g(){if(s||o!==void 0)return;let t=Math.min((e.reconnectBaseMs??l2)*2**a,u2);a+=1,o=setTimeout(()=>{o=void 0,_()},t)}function _(){if(s||i)return;u(`connecting`);let o;try{o=e.createSocket?.(t)??new WebSocket(t)}catch(e){d(e),u(`closed`),g();return}i=o,o.onopen=()=>{if(!(s||i!==o)){a=0;for(let[e,t]of r)h({kind:`subscribe`,threadId:e,includeSnapshot:c||t.includeSnapshot});c=!0;for(let e of n.values())e.phase===`queued`&&m(e);u(`open`)}},o.onmessage=e=>{if(s||i!==o)return;let t;try{t=b2(JSON.parse(String(e.data)))}catch{d(new p2(`INVALID_SERVER_FRAME`,`The workspace sent an invalid response. Reconnecting.`)),o.close();return}if(t.kind===`event`){let e=t.event,n=r.get(e.threadId)?.listeners;for(let t of[...n??[]])try{t(e)}catch(e){d(e)}return}let a=n.get(t.id);if(a){if(t.kind===`rpc_error`){f(t.id,new m2(t.code,t.message));return}if(!x2(a.frame.method,t.result)){f(t.id,new p2(`INVALID_SERVER_FRAME`,`The workspace returned an invalid result.`));return}n.delete(t.id),clearTimeout(a.timer),a.resolve(t.result===null?void 0:t.result)}},o.onerror=()=>{},o.onclose=()=>{if(!(s||i!==o)){i=null;for(let[e,t]of n)f(e,p(t));u(`closed`),g()}}}function v(t,r){if(s)return Promise.reject(new p2(`DISPOSED`,`The workspace connection was closed.`));if(!f2.has(t)&&i?.readyState!==WebSocket.OPEN)return Promise.reject(new p2(`NOT_CONNECTED`,`The connection is unavailable. The request was not sent.`));if(n.size>=d2)return Promise.reject(new p2(`TOO_MANY_REQUESTS`,`Too many workspace requests are pending.`));let a=`rpc-${l++}`;return new Promise((i,o)=>{let s=setTimeout(()=>{let e=n.get(a);e&&f(a,p(e,!0))},e.requestTimeoutMs??c2),c={frame:{kind:`rpc`,id:a,method:t,params:r},phase:`queued`,resolve:i,reject:o,timer:s};n.set(a,c),m(c)})}return _(),{dispose(){if(!s){s=!0,o&&clearTimeout(o),o=void 0,r.clear();for(let e of n.keys())f(e,new p2(`DISPOSED`,`The workspace connection was closed.`));i&&(i.onopen=null,i.onmessage=null,i.onclose=null,i.onerror=null,i.close()),i=null}},listThreads:e=>v(`listThreads`,e?[e]:[]),createThread:e=>v(`createThread`,e?[e]:[]),getThread:e=>v(`getThread`,[e]),sendMessage:(e,t)=>v(`sendMessage`,[e,t]),cancelRun:e=>v(`cancelRun`,[e]),clearQueue:e=>v(`clearQueue`,[e]),getAvailableModels:e=>v(`getAvailableModels`,e?[e]:[]),setModel:(e,t)=>v(`setModel`,[e,t]),setThinkingLevel:(e,t)=>v(`setThinkingLevel`,[e,t]),renameThread:(e,t)=>v(`renameThread`,[e,t]),archiveThread:e=>v(`archiveThread`,[e]),unarchiveThread:e=>v(`unarchiveThread`,[e]),deleteThread:e=>v(`deleteThread`,[e]),respondToHostUiRequest:(e,t)=>v(`respondToHostUiRequest`,[e,t]),subscribe(e,t,n){if(s)return()=>{};let a=e=>t(e),o=r.get(e);return o?(o.listeners.add(a),n?.includeSnapshot!==!1&&(o.includeSnapshot=!0,i?.readyState===WebSocket.OPEN&&h({kind:`subscribe`,threadId:e,includeSnapshot:!0}))):(o={listeners:new Set,includeSnapshot:n?.includeSnapshot!==!1},r.set(e,o),o.listeners.add(a),h({kind:`subscribe`,threadId:e,includeSnapshot:o.includeSnapshot})),()=>{let t=r.get(e);t&&t.listeners.delete(a)&&t.listeners.size===0&&(r.delete(e),h({kind:`unsubscribe`,threadId:e}))}}}}function _2(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function v2(e){return _2(e)&&typeof e.id==`string`&&[`idle`,`running`,`failed`].includes(String(e.status))}function y2(e){return _2(e)&&v2(e.metadata)&&Array.isArray(e.messages)}function b2(e){if(!_2(e))throw Error(`Invalid frame`);if(e.kind===`event`){let t=e.event;if(_2(t)&&typeof t.type==`string`&&typeof t.threadId==`string`&&Number.isSafeInteger(t.seq)&&Number(t.seq)>=0&&(t.type!==`snapshot`||y2(t.snapshot)))return e}else if(typeof e.id==`string`&&(e.kind===`rpc_ok`&&`result`in e||e.kind===`rpc_error`&&typeof e.message==`string`&&typeof e.code==`string`))return e;throw Error(`Invalid frame`)}function x2(e,t){switch(e){case`listThreads`:return Array.isArray(t)&&t.every(v2);case`getThread`:case`createThread`:return y2(t);case`getAvailableModels`:return Array.isArray(t)&&t.every(e=>_2(e)&&typeof e.provider==`string`&&typeof e.modelId==`string`);case`clearQueue`:return _2(t)&&Array.isArray(t.steering)&&t.steering.every(e=>typeof e==`string`)&&Array.isArray(t.followUp)&&t.followUp.every(e=>typeof e==`string`);default:return t===null}}async function S2(){try{let e=await fetch(`/api/v1/workbench/status`,{credentials:`same-origin`});return e.status===401||e.status===403?`unauthenticated`:e.ok?(await e.json()).enabled?`up`:`unconfigured`:`down`}catch{return`down`}}var C2={connecting:`reconnecting`,open:`online`,closed:`dropped`};function w2(){let{compaction:e,retry:t,contextUsage:n,readiness:r}=jQ(),i=r&&r.state!==`ready`?r:null;return(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i?(0,P.jsx)(sx,{variant:`high`,children:i.message}):null,e.active?(0,P.jsx)(sx,{variant:`secondary`,children:`Compacting context…`}):null,t.active?(0,P.jsxs)(sx,{variant:`high`,children:[`Retrying (attempt `,t.attempt,`)`]}):null,n?.percent==null?null:(0,P.jsxs)(`span`,{className:`text-muted-foreground text-xs tabular-nums`,title:`${n.tokens??`?`} / ${n.contextWindow} tokens`,children:[Math.round(n.percent),`% context`]})]})}var T2=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function E2({client:e}){let t=MQ(),n=$(e=>e.threadListItem),r=n?n.externalId??n.remoteId??n.id:null,[i,a]=(0,N.useState)([]),[o,s]=(0,N.useState)(null);(0,N.useEffect)(()=>{let t=!1;return e.getAvailableModels().then(e=>{t||a(e)},()=>{}),()=>{t=!0}},[e]);let c=t?.status===`running`,l=t?.config,u=l?.provider&&l.modelId?`${l.provider}/${l.modelId}`:``,d=l?.thinkingLevel??``,f=async e=>{s(null);try{await e()}catch(e){s(e instanceof Error?e.message:String(e))}};return r?(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i.length>0?(0,P.jsxs)(s2,{"aria-label":`Model`,title:`Model for this conversation`,value:u,disabled:c,onChange:t=>{let[n,...i]=t.target.value.split(`/`),a=i.join(`/`);n&&a&&f(()=>e.setModel(r,{provider:n,modelId:a}))},className:`h-7 w-auto max-w-44 text-xs`,children:[!u||i.every(e=>`${e.provider}/${e.modelId}`!==u)?(0,P.jsx)(`option`,{value:u,children:u||`Select a model`}):null,i.map(e=>(0,P.jsx)(`option`,{value:`${e.provider}/${e.modelId}`,children:e.name},`${e.provider}/${e.modelId}`))]}):null,(0,P.jsxs)(s2,{"aria-label":`Thinking level`,title:`Thinking level for this conversation`,value:d,disabled:c,onChange:t=>{let n=t.target.value;f(()=>e.setThinkingLevel(r,n))},className:`h-7 w-auto text-xs`,children:[(0,P.jsx)(`option`,{value:``,children:`Thinking…`}),T2.map(e=>(0,P.jsx)(`option`,{value:e,children:e},e))]}),o?(0,P.jsx)(`span`,{className:`text-destructive max-w-64 truncate text-xs`,title:o,children:o}):null]}):null}function D2({status:e,client:t}){let n=MQ();return(0,P.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2 border-b px-3 py-2`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,P.jsx)(`strong`,{className:`truncate text-sm font-semibold`,children:n?.title??`Live Workspace`}),n?.status===`running`?(0,P.jsx)(sx,{variant:`low`,children:`streaming`}):null]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,P.jsx)(w2,{}),(0,P.jsx)(E2,{client:t}),e===`open`?null:(0,P.jsx)(i2,{phase:C2[e]})]})]})}function O2(){let[e,t]=(0,N.useState)(`connecting`),n=(0,N.useMemo)(()=>g2({onStatusChange:t}),[]);(0,N.useEffect)(()=>()=>n.dispose(),[n]);let r=AQ({client:n,includeArchived:!0});return(0,P.jsx)(dG,{runtime:r,children:(0,P.jsxs)(`div`,{className:`grid h-[var(--workspace-height)] min-h-120 grid-cols-1 gap-4 md:grid-cols-[minmax(0,17rem)_minmax(0,1fr)]`,children:[(0,P.jsx)(g,{className:`hidden min-h-0 overflow-hidden p-0 md:flex`,children:(0,P.jsx)(U0,{})}),(0,P.jsxs)(g,{className:`flex min-h-0 flex-col overflow-hidden p-0`,children:[(0,P.jsx)(D2,{status:e,client:n}),(0,P.jsx)(o2,{}),(0,P.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,P.jsx)(x0,{})})]})]})})}function k2({state:e}){return(0,P.jsxs)(g,{className:`mx-auto max-w-lg items-start gap-3 p-6`,children:[(0,P.jsx)(`h2`,{className:`text-base font-semibold`,children:e===`unauthenticated`?`Sign in required`:e===`unconfigured`?`Live workspace not configured`:`Live workspace unreachable`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e===`unauthenticated`?`The live workspace is available to authenticated platform users.`:e===`unconfigured`?`Set WORKBENCH_CWD on the platform server to enable the hosted agent runtime (see docs/infra/workbench-integration.md).`:`The platform server did not answer. Check that it is running.`}),e===`unauthenticated`?(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsx)(`a`,{href:`/login`,children:`Sign in`})}):null]})}function A2({eyebrow:e,title:t,description:n,actions:r,className:i}){return(0,P.jsxs)(`header`,{className:a(`flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,i),children:[(0,P.jsxs)(`div`,{className:`min-w-0`,children:[e?(0,P.jsx)(`p`,{className:`text-muted-foreground mt-0 mb-2 text-2xs font-semibold tracking-[0.12em] uppercase`,children:e}):null,(0,P.jsx)(`h1`,{children:t}),n?(0,P.jsx)(`p`,{className:`mt-2 mb-0 max-w-[72ch]`,children:n}):null]}),r?(0,P.jsx)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:r}):null]})}function j2({sessions:e,value:t,onChange:n,className:r,id:i=`agent-session`}){let o=e[0];return(0,P.jsxs)(`div`,{className:a(`flex min-w-0 items-center gap-2`,r),children:[(0,P.jsx)(`label`,{className:`text-muted-foreground shrink-0 text-[13px]`,htmlFor:i,children:`Session`}),(0,P.jsxs)(s2,{"aria-label":`Agent session`,className:`w-auto min-w-0 max-w-[22rem] text-[13px]`,id:i,onChange:e=>n(e.target.value),value:t??`latest`,children:[(0,P.jsx)(`option`,{value:`latest`,children:o?`Latest — ${o.title||`Session`}`:`Latest session`}),(0,P.jsx)(`option`,{value:`all`,children:`All workspace sessions`}),e.map(e=>(0,P.jsxs)(`option`,{value:e.id,children:[e.title||`Session`,` · `,e.findingCount??0,` findings · `,e.runCount??0,` runs`]},e.id))]})]})}var M2=new jf({defaultOptions:{queries:{staleTime:1e4,retry:2,refetchOnWindowFocus:!0}}});function N2({section:e}){return(0,P.jsx)(Pf,{client:M2,children:(0,P.jsx)(F2,{section:e})})}function P2(){let e=Jf({queryKey:[`workbench-status`],queryFn:S2,retry:1,staleTime:15e3});return e.isLoading?(0,P.jsx)(L2,{compact:!0,title:`Connecting to the live workspace…`,detail:`Checking the platform agent runtime.`}):e.data&&e.data!==`up`?(0,P.jsx)(k2,{state:e.data}):(0,P.jsx)(O2,{})}function F2({section:e}){let[t,n]=(0,N.useState)(()=>typeof window<`u`?new URLSearchParams(window.location.search).get(`session`):null);(0,N.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`session`);e&&n(e);let t=e=>{let t=e;t.detail&&`sessionId`in t.detail&&n(t.detail.sessionId)};return window.addEventListener(`kifaru:sessionchange`,t),()=>window.removeEventListener(`kifaru:sessionchange`,t)},[e]);let r=e=>{let t=e===`latest`?null:e;if(n(t),typeof window<`u`){let e=new URL(window.location.href);t?e.searchParams.set(`session`,t):e.searchParams.delete(`session`),window.history.replaceState({},``,e.toString()),window.dispatchEvent(new CustomEvent(`kifaru:sessionchange`,{detail:{sessionId:t}}))}},[i,a]=(0,N.useState)(()=>typeof window<`u`?new URLSearchParams(window.location.search).get(`finding`):null),o=e=>{if(a(e),typeof window<`u`){let t=new URL(window.location.href);e?t.searchParams.set(`finding`,e):t.searchParams.delete(`finding`),window.history.replaceState({},``,t.toString())}},c=Jf({queryKey:[`agent-sessions`],queryFn:Ab.agentSessions,enabled:e===`runs`||e===`agent`||e===`findings`||e===`dashboard`||e===`lifecycle`,refetchInterval:2e3}),l=t===`all`?void 0:t||c.data?.items?.[0]?.id,u=Jf({queryKey:[`workflows`],queryFn:Ab.workflows,enabled:e===`workflows`||e===`assessments`}),d=Jf({queryKey:[`overview`,l],queryFn:()=>Ab.overview(l),enabled:e===`dashboard`||e===`assessments`||e===`lifecycle`,refetchInterval:2e3}),f=Jf({queryKey:[`runs`,l],queryFn:()=>Ab.runs({sessionId:l}),enabled:e===`runs`,refetchInterval:2e3}),p=Jf({queryKey:[`projects`],queryFn:Ab.projects,enabled:e===`assessments`}),h=Jf({queryKey:[`assessment-profiles`],queryFn:Ab.assessmentProfiles,enabled:e===`assessments`}),v=Jf({queryKey:[`findings`,l],queryFn:()=>Ab.findings({sessionId:l}),enabled:e===`findings`||e===`dashboard`||e===`lifecycle`||e===`reports`,refetchInterval:6e3}),y=Jf({queryKey:[`agent-session`,t],queryFn:()=>Ab.agentSession(t),enabled:e===`runs`&&!!t,refetchInterval:2e3}),b=Jf({queryKey:[`governance-events`],queryFn:Ab.governanceEvents,enabled:e===`reports`}),x=Jf({queryKey:[`workers`],queryFn:Ab.workers,enabled:e===`administration`}),S=Jf({queryKey:[`tokens`],queryFn:Ab.tokens,enabled:e===`administration`}),[C,w]=(0,N.useState)(``),[E,D]=(0,N.useState)(30),[O,k]=(0,N.useState)(!1),[j,M]=(0,N.useState)(null),[ee,te]=(0,N.useState)(!1),[ne,re]=(0,N.useState)(!1),[ae,oe]=(0,N.useState)(null),[se,ce]=(0,N.useState)(null);async function le(e){e.preventDefault(),k(!0),oe(null);try{let e=await Ab.mintToken({label:C.trim()||`CLI Token`,expiresInDays:E});M(e),w(``),M2.invalidateQueries({queryKey:[`tokens`]})}catch(e){oe(e instanceof Error?e.message:`Failed to mint token`)}finally{k(!1)}}async function ue(e){if(confirm(`Are you sure you want to revoke this token? Any CLI session or automation using it will immediately lose access.`)){ce(e);try{await Ab.revokeToken(e),M2.invalidateQueries({queryKey:[`tokens`]})}catch(e){alert(e instanceof Error?e.message:`Failed to revoke token`)}finally{ce(null)}}}let de=[...e===`workflows`||e===`assessments`?[u]:[],...e===`dashboard`?[d,v]:[],...e===`lifecycle`?[d,v]:[],...e===`runs`?[f,c]:[],...e===`runs`&&t?[y]:[],...e===`assessments`?[d,p,h]:[],...e===`findings`?[v]:[],...e===`reports`?[b,v]:[],...e===`administration`?[x,S]:[]];if(de.some(e=>e.isLoading))return(0,P.jsx)(L2,{title:`Loading workspace`,detail:`Reading durable platform state…`});let pe=de.find(e=>e.isError);if(pe){let e=pe.error,t=e&&typeof e==`object`&&`status`in e&&e.status===401;return(0,P.jsx)(L2,{title:`Platform unavailable`,detail:e instanceof Error?e.message:`The platform could not be reached.`,action:t?(0,P.jsx)(s,{asChild:!0,children:(0,P.jsx)(`a`,{href:`/login`,children:`Sign in`})}):(0,P.jsxs)(s,{onClick:()=>void pe.refetch(),children:[(0,P.jsx)(xe,{}),` Retry`]})})}let me=Gb(v.data?.findings??[]),he=me.filter(Hb);if(e===`dashboard`){let e=Object.fromEntries(Fb.map(e=>[e,he.filter(t=>t.severity===e).length])),n=d.data?.runs??{},i=Object.values(n).reduce((e,t)=>e+t,0),a=(n.queued??0)+(n.running??0),o=Kb(me),l=me.filter(e=>e.status===`confirmed`||e.status===`verified`);return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(A2,{actions:(0,P.jsx)(j2,{onChange:r,sessions:c.data?.items??[],value:t}),eyebrow:`Continuous assurance`,title:`Environment-wide risk posture`,description:`Posture recomputes on every run rather than at a point in time. Every number below comes from the platform ledger — agent runs, recorded tool calls and ingested findings.`}),(0,P.jsxs)(Jb,{children:[(0,P.jsx)(Yb,{hero:!0,tone:o??void 0,label:`Client posture`,value:o?Rb[o].toUpperCase():`NO CONFIRMED RISK`,meta:o?`Worst confirmed finding across ${l.length} confirmed finding${l.length===1?``:`s`}.`:`No finding has been confirmed yet.`}),(0,P.jsx)(Yb,{label:`Open findings`,value:he.length,meta:`${me.length-he.length} resolved`}),(0,P.jsx)(Yb,{label:`Critical / High`,value:`${e.critical} / ${e.high}`,meta:`${l.length} confirmed overall`}),(0,P.jsx)(Yb,{label:`Assessments`,value:i,meta:`${a} in flight`})]}),(0,P.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,P.jsx)(qb,{title:`Open findings by severity`,sub:`${he.length} active`,children:(0,P.jsx)(Xb,{counts:e})}),(0,P.jsx)(qb,{title:`Findings by data-lifecycle stage`,sub:`where the risk lives`,children:(0,P.jsx)(Zb,{findings:he})})]}),(0,P.jsx)(qb,{title:`Highest-priority open findings`,sub:(0,P.jsx)(`a`,{className:`link-more`,href:`/findings`,children:`View all`}),children:(0,P.jsx)(Qb,{findings:Vb(he).slice(0,5),onSelect:e=>{window.location.href=`/findings?finding=${encodeURIComponent(e.id)}`},emptyLabel:`No open findings. Agent runs report findings through the report_finding tool; none have been ingested yet.`})}),(0,P.jsxs)(`section`,{"aria-labelledby":`active-runs`,children:[(0,P.jsxs)(`div`,{className:`mb-4 flex items-baseline justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-muted-foreground mt-0 mb-1 text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Operations`}),(0,P.jsx)(`h2`,{id:`active-runs`,children:`Active runs`})]}),(0,P.jsxs)(`a`,{className:`link-more`,href:`/runs`,children:[`View all `,(0,P.jsx)(T,{"aria-hidden":`true`})]})]}),d.data?.recentRuns.filter(e=>e.status===`queued`||e.status===`running`).length?(0,P.jsx)(V2,{runs:d.data.recentRuns.filter(e=>e.status===`queued`||e.status===`running`)}):(0,P.jsx)(L2,{compact:!0,title:`No active runs`,detail:`Select a target endpoint to initialize a governed assessment.`,action:(0,P.jsx)(s,{asChild:!0,children:(0,P.jsx)(`a`,{href:`/assessments`,children:`New assessment`})})})]})]})}if(e===`lifecycle`)return(0,P.jsx)(z2,{findings:he});if(e===`workflows`)return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(I2,{title:`Workflows`,detail:`Standardized assessment procedures, risk classifications, and required worker capabilities.`}),(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:u.data?.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(sx,{variant:ox(U2(e.stages)),children:[`Highest risk `,U2(e.stages)]}),(0,P.jsxs)(`span`,{className:`font-mono`,children:[`v`,e.version]})]}),(0,P.jsx)(`h2`,{children:e.name}),(0,P.jsx)(`p`,{children:e.description}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.requiredCapabilities.map(e=>(0,P.jsx)(`span`,{children:e},e))}),(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsxs)(`a`,{href:`/assessments`,children:[`Check readiness `,(0,P.jsx)(T,{})]})})]},e.key))})]});if(e===`runs`){if(t&&y.data){let e=y.data,t=e.operations.filter(e=>e.status!==`completed`).length;return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsxs)(`header`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,children:`Session`}),(0,P.jsx)(`h1`,{children:e.session.title}),(0,P.jsx)(`p`,{children:`Recorded tool calls and findings for this agent session, newest run last.`})]}),(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsx)(`a`,{href:`/runs`,children:`All runs`})})]}),(0,P.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,P.jsx)(R2,{label:`Status`,value:G2(e.session.status),detail:`${e.session.runCount} run${e.session.runCount===1?``:`s`} in this session`}),(0,P.jsx)(R2,{label:`Tool calls`,value:String(e.session.operationCount),detail:t?`${t} did not complete`:`All completed`}),(0,P.jsx)(R2,{label:`Findings`,value:String(e.session.findingCount),detail:e.session.findingCount?`Ingested through report_finding`:`None reported in this session`})]}),(0,P.jsxs)(`div`,{className:`grid items-start gap-5 lg:grid-cols-[minmax(0,1.35fr)_minmax(280px,0.65fr)]`,"aria-live":`polite`,children:[(0,P.jsxs)(`section`,{"aria-labelledby":`agent-transcript`,children:[(0,P.jsx)(`h2`,{id:`agent-transcript`,children:`Transcript`}),e.operations.length?(0,P.jsx)(`div`,{className:`grid gap-2.5`,children:e.operations.map(e=>(0,P.jsxs)(`article`,{className:`bg-card rounded-lg border p-4 [&_p]:mt-2 [&_p]:mb-0 [&_p]:text-[13px] [&_p]:leading-relaxed [&_p]:break-words [&_p]:text-muted-foreground [&_p.font-mono]:max-h-28 [&_p.font-mono]:overflow-auto [&_p.font-mono]:rounded-sm [&_p.font-mono]:bg-[var(--plane)] [&_p.font-mono]:px-2.5 [&_p.font-mono]:py-2 [&_p.font-mono]:text-xs [&_p.font-mono]:whitespace-pre-wrap`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(`strong`,{children:e.tool}),(0,P.jsx)(sx,{variant:ox(e.status),children:G2(e.outcome)})]}),(0,P.jsxs)(`p`,{children:[e.runtime,` · `,new Date(e.startedAt).toLocaleTimeString(),e.completedAt?` · ${e.completedAt-e.startedAt}ms`:``]}),e.outputPreview?(0,P.jsx)(`p`,{className:`font-mono`,children:e.outputPreview.slice(0,400)}):null]},e.id))}):(0,P.jsx)(L2,{compact:!0,title:`Waiting for agent output`,detail:`Tool calls appear here as the runtime records them.`})]}),(0,P.jsxs)(`section`,{"aria-labelledby":`agent-runs`,children:[(0,P.jsx)(`h2`,{id:`agent-runs`,children:`Runs`}),(0,P.jsx)(`div`,{className:`grid gap-2.5`,children:e.runs.map(e=>(0,P.jsxs)(`article`,{className:`bg-card rounded-lg border p-4 [&_p]:mt-2 [&_p]:mb-0 [&_p]:text-[13px] [&_p]:leading-relaxed [&_p]:break-words [&_p]:text-muted-foreground`,children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(sx,{variant:ox(e.status),children:G2(e.status)}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.id.slice(0,12)})]}),(0,P.jsxs)(`p`,{children:[e.kind,` · `,new Date(e.createdAt).toLocaleString()]})]},e.id))})]})]}),e.findings.length?(0,P.jsxs)(`section`,{"aria-labelledby":`agent-findings`,children:[(0,P.jsx)(`h2`,{id:`agent-findings`,children:`Findings from this session`}),(0,P.jsx)(H2,{findings:e.findings})]}):null]})}return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(I2,{title:`Runs`,detail:`Governed assessment runs and the agent sessions behind them. Open a session to replay its transcript.`}),(0,P.jsxs)(`section`,{"aria-labelledby":`all-runs`,children:[(0,P.jsx)(`h2`,{id:`all-runs`,className:`mb-3`,children:`Runs`}),f.data?.runs.length?(0,P.jsx)(V2,{runs:f.data.runs}):(0,P.jsx)(L2,{compact:!0,title:`No runs yet`,detail:`Initialize an assessment to start the first governed run.`})]}),(0,P.jsxs)(`section`,{"aria-labelledby":`all-sessions`,children:[(0,P.jsx)(`h2`,{id:`all-sessions`,className:`mb-3`,children:`Sessions`}),c.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:c.data.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(sx,{variant:ox(e.status),children:G2(e.status)}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.source})]}),(0,P.jsx)(`h2`,{children:e.title}),(0,P.jsxs)(`p`,{children:[e.runCount,` run`,e.runCount===1?``:`s`,` · `,e.operationCount,` tool call`,e.operationCount===1?``:`s`,` · `,e.findingCount,` finding`,e.findingCount===1?``:`s`]}),(0,P.jsxs)(`p`,{children:[`Last active `,new Date(e.lastActivityAt).toLocaleString()]}),(0,P.jsx)(s,{variant:`outline`,asChild:!0,children:(0,P.jsx)(`a`,{href:`/runs?session=${e.id}`,children:`Open session`})})]},e.id))}):(0,P.jsx)(L2,{compact:!0,title:`No agent sessions`,detail:`Sessions appear here once an agent run reaches the platform.`})]})]})}if(e===`assessments`)return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(I2,{title:`Assessments`,detail:`Target environment configurations, authorization scopes, and historical run associations.`}),(0,P.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,P.jsx)(R2,{label:`Projects`,value:String(p.data?.items.length??0),detail:`Active workspace project boundaries`}),(0,P.jsx)(R2,{label:`Target bindings`,value:String(h.data?.items.length??0),detail:`Bound endpoints and infrastructure`}),(0,P.jsx)(R2,{label:`Recent runs`,value:String(d.data?.recentRuns.length??0),detail:`Assessment runs recorded in this workspace`})]}),h.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:h.data.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(sx,{variant:ox(e.allowedRisk),children:e.allowedRisk}),(0,P.jsxs)(`span`,{className:`font-mono`,children:[`rev `,e.revision]})]}),(0,P.jsx)(`h2`,{children:e.targets[0]?.displayName??e.targets[0]?.locator??`Bound target`}),(0,P.jsxs)(`p`,{children:[e.requiredWorkerClass,` worker · immutable launch policy`]}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.requiredCapabilities.map(e=>(0,P.jsx)(`span`,{children:e},e))})]},e.id))}):(0,P.jsx)(L2,{compact:!0,title:`No targets yet`,detail:`Configure a new target endpoint from the dashboard to initialize assessment tracking.`})]});if(e===`findings`){if(i)return(0,P.jsx)(`div`,{className:`grid gap-6`,children:(0,P.jsx)(aj,{findingId:i,onBack:()=>o(null)})});let e=Object.fromEntries(Fb.map(e=>[e,he.filter(t=>t.severity===e).length])),n=W2(me);return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(A2,{actions:(0,P.jsx)(j2,{id:`findings-session`,onChange:r,sessions:c.data?.items??[],value:t}),title:`Findings & assets`,description:`Every finding on the assessed estate, grouped by asset and placed on the data lifecycle. Click any finding to read it in full, verify it, and track it to resolution.`}),me.length?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,P.jsx)(qb,{title:`Open findings by severity`,sub:`${he.length} active`,children:(0,P.jsx)(Xb,{counts:e})}),(0,P.jsx)(qb,{title:`Findings by data-lifecycle stage`,sub:`where the risk lives`,children:(0,P.jsx)(Zb,{findings:he})})]}),(0,P.jsx)(qb,{title:`Control coverage`,sub:`pillar × lifecycle stage — worst open severity per cell`,children:(0,P.jsx)(ex,{findings:he,onSelectStage:()=>{}})}),n.map(({asset:e,items:t})=>(0,P.jsx)(qb,{title:e,sub:`${t.length} finding${t.length===1?``:`s`}`,children:(0,P.jsx)(Qb,{findings:Vb(t),onSelect:e=>o(e.id)})},e))]}):(0,P.jsx)(L2,{compact:!0,title:`No findings`,detail:`Discovered findings will appear here as agent runs report them. Source findings stay unverified until operation-level evidence confirms them.`})]})}return e===`agent`?(0,P.jsx)(P2,{}):e===`reports`?(0,P.jsxs)(`div`,{className:`grid gap-8`,children:[(0,P.jsx)(A2,{eyebrow:`Kifaru platform`,title:`Reports`,description:`The generated audit report for a run, and the finding-level evidence behind every claim.`}),(0,P.jsx)($A,{}),(0,P.jsx)(B2,{events:b.data?.items??[],findings:me})]}):e===`administration`?(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(I2,{title:`Administration & Access`,detail:`Personal access tokens, CLI credentials, worker registrations, and operational capabilities.`}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,P.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`0.5rem`},children:[(0,P.jsx)(fe,{size:18}),(0,P.jsx)(`h2`,{children:`Personal Access Tokens & CLI Sign-In`})]})}),(0,P.jsx)(`p`,{style:{marginTop:`0.25rem`,marginBottom:`1rem`},children:`Mint tokens to authenticate the Kifaru CLI or automated CI/CD pipelines without passwords.`}),j&&(0,P.jsxs)(`div`,{style:{background:`rgba(16, 185, 129, 0.12)`,border:`1px solid rgba(16, 185, 129, 0.4)`,borderRadius:`0.5rem`,padding:`1rem`,marginBottom:`1.25rem`},children:[(0,P.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`0.5rem`},children:[(0,P.jsxs)(`strong`,{style:{color:`var(--good)`,display:`flex`,alignItems:`center`,gap:`0.4rem`},children:[(0,P.jsx)(A,{size:16}),` Token Minted: `,j.label]}),(0,P.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>M(null),children:`Dismiss`})]}),(0,P.jsx)(`p`,{style:{fontSize:`0.85rem`,color:`var(--ink-2)`,marginBottom:`0.75rem`},children:`Make sure to copy your Personal Access Token now. You will not be able to see it again!`}),(0,P.jsxs)(`div`,{style:{display:`grid`,gap:`0.75rem`},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(_,{className:`text-muted-foreground mb-1 block text-2xs font-semibold tracking-[0.12em] uppercase`,children:`Token Value`}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,alignItems:`center`},children:[(0,P.jsx)(m,{type:`text`,readOnly:!0,value:j.token,className:`flex-1 font-mono`}),(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(j.token),te(!0),setTimeout(()=>te(!1),2e3)},children:[ee?(0,P.jsx)(A,{size:14}):(0,P.jsx)(ie,{size:14}),ee?`Copied`:`Copy Token`]})]})]}),(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`label`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,style:{display:`block`,marginBottom:`0.25rem`},children:`CLI Sign-In Command`}),(0,P.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,alignItems:`center`},children:[(0,P.jsxs)(`code`,{className:`font-mono`,style:{flex:1,borderRadius:`0.375rem`,padding:`0.45rem 0.65rem`,fontSize:`0.82rem`,color:`var(--accent)`},children:[`kifaru session login --token `,j.token]}),(0,P.jsxs)(s,{variant:`outline`,size:`sm`,onClick:()=>{navigator.clipboard.writeText(`kifaru session login --token `+j.token),re(!0),setTimeout(()=>re(!1),2e3)},children:[ne?(0,P.jsx)(A,{size:14}):(0,P.jsx)(ie,{size:14}),ne?`Copied`:`Copy Command`]})]})]})]})]}),(0,P.jsxs)(`form`,{onSubmit:le,style:{display:`flex`,flexWrap:`wrap`,alignItems:`flex-end`,gap:`0.75rem`,background:`var(--surface-2)`,border:`1px solid var(--border)`,borderRadius:`0.5rem`,padding:`0.85rem`,marginBottom:`1.25rem`},children:[(0,P.jsxs)(`div`,{style:{flex:`1 1 220px`},children:[(0,P.jsx)(_,{htmlFor:`mint-label`,className:`mb-1.5 block text-sm`,children:`Token Label`}),(0,P.jsx)(m,{id:`mint-label`,type:`text`,placeholder:`e.g. Workstation CLI, CI Runner`,value:C,onChange:e=>w(e.target.value)})]}),(0,P.jsxs)(`div`,{style:{width:`160px`},children:[(0,P.jsx)(_,{htmlFor:`mint-expiry`,className:`mb-1.5 block text-sm`,children:`Expiration`}),(0,P.jsxs)(s2,{id:`mint-expiry`,value:E,onChange:e=>D(Number(e.target.value)),children:[(0,P.jsx)(`option`,{value:30,children:`30 days`}),(0,P.jsx)(`option`,{value:60,children:`60 days`}),(0,P.jsx)(`option`,{value:90,children:`90 days`}),(0,P.jsx)(`option`,{value:365,children:`1 year`}),(0,P.jsx)(`option`,{value:0,children:`Never expires`})]})]}),(0,P.jsxs)(s,{type:`submit`,disabled:O,size:`sm`,children:[(0,P.jsx)(be,{size:15}),O?`Minting…`:`Mint Token`]})]}),ae&&(0,P.jsx)(`p`,{className:`text-destructive text-sm`,style:{marginBottom:`1rem`},children:ae}),(0,P.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,P.jsx)(`h3`,{style:{fontSize:`0.95rem`,fontWeight:600,marginBottom:`0.5rem`},children:`Active Tokens`}),S.data?.items.length?(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Label`}),(0,P.jsx)(`th`,{children:`Token Prefix`}),(0,P.jsx)(`th`,{children:`Role`}),(0,P.jsx)(`th`,{children:`Created`}),(0,P.jsx)(`th`,{children:`Expires`}),(0,P.jsx)(`th`,{children:`Action`})]})}),(0,P.jsx)(`tbody`,{children:S.data.items.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{style:{fontWeight:600,color:`var(--ink)`},children:e.label}),(0,P.jsxs)(`td`,{className:`font-mono`,children:[e.prefix,`…`]}),(0,P.jsx)(`td`,{children:(0,P.jsx)(sx,{variant:ox(`confirmed`),children:e.role})}),(0,P.jsx)(`td`,{children:new Date(e.createdAt).toLocaleDateString()}),(0,P.jsx)(`td`,{children:e.expiresAt?new Date(e.expiresAt).toLocaleDateString():`Never`}),(0,P.jsx)(`td`,{children:(0,P.jsxs)(s,{variant:`destructive`,size:`sm`,disabled:se===e.id,onClick:()=>ue(e.id),children:[(0,P.jsx)(je,{size:13}),se===e.id?`Revoking…`:`Revoke`]})})]},e.id))})]})}):(0,P.jsx)(`p`,{style:{color:`var(--muted)`,fontSize:`0.85rem`,fontStyle:`italic`},children:`No personal access tokens minted yet. Use the form above to create one.`})]}),(0,P.jsxs)(`div`,{style:{marginTop:`1.25rem`,background:`var(--surface-2)`,border:`1px dashed var(--border)`,borderRadius:`0.5rem`,padding:`0.85rem 1rem`,display:`flex`,alignItems:`center`,gap:`0.75rem`},children:[(0,P.jsx)(De,{size:20}),(0,P.jsxs)(`div`,{style:{fontSize:`0.82rem`,color:`var(--muted)`},children:[(0,P.jsx)(`strong`,{style:{color:`var(--ink)`},children:`Interactive Browser Sign-in:`}),` You can also run`,` `,(0,P.jsx)(`code`,{className:`font-mono`,style:{color:`var(--accent)`},children:`kifaru session login`}),` `,`in your terminal to authenticate interactively through your browser.`]})]})]}),(0,P.jsxs)(`div`,{style:{marginTop:`1rem`},children:[(0,P.jsx)(`h2`,{style:{fontSize:`1.15rem`,marginBottom:`0.75rem`},children:`Execution Workers`}),x.data?.items.length?(0,P.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:x.data.items.map(e=>(0,P.jsxs)(g,{children:[(0,P.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,P.jsx)(sx,{variant:ox(e.status),children:G2(e.status)}),(0,P.jsx)(`span`,{className:`font-mono`,children:e.status})]}),(0,P.jsx)(`h2`,{children:e.name}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:e.capabilities.map(e=>(0,P.jsx)(`span`,{children:e},e))})]},e.id))}):(0,P.jsx)(L2,{compact:!0,title:`No workers registered`,detail:`Connect an execution worker before launching capability-bound workflows.`})]})]}):(0,P.jsx)(L2,{title:`Not found`,detail:`This view does not exist.`})}function I2({title:e,detail:t}){return(0,P.jsx)(A2,{description:t,title:e})}function L2({title:e,detail:t,action:n,compact:r}){return(0,P.jsxs)(g,{className:`state ${r?`state-compact`:``}`,"aria-live":`polite`,children:[(0,P.jsx)(`div`,{className:`mb-1 grid size-9 place-items-center rounded-full border bg-[var(--accent-soft)] text-primary [&_svg]:size-[18px]`,children:(0,P.jsx)(b,{"aria-hidden":`true`})}),(0,P.jsx)(`h2`,{children:e}),(0,P.jsx)(`p`,{children:t}),n]})}function R2({label:e,value:t,detail:n}){return(0,P.jsxs)(g,{children:[(0,P.jsx)(`p`,{className:`text-2xs font-semibold tracking-[0.12em] uppercase text-muted-foreground`,children:e}),(0,P.jsx)(`strong`,{className:`my-1 block text-[28px] font-bold tracking-[-0.02em]`,children:t}),(0,P.jsx)(`p`,{children:n})]})}function z2({findings:e}){let[t,n]=(0,N.useState)(4),r=Mb(t),i=Vb(e.filter(e=>e.stage===t)),a=e.filter(e=>e.inferred).length;return(0,P.jsxs)(`div`,{className:`grid gap-6`,children:[(0,P.jsx)(A2,{eyebrow:`A control gap at any stage exposes the whole chain`,title:`Finding → data-lifecycle stage`,description:(0,P.jsxs)(P.Fragment,{children:[`Agents declare a stage by prefixing a finding’s category with`,` `,(0,P.jsx)(`span`,{className:`font-mono`,children:`L4·P1·`}),`.`,a?` ${a} of ${e.length} findings did not, so their stage is inferred from wording and marked as such.`:` Every finding here declared its own stage.`]})}),(0,P.jsx)($b,{findings:e,selected:t,onSelect:n}),(0,P.jsxs)(`div`,{className:`grid items-start gap-4 lg:grid-cols-[1.35fr_1fr]`,children:[(0,P.jsx)(qb,{title:`Stage ${r.n} · ${r.name}`,sub:`${i.length} finding${i.length===1?``:`s`}`,children:(0,P.jsx)(Qb,{findings:i,emptyLabel:`No open findings at this stage.`})}),(0,P.jsxs)(qb,{title:`Control pillar × lifecycle stage`,sub:`cell = open findings`,children:[(0,P.jsx)(ex,{findings:e,onSelectStage:n}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-4 text-xs font-medium`,style:{marginTop:12},children:[`critical`,`high`,`medium`,`low`].map(e=>(0,P.jsxs)(`span`,{children:[(0,P.jsx)(`i`,{className:`mcap`,style:{background:`var(${Lb[e]})`}}),`worst: `,Rb[e]]},e))})]})]})]})}function B2({events:e,findings:t}){let n=Vb(t.filter(e=>e.status===`confirmed`||e.status===`unverified`)),[r,i]=(0,N.useState)(null),a=n.find(e=>e.id===r)??n[0]??null,o=Jf({queryKey:[`finding`,a?.id],queryFn:()=>Ab.finding(a.id),enabled:!!a});return(0,P.jsxs)(`div`,{className:`grid gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`mb-0`,children:`Findings & evidence`}),(0,P.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Every finding carries the evidence chain that produced it; every platform mutation is recorded below.`})]}),(0,P.jsxs)(`div`,{className:`grid items-start gap-4 md:grid-cols-[300px_minmax(0,1fr)]`,children:[(0,P.jsxs)(`div`,{className:`bg-card overflow-hidden rounded-xl border [&_.ph]:text-muted-foreground [&_.ph]:border-b [&_.ph]:border-[var(--hair)] [&_.ph]:px-3.5 [&_.ph]:py-3 [&_.ph]:text-xs [&_.ph]:font-semibold`,children:[(0,P.jsx)(`div`,{className:`ph`,children:`Findings with evidence`}),n.length?n.map(e=>(0,P.jsxs)(`button`,{className:`block w-full border-0 border-b border-l-[3px] border-[var(--hair)] border-l-transparent bg-transparent px-3.5 py-2.5 text-left last:border-b-0 aria-pressed:border-l-primary aria-pressed:bg-[var(--accent-soft)] [&_.pt]:text-[13px] [&_.pt]:font-semibold`,type:`button`,"aria-pressed":e.id===a?.id,onClick:()=>i(e.id),children:[(0,P.jsx)(`span`,{className:`sevtag sev-${e.severity}`,children:Rb[e.severity]}),(0,P.jsx)(`div`,{className:`pt`,children:e.title})]},e.id)):(0,P.jsx)(`div`,{style:{padding:`14px`},children:(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No findings have been ingested yet, so there is no evidence to audit.`})})]}),(0,P.jsx)(`div`,{children:a?(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`div`,{className:`mb-4 flex justify-between gap-4`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`span`,{className:`sevtag sev-${a.severity}`,children:Rb[a.severity]}),(0,P.jsx)(`span`,{className:`font-mono text-muted-foreground text-xs`,style:{marginLeft:8},children:a.id}),(0,P.jsx)(`h2`,{style:{marginTop:9},children:a.title})]}),(0,P.jsx)(`span`,{className:`inline-flex shrink-0 self-start rounded-full border px-2.5 py-[3px] text-2xs font-semibold tracking-wide uppercase whitespace-nowrap text-muted-foreground`,children:a.status.replaceAll(`_`,` `)})]}),(0,P.jsx)(`p`,{children:a.description}),(0,P.jsx)(tx,{items:[{k:`CVSS`,v:o.data?.finding.cvssScore??`—`},{k:`Weakness`,v:o.data?.finding.cwe??`—`,mono:!0},{k:`Category`,v:a.displayCategory},{k:`Lifecycle stage`,v:(0,P.jsxs)(`span`,{className:`inline-flex items-center gap-[5px] [&_.d]:size-2 [&_.d]:rounded-[2px]`,children:[(0,P.jsx)(`span`,{className:`d`,style:{background:`var(${Mb(a.stage).v})`}}),a.stage,` · `,Nb(Mb(a.stage))]})}]}),(0,P.jsx)(nx,{title:`Evidence chain — provenance`,children:o.data?.finding.evidence.length?o.data.finding.evidence.map(e=>(0,P.jsx)(rx,{title:e.kind,detail:e.reason??`No reason recorded.`,verdict:e.verdict},e.id)):(0,P.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`No evidence records attached to this finding.`})}),o.data?.finding.remediation?(0,P.jsx)(nx,{title:`Remediation`,children:(0,P.jsx)(`p`,{children:o.data.finding.remediation})}):null]}):(0,P.jsx)(L2,{compact:!0,title:`Nothing to audit yet`,detail:`Evidence appears once an agent reports a finding through report_finding.`})})]}),(0,P.jsx)(qb,{surface:!1,title:`Governance ledger`,sub:`${e.length} recent event${e.length===1?``:`s`}`,children:e.length?(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`#`}),(0,P.jsx)(`th`,{children:`Action`}),(0,P.jsx)(`th`,{children:`Object`}),(0,P.jsx)(`th`,{children:`Actor`}),(0,P.jsx)(`th`,{children:`Outcome`}),(0,P.jsx)(`th`,{children:`Occurred`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`td`,{className:`font-mono`,children:e.sequence}),(0,P.jsx)(`td`,{children:e.action}),(0,P.jsxs)(`td`,{children:[e.objectType,` · `,(0,P.jsx)(`span`,{className:`font-mono`,children:e.objectID.slice(0,16)})]}),(0,P.jsx)(`td`,{className:`font-mono`,children:e.actorID??`—`}),(0,P.jsx)(`td`,{children:(0,P.jsx)(sx,{variant:ox(e.outcome),children:e.outcome})}),(0,P.jsx)(`td`,{children:new Date(e.createdAt).toLocaleString()})]},e.id))})]})}):(0,P.jsx)(L2,{compact:!0,title:`No governance events`,detail:`Run creation, state transitions, tool calls and finding ingestion are all recorded here.`})})]})}function V2({runs:e}){return(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Assessment`}),(0,P.jsx)(`th`,{children:`Kind`}),(0,P.jsx)(`th`,{children:`Status`}),(0,P.jsx)(`th`,{children:`Updated`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsxs)(`td`,{children:[(0,P.jsx)(`span`,{children:e.title}),(0,P.jsx)(`span`,{className:`font-mono block text-muted-foreground text-2xs`,children:e.id})]}),(0,P.jsx)(`td`,{children:G2(e.kind)}),(0,P.jsx)(`td`,{children:(0,P.jsx)(sx,{variant:ox(e.status),children:G2(e.status)})}),(0,P.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function H2({findings:e}){return(0,P.jsx)(`div`,{className:`overflow-x-auto rounded-xl border bg-card`,children:(0,P.jsxs)(`table`,{children:[(0,P.jsx)(`thead`,{children:(0,P.jsxs)(`tr`,{children:[(0,P.jsx)(`th`,{children:`Finding`}),(0,P.jsx)(`th`,{children:`Severity`}),(0,P.jsx)(`th`,{children:`Status`}),(0,P.jsx)(`th`,{children:`Asset`}),(0,P.jsx)(`th`,{children:`Updated`})]})}),(0,P.jsx)(`tbody`,{children:e.map(e=>(0,P.jsxs)(`tr`,{children:[(0,P.jsxs)(`td`,{children:[(0,P.jsx)(`a`,{href:`/findings`,children:e.title}),(0,P.jsx)(`span`,{className:`font-mono block text-muted-foreground text-2xs`,children:e.description??e.id})]}),(0,P.jsx)(`td`,{children:(0,P.jsx)(sx,{variant:ox(e.severity),children:G2(e.severity)})}),(0,P.jsx)(`td`,{children:(0,P.jsx)(sx,{variant:ox(e.status),children:G2(e.status)})}),(0,P.jsx)(`td`,{children:e.path??`—`}),(0,P.jsx)(`td`,{children:new Date(e.updatedAt).toLocaleString()})]},e.id))})]})})}function U2(e){return e.some(e=>e.risk===`R2`)?`R2`:e.some(e=>e.risk===`R1`)?`R1`:`R0`}function W2(e){let t=new Map;for(let n of e){let e=n.path?.trim()||`Unscoped`,r=t.get(e)??[];r.push(n),t.set(e,r)}return[...t.entries()].map(([e,t])=>({asset:e,items:t})).sort((e,t)=>t.items.length-e.items.length)}function G2(e){return e.replaceAll(`_`,` `).replaceAll(`-`,` `).replace(/\b\w/g,e=>e.toUpperCase())}export{N2 as PlatformRoute};
|