@pablopunk/webr 0.3.22 → 0.3.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bin/webr.mjs +0 -0
- package/dist/client/_astro/{App.lKW8lWGt.js → App.Cd8WC1am.js} +1 -1
- package/dist/client/_astro/{App.Dn52Mq-G.css → App.D4QoJ_Pi.css} +1 -1
- package/dist/client/harness-icons/agy.png +0 -0
- package/dist/client/harness-icons/amp.png +0 -0
- package/dist/client/harness-icons/claude.png +0 -0
- package/dist/client/harness-icons/cline.png +0 -0
- package/dist/client/harness-icons/codex.png +0 -0
- package/dist/client/harness-icons/copilot.png +0 -0
- package/dist/client/harness-icons/cursor.png +0 -0
- package/dist/client/harness-icons/devin.png +0 -0
- package/dist/client/harness-icons/droid.png +0 -0
- package/dist/client/harness-icons/gemini.png +0 -0
- package/dist/client/harness-icons/grok.png +0 -0
- package/dist/client/harness-icons/hermes.png +0 -0
- package/dist/client/harness-icons/kilo.png +0 -0
- package/dist/client/harness-icons/kimi.png +0 -0
- package/dist/client/harness-icons/kiro.png +0 -0
- package/dist/client/harness-icons/letta.png +0 -0
- package/dist/client/harness-icons/maki.png +0 -0
- package/dist/client/harness-icons/mastracode.png +0 -0
- package/dist/client/harness-icons/muse.png +0 -0
- package/dist/client/harness-icons/omp.png +0 -0
- package/dist/client/harness-icons/opencode.png +0 -0
- package/dist/client/harness-icons/pi.png +0 -0
- package/dist/client/harness-icons/qodercli.png +0 -0
- package/dist/client/harness-icons/qwen.png +0 -0
- package/dist/server/chunks/{App_B0fQPNEJ.mjs → App_BJmUpfw6.mjs} +36 -31
- package/dist/server/chunks/{_id__CccLGRJH.mjs → _id__I4w0eALi.mjs} +1 -1
- package/dist/server/chunks/{_tab__kNMNbgal.mjs → _tab__BKm1d6xh.mjs} +1 -1
- package/dist/server/chunks/{new_eGf9XMkI.mjs → new_BcxVJDeD.mjs} +1 -1
- package/dist/server/chunks/{settings_DrOhdnUA.mjs → settings_DC_qFSmv.mjs} +1 -1
- package/dist/server/entry.mjs +5 -5
- package/package.json +2 -1
- package/src/server/host.ts +4 -0
- package/src/server/uploads.ts +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_astro/xterm.B-l5AIf6.js","_astro/client.CLSsMr2g.js","_astro/addon-fit.jgKqzwky.js","_astro/addon-web-links.C9lyQRxI.js","_astro/addon-webgl.Bd5ox92E.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{a as e,i as t,n,r,t as i}from"./client.CLSsMr2g.js";import{t as a}from"./client.Bbg9OBwT.js";var o=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),s=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),c={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},l=e(r()),u=(0,l.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...u},d)=>(0,l.createElement)(`svg`,{ref:d,...c,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:s(`lucide`,i),...u},[...o.map(([e,t])=>(0,l.createElement)(e,t)),...Array.isArray(a)?a:[a]])),d=(e,t)=>{let n=(0,l.forwardRef)(({className:n,...r},i)=>(0,l.createElement)(u,{ref:i,iconNode:t,className:s(`lucide-${o(e)}`,n),...r}));return n.displayName=`${e}`,n},f=d(`ArchiveRestore`,[[`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`}]]),p=d(`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`}]]),m=d(`ArrowDown`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),h=d(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),g=d(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),_=d(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),v=d(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),y=d(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),b=d(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),x=d(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),S=d(`CircleAlert`,[[`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`}]]),C=d(`CircleArrowUp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),w=d(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),T=d(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),E=d(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),D=d(`Command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),O=d(`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`}]]),k=d(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),A=d(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),j=d(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),M=d(`FolderTree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),N=d(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]);d(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]);var P=d(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),F=d(`ImagePlus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),I=d(`ImageUp`,[[`path`,{d:`M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21`,key:`9csbqa`}],[`path`,{d:`m14 19.5 3-3 3 3`,key:`9vmjn0`}],[`path`,{d:`M17 22v-5.5`,key:`1aa6fl`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),L=d(`LayoutList`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}],[`path`,{d:`M14 4h7`,key:`3xa0d5`}],[`path`,{d:`M14 9h7`,key:`1icrd9`}],[`path`,{d:`M14 15h7`,key:`1mj8o2`}],[`path`,{d:`M14 20h7`,key:`11slyb`}]]),R=d(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),z=d(`MessageCircleQuestion`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),B=d(`Mic`,[[`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`,key:`131961`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),V=d(`Monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),ee=d(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),te=d(`PanelLeftClose`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),ne=d(`PanelLeftOpen`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),H=d(`PanelLeft`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),U=d(`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`}]]),re=d(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ie=d(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),ae=d(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),oe=d(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),se=d(`SquarePen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),ce=d(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),le=d(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ue=d(`Sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),de=d(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),fe=d(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),pe=d(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),W=typeof document<`u`?l.useLayoutEffect:()=>{};function me(){return typeof window<`u`}function he(e){return _e(e)?(e.nodeName||``).toLowerCase():`#document`}function G(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ge(e){return((_e(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function _e(e){return me()?e instanceof Node||e instanceof G(e).Node:!1}function K(e){return me()?e instanceof Element||e instanceof G(e).Element:!1}function ve(e){return me()?e instanceof HTMLElement||e instanceof G(e).HTMLElement:!1}function ye(e){return!me()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof G(e).ShadowRoot}function be(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=je(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function xe(e){return/^(table|td|th)$/.test(he(e))}function Se(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ce=/transform|translate|scale|rotate|perspective|filter/,we=/paint|layout|strict|content/,Te=e=>!!e&&e!==`none`,Ee;function De(e){let t=K(e)?je(e):e;return Te(t.transform)||Te(t.translate)||Te(t.scale)||Te(t.rotate)||Te(t.perspective)||!ke()&&(Te(t.backdropFilter)||Te(t.filter))||Ce.test(t.willChange||``)||we.test(t.contain||``)}function Oe(e){let t=Ne(e);for(;ve(t)&&!Ae(t);){if(De(t))return t;if(Se(t))return null;t=Ne(t)}return null}function ke(){return Ee??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Ee}function Ae(e){return/^(html|body|#document)$/.test(he(e))}function je(e){return G(e).getComputedStyle(e)}function Me(e){return K(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ne(e){if(he(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ye(e)&&e.host||ge(e);return ye(t)?t.host:t}function Pe(e){let t=Ne(e);return Ae(t)?(e.ownerDocument||e).body:ve(t)&&be(t)?t:Pe(t)}function Fe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Pe(e),i=r===e.ownerDocument?.body,a=G(r);if(i){let e=Ie(a);return t.concat(a,a.visualViewport||[],be(r)?r:[],e&&n?Fe(e):[])}return t.concat(r,Fe(r,[],n))}function Ie(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function q(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Le(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:Re,platform:ze,maxTouchPoints:Be}=Le(),Ve=Re.toLowerCase(),He=ze.toLowerCase(),Ue=/^i(os$|p)/.test(He)||He===`macintel`&&Be>1,We=`android`,Ge=He===We||Ve.includes(We),Ke=!Ue&&He.startsWith(`mac`);He.startsWith(`win`),!Ge&&/^(linux|chrome os)/.test(He);var qe=Ke||Ue,Je=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`),Ye=!Je&&Ve.includes(`firefox`);!Je&&Ve.includes(`chrom`);var Xe=qe,Ze=/jsdom|happydom/.test(Ve);function J(e){return e?.ownerDocument||document}var Qe={};function $e(e,t){let n=l.useRef(Qe);return n.current===Qe&&(n.current=e(t)),n}function et(){}var tt=Object.freeze([]),nt=Object.freeze({});function rt(e){l.useEffect(e,tt)}var it=0,at=class e{static create(){return new e}currentId=it;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=it,t()},e)}isStarted(){return this.currentId!==it}clear=()=>{this.currentId!==it&&(clearTimeout(this.currentId),this.currentId=it)};disposeEffect=()=>this.clear};function ot(){let e=$e(at.create).current;return rt(e.disposeEffect),e}var st=null;globalThis.requestAnimationFrame;var ct=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},lt=class e{static create(){return new e}static request(e){return ct.request(e)}static cancel(e){return ct.cancel(e)}currentId=st;request(e){this.cancel(),this.currentId=ct.request(()=>{this.currentId=st,e()})}cancel=()=>{this.currentId!==st&&(ct.cancel(this.currentId),this.currentId=st)};disposeEffect=()=>this.cancel};function ut(){let e=$e(lt.create).current;return rt(e.disposeEffect),e}var dt={},Y={},ft=``;function pt(e,t){return be(e)?e:t}function mt(e,t,n){return/hidden|clip/.test(e.getComputedStyle(pt(t,n)).overflowY)}function ht(e){if(typeof document>`u`)return!1;let t=J(e);return G(t).innerWidth-t.documentElement.clientWidth>0}function gt(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=J(e),n=t.documentElement,r=t.body,i=pt(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function _t(e){let t=J(e),n=t.documentElement,r=t.body,i=pt(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function vt(e){let t=J(e),n=t.documentElement,r=t.body,i=G(n),a=0,o=0,s=!1,c=lt.create();if(Je&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,dt={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},ft=n.style.scrollBehavior,Y={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=pt(n,r);if(s=gt(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,dt),Object.assign(r.style,Y),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=ft)}function d(){u(),c.request(l)}l();let f=q(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var yt=new class{lockCount=0;restore=null;timeoutLock=at.create();timeoutUnlock=at.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=J(e),n=t.documentElement,r=t.body,i=G(n);if(mt(i,n,r)){let t=new i.MutationObserver(()=>{mt(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Ue||!ht(e);this.restore=a?_t(e):vt(e)}};function bt(e=!0,t=null){W(()=>{if(e)return yt.acquire(t)},[e,t])}function xt(e){e.preventDefault(),e.stopPropagation()}function St(e){return`nativeEvent`in e}function Ct(e){return e.pointerType===``&&e.isTrusted?!0:Ge&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function wt(e){return Ze?!1:!Ge&&e.width===0&&e.height===0||Ge&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function Tt(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function Et(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function Dt(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function X(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&ye(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Ot(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var kt=`data-base-ui-focusable`,At=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,jt=`ArrowLeft`,Mt=`ArrowRight`,Nt=`ArrowUp`,Pt=`ArrowDown`,Ft=`data-starting-style`,It=`data-ending-style`,Lt={[Ft]:``},Rt={[It]:``},zt={transitionStatus(e){return e===`starting`?Lt:e===`ending`?Rt:null}},Bt=`data-open`,Vt=`data-closed`,Ht=`data-anchor-hidden`,Ut=`data-popup-open`,Wt=`data-pressed`,Gt={[Ut]:``},Kt={[Ut]:``,[Wt]:``},qt={[Bt]:``},Jt={[Vt]:``},Yt={[Ht]:``},Xt={open(e){return e?Gt:null}},Zt={open(e){return e?Kt:null}},Qt={open(e){return e?qt:Jt},anchorHidden(e){return e?Yt:null}},$t={...Qt,...zt},en=`data-trigger-disabled`;function tn(e,t){if(!K(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(en);for(let[,e]of t.entries())if(X(e,n))return!e.hasAttribute(en);return!1}function nn(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function rn(e){return e.matches(`html,body`)}function an(e){return ve(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function on(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${At}`)!=null}function sn(e){return e?e.getAttribute(`role`)===`combobox`&&an(e):!1}function cn(e){if(!e||Ze)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function ln(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function un(e,t){return t!=null&&!Tt(t)?0:typeof e==`function`?e():e}function dn(e,t,n){let r=un(e,n);return typeof r==`number`?r:r?.[t]}function fn(e){return typeof e==`function`?e():e}function pn(e,t){return t||e===`click`||e===`mousedown`}function mn(e){return e?.includes(`mouse`)&&e!==`mousedown`}var hn=`none`,gn=`trigger-press`,_n=`trigger-hover`,vn=`trigger-focus`,yn=`outside-press`,bn=`item-press`,xn=`close-press`,Sn=`input-change`,Cn=`input-clear`,wn=`input-press`,Tn=`focus-out`,En=`escape-key`,Dn=`list-navigation`,On=`keyboard`,kn=`pointer`,An=`cancel-open`,jn=`sibling-open`,Mn=`disabled`,Nn=`imperative-action`;function Z(e,t,n,r){let i=!1,a=!1,o=r??nt;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function Pn(e,t,n){let r=n??nt;return{reason:e,event:t??new Event(`base-ui`),...r}}var Fn=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Q=t(((e,t)=>{t.exports=Fn()}))(),In=l.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new at,currentIdRef:{current:null},currentContextRef:{current:null}});function Ln(e,t){e.current=t.current}function Rn(e,t={open:!1}){let{open:n}=t,r=`rootStore`in e?e.rootStore:e,i=r.useState(`floatingId`),{currentIdRef:a,delayRef:o,timeoutMs:s,initialDelayRef:c,currentContextRef:u,hasProvider:d,timeout:f}=l.useContext(In),[p,m]=l.useState(!1),h=l.useRef(n);return W(()=>{h.current=n},[n]),W(()=>{function e(){u.current?.setIsInstantPhase(!1),a.current=null,u.current=null,o.current=c.current,f.clear()}if(a.current&&!n&&a.current===i){if(m(!1),s){let t=i;return f.start(s,()=>{r.select(`open`)||a.current&&a.current!==t||e()}),()=>{(h.current||a.current!==t)&&f.clear()}}e()}},[n,i,a,o,s,c,u,f,r]),W(()=>{if(!n)return;let e=u.current,t=a.current;f.clear(),u.current={onOpenChange:r.setOpen,setIsInstantPhase:m},a.current=i,o.current={open:0,close:dn(c.current,`close`)},t!==null&&t!==i?(m(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,Z(hn))):(m(!1),e?.setIsInstantPhase(!1))},[n,i,r,a,o,c,u,f]),W(()=>()=>{if(a.current===i){if(u.current=null,!h.current)return;a.current=null,Ln(o,c),f.clear()}},[u,a,o,i,c,f]),l.useMemo(()=>({activeIdRef:a,hasProvider:d,delayRef:o,isInstantPhase:p}),[a,d,o,p])}function zn(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function Bn(e,t,n,r){let i=$e(Hn).current;return Un(i,e,t,n,r)&&Gn(i,[e,t,n,r]),i.callback}function Vn(e){let t=$e(Hn).current;return Wn(t,e)&&Gn(t,e),t.callback}function Hn(){return{callback:null,cleanup:null,refs:[]}}function Un(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Wn(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Gn(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}function Kn(e){let t=$e(qn,e).current;return t.next=e,W(t.effect),t}function qn(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Jn={...l},Yn=Jn.useInsertionEffect,Xn=Yn&&Yn!==Jn.useLayoutEffect?Yn:e=>e();function $(e){let t=$e(Zn).current;return t.next=e,Xn(t.effect),t.trampoline}function Zn(){let e={next:void 0,callback:Qn,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Qn(){}var $n={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},er={...$n,position:`fixed`,top:0,left:0},tr={...$n,position:`absolute`},nr=l.forwardRef(function(e,t){let[n,r]=l.useState();W(()=>{Xe&&Je&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,Q.jsx)(`span`,{...e,ref:t,style:er,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),rr=Math.min,ir=Math.max,ar=Math.round,or=Math.floor,sr=e=>({x:e,y:e}),cr={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function lr(e,t,n){return ir(e,rr(t,n))}function ur(e,t){return typeof e==`function`?e(t):e}function dr(e){return e.split(`-`)[0]}function fr(e){return e.split(`-`)[1]}function pr(e){return e===`x`?`y`:`x`}function mr(e){return e===`y`?`height`:`width`}function hr(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function gr(e){return pr(hr(e))}function _r(e,t,n){n===void 0&&(n=!1);let r=fr(e),i=gr(e),a=mr(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Er(o)),[o,Er(o)]}function vr(e){let t=Er(e);return[yr(e),t,yr(t)]}function yr(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var br=[`left`,`right`],xr=[`right`,`left`],Sr=[`top`,`bottom`],Cr=[`bottom`,`top`];function wr(e,t,n){switch(e){case`top`:case`bottom`:return n?t?xr:br:t?br:xr;case`left`:case`right`:return t?Sr:Cr;default:return[]}}function Tr(e,t,n,r){let i=fr(e),a=wr(dr(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(yr)))),a}function Er(e){let t=dr(e);return cr[t]+e.slice(t.length)}function Dr(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Or(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Dr(e)}function kr(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 Ar(e,t,n){return Math.floor(e/t)!==n}function jr(e,t){return t<0||t>=e.length}function Mr(e,t){return Pr(e.current,{disabledIndices:t})}function Nr(e,t){return Pr(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Pr(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&Ir(e,a,r));return a}function Fr(e,{event:t,orientation:n,loopFocus:r,onLoop:i,rtl:a,cols:o,disabledIndices:s,minIndex:c,maxIndex:l,prevIndex:u,stopEvent:d=!1}){let f=u,p;if(t.key===`ArrowUp`?p=`up`:t.key===`ArrowDown`&&(p=`down`),p){let n=[],a=[],m=!1,h=0;{let t=null,r=-1;e.forEach((e,i)=>{if(e==null)return;h+=1;let o=e.closest(`[role="row"]`);o&&(m=!0),(o!==t||r===-1)&&(t=o,r+=1,n[r]=[]),n[r].push(i),a[i]=r})}let g=!1,_=0;if(m)for(let e of n){let t=e.length;t>_&&(_=t),t!==o&&(g=!0)}let v=g&&h<e.length,y=_||o,b=o=>{if(!g||u===-1)return;let c=a[u];if(c==null)return;let l=n[c].indexOf(u),d=o===`up`?-1:1;for(let o=c+d,f=0;f<n.length;f+=1,o+=d){if(o<0||o>=n.length){if(!r||v)return;if(o=o<0?n.length-1:0,i){let e=Math.min(l,n[o].length-1),r=i(t,u,n[o][e]??n[o][0]);o=a[r]??o}}let c=n[o];for(let t=Math.min(l,c.length-1);t>=0;--t){let n=c[t];if(!Ir(e,n,s))return n}}},x=t=>{if(!v||u===-1)return;let n=u%y,i=t===`up`?-y:y,a=l-l%y,o=or(l/y)+1;for(let t=u-n+i,c=0;c<o;c+=1,t+=i){if(t<0||t>l){if(!r)return;t=t<0?a:0}let i=Math.min(t+y-1,l);for(let r=Math.min(t+n,i);r>=t;--r)if(!Ir(e,r,s))return r}};d&&xt(t);let S=b(p)??x(p);if(S!==void 0)f=S;else if(u===-1)f=p===`up`?l:c;else if(f=Pr(e,{startingIndex:u,amount:y,decrement:p===`up`,disabledIndices:s}),r){if(p===`up`&&(u-y<c||f<0)){let e=u%y,n=l%y,r=l-(n-e);f=n===e?l:n>e?r:r-y,i&&(f=i(t,u,f))}p===`down`&&u+y>l&&(f=Pr(e,{startingIndex:u%y-y,amount:y,disabledIndices:s}),i&&(f=i(t,u,f)))}jr(e,f)&&(f=u)}if(n===`both`){let n=or(u/o);t.key===(a?`ArrowLeft`:`ArrowRight`)&&(d&&xt(t),u%o===o-1?r&&(f=Pr(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):(f=Pr(e,{startingIndex:u,disabledIndices:s}),r&&Ar(f,o,n)&&(f=Pr(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f)))),Ar(f,o,n)&&(f=u)),t.key===(a?`ArrowRight`:`ArrowLeft`)&&(d&&xt(t),u%o===0?r&&(f=Pr(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f))):(f=Pr(e,{startingIndex:u,decrement:!0,disabledIndices:s}),r&&Ar(f,o,n)&&(f=Pr(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f)))),Ar(f,o,n)&&(f=u));let c=or(l/o)===n;jr(e,f)&&(r&&c?(f=t.key===(a?`ArrowRight`:`ArrowLeft`)?l:Pr(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):f=u)}return f}function Ir(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!Rr(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function Lr(e){return e.visibility===`hidden`||e.visibility===`collapse`}function Rr(e,t=e?je(e):null){return!e||!e.isConnected||!t||Lr(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var zr=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function Br(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return ye(n)?n.host:null}function Vr(e){for(let t of Array.from(e.children))if(he(t)===`summary`)return t;return null}function Hr(e,t){let n=Vr(t);return!!n&&(e===n||X(n,e))}function Ur(e){let t=e?he(e):``;return e!=null&&e.matches(zr)&&(t!==`summary`||e.parentElement!=null&&he(e.parentElement)===`details`&&Vr(e.parentElement)===e)&&(t!==`details`||Vr(e)==null)&&(t!==`input`||e.type!==`hidden`)}function Wr(e){if(!Ur(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=Br(t)){let n=t!==e,r=he(t)===`slot`;if(t.hasAttribute(`inert`)||n&&he(t)===`details`&&!t.open&&!Hr(e,t)||t.hasAttribute(`hidden`)||!r&&!Gr(t,n))return!1}return!0}function Gr(e,t){let n=je(e);return t?n.display!==`none`:Rr(e,n)}function Kr(e){let t=e.tabIndex;if(t<0){let t=he(e);if(t===`details`||t===`audio`||t===`video`||ve(e)&&e.isContentEditable)return 0}return t}function qr(e){if(he(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function Jr(e,t){let n=qr(e);if(!n)return!0;let r=t.find(e=>{let t=qr(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=qr(e);return t?.name===n.name&&t.form===n.form})===n}function Yr(e){if(ve(e)&&he(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return ve(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Xr(e,t){Yr(e).forEach(e=>{Ur(e)&&t.push(e),Xr(e,t)})}function Zr(e,t,n){Yr(e).forEach(e=>{ve(e)&&e.matches(t)&&n.push(e),Zr(e,t,n)})}function Qr(e){return Wr(e)&&Kr(e)>=0}function $r(e){let t=[];return Xr(e,t),t.filter(Wr)}function ei(e){let t=$r(e);return t.filter(e=>Kr(e)>=0&&Jr(e,t))}function ti(e,t){let n=ei(e),r=n.length;if(r===0)return;let i=Dt(J(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function ni(e){return ti(J(e).body,1)||e}function ri(e){return ti(J(e).body,-1)||e}function ii(e,t){if(!e)return null;let n=ei(J(e).body),r=n.length;if(r===0)return null;let i=n.indexOf(e);return i===-1?null:n[(i+t+r)%r]}function ai(e){return ii(e,1)}function oi(e){return ii(e,-1)}function si(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!X(n,r)}function ci(e){ei(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function li(e){let t=[];Zr(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function ui(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...ui(e,t.id,n)])}function di(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function fi(e){return`data-base-ui-${e}`}var pi=0;function mi(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(pi);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),et;let o=requestAnimationFrame(a);return pi=o,()=>{pi===o&&(cancelAnimationFrame(o),pi=0)}}var hi={inert:new WeakMap,"aria-hidden":new WeakMap},gi=`data-base-ui-inert`,_i={inert:new WeakSet,"aria-hidden":new WeakSet},vi=new WeakMap,yi=0;function bi(e){return _i[e]}function xi(e){return e?ye(e)?e.host:xi(e.parentNode):null}var Si=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=xi(t);return e.contains(n)?n:null}).filter(e=>e!=null),Ci=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},wi=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{he(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function Ti(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=Si(t,e),l=i?wi(t,Ci(c),new Set(c)):[],u=[],d=[];if(a){let e=hi[a],n=bi(a);s=n,o=e;let r=Si(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);wi(t,Ci(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(vi.get(e)||0)+1;vi.set(e,t),d.push(e),t===1&&e.setAttribute(gi,``)}),yi+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(vi.get(e)||0)-1;vi.set(e,t),t||e.removeAttribute(gi)}),--yi,yi||(hi.inert=new WeakMap,hi[`aria-hidden`]=new WeakMap,_i.inert=new WeakSet,_i[`aria-hidden`]=new WeakSet,vi=new WeakMap)}}function Ei(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=J(e[0]).body;return Ti(e,a,n,r,{mark:i})}var Di=0;function Oi(e,t=`mui`){let[n,r]=l.useState(e),i=e||n;return l.useEffect(()=>{n??(Di+=1,r(`${t}-${Di}`))},[n,t]),i}var ki=Jn.useId;function Ai(e,t){if(ki!==void 0){let n=ki();return e??(t?`${t}-${n}`:n)}return Oi(e,t)}function ji(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var Mi=ji(`https://base-ui.com/production-error`,`Base UI`),Ni=19;function Pi(e){return Ni>=e}function Fi(e){if(!l.isValidElement(e))return null;let t=e,n=t.props;return(Pi(19)?n?.ref:t.ref)??null}function Ii(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function Li(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Ri(e,t){return typeof e==`function`?e(t):e}function zi(e,t){return typeof e==`function`?e(t):e}var Bi={};function Vi(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Ui(t);let a=Ui(e);return t&&(a=Wi(a,t)),n&&(a=Wi(a,n)),r&&(a=Wi(a,r)),i&&(a=Wi(a,i)),a}function Hi(e){if(e.length===0)return Bi;if(e.length===1)return Ui(e[0]);let t=Ui(e[0]);for(let n=1;n<e.length;n+=1)t=Wi(t,e[n]);return t}function Ui(e){return Ji(e)?{...Yi(e,Bi)}:Gi(e)}function Wi(e,t){return Ji(t)?Yi(t,e):Ki(e,t)}function Gi(e){let t={...e};for(let e in t){let n=t[e];qi(e,n)&&(t[e]=Zi(n))}return t}function Ki(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Ii(e.style,r);break;case`className`:e[n]=$i(e.className,r);break;default:e[n]=qi(n,r)?Xi(e[n],r):r}}return e}function qi(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Ji(e){return typeof e==`function`}function Yi(e,t){return Ji(e)?e(t):e??Bi}function Xi(e,t){return t?e?(...n)=>{let r=n[0];if(ea(r)){let i=r;Qi(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:Zi(t):e}function Zi(e){return e&&((...t)=>{let n=t[0];return ea(n)&&Qi(n),e(...t)})}function Qi(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function $i(e,t){return t?e?t+` `+e:t:e}function ea(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function ta(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=aa(r));let i=na(t,n,r);if(n.enabled===!1)return null;let a=n.state??nt;return oa(e,r,i,a)}function na(e,t,n){let{className:r,style:i}=e,{state:a=nt,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Ri(r,a):void 0,d=l?zi(i,a):void 0,f=l?Li(a,c):nt,p=l&&s?ra(s):void 0,m=l?Ii(f,p)??{}:nt;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?Vn([m.ref,Fi(n),...o]):Bn(m.ref,Fi(n),o):Bn(null,null)),l?(u!==void 0&&(m.className=$i(m.className,u)),d!==void 0&&(m.style=Ii(m.style,d)),m):nt}function ra(e){return Array.isArray(e)?Hi(e):Vi(void 0,e)}var ia=Symbol.for(`react.lazy`);function aa(e){if(e?.$$typeof!==ia)return e;let t=l.Children.toArray(e)[0];return l.isValidElement(t)?t:e}function oa(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Vi(n,t.props);return e.ref=n.ref,l.cloneElement(t,e)}if(e&&typeof e==`string`)return sa(e,n);throw Error(Mi(8))}function sa(e,t){return e===`button`?(0,l.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,l.createElement)(`img`,{alt:``,...t,key:t.key}):l.createElement(e,t)}var ca={style:{transition:`none`}},la={fallbackAxisSide:`none`},ua={fallbackAxisSide:`end`},da={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},fa=e(n(),1),pa=l.createContext(null),ma=()=>l.useContext(pa),ha=fi(`portal`);function ga(e={}){let{ref:t,container:n,componentProps:r=nt,elementProps:i}=e,a=Ai(),o=ma()?.portalNode,[s,c]=l.useState(null),[u,d]=l.useState(null),f=$(e=>{e!==null&&d(e)}),p=l.useRef(null);W(()=>{if(n===null){p.current&&(p.current=null,d(null),c(null));return}let e=(n&&(_e(n)?n:n.current))??o??document.body;if(e==null){p.current&&(p.current=null,d(null),c(null));return}p.current!==e&&(p.current=e,d(null),c(e))},[n,o]);let m=ta(`div`,r,{ref:[t,f],props:[{id:a,[ha]:``},i]}),h=s&&m?fa.createPortal(m,s):null;return{node:u,nodeId:l.isValidElement(m)?m.props.id:void 0,subtree:h}}var _a=l.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:u,nodeId:d,subtree:f}=ga({container:o,ref:t,componentProps:e,elementProps:c}),p=l.useRef(null),m=l.useRef(null),h=l.useRef(null),g=l.useRef(null),[_,v]=l.useState(null),y=l.useRef(!1),b=_?.modal,x=_?.open,S=!!_&&!_.modal&&_.open&&!!u;l.useEffect(()=>{if(!u||b)return;function e(e){u&&e.relatedTarget&&si(e)&&(e.type===`focusin`?y.current&&=(li(u),!1):(ci(u),y.current=!0))}return zn(q(u,`focusin`,e,!0),q(u,`focusout`,e,!0))},[u,b]),W(()=>{u&&x===!0&&y.current&&(li(u),y.current=!1)},[x,u]);let C=l.useMemo(()=>({beforeOutsideRef:p,afterOutsideRef:m,beforeInsideRef:h,afterInsideRef:g,portalNode:u,setFocusManagerState:v}),[u]);return(0,Q.jsxs)(l.Fragment,{children:[f,(0,Q.jsxs)(pa.Provider,{value:C,children:[S&&u&&(0,Q.jsx)(nr,{"data-type":`outside`,ref:p,onFocus:e=>{si(e,u)?h.current?.focus():ri(_?_.domReference:null)?.focus()}}),S&&u&&(0,Q.jsx)(`span`,{role:s,"aria-owns":d,style:da}),u&&fa.createPortal(a,u),S&&u&&(0,Q.jsx)(nr,{"data-type":`outside`,ref:m,onFocus:e=>{si(e,u)?g.current?.focus():(ni(_?_.domReference:null)?.focus(),_?.closeOnFocusOut&&_?.onOpenChange(!1,Z(`focus-out`,e.nativeEvent)))}})]})]})});function va(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var ya=class{nodesRef={current:[]};events=va();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},ba=l.createContext(null),xa=l.createContext(null),Sa=()=>l.useContext(ba)?.id||null,Ca=e=>{let t=l.useContext(xa);return e??t};function wa(e){let t=Ai(),n=Ca(e),r=Sa();return W(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function Ta(e){let{children:t,id:n}=e,r=Sa();return(0,Q.jsx)(ba.Provider,{value:l.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Ea(e){let{children:t,externalTree:n}=e,r=$e(()=>n??new ya).current;return(0,Q.jsx)(xa.Provider,{value:r,children:t})}function Da(e){return e==null?e:`current`in e?e.current:e}function Oa(e,t){let n=G(Ot(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var ka=20,Aa=[];function ja(){Aa=Aa.filter(e=>e.deref()?.isConnected)}function Ma(e){ja(),e&&he(e)!==`body`&&(Aa.push(new WeakRef(e)),Aa.length>ka&&(Aa=Aa.slice(-20)))}function Na(){return ja(),Aa[Aa.length-1]?.deref()}function Pa(e){return e?Qr(e)?e:ei(e)[0]||e:null}function Fa(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=$r(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Qr(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function Ia(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=`rootStore`in t?t.rootStore:t,_=g.useState(`open`),v=g.useState(`domReferenceElement`),y=g.useState(`floatingElement`),{events:b,dataRef:x}=g.context,S=$(()=>x.current.floatingContext?.nodeId),C=i===!1,w=sn(v)&&C,T=Kn(i),E=Kn(a),D=Kn(u),O=Kn(_),k=Ca(m),A=ma(),j=l.useRef(!1),M=l.useRef(!1),N=l.useRef(!1),P=l.useRef(null),F=l.useRef(``),I=l.useRef(``),L=l.useRef(null),R=l.useRef(null),z=Bn(L,p,A?.beforeInsideRef),B=Bn(R,A?.afterInsideRef),V=ot(),ee=ot(),te=ut(),ne=A!=null,H=ln(y),U=$((e=H)=>e?ei(e):[]),re=$(()=>h?.().filter(e=>e!=null)??[]);l.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&X(H,Dt(J(H)))&&U().length===0&&!w&&xt(e)}return q(J(H),`keydown`,e)},[r,H,s,w,U]),l.useEffect(()=>{if(r||!_)return;let e=J(H);function t(){N.current=!1}function n(e){let t=Ot(e),n=re(),r=X(y,t)||X(v,t)||X(A?.portalNode,t)||n.some(e=>e===t||X(e,t));N.current=!r,I.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(M.current=!0,ee.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return zn(q(e,`pointerdown`,n,!0),q(e,`pointerup`,t,!0),q(e,`pointercancel`,t,!0),q(e,`keydown`,i,!0),t)},[r,y,v,H,_,A,ee,re]),l.useEffect(()=>{if(r||!c)return;let e=J(H);function t(){M.current=!0,ee.start(0,()=>{M.current=!1})}function n(e){let t=Ot(e);Qr(t)&&(P.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=Ot(t);s&&n==null&&i!=null&&X(y,i)&&Ma(i),queueMicrotask(()=>{let a=S(),c=g.context.triggerElements,l=re(),u=n?.hasAttribute(fi(`focus-guard`))&&[L.current,R.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,Da(f),Da(d)].includes(n),p=!(X(v,n)||X(y,n)||X(n,y)||X(A?.portalNode,n)||l.some(e=>e===n||X(e,n))||c.hasMatchingElement(e=>X(e,n))||u||k&&(ui(k.nodesRef.current,a).find(e=>X(e.context?.elements.floating,n)||X(e.context?.elements.domReference,n))||di(k.nodesRef.current,a).find(e=>[e.context?.elements.floating,ln(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===v&&H&&Fa(H),o&&r!==v&&!Rr(i)&&Dt(e)===e.body){if(ve(H)&&(H.focus(),o===`popup`)){te.request(()=>{H.focus()});return}let e=U(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||H;ve(n)&&n.focus()}if(x.current.insideReactTree){x.current.insideReactTree=!1;return}(w||!s)&&n&&p&&!M.current&&(w||n!==Na())&&(j.current=!0,g.setOpen(!1,Z(Tn,t)))})}function a(){N.current||(x.current.insideReactTree=!0,V.start(0,()=>{x.current.insideReactTree=!1}))}let l=ve(v)?v:null;if(y||l)return zn(l&&q(l,`focusout`,i),l&&q(l,`pointerdown`,t),y&&q(y,`focusin`,n),y&&q(y,`focusout`,i),y&&A&&q(y,`focusout`,a,!0))},[r,v,y,H,s,k,A,g,c,o,U,w,S,x,V,ee,te,d,f,re]),l.useEffect(()=>{if(r||!y||!_)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${fi(`portal`)}]`)||[]),t=(k?di(k.nodesRef.current,S()):[]).find(e=>sn(e.context?.elements.domReference||null))?.context?.elements.domReference,n=Ei([y,...e,L.current,R.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...re(),t,Da(f),Da(d),w?v:null].filter(e=>e!=null),{ariaHidden:s||w,mark:!1}),i=Ei([y,...e].filter(e=>e!=null));return()=>{i(),n()}},[_,r,v,y,s,A,w,k,S,d,f,re]),W(()=>{if(!_||r||!ve(H))return;F.current=``,I.current=``;let e=J(H),t=Dt(e);queueMicrotask(()=>{let n=T.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||X(H,t))return;let i=null,a=()=>(i??=U(H),i[0]||H),o;o=r===!0||r===null?a():Da(r),o||=a();let s=X(H,Dt(e));mi(o,{preventScroll:o===H,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=Dt(e);return!(t!==o&&X(H,t))}})})},[r,_,H,U,T,D,O]),W(()=>{if(r||!H)return;let e=J(H),t=Dt(e),n=D.current==null;Ma(t);function i(e){if(e.open||(F.current=Oa(e.nativeEvent,I.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(Ct(e.nativeEvent)||wt(e.nativeEvent))j.current=!1;else{let e=!1;J(H).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}b.on(`openchange`,i);function a(e){let r=E.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=v?.isConnected?v:null,o=t?.isConnected&&he(t)!==`body`?t:null,s=n?o||a:a||o;return s||=Na()||null,typeof i==`boolean`?s:Da(i)||s||null}return()=>{b.off(`openchange`,i);let t=Dt(e),n=re(),r=X(y,t)||n.some(e=>e===t||X(e,t))||k&&ui(k.nodesRef.current,S(),!1).some(e=>X(e.context?.elements.floating,t)),o=E.current,s=F.current,c=a(s);queueMicrotask(()=>{let n=Pa(c),i=typeof o!=`boolean`;if(o&&!j.current&&ve(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,y,H,E,D,b,k,v,S,re]),W(()=>{if(!Je||_||!y)return;let e=Dt(J(y));ve(e)&&an(e)&&X(y,e)&&e.blur()},[_,y]),W(()=>{if(!r&&A)return A.setFocusManagerState({modal:s,closeOnFocusOut:c,open:_,onOpenChange:g.setOpen,domReference:v}),()=>{A.setFocusManagerState(null)}},[r,A,s,_,g,c,v]),W(()=>{if(!r&&H)return Fa(H),()=>{queueMicrotask(ja)}},[r,H]);let ie=!r&&(!s||!w)&&(ne||s);return(0,Q.jsxs)(l.Fragment,{children:[ie&&(0,Q.jsx)(nr,{"data-type":`inside`,ref:z,onFocus:e=>{if(s){let e=U();mi(e[e.length-1])}else A?.portalNode&&(j.current=!1,si(e,A.portalNode)?ni(v)?.focus():Da(f??A.beforeOutsideRef)?.focus())}}),n,ie&&(0,Q.jsx)(nr,{"data-type":`inside`,ref:B,onFocus:e=>{s?mi(U()[0]):A?.portalNode&&(c&&(j.current=!0),si(e,A.portalNode)?ri(v)?.focus():Da(d??A.afterOutsideRef)?.focus())}})]})}function La(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=gn}=t,u=`rootStore`in e?e.rootStore:e,d=u.context.dataRef,f=l.useRef(void 0),p=ut(),m=ot(),h=l.useMemo(()=>{function e(e,t,n,r){let i=Z(c,t,n);e&&r===`touch`&&s>0?m.start(s,()=>{u.setOpen(!0,i)}):u.setOpen(e,i)}function t(e,t,n){let r=d.current.openEvent,a=u.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){f.current=Tt(e.pointerType,!0)&&wt(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=f.current,o=n.nativeEvent,s=u.select(`open`);if(n.button!==0||r===`click`||Tt(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),l=Ot(o);if(an(l)){e(c,o,l,i);return}let d=n.currentTarget;p.request(()=>{e(c,o,d,i)})},onClick(n){if(r===`mousedown-only`)return;let i=f.current;if(r===`mousedown`&&i){f.current=void 0;return}Tt(i,!0)&&a||e(t(u.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){f.current=void 0}}},[d,r,a,c,u,o,i,p,m,s]);return l.useMemo(()=>n?{reference:h}:nt,[n,h])}function Ra(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=a.width,u=a.height,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,l=0,u=0,!i||c?(l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f):i&&!c&&(u=t.axis===`x`?a.height:u,l=t.axis===`y`?a.width:l),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function za(e){return e!=null&&e.clientX!=null}function Ba(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=`rootStore`in e?e.rootStore:e,a=i.useState(`open`),o=i.useState(`floatingElement`),s=i.useState(`domReferenceElement`),c=i.context.dataRef,u=l.useRef(!1),d=l.useRef(null),[f,p]=l.useState(),[m,h]=l.useState([]),g=$(e=>{i.set(`positionReference`,e)}),_=$((e,t,n)=>{u.current||(!c.current.openEvent||za(c.current.openEvent))&&i.set(`positionReference`,Ra(n??s,{x:e,y:t,axis:r,dataRef:c,pointerType:f}))}),v=$(e=>{a?d.current||(_(e.clientX,e.clientY,e.currentTarget),h([])):_(e.clientX,e.clientY,e.currentTarget)}),y=Tt(f)?o:a;l.useEffect(()=>{if(!n){g(s);return}if(!y)return;function e(){d.current?.(),d.current=null}let t=G(o);function r(t){let n=Ot(t);X(o,n)?e():_(t.clientX,t.clientY)}return!c.current.openEvent||za(c.current.openEvent)?d.current=q(t,`mousemove`,r):g(s),e},[y,n,o,c,s,i,_,g,m]),l.useEffect(()=>()=>{i.set(`positionReference`,null)},[i]),l.useEffect(()=>{n&&!o&&(u.current=!1)},[n,o]),l.useEffect(()=>{!n&&a&&(u.current=!0)},[n,a]);let b=l.useMemo(()=>{function e(e){p(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:v,onMouseEnter:v}},[v]);return l.useMemo(()=>n?{reference:b,trigger:b}:{},[n,b])}function Va(){return!1}function Ha(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Ua(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Va,bubbles:s,externalTree:c}=t,u=`rootStore`in e?e.rootStore:e,d=u.useState(`open`),f=u.useState(`floatingElement`),{dataRef:p,events:m}=u.context,h=Ca(c),g=$(typeof i==`function`?i:()=>!1),_=typeof i==`function`?g:i,v=_!==!1,y=$(()=>a),{escapeKey:b,outsidePress:x}=Ha(s),S=l.useRef(!1),C=l.useRef(!1),w=l.useRef(!1),T=l.useRef(!1),E=l.useRef(!1),D=l.useRef(``),O=l.useRef(null),k=ot(),A=ot(),j=$(()=>{A.clear(),p.current.insideReactTree=!1}),M=$(e=>{let t=p.current.floatingContext?.nodeId;return(h?ui(h.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),N=$(e=>nn(e,u.select(`floatingElement`))||nn(e,u.select(`domReferenceElement`))),P=$(e=>{o()&&u.setOpen(!1,Z(gn,e.nativeEvent))}),F=$(e=>{if(!d||!n||!r||e.key!==`Escape`||E.current||!b&&M(`__escapeKeyBubbles`))return;let t=Z(En,St(e)?e.nativeEvent:e);u.setOpen(!1,t),t.isCanceled||e.preventDefault(),!b&&!t.isPropagationAllowed&&e.stopPropagation()}),I=$(()=>{p.current.insideReactTree=!0,A.start(0,j)}),L=$(e=>{if(!d||!n||e.button!==0)return;let t=Ot(e.nativeEvent);X(u.select(`floatingElement`),t)&&(S.current||(S.current=!0,C.current=!1))}),R=$(e=>{d&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&S.current&&(C.current=!0)});l.useEffect(()=>{function e(e){e.open||(T.current=!1)}return m.on(`openchange`,e),()=>{m.off(`openchange`,e)}},[m]),l.useEffect(()=>{if(!d||!n)return d||(T.current=!1),j;p.current.__escapeKeyBubbles=b,p.current.__outsidePressBubbles=x;let e=new at,t=new at,i=J(f);function a(){e.clear(),E.current=!0}function o(){e.start(Je?5:0,()=>{E.current=!1})}function s(){w.current=!0,t.start(0,()=>{w.current=!1})}function c(){S.current=!1,C.current=!1}function l(){let e=D.current,t=e===`pen`||!e?`mouse`:e,n=y(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=l();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function g(e){let t=p.current.floatingContext?.nodeId,n=h&&ui(h.nodesRef.current,t).some(t=>nn(e,t.context?.elements.floating));return N(e)||n}function A(e){if(m(e)){e.type!==`click`&&!N(e)&&(t.clear(),w.current=!1),j();return}if(p.current.insideReactTree){j();return}let n=Ot(e),r=`[${fi(`inert`)}]`,i=K(n)?n.getRootNode():null,a=Array.from((ye(i)?i:J(u.select(`floatingElement`))).querySelectorAll(r)),o=u.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>X(e,n))))return;let s=K(n)?n:null;for(;s&&!Ae(s);){let e=Ne(s);if(Ae(e)||!K(e))break;s=e}if(!(a.length&&K(n)&&!rn(n)&&!X(n,u.select(`floatingElement`))&&a.every(e=>!X(s,e)))){if(ve(n)&&!(`touches`in e)){let t=Ae(n),r=je(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!g(e)){if(l()===`intentional`){if(e.detail!==0&&!Ct(e)&&!T.current)return;if(w.current){t.clear(),w.current=!1;return}}(typeof _!=`function`||_(e))&&(M(`__outsidePressBubbles`)||(u.setOpen(!1,Z(yn,e)),j()))}}}function P(e){l()===`sloppy`&&e.pointerType!==`touch`&&u.select(`open`)&&n&&!N(e)&&A(e)}function I(e){if(l()!==`sloppy`||!u.select(`open`)||!n||N(e))return;let t=e.touches[0];t&&(O.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},k.start(1e3,()=>{O.current&&(O.current.dismissOnTouchEnd=!1,O.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=Ot(e);if(!n)return;let r=q(n,e.type,()=>{t(e),r()})}function R(e){D.current=`touch`,L(e,I)}function z(e){k.clear(),e.type===`pointerdown`&&(e.button===0&&(T.current=!0),D.current=e.pointerType),(e.type!==`mousedown`||!O.current||O.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?P(e):A(e)})}function B(e){if(e.type===`pointercancel`&&(T.current=!1),!S.current)return;let n=C.current;if(c(),l()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!g(e)){if(n){s();return}(typeof _!=`function`||_(e))&&(t.clear(),w.current=!0,j())}}}function V(e){if(l()!==`sloppy`||!O.current||N(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-O.current.startX),r=Math.abs(t.clientY-O.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(O.current.dismissOnTouchEnd=!0),i>10&&(A(e),k.clear(),O.current=null)}function ee(e){L(e,V)}function te(e){l()===`sloppy`&&O.current&&!N(e)&&(O.current.dismissOnTouchEnd&&A(e),k.clear(),O.current=null)}function ne(e){L(e,te)}let H=zn(r&&zn(q(i,`keydown`,F),q(i,`compositionstart`,a),q(i,`compositionend`,o)),v&&zn(q(i,`click`,z,!0),q(i,`pointerdown`,z,!0),q(i,`pointerup`,B,!0),q(i,`pointercancel`,B,!0),q(i,`mousedown`,z,!0),q(i,`mouseup`,B,!0),q(i,`touchstart`,R,{capture:!0,passive:!0}),q(i,`touchmove`,ee,{capture:!0,passive:!0}),q(i,`touchend`,ne,{capture:!0,passive:!0})));return()=>{H(),e.clear(),t.clear(),c(),w.current=!1,j()}},[p,f,r,v,_,d,n,b,x,F,j,y,M,N,h,u,k]);let z=l.useMemo(()=>({onKeyDown:F,onPointerDown:P,onClick:P}),[F,P]),B=l.useMemo(()=>({onKeyDown:F,onPointerDown:R,onMouseDown:R,onClickCapture:I,onMouseDownCapture(e){I(),L(e)},onPointerDownCapture(e){I(),L(e)},onMouseUpCapture:I,onTouchEndCapture:I,onTouchMoveCapture:I}),[F,I,L,R]);return l.useMemo(()=>n?{reference:z,floating:B,trigger:z}:{},[n,z,B])}function Wa(e,t,n){let{reference:r,floating:i}=e,a=hr(t),o=gr(t),s=mr(o),c=dr(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=fr(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Ga(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}=ur(t,e),p=Or(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=kr(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=kr(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 Ka=50,qa=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Ga},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Wa(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<Ka&&(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}=Wa(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Ja=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}=ur(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=dr(r),_=hr(o),v=dr(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Er(o)]:vr(o)),x=p!==`none`;!d&&x&&b.push(...Tr(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=_r(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`||_===hr(t)||T.every(e=>hr(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=hr(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{}}}},Ya=new Set([`left`,`top`]);async function Xa(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=dr(n),s=fr(n),c=hr(n)===`y`,l=Ya.has(o)?-1:1,u=a&&c?-1:1,d=ur(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 Za=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 Xa(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}}}}},Qa=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}=ur(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=hr(i),p=pr(f),m=u[p],h=u[f],g=(e,t)=>lr(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}}}}}},$a=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}=ur(e,t),u={x:n,y:r},d=hr(i),f=pr(d),p=u[f],m=u[d],h=ur(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=Ya.has(dr(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}}}},eo=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}=ur(e,t),c=await i.detectOverflow(t,s),l=dr(n),u=fr(n),d=hr(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=rr(p-c[m],g),y=rr(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*ir(c.left,c.right):S=p-2*ir(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 to(e){let t=je(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ve(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ar(n)!==a||ar(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function no(e){return K(e)?e:e.contextElement}function ro(e){let t=no(e);if(!ve(t))return sr(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=to(t),o=(a?ar(n.width):n.width)/r,s=(a?ar(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var io=sr(0);function ao(e){let t=G(e);return!ke()||!t.visualViewport?io:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function oo(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===G(e)}function so(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=no(e),o=sr(1);t&&(r?K(r)&&(o=ro(r)):o=ro(e));let s=oo(a,n,r)?ao(a):sr(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=G(a),t=K(r)?G(r):r,n=e,i=Ie(n);for(;i&&t!==n;){let e=ro(i),t=i.getBoundingClientRect(),r=je(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=G(i),i=Ie(n)}}return kr({width:u,height:d,x:c,y:l})}function co(e,t){let n=Me(e).scrollLeft;return t?t.left+n:so(ge(e)).left+n}function lo(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-co(e,n),y:n.top+t.scrollTop}}function uo(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=ge(r),s=t?Se(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=sr(1),u=sr(0),d=ve(r);if((d||!a)&&((he(r)!==`body`||be(o))&&(c=Me(r)),d)){let e=so(r);l=ro(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?lo(o,c):sr(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 fo(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function po(e){let t=Me(e),n=e.ownerDocument.body,r=ir(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=ir(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+co(e),o=-t.scrollTop;return je(n).direction===`rtl`&&(a+=ir(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var mo=25;function ho(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=G(e),a=ge(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!ke()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(co(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 go(e,t){let n=so(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=ro(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function _o(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=ho(e,n,t);else if(t===`document`)r=po(ge(e));else if(K(t))r=go(t,n);else{let n=ao(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return kr(r)}function vo(e,t){let n=t.get(e);if(n)return n;let r=Fe(e,[],!1).filter(e=>K(e)&&he(e)!==`body`),i=null,a=je(e).position===`fixed`,o=a?Ne(e):e;for(;K(o)&&!Ae(o);){let e=je(o),t=De(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ne(o)}return t.set(e,r),r}function yo(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Se(t)?[]:vo(t,this._c):[].concat(n),r],o=_o(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=_o(t,a[e],i);s=ir(n.top,s),c=rr(n.right,c),l=rr(n.bottom,l),u=ir(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function bo(e){let{width:t,height:n}=to(e);return{width:t,height:n}}function xo(e,t,n){let r=ve(t),i=ge(t),a=n===`fixed`,o=so(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=sr(0);if((r||!a)&&((he(t)!==`body`||be(i))&&(s=Me(t)),r)){let e=so(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=co(i));let l=i&&!r&&!a?lo(i,s):sr(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 So(e){return je(e).position===`static`}function Co(e,t){if(!ve(e)||je(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return ge(e)===n&&(n=n.ownerDocument.body),n}function wo(e,t){let n=G(e);if(Se(e))return n;if(!ve(e)){let t=Ne(e);for(;t&&!Ae(t);){if(K(t)&&!So(t))return t;t=Ne(t)}return n}let r=Co(e,t);for(;r&&xe(r)&&So(r);)r=Co(r,t);return r&&Ae(r)&&So(r)&&!De(r)?n:r||Oe(e)||n}var To=async function(e){let t=this.getOffsetParent||wo,n=this.getDimensions,r=await n(e.floating);return{reference:xo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Eo(e){return je(e).direction===`rtl`}var Do={convertOffsetParentRelativeRectToViewportRelativeRect:uo,getDocumentElement:ge,getClippingRect:yo,getOffsetParent:wo,getElementRects:To,getClientRects:fo,getDimensions:bo,getScale:ro,isElement:K,isRTL:Eo};function Oo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ko(e,t,n){let r=null,i,a=ge(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=or(d),h=or(a.clientWidth-(u+f)),g=or(a.clientHeight-(d+p)),_=or(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:ir(0,rr(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Oo(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=G(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Ao(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=no(e),u=i||a?[...l?Fe(l):[],...t?Fe(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?ko(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?so(e):null;c&&g();function g(){let t=so(e);h&&!Oo(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 jo=Za,Mo=Qa,No=Ja,Po=eo,Fo=$a,Io=(e,t,n)=>{let r=new Map,i=n??{},a={...Do,...i.platform,_c:r};return qa(e,t,{...i,platform:a})},Lo=typeof document<`u`?l.useLayoutEffect:function(){};function Ro(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(!Ro(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)&&!Ro(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function zo(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bo(e,t){let n=zo(e);return Math.round(t*n)/n}function Vo(e){let t=l.useRef(e);return Lo(()=>{t.current=e}),t}function Ho(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:u}=e,[d,f]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=l.useState(r);Ro(p,r)||m(r);let[h,g]=l.useState(null),[_,v]=l.useState(null),y=l.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=l.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=l.useRef(null),w=l.useRef(null),T=l.useRef(d),E=c!=null,D=Vo(c),O=Vo(i),k=Vo(u),A=l.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),Io(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Ro(T.current,t)&&(T.current=t,fa.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);Lo(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[u]);let j=l.useRef(!1);Lo(()=>(j.current=!0,()=>{j.current=!1}),[]),Lo(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=l.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=l.useMemo(()=>({reference:x,floating:S}),[x,S]),P=l.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Bo(N.floating,d.x),r=Bo(N.floating,d.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...zo(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,d.x,d.y]);return l.useMemo(()=>({...d,update:A,refs:M,elements:N,floatingStyles:P}),[d,A,M,N,P])}var Uo=(e,t)=>{let n=jo(e);return{name:n.name,fn:n.fn,options:[e,t]}},Wo=(e,t)=>{let n=Mo(e);return{name:n.name,fn:n.fn,options:[e,t]}},Go=(e,t)=>({fn:Fo(e).fn,options:[e,t]}),Ko=(e,t)=>{let n=No(e);return{name:n.name,fn:n.fn,options:[e,t]}},qo=(e,t)=>{let n=Po(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jo=t((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Yo=t(((e,t)=>{t.exports=Jo()})),Xo=t((e=>{var t=r(),n=Yo();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Zo=t(((e,t)=>{t.exports=Xo()})),Qo=[],$o=void 0;function es(){return $o}function ts(e){Qo.push(e)}function ns(e){let t=(t,n)=>{let r=$e(is).current,i;try{$o=r;for(let e of Qo)e.before(r);i=e(t,n);for(let e of Qo)e.after(r);r.didInitialize=!0}finally{$o=void 0}return i};return t.displayName=e.displayName||e.name,t}function rs(e){return l.forwardRef(ns(e))}function is(){return{didInitialize:!1}}var as=Yo(),os=Zo(),ss=Pi(19)?us:ds;function cs(e,t,n,r,i){return ss(e,t,n,r,i)}function ls(e,t,n,r,i){let a=l.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,as.useSyncExternalStore)(e.subscribe,a,a)}ts({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,as.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function us(e,t,n,r,i){let a=es();if(!a)return ls(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function ds(e,t,n,r,i){return(0,os.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var fs=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return cs(this,e,t,n,r)}},ps=class extends fs{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){l.useDebugValue(e);let n=this;W(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;W(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;W(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){l.useDebugValue(e);let n=this,r=t!==void 0;W(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return l.useDebugValue(e),cs(this,this.selectors[e],t,n,r)}useContextCallback(e,t){l.useDebugValue(e);let n=$(t??et);this.context[e]=n}useStateSetter(e){let t=l.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},ms={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},hs=class extends ps{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:va(),nested:n,triggerElements:i},ms),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&Et(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function gs(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),u=t.useState(n?`popupElement`:`positionerElement`),d=t.context.triggerElements,f=o,p=l.useRef(null);r===void 0&&p.current===null&&(p.current=new hs({open:s,transitionStatus:void 0,referenceElement:c,floatingElement:u,triggerElements:d,onOpenChange:f,floatingId:i,syncOnly:!0,nested:a}));let m=r??p.current;return t.useSyncedValue(`floatingId`,i),W(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:u};K(c)&&(e.domReferenceElement=c),m.state.positionReference===m.state.referenceElement&&(e.positionReference=c),m.update(e)},[s,i,c,u,m]),m.context.onOpenChange=f,m.context.nested=a,m}function _s(e,t=!1,n=!1,r=!1){let[i,a]=l.useState(e&&t?`idle`:void 0),[o,s]=l.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),W(()=>{if(!e&&o&&i!==`ending`&&n){let e=lt.request(()=>{a(`ending`)});return()=>{lt.cancel(e)}}},[e,o,i,n]),W(()=>{if(!e||t)return;let n=lt.request(()=>{a(void 0)});return()=>{lt.cancel(n)}},[t,e]),W(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=lt.request(()=>{a(`idle`)});return()=>{lt.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}var vs=null;function ys(e){if(!vs){let e=[];vs=e,queueMicrotask(()=>{vs=null,fa.flushSync(()=>{for(let t of e)t()})})}vs.push(e)}function bs(e,t=!1,n=!1){let r=ut();return $((i,a=null)=>{r.cancel();let o=Da(e);if(o==null)return;let s=o,c=()=>{if(!n){fa.flushSync(i);return}ys(()=>{a?.aborted||i()})};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(s.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||c()},()=>{if(!a?.aborted){if(s.getAnimations().some(e=>e.pending||e.playState!==`finished`)){l();return}c()}})}if(t){let e=Ft;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}r.request(l)})}function xs(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=$(a),s=bs(r,n,i);l.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}var Ss={tabIndex:-1,[kt]:``};function Cs(e){return t=>t!==`touch`||e.current}function ws(e,t=!1){let n=Ai(),r=Sa()!=null,i=$e(()=>e(n,r)).current;return gs({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Ts({handle:e,store:t}){return W(()=>e.attachStore(t),[e,t]),null}function Es(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function Ds(e,t){let n=l.useRef(null);return $(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),Es(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),Es(t))})}function Os(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s}}function ks(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function As(e,t,n,r={}){let i=n.reason,a=i===_n,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=ks(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=Os(e.state,t,n.trigger,c()),l={...r.extraState,...i};o?l.instantType=`focus`:s?l.instantType=`dismiss`:a&&(l.instantType=void 0),e.update(l)};a?fa.flushSync(l):l()}function js(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Ds(e,n),o=$(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=$(e=>{a(e),e&&o(e)});return W(()=>(s(t.current),()=>s(null)),[s,t,n,e]),W(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Ms(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=l.useRef(null),i=e.useState(`open`);W(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=Z(hn);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function Ns(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=_s(e,!1,!1,r),s=t.useState(`preventUnmountingOnClose`),c=!e&&s;t.useSyncedValues({mounted:i,transitionStatus:o,preventUnmountingOnClose:c});let l=$(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return xs({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function Ps(e,t){e.useSyncedValues(t),W(()=>()=>{e.update({activeTriggerProps:nt,inactiveTriggerProps:nt,popupProps:nt})},[e])}function Fs(e,t){W(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),W(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Is=class{constructor(){this.idMap=new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function Ls(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new hs({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:nt,inactiveTriggerProps:nt,popupProps:nt}}var Rs=e=>e.triggerIdProp??e.activeTriggerId,zs=e=>e.openProp??e.open,Bs=e=>(e.popupElement?.id??e.floatingId)||void 0;function Vs(e,t){return t!==void 0&&zs(e)&&Rs(e)===t}function Hs(e,t){return Vs(e,t)?!0:t!==void 0&&zs(e)&&Rs(e)==null&&e.triggerCount===1}var Us={open:zs,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Rs,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Bs,isTriggerActive:(e,t)=>t!==void 0&&Rs(e)===t,isOpenedByTrigger:(e,t)=>Vs(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Rs(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Hs(e,t)?Bs(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Ws(e){let t=l.useCallback(t=>e===void 0?et:e.subscribeStore(t),[e]),n=l.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,as.useSyncExternalStore)(t,n,()=>e?.serverStore)}function Gs(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Ai(),a=Sa()!=null,o=$e(()=>new hs({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Is,floatingId:i,syncOnly:!1,nested:a})).current;return W(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=K(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function Ks(e){return qs(e,e.rootContext)}function qs(e,t){let{nodeId:n,externalTree:r}=e,i=t.useState(`referenceElement`),a=t.useState(`floatingElement`),o=t.useState(`domReferenceElement`),s=t.useState(`open`),c=t.useState(`floatingId`),[u,d]=l.useState(null),[f,p]=l.useState(void 0),[m,h]=l.useState(void 0),g=l.useRef(null),_=Ca(r),v=l.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),y=Ho({...e,elements:{...v,...u&&{reference:u}}}),b=K(f)?f:null,x=m===void 0?t.state.floatingElement:m;t.useSyncedValue(`referenceElement`,f??null),t.useSyncedValue(`domReferenceElement`,f===void 0?o:b),t.useSyncedValue(`floatingElement`,x);let S=l.useCallback(e=>{let t=K(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;d(t),y.refs.setReference(t)},[y.refs]),C=l.useCallback(e=>{(K(e)||e===null)&&(g.current=e,p(e)),(K(y.refs.reference.current)||y.refs.reference.current===null||e!==null&&!K(e))&&y.refs.setReference(e)},[y.refs,p]),w=l.useCallback(e=>{h(e),y.refs.setFloating(e)},[y.refs]),T=l.useMemo(()=>({...y.refs,setReference:C,setFloating:w,setPositionReference:S,domReference:g}),[y.refs,C,w,S]),E=l.useMemo(()=>({...y.elements,domReference:o}),[y.elements,o]),D=l.useMemo(()=>({...y,dataRef:t.context.dataRef,open:s,onOpenChange:t.setOpen,events:t.context.events,floatingId:c,refs:T,elements:E,nodeId:n,rootStore:t}),[y,T,E,n,t,s,c]);return W(()=>{o&&(g.current=o)},[o]),W(()=>{t.context.dataRef.current.floatingContext=D;let e=_?.nodesRef.current.find(e=>e.id===n);e&&(e.context=D)}),l.useMemo(()=>({...y,context:D,refs:T,elements:E,rootStore:t}),[y,T,E,D,t])}var Js=Ke&&Je;function Ys(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=l.useRef(!1),c=l.useRef(null),u=l.useRef(!0),d=ot();l.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=G(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&ve(e)&&e===Dt(J(e))&&(s.current=!0,c.current=e)}function a(){u.current=!0}function o(){u.current=!1}return zn(q(t,`blur`,r),Js&&q(t,`keydown`,a,!0),Js&&q(t,`pointerdown`,o,!0))},[i,n]),l.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);K(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let f=l.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=Ot(t.nativeEvent);if(K(a)){if(Js&&!t.relatedTarget){if(!u.current&&!an(a))return}else if(!cn(a))return}let o=tn(t.relatedTarget,i.context.triggerElements),{nativeEvent:l,currentTarget:f}=t,p=typeof r==`function`?r():r;if(i.select(`open`)&&o||p===0||p===void 0){i.setOpen(!0,Z(vn,l,f));return}d.start(p,()=>{s.current||i.setOpen(!0,Z(vn,l,f))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=K(n)&&n.hasAttribute(fi(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;d.start(0,()=>{let e=i.select(`domReferenceElement`),t=Dt(J(e));(n||t!==e)&&(X(o.current.floatingContext?.refs.floating.current,t)||X(e,t)||a||tn(n??t,i.context.triggerElements)||i.setOpen(!1,Z(vn,r)))})}}},[o,r,i,d]);return l.useMemo(()=>n?{reference:f,trigger:f}:{},[n,f])}var Xs=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new at,this.restTimeout=new at,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},Zs=new WeakMap;function Qs(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&Zs.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),Zs.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function $s(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=Zs.get(n);a&&a!==e&&Qs(a),Qs(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,Zs.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function ec(e){let t=e.context.dataRef.current,n=$e(()=>t.hoverInteractionState??Xs.create()).current;return t.hoverInteractionState||=n,rt(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function tc(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,o=a.useState(`open`),s=a.useState(`floatingElement`),c=a.useState(`domReferenceElement`),{dataRef:u}=a.context,d=Ca(),f=Sa(),p=ec(a),m=ot(),h=$(()=>pn(u.current.openEvent?.type,p.interactedInside)),g=$(()=>mn(u.current.openEvent?.type)),_=$(()=>{Qs(p)});W(()=>{o||(p.pointerType=void 0,p.restTimeoutPending=!1,p.interactedInside=!1,_())},[o,p,_]),l.useEffect(()=>_,[_]),W(()=>{if(n&&o&&p.handleCloseOptions?.blockPointerEvents&&g()&&K(c)&&s){let e=c,t=s,n=J(s),r=d?.nodesRef.current.find(e=>e.id===f)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=p.pointerEventsScopeElement===t?null:p.pointerEventsScopeElement,a=r===t?null:r,o=p.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return $s(p,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{_()}}},[n,o,c,s,p,g,d,f,_]),l.useEffect(()=>{if(!n)return;function e(){return!!(d&&f&&ui(d.nodesRef.current,f).length>0)}function t(e){let t=dn(r,`close`,p.pointerType),n=()=>{a.setOpen(!1,Z(_n,e)),d?.events.emit(`floating.closed`,e)};t?p.openChangeTimeout.start(t,n):(p.openChangeTimeout.clear(),n())}function o(e){let t=Ot(e);if(!on(t)){p.interactedInside=!1;return}p.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function c(){p.openChangeTimeout.clear(),m.clear(),d?.events.off(`floating.closed`,v),_()}function l(n){if(e()&&d){d.events.on(`floating.closed`,v);return}if(tn(n.relatedTarget,a.context.triggerElements))return;let r=u.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(d&&r&&K(o)&&ui(d.nodesRef.current,r,!1).some(e=>X(e.context?.elements.floating,o)))){if(p.handler){p.handler(n);return}_(),g()&&!h()&&t(n)}}function v(t){d&&f&&!e()&&m.start(0,()=>{d.events.off(`floating.closed`,v),a.setOpen(!1,Z(_n,t)),d.events.emit(`floating.closed`,t)})}let y=s;return zn(y&&q(y,`mouseenter`,c),y&&q(y,`mouseleave`,l),y&&q(y,`pointerdown`,o,!0),()=>{d?.events.off(`floating.closed`,v)})},[n,s,a,u,r,i,g,h,_,p,d,f,m])}var nc={current:null};function rc(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=nc,externalTree:u,isActiveTrigger:d=!0,getHandleCloseContext:f,isClosing:p,shouldOpen:m,guardStaleOpen:h=!1}=t,g=`rootStore`in e?e.rootStore:e,{dataRef:_,events:v}=g.context,y=Ca(u),b=ec(g),x=l.useRef(!1),S=Kn(i),C=Kn(r),w=Kn(o),T=Kn(n),E=Kn(m),D=Kn(p),O=$(()=>pn(_.current.openEvent?.type,b.interactedInside)),k=$(()=>E.current?.()!==!1),A=$((e,t,n)=>{let r=g.context.triggerElements;if(r.hasElement(t))return!e||!X(e,t);if(!K(n))return!1;let i=n;return r.hasMatchingElement(e=>X(e,i))&&(!e||!X(e,i))}),j=$(()=>{b.handler&&=(J(g.select(`domReferenceElement`)).removeEventListener(`mousemove`,b.handler),void 0)}),M=$(()=>{Qs(b)});return d&&(b.handleCloseOptions=i?.__options),l.useEffect(()=>j,[j]),l.useEffect(()=>{if(!n)return;function e(e){e.open?x.current=!1:(x.current=e.reason===_n,j(),b.openChangeTimeout.clear(),b.restTimeout.clear(),b.blockMouseMove=!0,b.restTimeoutPending=!1)}return v.on(`openchange`,e),()=>{v.off(`openchange`,e)}},[n,v,b,j]),l.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=dn(C.current,`close`,b.pointerType);n?b.openChangeTimeout.start(n,()=>{g.setOpen(!1,Z(_n,e)),y?.events.emit(`floating.closed`,e)}):t&&(b.openChangeTimeout.clear(),g.setOpen(!1,Z(_n,e)),y?.events.emit(`floating.closed`,e))}let t=c.current??(d?g.select(`domReferenceElement`):null);if(!K(t))return;function r(e){if(b.openChangeTimeout.clear(),b.blockMouseMove=!1,a&&!Tt(b.pointerType))return;let t=fn(w.current),n=dn(C.current,`open`,b.pointerType),r=Ot(e),i=e.currentTarget??null,o=g.select(`domReferenceElement`),s=i;if(K(r)&&!g.context.triggerElements.hasElement(r)){for(let e of g.context.triggerElements.elements())if(X(e,r)){s=e;break}}K(i)&&K(o)&&!g.context.triggerElements.hasElement(i)&&X(i,o)&&(s=o);let c=s!=null&&A(o,s,r),l=g.select(`open`),u=D.current?.()??g.select(`transitionStatus`)===`ending`,d=!l&&u&&x.current,f=!c&&K(s)&&K(o)&&X(o,s)&&d,p=t>0&&!n,m=c&&(l||d)||f,h=!l||c;if(m){k()&&g.setOpen(!0,Z(_n,e,s));return}p||(n?b.openChangeTimeout.start(n,()=>{h&&k()&&g.setOpen(!0,Z(_n,e,s))}):h&&k()&&g.setOpen(!0,Z(_n,e,s)))}function i(t){if(O()){M();return}j();let n=J(g.select(`domReferenceElement`));b.restTimeout.clear(),b.restTimeoutPending=!1;let r=_.current.floatingContext??f?.();if(!tn(t.relatedTarget,g.context.triggerElements)){if(S.current&&r){g.select(`open`)||b.openChangeTimeout.clear();let i=c.current;b.handler=S.current({...r,tree:y,x:t.clientX,y:t.clientY,onClose(){M(),j(),T.current&&!O()&&i===g.select(`domReferenceElement`)&&e(t,!0)}}),n.addEventListener(`mousemove`,b.handler),b.handler(t);return}(b.pointerType!==`touch`||!X(g.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){X(t,e.relatedTarget)||(b.openChangeTimeout.clear(),b.restTimeout.clear(),b.restTimeoutPending=!1)}let l=h?q(t,`mouseout`,o):void 0;return s?zn(q(t,`mousemove`,r,{once:!0}),q(t,`mouseenter`,r),q(t,`mouseleave`,i),l):zn(q(t,`mouseenter`,r),q(t,`mouseleave`,i),l)},[j,M,_,C,g,n,S,b,d,A,O,a,s,w,c,y,T,f,D,k,h]),l.useMemo(()=>{if(!n)return;function e(e){b.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=g.select(`domReferenceElement`),i=g.select(`open`),o=A(r,n,e.target);if(a&&!Tt(b.pointerType))return;if(i&&o&&b.handleCloseOptions?.blockPointerEvents){let e=g.select(`floatingElement`);if(e){let t=b.handleCloseOptions?.getScope?.()??n.ownerDocument.body;$s(b,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=fn(w.current);if(i&&!o||s===0||!o&&b.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;b.restTimeout.clear();function c(){if(b.restTimeoutPending=!1,O())return;let e=g.select(`open`);!b.blockMouseMove&&(!e||o)&&k()&&g.setOpen(!0,Z(_n,t,n))}b.pointerType===`touch`?fa.flushSync(()=>{c()}):o&&i?c():(b.restTimeoutPending=!0,b.restTimeout.start(s,c))}}},[n,b,O,A,a,g,w,k])}var ic=`Escape`;function ac(e){return Je&&e.movementX===0&&e.movementY===0}function oc(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function sc(e,t){return oc(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function cc(e,t,n){return oc(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function lc(e,t,n){return oc(t,n?e===jt:e===Mt,e===Pt)}function uc(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===ic:oc(t,n?e===Mt:e===jt,e===Nt)}function dc(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:u=!1,rtl:d=!1,virtual:f=!1,focusItemOnOpen:p=`auto`,focusItemOnHover:m=!0,openOnArrowKeyDown:h=!0,disabledIndices:g=void 0,orientation:_=`vertical`,parentOrientation:v,id:y,resetOnPointerLeave:b=!0,externalTree:x,grid:S}=t,C=S!=null,w=`rootStore`in e?e.rootStore:e,T=w.useState(`open`),E=w.useState(`floatingElement`),D=w.useState(`domReferenceElement`),O=w.context.dataRef,k=ln(E),A=sn(D),j=Kn(k),M=Sa(),N=Ca(x),P=l.useRef(p),F=l.useRef(o??-1),I=l.useRef(null),L=l.useRef(!0),R=$(e=>{i(F.current===-1?null:F.current,e)}),z=l.useRef(!!E),B=l.useRef(T),V=l.useRef(!1),ee=l.useRef(!1),te=l.useRef(null),ne=Kn(g),H=Kn(T),U=Kn(o),re=Kn(b),ie=ut(),ae=ut(),oe=$(()=>{function e(e){f?N?.events.emit(`virtualfocus`,e):te.current=mi(e,{sync:V.current,preventScroll:!0})}let t=n.current[F.current],r=ee.current;t&&e(t),(V.current?e=>e():e=>ie.request(e))(()=>{let i=n.current[F.current]||t;i&&(t||e(i),fe&&(r||!L.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});W(()=>{O.current.orientation=_},[O,_]),W(()=>{a&&(T&&E?(F.current=o??-1,P.current&&o!=null&&(ee.current=!0,R())):z.current&&(F.current=-1,R()))},[a,T,E,o,R]),W(()=>{if(a){if(!T){V.current=!1;return}if(E){if(r==null){if(V.current=!1,U.current!=null)return;if(z.current&&(F.current=-1,oe()),(!B.current||!z.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ae.request(e):queueMicrotask)(t),e+=1):(F.current=I.current==null||cc(I.current,_,d)||u?Mr(n):Nr(n),I.current=null,R())};t()}}else jr(n.current,r)||(F.current=r,oe(),ee.current=!1)}}},[a,T,E,r,U,u,n,_,d,R,oe,ae]),W(()=>{if(!a||E||!N||f||!z.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=Dt(J(D??t??null)),r=e.some(e=>e.context&&X(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[a,E,D,N,M,f]),W(()=>{B.current=T,z.current=!!E}),W(()=>{T||(I.current=null,P.current=p)},[T,p]);let se=r!=null,ce=$(e=>{if(!H.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||r!==t)&&(F.current=t,R(e))}),le=$(()=>v??N?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),ue=$(()=>Mr(n,ne.current)),de=$(e=>{if(L.current=!1,V.current=!0,e.which===229||!H.current&&e.currentTarget===j.current)return;if(u&&uc(e.key,_,d,C)){sc(e.key,le())||xt(e),w.setOpen(!1,Z(Dn,e.nativeEvent)),ve(D)&&(f?N?.events.emit(`virtualfocus`,D):D.focus());return}let t=F.current,r=Mr(n,g),i=Nr(n,g);if(A||(e.key===`Home`&&(xt(e),F.current=r,R(e)),e.key===`End`&&(xt(e),F.current=i,R(e))),S!=null){let t=S(e,F.current,n,_,c,d,g,r,i);if(t!=null&&(F.current=t,R(e)),_===`both`)return}if(sc(e.key,_)){if(xt(e),T&&!f&&Dt(e.currentTarget.ownerDocument)===e.currentTarget){F.current=cc(e.key,_,d)?r:i,R(e);return}cc(e.key,_,d)?c?t>=i?s&&t!==n.current.length?F.current=-1:(V.current=!1,F.current=r):F.current=Pr(n.current,{startingIndex:t,disabledIndices:g}):F.current=Math.min(i,Pr(n.current,{startingIndex:t,disabledIndices:g})):c?t<=r?s&&t!==-1?F.current=n.current.length:(V.current=!1,F.current=i):F.current=Pr(n.current,{startingIndex:t,decrement:!0,disabledIndices:g}):F.current=Math.max(r,Pr(n.current,{startingIndex:t,decrement:!0,disabledIndices:g})),jr(n.current,F.current)&&(F.current=-1),R(e)}}),fe=l.useMemo(()=>({onFocus(e){V.current=!0,ce(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){ac(e)||(V.current=!0,ee.current=!1,m&&ce(e))},onPointerLeave(e){if(!H.current||!L.current||e.pointerType===`touch`)return;V.current=!0;let t=e.relatedTarget;if(m&&!n.current.includes(t)&&re.current&&(te.current?.(),te.current=null,F.current=-1,R(e),!f)){let e=j.current,t=Dt(J(e));e&&X(e,t)&&e.focus({preventScroll:!0})}}}),[ce,H,j,m,n,R,re,f]),pe=l.useMemo(()=>f&&T&&se&&{"aria-activedescendant":`${y}-${r}`},[f,T,se,y,r]),me=l.useMemo(()=>({...A?{}:pe,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&T&&!f){let t=Ot(e.nativeEvent);if(t&&!X(j.current,t))return;xt(e),w.setOpen(!1,Z(Tn,e.nativeEvent)),ve(D)&&D.focus();return}de(e)},onPointerMove(e){ac(e)||(L.current=!0)}}),[pe,de,j,A,w,T,f,D]),he=l.useMemo(()=>{function e(e){w.setOpen(!0,Z(Dn,e.nativeEvent,e.currentTarget))}function t(e){p===`auto`&&Ct(e.nativeEvent)&&(P.current=!f)}function n(e){P.current=p,p===`auto`&&wt(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(t){let n=w.select(`open`);L.current=!1;let r=t.key.startsWith(`Arrow`),i=lc(t.key,le(),d),a=sc(t.key,_),o=(u?i:a)||t.key===`Enter`||t.key.trim()===``;if(f&&n)return de(t);if(n||h||!r){if(o){let e=sc(t.key,le());I.current=u&&e?null:t.key}if(u){i&&(xt(t),n?(F.current=ue(),R(t)):e(t));return}a&&(U.current!=null&&(F.current=U.current),xt(t),!n&&h?e(t):de(t),n&&R(t))}},onFocus(e){w.select(`open`)&&!f&&(F.current=-1,R(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[de,p,ue,u,R,w,h,_,le,d,U,f]),G=l.useMemo(()=>({...pe,...he}),[pe,he]);return l.useMemo(()=>a?{reference:G,floating:me,item:fe,trigger:he}:{},[a,G,me,he,fe])}function fc(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:u=750,selectedIndex:d=null}=t,f=`rootStore`in e?e.rootStore:e,p=f.useState(`open`),m=ot(),h=l.useRef(``),g=l.useRef(d??i??-1),_=l.useRef(null),v=$(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!Rr(n)||n?.matches(`:disabled`)?!1:o==null||!Ir(tt,e,o)}function l(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&c(n))return n}return-1}let f=n.current;if(h.current.length>0&&e.key===` `&&(xt(e),s?.(!0)),h.current.length>0&&h.current[0]!==` `&&l(f,h.current)===-1&&e.key!==` `&&s?.(!1),f==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;p&&e.key!==` `&&(xt(e),s?.(!0));let v=h.current===``;v&&(g.current=d??i??-1),f.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&h.current===e.key&&(h.current=``,g.current=_.current),h.current+=e.key,m.start(u,()=>{h.current=``,g.current=_.current,s?.(!1)});let y=((v?d??i??-1:g.current)??0)+1,b=l(f,h.current,y);b===-1?e.key!==` `&&(h.current=``,s?.(!1)):(a?.(b),_.current=b)}),y=$(e=>{let t=e.relatedTarget,n=f.select(`domReferenceElement`),r=f.select(`floatingElement`);X(n,t)||X(r,t)||(m.clear(),h.current=``,g.current=_.current,s?.(!1))});W(()=>{(p||d===null)&&(m.clear(),_.current=null,h.current!==``&&(h.current=``))},[p,d,m]);let b=l.useMemo(()=>({onKeyDown:v,onBlur:y}),[v,y]);return l.useMemo(()=>c?{reference:b,floating:b}:{},[c,b])}var pc=.1,mc=pc*pc,hc=.5;function gc(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function _c(e,t,n,r,i,a,o,s,c,l){let u=!1;return gc(e,t,n,r,i,a)&&(u=!u),gc(e,t,i,a,o,s)&&(u=!u),gc(e,t,o,s,c,l)&&(u=!u),gc(e,t,c,l,n,r)&&(u=!u),u}function vc(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function yc(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function bc(e={}){let{blockPointerEvents:t=!1}=e,n=new at,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*mc;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Ot(r),g=r.type===`mouseleave`,_=X(u,h),v=X(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&K(r.relatedTarget)&&X(u,r.relatedTarget))return;function y(){return!!(s&&ui(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=yc(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=yc(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=yc(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=yc(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!vc(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?hc/2:hc*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+hc+1,o=C||T?S.bottom-hc:S.top,s=C?T?S.bottom-hc:S.top:S.bottom-hc;M=_c(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?hc/2:hc*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-hc,o=C||T?S.top+hc:S.bottom,s=C?T?S.top+hc:S.bottom:S.top+hc;M=_c(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?hc/2:hc*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+hc+1,o=w||E?S.right-hc:S.left,s=w?E?S.right-hc:S.left:S.right-hc;M=_c(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?hc/2:hc*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-hc,o=w||E?S.left+hc:S.right,s=w?E?S.left+hc:S.right:S.left+hc;M=_c(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function xc({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,u]=l.useState(0),[d,f]=l.useState(0),p=c===0,m=Ua(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Ot(t);if(p&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||X(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return bt(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{u(e),f(t)}),W(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,d+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,d,t]),Ps(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:d}),null}var Sc=l.createContext(void 0);function Cc(e){let t=l.useContext(Sc);if(!e&&t===void 0)throw Error(Mi(27));return t}var wc={...Us,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Tc=class extends ps{constructor(e,t,n){let r=new Is,i=Ec(e,r,t,n);super(i,Dc(r),wc)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(Os(this.state,e,t.trigger)))}};function Ec(e,t,n,r=!1){return{...Ls(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function Dc(e){return{popupRef:l.createRef(),backdropRef:l.createRef(),internalBackdropRef:l.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Oc(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:u,handle:d,triggerId:f,defaultTriggerId:p=null}=t,m=e===`drawer`,h=e===`alert-dialog`,g=h?!0:c,_=h||s,v=h?`alertdialog`:`dialog`,y=Cc(!0),b={modal:g,disablePointerDismissal:_,nested:y!=null,role:v},x=ws((e,t)=>new Tc({open:i,openProp:r,activeTriggerId:p,triggerIdProp:f,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,f),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);Fs(x,S),Ms(x);let{forceUnmount:T}=Ns(S,x);l.useImperativeHandle(u,()=>({unmount:T,close:()=>x.setOpen(!1,Z(Nn))}),[T,x]);let E=S||C;return(0,Q.jsxs)(Sc.Provider,{value:x,children:[d&&(0,Q.jsx)(Ts,{handle:d,store:x}),E&&(0,Q.jsx)(xc,{store:x,parentContext:y?.context,isDrawer:m}),typeof n==`function`?n({payload:w}):n]})}function kc(e){return Oc(`alert-dialog`,e)}var Ac=l.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=Cc(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return ta(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:$t,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),jc=l.createContext(void 0);function Mc(e=!1){let t=l.useContext(jc);if(t===void 0&&!e)throw Error(Mi(16));return t}function Nc(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:l.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function Pc(e,t,{detail:n=0}={}){e.dispatchEvent(new(G(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Fc(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=l.useRef(null),s=Mc(!0),c=a??s!==void 0,{props:u}=Nc({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),d=l.useCallback(()=>{let e=o.current;Ic(e)&&c&&t&&u.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,u.disabled,c]);return W(d,[d]),{getButtonProps:l.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...l}=e;return Vi({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Qi(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=Ic(r),s=!i&&Lc(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),Pc(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),Pc(r,e)))},onKeyUp(e){if(!t){if(Qi(e),a?.(e),e.target===e.currentTarget&&i&&c&&Ic(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),Pc(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},u,l)},[t,u,c,i]),buttonRef:$(e=>{o.current=e,d()})}}function Ic(e){return ve(e)&&e.tagName===`BUTTON`}function Lc(e){return ve(e)&&e.tagName===`A`&&!!e.href}var Rc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=Cc(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=Fc({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Z(xn,e.nativeEvent))}return ta(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})});function zc(e){return Ai(e,`base-ui`)}var Bc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Cc(),c=zc(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),ta(`p`,e,{ref:t,props:[{id:c},o]})}),Vc=l.createContext(void 0);function Hc(){let e=l.useContext(Vc);if(e===void 0)throw Error(Mi(26));return e}var Uc=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),Wc=`--nested-dialogs`,Gc=`data-nested-dialog-open`,Kc={...Qt,...zt,nestedDialogOpen(e){return e?{[Gc]:``}:null}},qc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=Cc(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);Hc(),xs({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?Cs(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=ta(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...Ss,hidden:!m,onKeyDown(e){Uc.has(e.key)&&e.stopPropagation()},style:{[Wc]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:Kc});return(0,Q.jsx)(Ia,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})});function Jc(e){return Pi(19)?e:e?`true`:void 0}var Yc=l.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Q.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),Xc=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Cc(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Q.jsx)(Vc.Provider,{value:n,children:(0,Q.jsxs)(_a,{ref:t,...r,children:[a&&o===!0&&(0,Q.jsx)(Yc,{ref:i.context.internalBackdropRef,inert:Jc(!s)}),e.children]})}):null}),Zc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Cc(),c=zc(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),ta(`h2`,e,{ref:t,props:[{id:c},o]})});function Qc(e){let t=l.useRef(``),n=l.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:l.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function $c(e,t){let n=l.useRef(e),r=$(t);W(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function el(e,t){let{onClick:n,onPointerDown:r}=Qc($((n,r)=>{(typeof e==`function`?e():e)||t(r||(Ue?`touch`:``))}));return l.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function tl(e){let[t,n]=l.useState(null),r=el(e,n);return $c(e,t=>{t&&!e&&n(null)}),l.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var nl=i(),rl,il,al=e=>{rl??=(0,nl.createRoot)(document.body.appendChild(document.createElement(`div`))),il?.resolve(!1),il=e,rl.render((0,Q.jsx)(ol,{request:e,settle:t=>{il===e&&(il=void 0,rl?.render(null),e.resolve(t))}}))};function ol({request:e,settle:t}){return(0,Q.jsx)(kc,{open:!0,onOpenChange:e=>{e||t(!1)},children:(0,Q.jsxs)(Xc,{children:[(0,Q.jsx)(Ac,{className:`dialog-backdrop`}),(0,Q.jsxs)(qc,{className:`dialog`,children:[(0,Q.jsx)(Bc,{className:`dialog-message`,children:e.message}),(0,Q.jsxs)(`div`,{className:`dialog-actions`,children:[e.cancelLabel&&(0,Q.jsx)(Rc,{className:`dialog-button`,children:e.cancelLabel}),(0,Q.jsx)(`button`,{type:`button`,autoFocus:!0,className:`dialog-button is-primary ${e.danger?`is-danger`:``}`,onClick:()=>t(!0),children:e.confirmLabel})]})]})]})})}var sl=(e,{confirmLabel:t=`Confirm`,danger:n=!1}={})=>new Promise(r=>al({message:e,confirmLabel:t,cancelLabel:`Cancel`,danger:n,resolve:r})),cl=e=>new Promise(t=>al({message:e,confirmLabel:`OK`,resolve:()=>t()})),ll=l.createContext(void 0);function ul(e){let t=l.useContext(ll);if(t===void 0&&!e)throw Error(Mi(72));return t}var dl={...Us,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},fl=class extends ps{constructor(e,t,n){let r=new Is;super(pl(e,r,t,n),ml(r),dl)}setOpen=(e,t)=>{As(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,Z(gn,e))}};function pl(e,t,n,r=!1){return{...Ls(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function ml(e){return{popupRef:l.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var hl=ns(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:u,triggerId:d,defaultTriggerId:f=null,children:p}=e,m=ws((e,t)=>new fl({open:n,openProp:r,activeTriggerId:f,triggerIdProp:d},e,t));m.useControlledProp(`openProp`,r),m.useControlledProp(`triggerIdProp`,d),m.useContextCallback(`onOpenChange`,s),m.useContextCallback(`onOpenChangeComplete`,c);let h=m.useState(`open`),g=!t&&h,_=m.useState(`activeTriggerId`),v=m.useState(`mounted`),y=m.useState(`payload`);m.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),Ms(m,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=Ns(g,m),S=m.useState(`isInstantPhase`),C=m.useState(`instantType`),w=m.useState(`lastOpenChangeReason`),T=l.useRef(null);W(()=>{h&&t&&m.setOpen(!1,Z(Mn))},[h,t,m]),W(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),m.set(`instantType`,`delay`)):T.current!==null&&(m.set(`instantType`,T.current),T.current=null)},[x,S,w,C,m]),W(()=>{g&&(_??m.set(`payload`,void 0))},[m,_,g]),l.useImperativeHandle(o,()=>({unmount:b,close:()=>m.setOpen(!1,Z(Nn))}),[b,m]);let E=g||v||!t&&a!==`none`;return(0,Q.jsxs)(ll.Provider,{value:m,children:[u&&(0,Q.jsx)(Ts,{handle:u,store:m}),E&&(0,Q.jsx)(gl,{store:m,disabled:t,trackCursorAxis:a}),typeof p==`function`?p({payload:y}):p]})});function gl({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=Ua(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=Ba(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=l.useMemo(()=>Vi(a.reference,i.reference),[a.reference,i.reference]);return Ps(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??nt}),null}var _l=l.createContext(void 0);function vl(){return l.useContext(_l)}var yl=`data-base-ui-tooltip-trigger`;function bl(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(K(n))return n}}let t=e.target;return K(t)?t:null}function xl(e){let t=e;for(;t;){let e=t.closest(`[${yl}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&K(n.host)?n.host:null}return null}var Sl=rs(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:u=!0,closeDelay:d,id:f,...p}=e,m=ul(!0),h=Ws(a)??m;if(!h)throw Error(Mi(82));let g=zc(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`isOpenedByTrigger`,g),y=h.useState(`floatingRootContext`),b=l.useRef(null),x=d??0,{registerTrigger:S,isMountedByThisTrigger:C}=js(g,b,h,{payload:o,closeOnClick:u,closeDelay:x}),w=vl(),{activeIdRef:T,delayRef:E,isInstantPhase:D,hasProvider:O}=Rn(y,{open:v}),k=ec(y);h.useSyncedValue(`isInstantPhase`,D);let A=h.useState(`disabled`),j=s??A,M=Kn(j),N=h.useState(`trackCursorAxis`),P=h.useState(`disableHoverablePopup`),F=l.useRef(!1),I=ot(),L=l.useRef(void 0);function R(){return O&&T.current!=null?0:c??w??600}function z(e){let t=b.current;if(!t||!e)return!1;let n=xl(e);return n!==null&&n!==t&&X(t,n)}function B(e){let t=z(e);return F.current=t,t&&(k.openChangeTimeout.clear(),k.restTimeout.clear(),k.restTimeoutPending=!1,I.clear()),t}let V=rc(y,{enabled:!j,mouseOnly:!0,move:!1,handleClose:!P&&N!==`both`?bc():null,restMs:R,delay(){return d==null&&O?{close:dn(E.current,`close`)}:{close:x}},triggerElementRef:b,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`,shouldOpen(){return!F.current}}),ee=Ys(y,{enabled:!j}).reference,te=e=>{let t=F.current,n=bl(e),r=B(n),i=b.current,a=i&&n&&X(i,n);if(r&&h.select(`open`)&&h.select(`lastOpenChangeReason`)===`trigger-hover`){h.setOpen(!1,Z(_n,e));return}if(t&&!r&&a&&!M.current&&!h.select(`open`)&&i&&Tt(L.current)){let t=()=>{!F.current&&!M.current&&!h.select(`open`)&&h.setOpen(!0,Z(_n,e,i))},n=R();n===0?(I.clear(),t()):I.start(n,t)}},ne=h.useState(`triggerProps`,C);return ta(`button`,e,{state:{open:v},ref:[t,S,b],props:[V,ee,C||N!==`none`?ne:void 0,{onMouseOver(e){te(e.nativeEvent)},onFocus(e){z(bl(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){F.current=!1,I.clear(),L.current=void 0},onPointerEnter(e){L.current=e.pointerType},onPointerDown(e){L.current=e.pointerType,h.set(`closeOnClick`,u),u&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},onClick(e){u&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},id:g,[en]:j?``:void 0,[yl]:j?void 0:``},p],stateAttributesMapping:Xt})}),Cl=l.createContext(void 0);function wl(){let e=l.useContext(Cl);if(e===void 0)throw Error(Mi(70));return e}var Tl=l.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:u}=ga({container:r,ref:t,componentProps:e,elementProps:s});return!u&&!c?null:(0,Q.jsxs)(l.Fragment,{children:[u,c&&fa.createPortal(n,c)]})}),El=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return ul().useState(`mounted`)||n?(0,Q.jsx)(Cl.Provider,{value:n,children:(0,Q.jsx)(Tl,{ref:t,...r})}):null}),Dl=l.createContext(void 0);function Ol(){let e=l.useContext(Dl);if(e===void 0)throw Error(Mi(71));return e}var kl=l.createContext(void 0);function Al(){return l.useContext(kl)?.direction??`ltr`}var jl=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,offsetParent:d=`real`}=ur(e,t)||{};if(l==null)return{};let f=Or(u),p={x:n,y:r},m=gr(i),h=mr(m),g=await o.getDimensions(l),_=m===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[h]+a.reference[m]-p[m]-a.floating[h],S=p[m]-a.reference[m],C=d===`real`?await o.getOffsetParent?.(l):s.floating,w=s.floating[b]||a.floating[h];(!w||!await o.isElement?.(C))&&(w=s.floating[b]||a.floating[h]);let T=x/2-S/2,E=w/2-g[h]/2-1,D=Math.min(f[v],E),O=Math.min(f[y],E),k=D,A=w-g[h]-O,j=w/2-g[h]/2+T,M=lr(k,j,A),N=!c.arrow&&fr(i)!=null&&j!==M&&a.reference[h]/2-(j<k?D:O)-g[h]/2<0,P=N?j<k?j-k:j-A:0;return{[m]:p[m]+P,data:{[m]:M,centerOffset:j-M-P,...N&&{alignmentOffset:P}},reset:N}}}),Ml=(e,t)=>{let{name:n,fn:r}=jl(e);return{name:n,fn:r,options:[e,t]}},Nl={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},Pl={sideX:`left`,sideY:`top`},Fl=`--available-width`,Il=`--available-height`,Ll=`--anchor-width`,Rl=`--anchor-height`,zl=`--transform-origin`,Bl=Fl,Vl=Il;function Hl(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function Ul(e,t,n){let{rects:r,placement:i}=e;return{side:Hl(t,dr(i),n),align:fr(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Wl(e){return Gl(e,Ks)}function Gl(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:u=5,sticky:d=!1,arrowPadding:f=5,disableAnchorTracking:p=!1,inline:m,keepMounted:h=!1,floatingRootContext:g,mounted:_,collisionAvoidance:v,shift:y,nodeId:b,adaptiveOrigin:x,lazyFlip:S=!1,externalTree:C}=e,[w,T]=l.useState(null);!_&&w!==null&&T(null);let E=v.side||`flip`,D=v.align||`flip`,O=v.fallbackAxisSide||`end`,k=y?.crossAxis??!1,A=y?.rootBoundary,j=typeof n==`function`?n:void 0,M=$(j),N=j?M:n,P=Kn(n),F=Kn(_),I=Al()===`rtl`,L=w||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":I?`left`:`right`,"inline-start":I?`right`:`left`}[i],R=o===`center`?L:`${L}-${o}`,z=u;typeof z==`number`?z={top:z,right:z,bottom:z,left:z}:z&&={top:z.top||0,right:z.right||0,bottom:z.bottom||0,left:z.left||0};let B=+(i===`bottom`),V=+(i===`top`),ee=+(i===`right`),te=+(i===`left`),ne={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:z},H=l.useRef(null),U=Kn(a),re=Kn(s),ie=typeof a==`function`?0:a,ae=typeof s==`function`?0:s,oe=[];m&&oe.push(m),oe.push(Uo(e=>{let t=Ul(e,i,I),n=typeof U.current==`function`?U.current(t):U.current,r=typeof re.current==`function`?re.current(t):re.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[ie,ae,I,i]));let se=D===`none`&&E!==`shift`,ce=!se&&(d||k||E===`shift`),le=E===`none`?null:Ko({...ne,padding:{top:z.top+1+B,right:z.right+1+te,bottom:z.bottom+1+V,left:z.left+1+ee},mainAxis:!k&&E===`flip`,crossAxis:D===`flip`&&`alignment`,fallbackAxisSideDirection:O}),ue=se?null:Wo({...ne,rootBoundary:A,mainAxis:D!==`none`,crossAxis:ce,limiter:d||k?void 0:Go(e=>{if(!H.current)return{};let{width:t,height:n}=H.current.getBoundingClientRect(),r=hr(dr(e.placement)),i=r===`y`?t:n,a=r===`y`?z.left+z.right:z.top+z.bottom;return{offset:i/2+a/2}})},[ne,d,k,A,z,D]);E===`shift`||D===`shift`||o===`center`?oe.push(ue,le):oe.push(le,ue),oe.push(qo({...ne,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!F.current)return;let i=e.style;i.setProperty(Bl,`${t}px`),i.setProperty(Vl,`${n}px`);let a=G(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(Ll,`${u}px`),i.setProperty(Rl,`${d}px`)}}),Ml(e=>({element:H.current||J(e.elements.floating).createElement(`div`),padding:H.current?f:0,offsetParent:`floating`}),[f]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=dr(r),u=fr(r),d=hr(l)===`y`,f=H.current,p=typeof a==`function`?a(Ul(e,i,I)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return ce&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(zl,d?`${m} ${h}`:`${h} ${m}`),{}}},Nl,x),W(()=>{!_&&g&&g.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[_,g]);let de=l.useMemo(()=>({ancestorScroll:!p,elementResize:!p&&typeof ResizeObserver<`u`,layoutShift:!p&&typeof IntersectionObserver<`u`}),[p]),{refs:fe,elements:pe,x:me,y:he,middlewareData:ge,update:_e,placement:K,context:ve,isPositioned:ye,floatingStyles:be}=t({rootContext:g,open:h?_:void 0,placement:R,middleware:oe,strategy:r,whileElementsMounted:h?void 0:(...e)=>Ao(...e,de),nodeId:b,externalTree:C}),{sideX:xe,sideY:Se}=ge.adaptiveOrigin||Pl,Ce=ye?r:`fixed`,we=l.useMemo(()=>{let e;return e=ye?x?{position:Ce,[xe]:me,[Se]:he}:{...be,position:Ce}:{position:Ce,top:0,left:0},e[Bl]=`100vw`,e[Vl]=`100vh`,ye||(e.opacity=0),e},[x,Ce,xe,me,Se,he,be,ye]),Te=l.useRef(null);W(()=>{if(!_)return;let e=P.current,t=typeof e==`function`?e():e,n=(Kl(t)?t.current:t)||null;n!==Te.current&&(fe.setPositionReference(n),Te.current=n)},[_,fe,N,P]),l.useEffect(()=>{if(!_)return;let e=P.current;typeof e!=`function`&&Kl(e)&&e.current!==Te.current&&(fe.setPositionReference(e.current),Te.current=e.current)},[_,fe,N,P]),l.useEffect(()=>{if(h&&_&&pe.reference&&pe.floating)return Ao(pe.reference,pe.floating,_e,de)},[h,_,pe,_e,de]);let Ee=dr(K),De=Hl(i,Ee,I),Oe=fr(K)||`center`,ke=!!ge.hide?.referenceHidden;W(()=>{S&&_&&ye&&Ee!==L&&T(Ee)},[S,_,ye,Ee,L]);let Ae=l.useMemo(()=>({position:`absolute`,top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),je=ge.arrow?.centerOffset!==0;return l.useMemo(()=>({positionerStyles:we,arrowStyles:Ae,arrowRef:H,arrowUncentered:je,side:De,align:Oe,physicalSide:Ee,anchorHidden:ke,refs:fe,context:ve,isPositioned:ye,update:_e}),[we,Ae,H,je,De,Oe,Ee,ke,fe,ve,ye,_e])}function Kl(e){return e!=null&&`current`in e}function ql(e){return e===`starting`?ca:nt}function Jl(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),ta(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},ql(r),i],stateAttributesMapping:Qt})}var Yl=l.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:u=0,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f=5,arrowPadding:p=5,sticky:m=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=ua,style:_,...v}=e,y=ul(),b=wl(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`trackCursorAxis`),w=y.useState(`disableHoverablePopup`),T=y.useState(`floatingRootContext`),E=y.useState(`instantType`),D=y.useState(`transitionStatus`),O=Wl({anchor:i,positionMethod:a,floatingRootContext:T,mounted:S,side:o,sideOffset:c,align:s,alignOffset:u,collisionBoundary:d,collisionPadding:f,sticky:m,arrowPadding:p,disableAnchorTracking:h,keepMounted:b,collisionAvoidance:g,adaptiveOrigin:y.useState(`adaptiveOrigin`)}),k=Jl(e,l.useMemo(()=>({open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:C===`none`?E:`tracking-cursor`}),[x,O.side,O.align,O.anchorHidden,C,E]),{styles:O.positionerStyles,transitionStatus:D,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x||C===`both`||w});return(0,Q.jsx)(Dl.Provider,{value:O,children:k})}),Xl=l.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=ul(),{side:s,align:c}=Ol(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);xs({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),tc(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return ta(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[Ss,f,ql(d),a],stateAttributesMapping:$t})});function Zl({label:e,side:t=`top`,children:n}){return(0,Q.jsxs)(hl,{children:[(0,Q.jsx)(Sl,{render:n}),(0,Q.jsx)(El,{children:(0,Q.jsx)(Yl,{className:`tooltip-positioner`,side:t,sideOffset:8,collisionPadding:8,children:(0,Q.jsx)(Xl,{className:`tooltip-popup`,children:e})})})]})}var Ql={clover:{label:`Clover`,color:`#35B8FF`,face:`eyes`,faceX:50,faceY:50,faceScale:1},flower:{label:`Flower`,color:`#2FCB7A`,face:`eyes`,faceX:50,faceY:51,faceScale:.95},triangle:{label:`Triangle`,color:`#DC48FF`,face:`eyes`,faceX:50,faceY:61,faceScale:.9},square:{label:`Square`,color:`#35B8FF`,face:`eyes`,faceX:50,faceY:50,faceScale:1},blob:{label:`Blob`,color:`#2FCB7A`,face:`eyes`,faceX:49.5,faceY:50,faceScale:1},ghost:{label:`Ghost`,color:`#F4F2FA`,face:`eyes`,faceX:50,faceY:48,faceScale:.95},circle:{label:`Circle`,color:`#9A62FF`,face:`eyes`,faceX:50,faceY:50,faceScale:1},drop:{label:`Drop`,color:`#1ED3C6`,face:`eyes`,faceX:50,faceY:62,faceScale:.9},star:{label:`Star`,color:`#FFD32B`,face:`eyes`,faceX:50,faceY:52,faceScale:.82},droid:{label:`Droid`,color:`#D5DBEA`,face:`eyes`,faceX:50,faceY:60,faceScale:.95},mech:{label:`Mech`,color:`#95A6C4`,face:`eyes`,faceX:50,faceY:59,faceScale:1},alien:{label:`Alien`,color:`#9BE85A`,face:`eyes`,faceX:50,faceY:45,faceScale:1.05},hexagon:{label:`Hexagon`,color:`#FF2A2A`,face:`eyes`,faceX:50,faceY:50,faceScale:.95},cat:{label:`Cat`,color:`#FF8C42`,face:`eyes`,faceX:50,faceY:58,faceScale:1},cloud:{label:`Cloud`,color:`#CFE6FF`,face:`eyes`,faceX:50,faceY:58,faceScale:.95},pill:{label:`Pill`,color:`#7B77F0`,face:`eyes`,faceX:50,faceY:50,faceScale:.9},pebble:{label:`Pebble`,color:`#2FCB7A`,face:`eyes`,faceX:50,faceY:50,faceScale:.95},puddle:{label:`Puddle`,color:`#FF2A2A`,face:`eyes`,faceX:50,faceY:50,faceScale:.95}},$l=Object.keys(Ql);Object.fromEntries($l.map(e=>[e,Ql[e].color]));var eu={default:`idle`,working:`working`,sleeping:`sleeping`},tu={clover:`M26.53 22.38A25 25 0 0 1 73.47 22.38A7 7 0 0 0 77.62 26.53A25 25 0 0 1 77.62 73.47A7 7 0 0 0 73.47 77.62A25 25 0 0 1 26.53 77.62A7 7 0 0 0 22.38 73.47A25 25 0 0 1 22.38 26.53A7 7 0 0 0 26.53 22.38Z`,flower:`M31.2 19.82A20.5 20.5 0 0 1 68.8 19.82A5 5 0 0 0 72.9 22.8A20.5 20.5 0 0 1 84.51 58.55A5 5 0 0 0 82.95 63.37A20.5 20.5 0 0 1 52.54 85.47A5 5 0 0 0 47.46 85.47A20.5 20.5 0 0 1 17.05 63.37A5 5 0 0 0 15.49 58.55A20.5 20.5 0 0 1 27.1 22.8A5 5 0 0 0 31.2 19.82Z`,triangle:`M38.75 27.43A13 13 0 0 1 61.25 27.43L82.7 64.49A13 13 0 0 1 71.45 84L28.55 84A13 13 0 0 1 17.3 64.49L38.75 27.43Z`,square:`M93 50C93 53.66 92.96 58.23 92.88 60.97C92.8 63.71 92.67 64.81 92.51 66.44C92.35 68.08 92.15 69.44 91.9 70.77C91.66 72.1 91.37 73.3 91.04 74.44C90.72 75.58 90.35 76.63 89.94 77.63C89.53 78.63 89.07 79.55 88.58 80.43C88.08 81.31 87.54 82.13 86.96 82.9C86.37 83.67 85.75 84.39 85.07 85.07C84.39 85.75 83.67 86.37 82.9 86.96C82.13 87.54 81.31 88.08 80.43 88.58C79.55 89.07 78.63 89.53 77.63 89.94C76.63 90.35 75.58 90.72 74.44 91.04C73.3 91.37 72.1 91.66 70.77 91.9C69.44 92.15 68.08 92.35 66.44 92.51C64.81 92.67 63.71 92.8 60.97 92.88C58.23 92.96 53.66 93 50 93C46.34 93 41.77 92.96 39.03 92.88C36.29 92.8 35.19 92.67 33.56 92.51C31.92 92.35 30.56 92.15 29.23 91.9C27.9 91.66 26.7 91.37 25.56 91.04C24.42 90.72 23.37 90.35 22.37 89.94C21.37 89.53 20.45 89.07 19.57 88.58C18.69 88.08 17.87 87.54 17.1 86.96C16.33 86.37 15.61 85.75 14.93 85.07C14.25 84.39 13.63 83.67 13.04 82.9C12.46 82.13 11.92 81.31 11.42 80.43C10.93 79.55 10.47 78.63 10.06 77.63C9.65 76.63 9.28 75.58 8.96 74.44C8.63 73.3 8.34 72.1 8.1 70.77C7.85 69.44 7.65 68.08 7.49 66.44C7.33 64.81 7.2 63.71 7.12 60.97C7.04 58.23 7 53.66 7 50C7 46.34 7.04 41.77 7.12 39.03C7.2 36.29 7.33 35.19 7.49 33.56C7.65 31.92 7.85 30.56 8.1 29.23C8.34 27.9 8.63 26.7 8.96 25.56C9.28 24.42 9.65 23.37 10.06 22.37C10.47 21.37 10.93 20.45 11.42 19.57C11.92 18.69 12.46 17.87 13.04 17.1C13.63 16.33 14.25 15.61 14.93 14.93C15.61 14.25 16.33 13.63 17.1 13.04C17.87 12.46 18.69 11.92 19.57 11.42C20.45 10.93 21.37 10.47 22.37 10.06C23.37 9.65 24.42 9.28 25.56 8.96C26.7 8.63 27.9 8.34 29.23 8.1C30.56 7.85 31.92 7.65 33.56 7.49C35.19 7.33 36.29 7.2 39.03 7.12C41.77 7.04 46.34 7 50 7C53.66 7 58.23 7.04 60.97 7.12C63.71 7.2 64.81 7.33 66.44 7.49C68.08 7.65 69.44 7.85 70.77 8.1C72.1 8.34 73.3 8.63 74.44 8.96C75.58 9.28 76.63 9.65 77.63 10.06C78.63 10.47 79.55 10.93 80.43 11.42C81.31 11.92 82.13 12.46 82.9 13.04C83.67 13.63 84.39 14.25 85.07 14.93C85.75 15.61 86.37 16.33 86.96 17.1C87.54 17.87 88.08 18.69 88.58 19.57C89.07 20.45 89.53 21.37 89.94 22.37C90.35 23.37 90.72 24.42 91.04 25.56C91.37 26.7 91.66 27.9 91.9 29.23C92.15 30.56 92.35 31.92 92.51 33.56C92.67 35.19 92.8 36.29 92.88 39.03C92.96 41.77 93 46.34 93 50Z`,blob:`M93.92 50C94.18 51.9 94.24 53.9 93.99 55.79C93.73 57.68 93.18 59.61 92.39 61.36C91.6 63.1 90.48 64.78 89.27 66.27C88.07 67.76 86.58 69.08 85.14 70.29C83.7 71.49 82.1 72.5 80.62 73.5C79.14 74.49 77.64 75.34 76.24 76.24C74.84 77.15 73.51 78 72.2 78.93C70.88 79.86 69.66 80.83 68.36 81.8C67.06 82.76 65.78 83.82 64.39 84.74C63 85.67 61.55 86.63 60.01 87.35C58.47 88.08 56.82 88.73 55.15 89.1C53.48 89.47 51.71 89.64 50 89.57C48.29 89.5 46.55 89.16 44.91 88.68C43.27 88.21 41.67 87.47 40.16 86.72C38.65 85.96 37.24 85.02 35.86 84.13C34.48 83.24 33.19 82.29 31.89 81.37C30.58 80.46 29.32 79.56 28.03 78.63C26.74 77.71 25.44 76.82 24.16 75.84C22.88 74.86 21.57 73.87 20.36 72.74C19.15 71.62 17.95 70.42 16.91 69.1C15.88 67.79 14.92 66.35 14.15 64.85C13.38 63.35 12.76 61.73 12.29 60.1C11.81 58.48 11.52 56.78 11.29 55.1C11.06 53.41 10.98 51.71 10.91 50C10.83 48.29 10.83 46.59 10.83 44.84C10.84 43.1 10.85 41.34 10.93 39.53C11.02 37.72 11.09 35.86 11.34 33.99C11.59 32.12 11.88 30.16 12.43 28.31C12.99 26.46 13.69 24.56 14.66 22.88C15.64 21.21 16.86 19.58 18.27 18.27C19.69 16.96 21.4 15.84 23.17 15.03C24.93 14.22 26.95 13.71 28.89 13.43C30.83 13.15 32.9 13.21 34.82 13.36C36.74 13.5 38.66 13.92 40.43 14.28C42.2 14.65 43.87 15.16 45.46 15.54C47.06 15.93 48.52 16.31 50 16.58C51.48 16.85 52.87 17.02 54.32 17.17C55.77 17.32 57.22 17.36 58.71 17.49C60.2 17.62 61.74 17.7 63.28 17.95C64.81 18.19 66.39 18.5 67.91 18.98C69.43 19.46 70.95 20.08 72.38 20.83C73.81 21.58 75.19 22.5 76.5 23.5C77.81 24.5 79.03 25.63 80.22 26.81C81.41 27.99 82.54 29.25 83.65 30.57C84.76 31.89 85.85 33.26 86.89 34.72C87.93 36.18 88.98 37.69 89.9 39.31C90.82 40.92 91.73 42.64 92.4 44.42C93.07 46.2 93.66 48.1 93.92 50Z`,ghost:`M17 50C17 31.78 31.78 17 50 17C68.22 17 83 31.78 83 50V81.5Q72 93.5 61 81.5Q50 93.5 39 81.5Q28 93.5 17 81.5Z`,circle:`M50 8A42 42 0 1 1 50 92A42 42 0 1 1 50 8Z`,drop:`M50 8.5C52.2 8.5 53.4 10.3 56.4 15.2C62.9 25.5 84 44.6 84 61.5C84 80.3 68.8 92 50 92C31.2 92 16 80.3 16 61.5C16 44.6 37.1 25.5 43.6 15.2C46.6 10.3 47.8 8.5 50 8.5Z`,star:`M45.77 9.7A5 5 0 0 1 54.23 9.7L65.02 26.81A4 4 0 0 0 67.42 28.55L87.02 33.53A5 5 0 0 1 89.63 41.57L76.7 57.12A4 4 0 0 0 75.78 59.94L77.11 80.12A5 5 0 0 1 70.26 85.09L51.48 77.59A4 4 0 0 0 48.52 77.59L29.74 85.09A5 5 0 0 1 22.89 80.12L24.22 59.94A4 4 0 0 0 23.3 57.12L10.37 41.57A5 5 0 0 1 12.98 33.53L32.58 28.55A4 4 0 0 0 34.98 26.81L45.77 9.7Z`,droid:`M16 50C16 38.95 24.95 30 36 30H64C75.05 30 84 38.95 84 50V70C84 81.05 75.05 90 64 90H36C24.95 90 16 81.05 16 70ZM4 62A7 7 0 1 1 18 62A7 7 0 1 1 4 62ZM82 62A7 7 0 1 1 96 62A7 7 0 1 1 82 62Z`,mech:`M10 48C10 38.06 18.06 30 28 30H72C81.94 30 90 38.06 90 48V70C90 79.94 81.94 88 72 88H28C18.06 88 10 79.94 10 70ZM3 54C3 51.79 4.79 50 7 50H11V72H7C4.79 72 3 70.21 3 68ZM89 50H93C95.21 50 97 51.79 97 54V68C97 70.21 95.21 72 93 72H89Z`,alien:`M50 10C70 10 83 27 83 46C83 65 64 92 50 92C36 92 17 65 17 46C17 27 30 10 50 10Z`,hexagon:`M91.4 45.5A9 9 0 0 1 91.4 54.5L74.6 83.61A9 9 0 0 1 66.8 88.11L33.2 88.11A9 9 0 0 1 25.4 83.61L8.6 54.5A9 9 0 0 1 8.6 45.5L25.4 16.39A9 9 0 0 1 33.2 11.89L66.8 11.89A9 9 0 0 1 74.6 16.39L91.4 45.5Z`,cat:`M50 20A36 36 0 1 1 50 92A36 36 0 1 1 50 20ZM24.72 44.64A4.5 4.5 0 0 1 17.35 40.67L20.21 16.66A4.5 4.5 0 0 1 26.86 13.26L42.3 21.83A4.5 4.5 0 0 1 43.02 29.21L24.72 44.64ZM82.65 40.67A4.5 4.5 0 0 1 75.28 44.64L56.98 29.21A4.5 4.5 0 0 1 57.7 21.83L73.14 13.26A4.5 4.5 0 0 1 79.79 16.66L82.65 40.67Z`,cloud:`M19 44A25 25 0 1 1 69 44A25 25 0 1 1 19 44ZM47 50A21 21 0 1 1 89 50A21 21 0 1 1 47 50ZM7 68A17 17 0 1 1 41 68A17 17 0 1 1 7 68ZM32 73A18 18 0 1 1 68 73A18 18 0 1 1 32 73ZM60 70A16 16 0 1 1 92 70A16 16 0 1 1 60 70Z`,pill:`M28 28H72C84.15 28 94 37.85 94 50C94 62.15 84.15 72 72 72H28C15.85 72 6 62.15 6 50C6 37.85 15.85 28 28 28Z`,pebble:`M94.6 50C94.71 51.92 94.56 53.93 94.17 55.82C93.79 57.7 93.13 59.6 92.28 61.33C91.44 63.06 90.32 64.72 89.1 66.19C87.87 67.67 86.41 69.01 84.92 70.16C83.42 71.31 81.75 72.29 80.11 73.1C78.47 73.92 76.73 74.55 75.06 75.06C73.39 75.58 71.7 75.91 70.1 76.2C68.5 76.48 66.93 76.62 65.45 76.76C63.96 76.9 62.55 76.94 61.2 77.03C59.84 77.11 58.57 77.16 57.31 77.26C56.05 77.36 54.86 77.48 53.64 77.63C52.42 77.79 51.24 77.98 50 78.18C48.76 78.39 47.52 78.64 46.2 78.85C44.89 79.06 43.53 79.3 42.11 79.46C40.69 79.61 39.2 79.75 37.67 79.77C36.14 79.78 34.54 79.74 32.95 79.54C31.35 79.33 29.7 79.03 28.1 78.55C26.49 78.07 24.86 77.45 23.33 76.67C21.8 75.88 20.29 74.94 18.92 73.85C17.54 72.77 16.23 71.51 15.08 70.16C13.94 68.8 12.9 67.29 12.04 65.72C11.17 64.16 10.45 62.46 9.91 60.74C9.36 59.03 8.98 57.22 8.76 55.43C8.55 53.64 8.5 51.8 8.6 50C8.71 48.2 8.98 46.39 9.38 44.65C9.79 42.91 10.35 41.19 11.02 39.56C11.7 37.92 12.52 36.34 13.43 34.85C14.34 33.37 15.39 31.96 16.5 30.66C17.61 29.36 18.84 28.15 20.11 27.07C21.39 25.98 22.76 25 24.15 24.15C25.54 23.3 27.01 22.56 28.48 21.95C29.94 21.33 31.46 20.85 32.95 20.46C34.44 20.08 35.95 19.83 37.43 19.66C38.91 19.48 40.38 19.43 41.81 19.43C43.24 19.43 44.64 19.53 46.01 19.66C47.37 19.78 48.7 19.98 50 20.18C51.3 20.39 52.57 20.63 53.83 20.87C55.1 21.11 56.34 21.37 57.6 21.62C58.87 21.87 60.13 22.12 61.43 22.39C62.74 22.66 64.07 22.93 65.45 23.24C66.83 23.56 68.25 23.88 69.72 24.3C71.19 24.72 72.71 25.17 74.25 25.75C75.78 26.34 77.37 27 78.91 27.81C80.46 28.63 82.04 29.56 83.5 30.66C84.97 31.75 86.43 33 87.7 34.38C88.98 35.77 90.19 37.32 91.17 38.97C92.14 40.62 92.98 42.43 93.56 44.27C94.13 46.1 94.5 48.08 94.6 50Z`,puddle:`M85.34 50C85.65 51.54 85.9 53.13 86.01 54.74C86.11 56.35 86.11 58 85.95 59.63C85.8 61.26 85.51 62.93 85.07 64.52C84.62 66.12 84.03 67.72 83.3 69.23C82.58 70.74 81.7 72.21 80.72 73.57C79.74 74.94 78.62 76.23 77.43 77.43C76.24 78.62 74.93 79.72 73.58 80.73C72.23 81.74 70.79 82.65 69.33 83.48C67.86 84.31 66.34 85.04 64.79 85.71C63.24 86.37 61.65 86.95 60.04 87.46C58.42 87.96 56.77 88.4 55.1 88.75C53.43 89.09 51.72 89.37 50 89.54C48.28 89.71 46.52 89.81 44.76 89.76C43.01 89.72 41.22 89.58 39.47 89.29C37.72 89 35.95 88.58 34.26 88C32.57 87.42 30.89 86.69 29.33 85.8C27.77 84.92 26.26 83.87 24.91 82.7C23.56 81.53 22.3 80.19 21.23 78.77C20.16 77.35 19.22 75.79 18.47 74.2C17.71 72.61 17.13 70.91 16.7 69.23C16.26 67.55 16.02 65.81 15.88 64.13C15.75 62.45 15.78 60.76 15.88 59.14C15.97 57.52 16.21 55.94 16.45 54.42C16.7 52.89 17.03 51.43 17.34 50C17.65 48.57 18 47.2 18.32 45.83C18.63 44.46 18.94 43.13 19.24 41.76C19.53 40.39 19.79 39.03 20.08 37.61C20.36 36.18 20.62 34.74 20.95 33.23C21.28 31.72 21.61 30.16 22.07 28.57C22.52 26.98 23.02 25.32 23.69 23.69C24.35 22.06 25.11 20.38 26.05 18.79C26.99 17.21 28.08 15.62 29.33 14.2C30.58 12.78 32 11.41 33.54 10.26C35.08 9.12 36.8 8.11 38.57 7.35C40.34 6.6 42.27 6.04 44.17 5.73C46.08 5.43 48.08 5.37 50 5.54C51.92 5.71 53.87 6.15 55.69 6.75C57.52 7.36 59.3 8.22 60.94 9.19C62.57 10.15 64.11 11.33 65.51 12.56C66.91 13.78 68.17 15.15 69.33 16.52C70.48 17.89 71.5 19.34 72.44 20.76C73.38 22.18 74.19 23.62 74.97 25.03C75.75 26.43 76.44 27.83 77.12 29.19C77.8 30.56 78.42 31.89 79.05 33.23C79.67 34.57 80.28 35.87 80.87 37.21C81.46 38.55 82.05 39.88 82.6 41.27C83.14 42.65 83.68 44.05 84.14 45.51C84.6 46.96 85.03 48.46 85.34 50Z`},nu={droid:`M47.5 14H52.5V32H47.5ZM43 11A7 7 0 1 1 57 11A7 7 0 1 1 43 11Z`,mech:`M19.5 32L24.5 32L17 13L12 13ZM75.5 32L80.5 32L88 13L83 13ZM10 11.5A4.5 4.5 0 1 1 19 11.5A4.5 4.5 0 1 1 10 11.5ZM81 11.5A4.5 4.5 0 1 1 90 11.5A4.5 4.5 0 1 1 81 11.5Z`};function ru(e){let t=e.trim(),n=t.match(/^hsla?\(\s*([\d.]+)(?:deg)?[,\s]+([\d.]+)%[,\s]+([\d.]+)%/i);if(n)return lu([Number(n[1])/360,Number(n[2])/100,Number(n[3])/100]);let r=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(r){let e=r[1];e.length===3&&(e=e.split(``).map(e=>e+e).join(``));let t=parseInt(e,16);return[t>>16&255,t>>8&255,t&255]}let i=t.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);return i?[Number(i[1]),Number(i[2]),Number(i[3])]:null}function iu(e){let t=ru(e);if(!t)return .5;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*n(t[0])+.7152*n(t[1])+.0722*n(t[2])}var au=`#1E1A33`,ou=`#F7F5F2`;function su(e){return iu(e)<.13?ou:au}function cu([e,t,n]){e/=255,t/=255,n/=255;let r=Math.max(e,t,n),i=Math.min(e,t,n),a=(r+i)/2;if(r===i)return[0,0,a];let o=r-i,s=a>.5?o/(2-r-i):o/(r+i),c=0;return c=r===e?(t-n)/o+(t<n?6:0):r===t?(n-e)/o+2:(e-t)/o+4,[c/6,s,a]}function lu([e,t,n]){if(t===0)return[n*255,n*255,n*255];let r=n<.5?n*(1+t):n+t-n*t,i=2*n-r,a=e=>(e=(e%1+1)%1,e<1/6?i+(r-i)*6*e:e<1/2?r:e<2/3?i+(r-i)*(2/3-e)*6:i);return[a(e+1/3)*255,a(e)*255,a(e-1/3)*255]}function uu([e,t,n]){return`hsl(${(e*360).toFixed(1)} ${(t*100).toFixed(1)}% ${(n*100).toFixed(1)}%)`}var du=e=>Math.min(1,Math.max(0,e));function fu(e,t,n=0){let r=ru(e);if(!r)return e;let[i,a,o]=cu(r);return uu([i,du(a+n+(t<0?-t*.25:0)),du(o+t)])}var pu=[`default`,`working`,`sleeping`],mu=.68,hu=26,gu=.2,_u={height:hu,time:mu,stretch:1,squash:1.15,squashTime:.37,squashEase:`pulse`,groundTime:.11,groundEase:`pulse`,riseTime:.33,riseEase:`pulse`,clickSquashTime:.24,spin:1,lean:6,every:8,land:0},vu=(e,t)=>t?e.clickSquashTime:gu*e.time,yu=(e,t)=>vu(e,t)+e.time+bu[e.squashEase]*(t?e.clickSquashTime:e.squashTime)+Math.max(0,e.groundTime)+e.riseTime+Math.max(0,e.land)+.05,bu={sharp:0,pulse:2/7,soft:.5,bouncy:.144},xu=(e,t)=>{if(e<=0)return 1;if(e>=1)return 0;switch(t){case`sharp`:return(1-e)*(1-e);case`soft`:return .5+.5*Math.cos(Math.PI*e);case`bouncy`:return Math.exp(-3.2*e)*Math.cos(5.4*e)-e*e*e*.026;default:{let t=4.2*e;return(1+t)*Math.exp(-t)-e*e*e*.078}}},Su=(e,t)=>1+.25*Cu(e,t),Cu=(e,t)=>{if(e<=0||e>=1)return 0;let n;switch(t){case`sharp`:n=(1-e)*(1-e);break;case`soft`:n=Math.sin(Math.PI*e)**2;break;case`bouncy`:n=Math.exp(-3.15*e)*Math.sin(8.43*e)/.596;break;default:{let t=7*e;n=t*t*Math.exp(2-t)/4}}let r=e>.85?1-(e-.85)/.15:1;return n*r*r*(3-2*r)},wu=e=>Math.exp(-((Math.min(Math.abs(e),Math.abs(e-1))/.11)**2)),Tu=Math.PI/180,Eu=Math.PI*2,Du={default:1.2,working:.7,sleeping:1.4},Ou=1;function ku(e){let t=e*2654435761>>>0||1;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function Au(e,t,n,r){return e+(t-e)*(1-Math.exp(-n*r))}var ju=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,Mu=e=>.5-.5*Math.cos(Math.PI*e),Nu=class{constructor(e,t,n,r,i,a=!1){this.rand=e,this.amp=t,this.holdMin=n,this.holdMax=r,this.rate=i,this.spring=a,this.value=0,this.vel=0,this.target=0,this.next=0}update(e,t){if(e>=this.next&&(this.target=(this.rand()*2-1)*this.amp,this.next=e+this.holdMin+this.rand()*(this.holdMax-this.holdMin)),this.spring){let e=this.rate*1.6;this.vel+=(e*e*(this.target-this.value)-1.8*e*this.vel)*t,this.value+=this.vel*t}else this.value=Au(this.value,this.target,this.rate,t)}aim(e){this.target=e,this.next=1/0}set(e,t,n,r){this.amp=e,this.holdMin=t,this.holdMax=n,this.rate=r,this.next=0}},Pu=class{constructor(e){this.duration=e,this.p=-1}fire(){this.p=0}get active(){return this.p>=0}update(e){this.p<0||(this.p+=e/this.duration,this.p>=1&&(this.p=-1))}},Fu=35*Tu,Iu=14*Tu,Lu=3.2*Tu,Ru=2.6,zu={default:{pitch:0,roll:0,y:0,lookX:0,lookY:0},working:{pitch:5*Tu,roll:0,y:0,lookX:0,lookY:0},sleeping:{pitch:-16*Tu,roll:6*Tu,y:3,lookX:0,lookY:1}},Bu=class{constructor(e,t=`default`){this.pose={yaw:0,pitch:0,roll:0,x:0,y:0,sx:1,sy:1,eyeOpen:1,blinkL:0,blinkR:0,lookX:0,lookY:0,breath:0,laugh:0,whirl:0,whirlAngle:0,w:[1,0,0]},this.state=`default`,this.t=0,this.wFrom=[1,0,0],this.tr=1,this.trDuration=1.2,this.blink=new Pu(.17),this.blinkAgain=!1,this.dart=new Pu(.12),this.dartX=0,this.dartY=0,this.flip=new Pu(yu(_u,!1)),this.flipPoked=!1,this.jump={..._u},this.flipSide=1,this.nod=new Pu(1.7),this.hopPhase=0,this.hopCount=0,this.hopGain=0,this.laughEv=new Pu(.8),this.prevYaw=0,this.jelly=0,this.jellyV=0,this.gazeLead=0,this.gazeDir=[0,0],this.gazeAt=0,this.turnK=1,this.breathPhase=0,this.ptrX=0,this.ptrY=0,this.ptrS=0,this.ptrTargetX=0,this.ptrTargetY=0,this.ptrTargetS=0,this.baseYaw=0,this.rand=ku(Math.floor(e*1e6)+1);let n=this.rand;this.yawW=new Nu(n,36*Tu,1.1,2.6,3,!0),this.pitchW=new Nu(n,10*Tu,1.1,2.6,2.6,!0),this.rollW=new Nu(n,5*Tu,1.6,3.2,2,!0),this.lookXW=new Nu(n,3.6,.5,2,14),this.lookYW=new Nu(n,2.4,.5,2,14),this.t=n()*10,this.hopPhase=n(),this.breathPhase=n(),this.blinkAt=this.t+1+n()*3,this.flipAt=this.nextFlip(this.t,1),this.nodAt=this.t+3+n()*4,this.dartAt=this.t+1+n()*2,this.laughAt=this.t+.6+n()*1.5,this.setState(t,!0)}setState(e,t=!1){if(e===this.state&&!t)return;let n=this.state;this.state=e;let r=this.pose.w;if(t){for(let t=0;t<3;t++)r[t]=+(pu[t]===e);this.tr=1}else this.wFrom=[r[0],r[1],r[2]],this.tr=0,this.trDuration=n===`sleeping`?Ou:Du[e];switch(e){case`default`:this.yawW.set(Fu,2.6,5.4,2),this.pitchW.set(Iu,2.8,5.8,1.8),this.rollW.set(Lu,3.4,6.6,1.5),this.gazeAt=0,this.gazeDir=[0,0],this.lookXW.set(3.6,.6,2.2,13),this.lookYW.set(2.4,.6,2.2,13),this.flipAt=this.nextFlip(this.t,.6);break;case`working`:this.yawW.set(16*Tu,.9,1.8,4),this.pitchW.set(3*Tu,1.2,2.4,3),this.rollW.set(0,1,2,3),this.lookXW.set(2,.5,1.2,12),this.lookYW.set(1,.5,1.2,12),this.hopPhase=0,this.hopCount=0,this.laughAt=this.t+.5+this.rand()*1.2;break;case`sleeping`:this.yawW.set(7*Tu,3,6,.7),this.pitchW.set(3*Tu,3,6,.7),this.rollW.set(2*Tu,3,6,.6),this.lookXW.set(0,2,4,2),this.lookYW.set(0,2,4,2),this.nodAt=this.t+2.5+this.rand()*4}}setPointer(e,t,n){this.ptrTargetX=Math.max(-1.2,Math.min(1.2,e)),this.ptrTargetY=Math.max(-1.2,Math.min(1.2,t)),this.ptrTargetS=Math.max(0,Math.min(1,n))}poke(){this.flip.active&&this.flip.p<.6||(this.flipPoked=!0,this.flip.duration=yu(this.jump,!0),this.flipSide=this.rand()<.5?-1:1,this.flip.fire(),this.flipAt=this.nextFlip(this.t,1.1))}setTurn(e){let t=Math.max(0,e);t!==this.turnK&&(this.turnK=t,this.state==="default"&&(this.gazeAt=0))}setJump(e){let t=this.jump.every;Object.assign(this.jump,e),e.every!==void 0&&e.every!==t&&(this.flipAt=this.nextFlip(this.t,1))}nextGaze(){let e=this.rand,[t,n]=this.gazeDir;if(t!==0||n!==0){let r=e();return r<.66?[-t,-n]:r<.85?[-t,n]:[0,0]}let r=[[1,-1],[-1,1],[-1,-1],[1,1]];return r[Math.floor(e()*r.length)]}nextFlip(e,t){let n=this.jump.every;return n>0?e+n*t*(.625+this.rand()*.75):1/0}update(e){e=Math.min(e,.05),this.t+=e;let t=this.t,n=this.pose,r=n.w;if(this.tr<1){this.tr=Math.min(1,this.tr+e/this.trDuration);let t=Mu(this.tr);for(let e=0;e<3;e++){let n=+(pu[e]===this.state);r[e]=this.wFrom[e]+(n-this.wFrom[e])*t}}let[i,a,o]=r,s={pitch:0,roll:0,y:0,lookX:0,lookY:0};for(let e=0;e<3;e++){let t=zu[pu[e]];s.pitch+=t.pitch*r[e],s.roll+=t.roll*r[e],s.y+=t.y*r[e],s.lookX+=t.lookX*r[e],s.lookY+=t.lookY*r[e]}if(this.state==="default"&&t>=this.gazeAt){let[e,n]=this.nextGaze();this.gazeDir=[e,n];let r=.84+this.rand()*.16;this.yawW.aim(e*Fu*r*this.turnK),this.pitchW.aim(n*Iu*r),this.rollW.aim(e*Lu*r*this.turnK),this.gazeAt=t+Ru+this.rand()*1.8000000000000003}this.yawW.update(t,e),this.pitchW.update(t,e),this.rollW.update(t,e),this.lookXW.update(t,e),this.lookYW.update(t,e),this.ptrS=Au(this.ptrS,this.ptrTargetS,8,e),this.ptrX=Au(this.ptrX,this.ptrTargetX,14,e),this.ptrY=Au(this.ptrY,this.ptrTargetY,14,e);let c=this.ptrS,l=1-.75*c;this.baseYaw=Au(this.baseYaw,this.yawW.value*l+22*Tu*this.ptrX*c,5,e);let u=s.pitch+this.pitchW.value*l-12*Tu*this.ptrY*c,d=s.roll+this.rollW.value*l,f=s.y,p=s.lookX+this.lookXW.value*l+4.5*this.ptrX*c,m=s.lookY+this.lookYW.value*l+3*this.ptrY*c,h=0,g=0,_=1,v=1,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0,D=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)},O=e=>D(.1,.26,e)*(1-D(.66,.9,e)),k=e=>Eu*(1.5*e+.9*ju(e));if(t>=this.blinkAt&&!this.blink.active&&i+a>.5&&(this.blink.fire(),this.blinkAgain=!this.blinkAgain&&this.rand()<.22,this.blinkAt=t+(this.blinkAgain?.28:2.2+this.rand()*2.6)),this.blink.update(e),this.blink.active&&(x=Math.sin(Math.PI*this.blink.p)),t>=this.dartAt&&!this.dart.active&&i+a>.5&&(this.dart.fire(),this.dartX=(this.rand()*2-1)*4,this.dartY=(this.rand()*2-1)*2,this.dart.duration=.25+this.rand()*.45,this.dartAt=t+1.2+this.rand()*2.6),this.dart.update(e),this.dart.active){let e=this.dart.p,t=e<.15?e/.15:e>.8?(1-e)/.2:1;S+=this.dartX*t*(i+a),C+=this.dartY*t*(i+a)}if(this.state==="default"&&t>=this.flipAt&&!this.flip.active&&(this.flipPoked=!1,this.flip.duration=yu(this.jump,!1),this.flipSide=this.rand()<.5?-1:1,this.flip.fire(),this.flipAt=this.nextFlip(t,1)),this.flip.update(e),this.flip.active){let e=this.jump,t=vu(e,this.flipPoked),n=(this.flip.p*this.flip.duration-t)/e.time,r=Math.min(1,Math.max(0,n)),i=Math.sin(Math.PI*r);h+=Eu*e.spin*ju(r),g-=e.height*i;let a=(n-1)*e.time-e.land,o=this.flipPoked?e.clickSquashTime:e.squashTime,s=e=>this.flipPoked?e*e*(3-2*e):wu(e-1),c=Math.max(0,e.groundTime),l=bu[e.squashEase]*o,u=a-l-c,d=a<=l?Cu(a/o,e.squashEase):u<=0?Su((a-l)/c,e.groundEase):xu(u/e.riseTime,e.riseEase),f=(n<0?s(Math.max(0,1+n*e.time/t)):a>0?d:n<.2?wu(n):0)*e.squash;_+=.16*f-.06*i*e.stretch,v+=-.18*f+.09*i*e.stretch,b+=this.flipSide*e.lean*Tu*i,e.spin>0&&(w=Math.max(w,i),T=Math.max(T,O(r)),E=k(r))}let A=this.jump,j=Math.max(0,A.groundTime),M=j+A.riseTime;if(this.state===`working`&&(this.hopGain=a),this.hopGain>.02&&(this.state===`working`||this.hopPhase>0)){this.hopPhase+=e/mu,this.hopPhase>=1&&(this.state===`working`?(--this.hopPhase,this.hopCount+=1):(this.hopPhase-1)*mu>=M&&(this.hopPhase=0,this.hopGain=0));let t=this.hopGain,n=Math.min(1,this.hopPhase),r=Math.sin(Math.PI*n),i=this.hopCount%3==2;g-=(i?hu:18)*r*t;let a=this.state!==`working`&&this.hopPhase>1?(this.hopPhase-1)*mu:-1,o=a<0?wu(this.hopPhase):a<j?Su(a/j,A.groundEase):xu((a-j)/A.riseTime,A.riseEase);_+=(.16*o-.06*r)*t,v+=(-.18*o+.09*r)*t,i&&(h+=Eu*ju(n)*t,w=Math.max(w,r*t),O(n)*t>T&&(T=O(n)*t,E=k(n))),b+=(this.hopCount%2==0?1:-1)*6*Tu*r*t}if(this.state===`working`&&t>=this.laughAt&&!this.laughEv.active&&(this.laughEv.fire(),this.laughEv.duration=.6+this.rand()*.5,this.laughAt=t+1.6+this.rand()*2.2),this.laughEv.update(e),this.laughEv.active){let e=this.laughEv.p;w=Math.max(w,e<.18?e/.18:e>.78?(1-e)/.22:1)}if(this.state===`sleeping`&&t>=this.nodAt&&!this.nod.active&&(this.nod.fire(),this.nodAt=t+4+this.rand()*4),this.nod.update(e),this.nod.active){let e=this.nod.p,t=e<.72?ju(e/.72):1-ju((e-.72)/.28);y-=13*Tu*t*o}this.breathPhase+=e/(3.6+1.2*o);let N=Math.sin(this.breathPhase*Eu);n.breath=N,_+=N*(.008+.014*o),v+=N*(.012+.02*o);let P=Math.sin(t*Eu/3.4)*2*(1-o);n.yaw=this.baseYaw+h;let F=this.baseYaw-this.prevYaw;F=((F+Math.PI)%Eu+Eu)%Eu-Math.PI,this.prevYaw=this.baseYaw;let I=e>0?Math.abs(F)/e:0,L=e>0?Math.max(-2.2,Math.min(2.2,F/e*2.4)):0;this.gazeLead=Au(this.gazeLead,L,9,e);let R=Math.min(.22,.055*I);this.jellyV+=(256*(R-this.jelly)-14.4*this.jellyV)*e,this.jelly+=this.jellyV*e;let z=Math.max(-.08,Math.min(.28,this.jelly))*.6;_*=1+z,v*=1-.55*z,n.pitch=u+y,n.roll=d+b,n.x=0,n.y=f+g+P,n.sx=_,n.sy=v,n.eyeOpen=1,n.laugh=Au(n.laugh,w,30,e),n.blinkL=x,n.blinkR=x,n.lookX=p+S+this.gazeLead,n.lookY=m+C,n.whirl=T,n.whirlAngle=E}};function Vu(e){let t=zu[e];return{yaw:0,pitch:t.pitch,roll:t.roll,x:0,y:t.y,sx:1,sy:1,eyeOpen:1,blinkL:0,blinkR:0,lookX:t.lookX,lookY:t.lookY,breath:0,laugh:0,whirl:0,whirlAngle:0,w:pu.map(t=>+(t===e))}}var Hu=64,Uu=4096,Wu=24,Gu=0xe8d4a51000,Ku=48*Math.PI/180,qu=Math.cos(Ku),Ju=Math.sin(Ku),Yu=(e,t)=>t+(1-t)*Math.sqrt(Math.max(0,1-e*e));function Xu(e,t,n,r,i,a){let o=0;i[0]=0,a[0]=-1e30,a[1]=1e30;for(let n=1;n<t;n++){let t=0;for(;;){let r=i[o];if(t=(e[n]+n*n-e[r]-r*r)/(2*(n-r)),t>a[o])break;o--}o++,i[o]=n,a[o]=t,a[o+1]=1e30}o=0;for(let s=0;s<t;s++){for(;a[o+1]<s;)o++;let t=i[o];n[s]=(s-t)*(s-t)+e[t],r[s]=t}}function Zu(e,t,n,r,i){let a=new Float32Array(n),o=new Float32Array(n),s=new Int32Array(n),c=new Int32Array(n),l=new Float32Array(n+1),u=new Float32Array(n*n),d=new Int32Array(n*n);for(let r=0;r<n;r++){for(let i=0;i<n;i++)a[i]=e[i*n+r]===t?0:Gu;Xu(a,n,o,s,c,l);for(let e=0;e<n;e++)u[e*n+r]=o[e],d[e*n+r]=s[e]}for(let e=0;e<n;e++){let t=e*n;for(let e=0;e<n;e++)a[e]=u[t+e];Xu(a,n,o,s,c,l);for(let e=0;e<n;e++)r[t+e]=o[e],i&&(i[t+e]=d[t+s[e]]*n+s[e])}}function Qu(e,t,n){for(let r=0;r<t;r++){let i=r*t;for(let r=0;r<t;r++){let a=r<2?0:r-2,o=r<1?0:r-1,s=r>t-2?t-1:r+1,c=r>t-3?t-1:r+2;n[i+r]=(e[i+a]+4*e[i+o]+6*e[i+r]+4*e[i+s]+e[i+c])*.0625}}for(let r=0;r<t;r++)for(let i=0;i<t;i++){let a=i<2?0:i-2,o=i<1?0:i-1,s=i>t-2?t-1:i+1,c=i>t-3?t-1:i+2;e[i*t+r]=(n[a*t+r]+4*n[o*t+r]+6*n[i*t+r]+4*n[s*t+r]+n[c*t+r])*.0625}}function $u(e,t,n){let r=[];for(let n=t,i=1;i<=4&&n%2==0||i===1;n>>=1,i<<=1){let a=new Uint8Array(n*n);for(let r=0;r<n;r++)for(let o=0;o<n;o++){let s=0;for(let n=0;n<i;n++)for(let a=0;a<i;a++)s+=e[(r*i+n)*t+o*i+a];a[r*n+o]=+(s>=128*i*i)}if(r.push({n,mask:a,phi:new Float32Array(n*n)}),i===4)break}let i=(e,t,n,r)=>{let{n:i,mask:a,phi:o}=e,s=t*t;for(let e=0;e<n;e++)for(let e=1;e<i-1;e++){let t=e*i;for(let e=1;e<i-1;e++){let n=t+e;if(!a[n])continue;let c=(o[n-1]+o[n+1]+o[n-i]+o[n+i]+s)*.25;o[n]+=r*(c-o[n])}}};for(let e=r.length-1;e>=0;e--){let t=r[e],a=1<<e;if(e<r.length-1){let n=r[e+1],i=t.n,a=n.n;for(let e=0;e<i;e++){let r=Math.min(a-1,Math.max(0,(e+.5)/2-.5)),o=r|0,s=Math.min(a-1,o+1),c=r-o;for(let r=0;r<i;r++){let l=e*i+r;if(!t.mask[l])continue;let u=Math.min(a-1,Math.max(0,(r+.5)/2-.5)),d=u|0,f=Math.min(a-1,d+1),p=u-d;t.phi[l]=(n.phi[o*a+d]*(1-p)+n.phi[o*a+f]*p)*(1-c)+(n.phi[s*a+d]*(1-p)+n.phi[s*a+f]*p)*c}}}let o=Math.min(1.9,2/(1+Math.sin(Math.PI/t.n))-.05);i(t,n*a,4,1),i(t,n*a,e===2?100:e===1?30:16,o),i(t,n*a,8,1)}return r[0].phi}var ed=[1,1,0,-1,-1,-1,0,1],td=[0,1,1,1,0,-1,-1,-1],nd=[1,Math.SQRT2,1,Math.SQRT2,1,Math.SQRT2,1,Math.SQRT2];function rd(e,t,n){let r=106/t,i=t*t,a=new Uint8Array(i);for(let t=0;t<i;t++)a[t]=+(e[t]>=128);let o=new Float32Array(i),s=new Float32Array(i),c=new Int32Array(i);Zu(a,0,t,o,null),Zu(a,1,t,s,c);let l=new Float32Array(i),u=new Float32Array(i);for(let t=0;t<i;t++){let n=e[t]/255;l[t]=r*(n>0&&n<1?n-.5:a[t]?Math.sqrt(o[t])-.5:.5-Math.sqrt(s[t]))}Qu(l,t,u),Qu(l,t,u);let d=$u(e,t,r),f=0;for(let e=0;e<i;e++)d[e]>f&&(f=d[e]);let p=2*Math.sqrt(f),m=Math.min(.9*n+.12*p,1.2*p),h=f>0?m/Math.sqrt(f):0,g=new Float32Array(i);for(let e=0;e<i;e++)g[e]=d[e]>0?h*Math.sqrt(d[e]):0;Qu(g,t,u);let _={N:t,i00:new Uint16Array(i),wx:new Uint8Array(i),wy:new Uint8Array(i),ao:new Uint8Array(i)},{i00:v,wx:y,wy:b,ao:x}=_,S=t<=64?[1,2,3,5,8]:t<=96?[1,2,4,7,11]:[1,2,4,7,11,15],C=t-1;for(let e=0;e<t;e++)for(let n=0;n<t;n++){let i=e*t+n,o=a[i]?i:s[i]<=9?c[i]:-1;if(o<0)continue;let u=o%t,d=(o-u)/t,f=u>0?u-1:0,p=u<C?u+1:C,m=d>0?d-1:0,h=d<C?d+1:C,_=-(g[d*t+p]-g[d*t+f])/(2*r),w=-(g[h*t+u]-g[m*t+u])/(2*r),T=1,E=Math.sqrt(_*_+w*w+1);_/=E,w/=E,T/=E;let D=Math.max(0,l[o]);if(D<2){let e=l[d*t+p]-l[d*t+f],n=l[h*t+u]-l[m*t+u],r=Math.hypot(e,n)||1;e/=r,n/=r;let i=.7*(1-D/2);_+=i*(-e-_),w+=i*(-n-w),T+=i*(0-T),E=Math.sqrt(_*_+w*w+T*T)||1,_/=E,w/=E,T/=E}let O=g[o],k=0;for(let e=0;e<8;e++){let n=0;for(let i=0;i<S.length;i++){let a=S[i],o=u+ed[e]*a,s=d+td[e]*a;o<0?o=0:o>C&&(o=C),s<0?s=0:s>C&&(s=C);let c=(g[s*t+o]-O)/(a*r*nd[e]);c>n&&(n=c)}k+=n/Math.sqrt(1+n*n)}let A=1-Math.min(1,D/3),j=1-.2*A*A,M=(1-.9*k/8)**1.5*j;x[i]=Math.max(1,Math.round(255*M**(1/2.2)));let N=(_*.5+.5)*63,P=(w*.5+.5)*63,F=Math.min(62,Math.max(0,N|0)),I=Math.min(62,Math.max(0,P|0));v[i]=I*Hu+F,y[i]=Math.round(255*Math.min(1,Math.max(0,N-F))),b[i]=Math.round(255*Math.min(1,Math.max(0,P-I)))}return _}function id(e){if(typeof OffscreenCanvas==`function`)return new OffscreenCanvas(e,e);if(typeof document<`u`){let t=document.createElement(`canvas`);return t.width=t.height=e,t}return null}function ad(e,t){return e.getContext(`2d`,t?{willReadFrequently:!0}:void 0)}function od(e,t){let n=id(t),r=n&&ad(n,!0);if(!r)return null;let i=106/t;r.setTransform(1/i,0,0,1/i,3/i,3/i),r.fillStyle=`#fff`,r.fill(e);let a=r.getImageData(0,0,t,t).data,o=new Uint8ClampedArray(t*t);for(let e=0;e<t*t;e++)o[e]=a[e*4+3];return o}var sd=new Map,cd=new Set,ld=new WeakMap,ud=0;function dd(e){let t=ld.get(e);return t||ld.set(e,t=`p${ud++}`),t}var fd=[],pd=!1;function md(){pd=!1;let e=fd.shift();e&&e(),fd.length&&hd()}function hd(){if(pd)return;pd=!0;let e=globalThis.requestIdleCallback;e?e(md,{timeout:120}):setTimeout(md,16)}function gd(e){fd.push(e),hd()}function _d(e,t,n,r,i){let a=`${e}|${n}|${Math.round(r)}`,o=sd.get(a);if(o)return o;let s=()=>{if(cd.delete(a),sd.has(a))return;let e=od(t,n);e&&(sd.size>=48&&sd.clear(),sd.set(a,rd(e,n,r)))};return i?(s(),sd.get(a)??null):(cd.has(a)||(cd.add(a),gd(s)),null)}function vd(e,t,n=192,r=.65){_d(e,t,yd(n),15*r,!0)}function yd(e){return e<=100?64:e<=224?96:128}var bd=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,xd=new Map;function Sd(e){let t=xd.get(e);if(!t){let n=ru(e);if(!n){let t=id(1),r=t&&ad(t,!0);if(r){r.fillStyle=e,r.fillRect(0,0,1,1);let t=r.getImageData(0,0,1,1).data;n=[t[0],t[1],t[2]]}else n=[128,128,128]}t=[bd(n[0]/255),bd(n[1]/255),bd(n[2]/255)],xd.size>200&&xd.clear(),xd.set(e,t)}return t}var Cd=2048,wd=2.5,Td=Cd/wd,Ed=new Float32Array(Cd);for(let e=0;e<Cd;e++){let t=(e+.5)/Td,n=t<=.75?t:.75+.25*(1-Math.exp(-(t-.75)/.25));Ed[e]=255*(n<=.0031308?12.92*n:1.055*n**(1/2.4)-.055)}var Dd=e=>Ed[e<=0?0:e>=wd?2047:e*Td|0],Od=1024,kd=new Map;function Ad(e){let t=kd.get(e);if(!t){t=new Float32Array(1025);for(let n=0;n<=Od;n++)t[n]=(n/Od)**+e;kd.size>16&&kd.clear(),kd.set(e,t)}return t}var jd=[.92,.96,1],Md=[1,.98,.95],Nd=(e,t,n)=>{let r=n<=e?0:n>=t?1:(n-e)/(t-e);return r*r*(3-2*r)},Pd=(e,t,n)=>1-Nd(e-t,e+t,n);function Fd(e,t,n,r){let{L:i,V:a,H:o,U:s,W:c,A:l,B:u}=n,d=Math.max(t[0],t[1],t[2],.05),f=[t[0]/d,t[1]/d,t[2]/d],p=Math.max(.03,.3-.15*r.shadow),m=.15+.14*r.spread,h=.85,g=Math.min(90,Math.round(110/r.spread**1.3)),_=Math.max(2,Math.round(8/r.spread)),v=Ad(g),y=Ad(_),b=.45*r.highlight,x=.1*r.highlight,S=.11*r.highlight,C=.3*r.rim,w=[p*f[0],p*f[1],p*f[2]];for(let n=0;n<Hu;n++)for(let r=0;r<Hu;r++){let d=r/63*2-1,f=n/63*2-1,p=d*d+f*f;if(p>1.14)continue;if(p>1){let e=1/Math.sqrt(p);d*=e,f*=e,p=1}let g=Math.sqrt(1-p),_=d*i[0]+f*i[1]+g*i[2],T=Math.max(0,d*a[0]+f*a[1]+g*a[2]),E=Math.max(0,d*o[0]+f*o[1]+g*o[2]),D=Math.min(1,Math.max(0,(_+m)/(1+m))),O=1-T,k=O*O,A=k*O,j=A*k,M=E*Od|0,N=(b*v[M]+x*y[M])*(1+3*j),P=2*T*d-a[0],F=2*T*f-a[1],I=2*T*g-a[2],L=.45+.55*Nd(-.4,.6,P*s[0]+F*s[1]+I*s[2]),R=P*c[0]+F*c[1]+I*c[2],z=0;if(R>.5){let e=(P*l[0]+F*l[1]+I*l[2])/R,t=(P*u[0]+F*u[1]+I*u[2])/R;z=Pd(.34,.12,Math.abs(e))*Pd(.12,.06,Math.abs(t))}let B=C*A*L+S*z,V=(n*Hu+r)*3;e[V]=Dd(t[0]*(w[0]+h*D)+N*Md[0]+B*jd[0]),e[V+1]=Dd(t[1]*(w[1]+h*D)+N*Md[1]+B*jd[1]),e[V+2]=Dd(t[2]*(w[2]+h*D)+N*Md[2]+B*jd[2])}}function Id(e,t,n,r){let i=(t*.5+.5)*63,a=(n*.5+.5)*63,o=Math.min(62,Math.max(0,i|0)),s=Math.min(62,Math.max(0,a|0)),c=i-o,l=a-s,u=(s*Hu+o)*3,d=(1-c)*(1-l),f=c*(1-l),p=(1-c)*l,m=c*l;for(let t=0;t<3;t++)r[t]=e[u+t]*d+e[u+3+t]*f+e[u+192+t]*p+e[u+192+3+t]*m}function Ld(e,t,n,r){let{N:i,i00:a,wx:o,wy:s,ao:c}=e;for(let e=0,l=0;e<i*i;e++,l+=4){let i=c[e];if(i===0){n[l+3]=0;continue}let u=r[i],d=a[e]*3,f=o[e]*(1/255),p=s[e]*(1/255),m=(1-f)*(1-p)*u,h=f*(1-p)*u,g=(1-f)*p*u,_=f*p*u;n[l]=t[d]*m+t[d+3]*h+t[d+192]*g+t[d+192+3]*_,n[l+1]=t[d+1]*m+t[d+4]*h+t[d+192+1]*g+t[d+192+4]*_,n[l+2]=t[d+2]*m+t[d+5]*h+t[d+192+2]*g+t[d+192+5]*_,n[l+3]=255}}var Rd=e=>{let t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function zd(e){let t=Math.cos(e.roll),n=Math.sin(e.roll),r=t*e.lx+n*e.ly,i=-n*e.lx+t*e.ly,a=e.facing<0?-1:1,o=a*Math.min(1,Math.abs(e.facing)/.16),{cy:s,sy:c,cp:l,sp:u}=e,d=(e,t,n,r=o)=>Rd([s*e+c*u*t-c*l*n,l*t+u*n,r*(c*e-s*u*t+s*l*n)]),f=d(qu*r,qu*i,Ju),p=d(0,0,1,a),m=Rd([f[0]+p[0],f[1]+p[1],f[2]+p[2]]),h=d(r,i,0,a),g=Math.cos(80*Math.PI/180),_=Math.sin(80*Math.PI/180),v=g*r-_*i,y=_*r+g*i,b=Rd([.55*v,.55*y,.83]),x=Rd([b[1],-b[0],0]),S=[b[1]*x[2]-b[2]*x[1],b[2]*x[0]-b[0]*x[2],b[0]*x[1]-b[1]*x[0]];return{L:f,V:p,H:m,U:h,W:d(b[0],b[1],b[2],a),A:d(x[0],x[1],x[2],a),B:d(S[0],S[1],S[2],a)}}var Bd=new WeakMap;function Vd(e,t){let n=e.canvas??e,r=Bd.get(n);r||(r=new Map,Bd.set(n,r));let i=r.get(t);return i||(i={N:0,img:null,mc:new Float32Array(Uu*3),mcPrev:new Float32Array(Uu*3),mcMix:new Float32Array(Uu*3),mixVersion:0,blendT:1,blendFrames:1,sinceBuild:0,L:null,V:null,lx:NaN,ly:NaN,base:``,shadow:NaN,highlight:NaN,spread:NaN,rim:NaN,version:0,imgVersion:-1,imgAoK:NaN,imgForm:null,aoK:-1,aoMul:new Float32Array(256),near:null,rimG:null,far:null,scratch:[null,null],scratchIdx:0,scratchN:0,scratchStale:!0,sprites:[null,null,null],spriteVersion:-1,spritePx:0},r.size>4&&r.clear(),r.set(t,i)),i}var Hd=1/48,Ud=(e,t)=>!t||Math.abs(e[0]-t[0])>=Hd||Math.abs(e[1]-t[1])>=Hd||Math.abs(e[2]-t[2])>=Hd;function Wd(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}function Gd(e,t,n,r,i){let a=Math.sqrt(1-n*n),o=[0,0,0],s=1-r;if(typeof e.createConicGradient==`function`){let n=e.createConicGradient(0,50,50);for(let e=0;e<=Wu;e++){let r=e/Wu*Math.PI*2;Id(t,a*Math.cos(r),a*Math.sin(r),o),n.addColorStop(e/Wu,`rgb(${o[0]*s|0} ${o[1]*s|0} ${o[2]*s|0})`)}return n}let c=e.createLinearGradient(50+i[0]*50,50+i[1]*50,50-i[0]*50,50-i[1]*50),l=(e,n,r)=>{Id(t,e,n,o),c.addColorStop(r,`rgb(${o[0]*s|0} ${o[1]*s|0} ${o[2]*s|0})`)};return l(a*i[0],a*i[1],0),l(-a*i[1],a*i[0],.5),l(-a*i[0],-a*i[1],1),c}var Kd=typeof navigator<`u`&&/AppleWebKit\//.test(navigator.userAgent)&&!/Chrome\/|Chromium\/|Edg\//.test(navigator.userAgent),qd=[[.55,()=>0],[0,()=>0],[0,e=>Math.min(.6,.25*e.shadow)]];function Jd(e,t,n,r,i,a){let o=yd(n.dev),s=_d(t.typeKey??dd(t.path),t.path,o,n.halfDepth,!!n.still);if(!s)return!1;let c=Vd(e,t.typeKey??dd(t.path)),l=zd(n),u=(()=>{let e=Math.hypot(l.L[0],l.L[1]);return e<.05?[0,-1]:[l.L[0]/e,l.L[1]/e]})();if((Ud(l.L,c.L)||Ud(l.V,c.V)||n.lx!==c.lx||n.ly!==c.ly||r.base!==c.base||a.shadow!==c.shadow||a.highlight!==c.highlight||a.spread!==c.spread||a.rim!==c.rim)&&(c.version>0&&c.mcPrev.set(c.mcMix),Fd(c.mc,Sd(r.base),l,a),c.version===0?(c.mcMix.set(c.mc),c.blendT=1):(c.blendFrames=Math.min(10,Math.max(1,c.sinceBuild)),c.blendT=0),c.sinceBuild=0,c.mixVersion++,c.L=l.L,c.V=l.V,c.lx=n.lx,c.ly=n.ly,c.base=r.base,c.shadow=a.shadow,c.highlight=a.highlight,c.spread=a.spread,c.rim=a.rim,c.version++,c.near=c.rimG=c.far=null),c.sinceBuild++,c.blendT<1){c.blendT=Math.min(1,c.blendT+1/c.blendFrames);let e=c.blendT>=1?1:c.blendT*c.blendT*(3-2*c.blendT),t=c.mcPrev,n=c.mc,r=c.mcMix;for(let i=0;i<Uu*3;i++)r[i]=t[i]+(n[i]-t[i])*e;c.mixVersion++}let d=Math.min(1.3,1.2*a.shadow);if(d!==c.aoK){for(let e=0;e<256;e++)c.aoMul[e]=Math.max(0,1-d*(1-e/255));c.aoK=d}if((!c.img||c.N!==o)&&(c.img=new ImageData(o,o),c.N=o,c.imgVersion=-1),(c.imgVersion!==c.mixVersion||c.imgAoK!==d||c.imgForm!==s)&&(Ld(s,c.mcMix,c.img.data,c.aoMul),c.imgVersion=c.mixVersion,c.imgAoK=d,c.imgForm=s,c.scratchStale=!0),c.scratchN!==o&&(c.scratch=[null,null],c.scratchN=o,c.scratchStale=!0),c.scratchStale){c.scratchIdx^=1;let e=c.scratch[c.scratchIdx];if(!e){let t=id(o),n=t&&ad(t,!1);if(!t||!n)return!1;e=c.scratch[c.scratchIdx]={c:t,g:n}}e.g.putImageData(c.img,0,0),c.scratchStale=!1}let f=c.scratch[c.scratchIdx],p=t.sides===`sprite`||t.sides!==`vector`&&Kd;if(p){let e=Math.ceil(106*n.dev/100);if(c.spritePx!==e&&(c.sprites=[null,null,null],c.spritePx=e,c.spriteVersion=-1),c.spriteVersion!==c.version){let n=e/106;for(let r=0;r<3&&p;r++){let i=c.sprites[r];if(!i){let t=id(e),n=t&&ad(t,!1);if(!t||!n){p=!1;break}i=c.sprites[r]={c:t,g:n}}i.g.setTransform(1,0,0,1,0,0),i.g.clearRect(0,0,e,e),i.g.setTransform(n,0,0,n,3*n,3*n),i.g.fillStyle=Gd(i.g,c.mc,qd[r][0],qd[r][1](a),u),i.g.fill(t.path)}p&&(c.spriteVersion=c.version)}}!p&&!c.near&&(c.near=Gd(e,c.mc,.55,0,u),c.rimG=Gd(e,c.mc,0,0,u),c.far=Gd(e,c.mc,0,Math.min(.6,.25*a.shadow),u));let{cy:m,sy:h,cp:g,sp:_,halfDepth:v,cap:y}=n,b=n.facing>=0?1:-1,[x,S,C,w,T,E]=n.ctm,D=null;p&&(e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`);let O=1,k=0,A=0,j=1,M=0,N=0;for(let n=0;n<16;n++){let r=-1+2*(b>0?n:16-n)/16,i=Yu(r,y),a=r*b,o=m*i,s=h*_*i,l=g*i,u=r*h*v-50*o,d=-r*m*_*v-50*s-50*l,f=O*j-k*A,x=j/f,S=-k/f,C=-A/f,w=O/f,T=(A*N-j*M)/f,E=(k*M-O*N)/f;e.transform(x*o+C*s,S*o+w*s,C*l,w*l,x*u+C*d+T,S*u+w*d+E),O=o,k=s,A=0,j=l,M=u,N=d;let P=a>.4?0:a>=0?1:2;if(p)e.drawImage(c.sprites[P].c,-3,-3,106,106);else{let n=P===0?c.near:P===1?c.rimG:c.far;n!==D&&(e.fillStyle=D=n),e.fill(t.path)}}e.setTransform(x,S,C,w,T,E);let P=1/(m*g),F=h*v/m,I=-_*v*P,L=Math.hypot(F,I),R=L>1e-6?b*F/L:1,z=L>1e-6?b*I/L:0,B=50*y+Math.hypot(50*(1-y),L),V=(B+50)/100,ee=(B-50)/2,te=1+(V-1)*R*R,ne=(V-1)*R*z,H=1+(V-1)*z*z,U=Wd(Wd(n.ctm,[m,h*_,0,g,0,0]),[te,ne,ne,H,ee*R-50*te-50*ne,ee*z-50*ne-50*H]);if(e.save(),e.setTransform(U[0],U[1],U[2],U[3],U[4],U[5]),e.clip(t.path),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`,e.drawImage(f.c,-3,-3,106,106),e.restore(),n.dev>=256&&a.rim>0&&a.highlight>0){e.save(),e.globalCompositeOperation=`source-atop`,e.setTransform(U[0],U[1],U[2],U[3],U[4],U[5]);let n=Math.min(.5,.3*a.rim*Math.min(1.4,a.highlight)),r=e.createLinearGradient(50+u[0]*50,50+u[1]*50,50-u[0]*50,50-u[1]*50);r.addColorStop(0,`rgba(235,244,255,${n.toFixed(3)})`),r.addColorStop(.45,`rgba(235,244,255,${(.35*n).toFixed(3)})`),r.addColorStop(.75,`rgba(235,244,255,0)`),e.strokeStyle=r,e.lineJoin=`round`,e.lineWidth=1.3,e.stroke(t.path),e.restore()}return!0}var Yd=1.5,Xd=.1,Zd=17,Qd=15,$d=(e,t)=>t+(1-t)*Math.sqrt(Math.max(0,1-e*e)),ef=25,tf=6.3,nf={eyes:1,mouth:-3.5},rf=new Map;function af(e,t,n){let r=`${e}|${t}|${n}`,i=rf.get(r);if(!i){let a=fu(e,-.3*t,.05*t),o=fu(e,-.12*t,.03*t),s=[],c=[];for(let t=0;t<Zd;t++){let n=t/16;s.push(n>.6?``:sf(a,o,n/.6)),c.push(n>=.5?e:sf(a,e,n/.5))}i={base:e,far:a,near:o,light:fu(e,.04*n),dark:fu(e,-.3*t,.05*t),capTop:fu(e,.035*n),capBottom:fu(e,-.035*t),crispMix:s,smoothMix:c,grad:null},rf.size>200&&rf.clear(),rf.set(r,i)}return i}var of=e=>(e.startsWith(`hsl(`)?e:fu(e,0)).match(/[\d.]+/g).map(Number);function sf(e,t,n){let r=of(e),i=of(t),a=r.map((e,t)=>e+(i[t]-e)*n);return`hsl(${a[0].toFixed(1)} ${a[1].toFixed(1)}% ${a[2].toFixed(1)}%)`}var cf=34,lf=Math.PI*1.55,uf=57,df=.4,ff=-.28,pf=new Map;function mf(e){let t=pf.get(e);return t||(t={base:fu(e,.1,.02),light:fu(e,.3,.04),dark:fu(e,-.22,.08),halo:fu(e,.2)},pf.size>200&&pf.clear(),pf.set(e,t)),t}var hf=(e,t)=>e.replace(`)`,` / ${Math.max(0,Math.min(1,t)).toFixed(3)})`);function gf(e,t,n,r,i,a,o){let s=o?.strength??0,c=Math.min(1,t.whirl*s);if(c<=.01)return;let l=o?.size??1,u=o?.width??1,d=o?.length??1,f=o?.tilt??1,p=lf*d,m=mf(n),h=-t.whirlAngle,g=uf*l,_=g*df*f*(a?1.14:.86),v=Math.atan2(i,r)-ff;e.save(),e.rotate(ff),e.translate(0,5),e.lineCap=`butt`;let y=(t,n,r,i,a)=>{e.strokeStyle=i,e.lineWidth=r,e.beginPath(),e.ellipse(0,a,g,_,0,t,n,!1),e.stroke()};if(a)for(let e=0;e<cf;e++){let t=e/cf,n=h+t*p,r=n+p/cf+.012;if(Math.sin((r+n)/2)<=0)continue;let i=(1-t)**1.3;y(n,r,(2+8*i)*1.5*u,`rgba(0,0,0,${(.2*c*i).toFixed(3)})`,3.5)}for(let e=0;e<cf;e++){let t=e/cf,n=h+t*p,r=n+p/cf+.012,i=(r+n)/2;if(Math.sin(i)>0!==a)continue;let o=.6+.4*Math.sin(i),s=(1-t)**1.3,l=1+.18*Math.sin(t*9+1.2),d=(2+8*s)*o*u*l,f=c*(.3+.7*s)*o,g=.5+.5*Math.cos(i-v);y(n,r,d*2.6,hf(m.halo,f*.2),0),y(n,r,d*.8,hf(m.dark,f*.45),d*.32),y(n,r,d,hf(m.base,f*.72),0),y(n,r,d*.62,hf(m.light,f*.78*(.4+.6*g)),-d*.16),y(n,r,d*.24,`rgba(255,255,255,${(f*.9*(.15+.85*g*g)).toFixed(3)})`,-d*.3)}e.restore()}function _f(e,t,n,r){let i=t*Yd;e.clearRect(0,0,i,i);let a=t/100,o,s;if(r.dpr!==void 0)o=r.dpr,s=[o,0,0,o,0,0];else if(e.getTransform){let t=e.getTransform();s=[t.a,t.b,t.c,t.d,t.e,t.f],o=t.a||1}else o=1,s=[1,0,0,1,0,0];let c=r.shadow??.35,l=r.highlight??1.3,u=Qd*(r.depth??.65),d=1-.09999999999999998*(r.rim??.5),f=r.spread??1.55,p=(r.light??265)*Math.PI/180,m=Math.sin(p),h=-Math.cos(p),g=af(r.color,c,l),_=Math.cos(n.yaw),v=Math.sin(n.yaw),y=Math.cos(n.pitch),b=Math.sin(n.pitch),x=_*y,S=e=>Math.abs(e)<.22?e<0?-.22:.22:e,C=S(_),w=S(y),T=Math.cos(n.roll),E=Math.sin(n.roll),D=n.sx*a,O=n.sy*a,k=50*(1-n.sy)*a,A=Wd(s,[T*D,E*D,-E*O,T*O,i/2+n.x*a-E*k,i/2+Xd*t+n.y*a+T*k]);e.save(),e.setTransform(A[0],A[1],A[2],A[3],A[4],A[5]),e.lineCap=`round`,e.lineJoin=`round`;let j=r.shading,M=(i,a,s)=>{let u=g.near,p=g.base;if(j===`crisp`){if(!g.grad||g.grad.lx!==m||g.grad.ly!==h){let t=e.createLinearGradient(m*56,h*56,-m*56,-h*56);t.addColorStop(0,g.light),t.addColorStop(.45,g.near),t.addColorStop(1,g.dark);let n=e.createLinearGradient(m*46,h*46,-m*46,-h*46);n.addColorStop(0,g.capTop),n.addColorStop(1,g.capBottom),g.grad={lx:m,ly:h,lit:t,cap:n}}u=g.grad.lit,p=g.grad.cap}let _=!1;j===`plastic`&&(_=Jd(e,{...r,path:i,typeKey:a},{cy:C,sy:v,cp:w,sp:b,facing:x,roll:n.roll,halfDepth:s,cap:d,lx:m,ly:h,dev:t*o,ctm:A,still:r.still},g,null,{shadow:c,highlight:l,spread:f,rim:r.rim??.5}));let y=j===`plastic`&&!_?`smooth`:j,S=y===`smooth`,T=S&&typeof Path2D==`function`?new Path2D:null,E=x>=0?1:-1,[D,O,k,M,N,P]=A,F=null,I=1,L=0,R=0,z=1,B=0,V=0;for(let t=0;t<Zd&&!_;t++){let n=-1+2*(E>0?t:16-t)/16,r=$d(n,d),a=t/16,o=C*r,c=v*b*r,l=w*r,f=n*v*s-50*o,m=-n*C*b*s-50*c-50*l,h=I*z-L*R,_=z/h,y=-L/h,x=-R/h,D=I/h,O=(R*V-z*B)/h,k=(L*B-I*V)/h;e.transform(_*o+x*c,y*o+D*c,x*l,D*l,_*f+x*m+O,y*f+D*m+k),I=o,L=c,R=0,z=l,B=f,V=m;let A;A=S?g.smoothMix[t]:t===16?p:a>.6?u:g.crispMix[t],A!==F&&(e.fillStyle=F=A),e.fill(i),T&&T.addPath(i,{a:o,b:c,c:0,d:l,e:f,f:m})}if(_||e.setTransform(D,O,k,M,N,P),T&&y===`smooth`){e.save(),e.clip(T);let t=Math.min(1,.34*c),n=e.createRadialGradient(-m*45,-h*45,4*f,-m*45,-h*45,84*f);n.addColorStop(0,`rgba(0,0,0,${t})`),n.addColorStop(.5,`rgba(0,0,0,${t*.35})`),n.addColorStop(1,`rgba(0,0,0,0)`),e.globalCompositeOperation=`multiply`,e.fillStyle=n,e.fillRect(-120,-120,240,240),e.globalCompositeOperation=`source-over`;let r=Math.min(1,.22*l),i=e.createRadialGradient(m*37,h*37,0,m*37,h*37,62*f);i.addColorStop(0,`rgba(255,255,255,${r})`),i.addColorStop(.6,`rgba(255,255,255,${r*.23})`),i.addColorStop(1,`rgba(255,255,255,0)`),e.fillStyle=i,e.fillRect(-120,-120,240,240),e.restore()}return _};gf(e,n,r.color,m,h,!1,r.whirl),r.parts&&M(r.parts,`${r.typeKey??`custom`}:parts`,u*(r.partsDepth??.4));let N=M(r.path,r.typeKey??`custom`,u);if(x>-.2){e.save();{let t=x>=0?1:-1,n=$d(t,d),i=C*n,a=v*b*n,o=w*n,s=t*v*u-50*i,c=-t*C*b*u-50*a-50*o,[l,f,p,m,h,g]=A;e.setTransform(l*i+p*a,f*i+m*a,p*o,m*o,l*s+p*c+h,f*s+m*c+g),e.clip(r.path),e.setTransform(l,f,p,m,h,g)}e.translate(r.faceX-50,r.faceY-50),e.scale(r.faceScale,r.faceScale),N&&(e.globalAlpha=.93),Df(e,n,r),e.restore()}gf(e,n,r.color,m,h,!0,r.whirl),e.restore()}var vf=30;function yf(e,t,n,r){let i=Math.asin(Math.max(-1,Math.min(1,e/vf)))+n,a=Math.asin(Math.max(-1,Math.min(1,-t/vf)))+r,o=Math.cos(a);return{x:vf*Math.sin(i)*o,y:-30*Math.sin(a),sx:Math.cos(i),sy:o,z:Math.cos(i)*o}}var bf=8,xf=new Map;function Sf(e,t,n){let r=Math.round(e*50),i=Math.round(t*50),a=Math.round(n*50),o=r+2e3*i+4e6*a,s=xf.get(o);if(!s){let e=r/50,t=i/50,n=a/50,c=`M${-e} ${t}`;for(let r=1;r<=bf;r++){let i=r/bf,a=1-i;c+=` L${(a*a*-e+i*i*e).toFixed(3)} ${((a*a+i*i)*t+2*a*i*n).toFixed(3)}`}s=new Path2D(c),xf.size>256&&xf.clear(),xf.set(o,s)}return s}var Cf=Math.sin(.684),wf=Math.cos(.684),Tf=new Map;function Ef(e){let t=e=>Math.round(e*50)/50,n=t(e.hw),r=t(e.t0),i=t(e.a),a=t(e.yt),o=t(e.ab),s=t(e.yb),c=`${n},${r},${i},${a},${o},${s}`,l=Tf.get(c);if(l)return l;let u=e=>e.toFixed(3),d=r*Cf,f=r*wf,p=-n+d,m=-f,h=n-d,g=-f,_=-n-d,v=f,y=n+d,b=f,x=4/3*r*wf,S=4/3*r*Cf,C=`M${u(p)} ${u(m)}C${u(-n+i*n)} ${u(a-r)} ${u(n-i*n)} ${u(a-r)} ${u(h)} ${u(g)}C${u(h+x)} ${u(g-S)} ${u(y+x)} ${u(b-S)} ${u(y)} ${u(b)}C${u(n-o*n)} ${u(s+r)} ${u(-n+o*n)} ${u(s+r)} ${u(_)} ${u(v)}C${u(_-x)} ${u(v-S)} ${u(p-x)} ${u(m-S)} ${u(p)} ${u(m)}Z`;return l=new Path2D(C),Tf.size>256&&Tf.clear(),Tf.set(c,l),l}function Df(e,t,n){let[r,i,a]=t.w,o=n.ink,s=nf[n.face],c=ef/2,l=t.lookX,u=t.lookY,{yaw:d,pitch:f}=t,p=(t,n,r,i=1)=>{let a=yf(t,n,d,f);a.z<=.02||i<=.01||(e.save(),e.globalAlpha=i*Math.min(1,a.z*5),e.translate(a.x,a.y),e.scale(Math.max(.02,a.sx),Math.max(.02,a.sy)),r(),e.restore())},m=(e,t)=>Math.abs(e)<=t?0:Math.sign(e)*(Math.abs(e)-t)/(1-t),h=e=>Math.max(-1,Math.min(1,e)),g=m(h(-t.pitch/.26-t.lookY/7),.34),_=Math.abs(m(h(t.lookX/4.5),.4)),v=Math.max(.3,1+.55*g-.1*_),y=1-.05*g+.12*_,b=r+i*(1-t.laugh),x=i*t.laugh,S=Math.max(0,-t.y)/26,C=.5+.5*t.breath;for(let n of[-1,1]){let r=n<0?t.blinkL:t.blinkR,i=Math.max(0,Math.min(1,t.eyeOpen*(1-r))),d=b*i,f=b*(1-i),m=x,h=a,g=d*.01+f*5.4+m*6.2+h*6,_=d*1.1*v+f*.6+m*(2.2-S*1.5)+h*(-1.4+C),w=d*-3.3*v+f*.6+m*(-11.4-4*S)+h*(5.4+2*C),T=d*tf*2*y+f*2.8+m*4.4+h*4,E=l*(d+.5*(f+m)),D=u*(d+.5*f);p(n*c+E,s+D,()=>{e.strokeStyle=o,e.lineWidth=T,e.stroke(Sf(g,_,w))})}if(n.face===`mouth`){let n=l*.35,s=(.6+.4*r)*(1+.06*t.breath),c=(.6+.4*i)*(1+.25*Math.max(0,-t.y)/26),u=2.7*a*(1+.25*t.breath),d=(e,t,n)=>r*e+i*t+a*n,f={hw:d(6.5*s,9.5*c,u),t0:d(1.9,0,0),a:d(2/3,2/3,0),yt:d(3.53*s,1.6*c,-4*u/3),ab:d(2/3,0,0),yb:d(3.53*s,17.3*c,4*u/3)};p(n,d(12.5,11.6,15.5),()=>{e.fillStyle=o,e.fill(Ef(f))})}}var Of={x:NaN,y:NaN},kf=new Set,Af=0,jf=0;function Mf(e){Af=0;let t=jf?Math.min(.1,(e-jf)/1e3):0;jf=e,kf.forEach(e=>e(t)),kf.size&&(Af=requestAnimationFrame(Mf))}function Nf(){Af||typeof document>`u`||document.hidden||(jf=0,Af=requestAnimationFrame(Mf))}var Pf=!1;function Ff(){Pf||typeof document>`u`||(Pf=!0,document.addEventListener(`pointermove`,e=>{Of.x=e.clientX,Of.y=e.clientY},{passive:!0}),document.addEventListener(`pointerleave`,()=>{Of.x=NaN,Of.y=NaN}),window.addEventListener(`blur`,()=>{Of.x=NaN,Of.y=NaN}),document.addEventListener(`visibilitychange`,()=>{document.hidden?(Af&&cancelAnimationFrame(Af),Af=0):kf.size&&Nf()}))}function If(e){return Ff(),kf.add(e),Nf(),()=>{kf.delete(e),!kf.size&&Af&&(cancelAnimationFrame(Af),Af=0)}}function Lf(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0)%1e3/1e3}var Rf=(e,t,n)=>Math.min(n,Math.max(t,Number.isFinite(e)?e:1)),zf=new Map;function Bf(e){let t=zf.get(e);return t||(t=new Path2D(e),zf.set(e,t)),t}var Vf=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,Hf=(0,l.forwardRef)(function({type:e=`clover`,path:t,face:n,state:r=`default`,size:i=64,color:a,ink:o,brightness:s=1,saturation:c=1.5,speed:u=1,paused:d=!1,seed:f,shading:p=`plastic`,shadow:m=.35,highlight:h=1.3,depth:g=.65,light:_=265,rim:v=.5,spread:y=1.55,interactive:b=!0,turn:x=1,theme:S=`auto`,whirl:C=0,whirlSize:w=1,whirlWidth:T=1,whirlLength:E=1,whirlTilt:D=1,jumpHeight:O=26,jumpTime:k=.68,jumpStretch:A=1,jumpSpin:j=1,jumpLean:M=6,jumpEvery:N=8,jumpLand:P=0,jumpSquash:F=1.15,jumpSquashTime:I=.37,jumpSquashEase:L=`pulse`,jumpGroundTime:R=.11,jumpGroundEase:z=`pulse`,jumpRiseTime:B=.33,jumpRiseEase:V=`pulse`,jumpClickSquashTime:ee=.24,className:te,style:ne,"aria-label":H,...U},re){let ie=(0,l.useRef)(null);(0,l.useImperativeHandle)(re,()=>ie.current);let ae=(0,l.useId)(),oe=Ql[e]??Ql.clover,se=n??oe.face,ce=a??oe.color,le=s===1&&c===1?ce:fu(ce,(Math.min(2,Math.max(0,s))-1)*.35,(Math.min(2,Math.max(0,c))-1)*.5),ue=o??su(le),de=Math.min(1,Math.max(0,f??Lf(ae))),fe=r in eu?r:`default`,pe=d||!(u>0),W=p===!0?`crisp`:p===!1?`flat`:p,me=typeof t==`string`&&t.trim()?t.trim():null,he=me?`path:${Lf(me)}:${me.length}`:e,G=(0,l.useRef)(null),ge=(0,l.useRef)(null),_e=(0,l.useRef)(0),K=(0,l.useRef)(u);K.current=u;let ve=(0,l.useRef)(b);ve.current=b,ge.current={path:typeof Path2D>`u`?null:Bf(me??tu[e]??tu.clover),face:se,faceX:oe.faceX,faceY:oe.faceY,faceScale:oe.faceScale,color:le,ink:ue,shading:W,shadow:Rf(m,0,2),highlight:Rf(h,0,2),depth:Rf(g,.2,2),light:_,rim:Rf(v,0,2),spread:Rf(y,.4,2.5),typeKey:he,still:pe||Vf(),whirl:{strength:Rf(C,0,2),size:Rf(w,.6,1.6),width:Rf(T,.4,2),length:Rf(E,.4,1.6),tilt:Rf(D,.5,1.8)},parts:typeof Path2D<`u`&&!me&&nu[e]?Bf(nu[e]):void 0};let ye=e=>{if(S!==`auto`)return S;let t=e?.closest(`[data-theme], .dark, .light`);if(t){let e=t.getAttribute(`data-theme`);if(e===`dark`||e===`light`)return e;if(t.classList.contains(`dark`))return`dark`;if(t.classList.contains(`light`))return`light`}return typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: light)`).matches?`light`:`dark`},be=()=>{let e=ie.current,t=ge.current;if(!e||!t||!t.path)return;let n=e.clientWidth/1.5||_e.current||(typeof i==`number`?i:64);if(!n)return;let r=Math.min(2,typeof devicePixelRatio==`number`&&devicePixelRatio||1),a=Math.round(n*Yd*r);(e.width!==a||e.height!==a)&&(e.width=a,e.height=a),_e.current=n;let o=e.getContext(`2d`);o&&(o.setTransform(r,0,0,r,0,0),t.dpr=r,_f(o,n,G.current?G.current.pose:Vu(fe),t))};(0,l.useLayoutEffect)(()=>{if(G.current?G.current.setState(fe):G.current=new Bu(de,fe),G.current.setTurn(Rf(x,0,2)),G.current.setJump({height:O,time:Math.max(.2,k),stretch:A,spin:Math.max(0,Math.round(j)),lean:M,every:N,land:P,squash:F,squashTime:Math.max(.05,I),squashEase:L,groundTime:Math.max(0,R),groundEase:z,riseTime:Math.max(.05,B),riseEase:V,clickSquashTime:Math.max(.05,ee)}),Vf()){let e=ie.current;if(e&&ge.current&&ge.current.path){let t=e.clientWidth/1.5||_e.current||(typeof i==`number`?i:64);if(!t)return;_e.current=t;let n=Math.min(2,typeof devicePixelRatio==`number`&&devicePixelRatio||1);e.width=e.height=Math.round(t*Yd*n);let r=e.getContext(`2d`);r&&(ge.current.theme=ye(e),ge.current.dpr=n,r.setTransform(n,0,0,n,0,0),_f(r,t,Vu(fe),ge.current))}return}ge.current&&ie.current&&(ge.current.theme=ye(ie.current)),be()}),(0,l.useEffect)(()=>{var e;if(W!==`plastic`||!((e=ge.current)!=null&&e.path))return;let t=ge.current.path,n=(typeof i==`number`?i:64)*Math.min(2,typeof devicePixelRatio==`number`&&devicePixelRatio||1),r=(typeof requestIdleCallback==`function`?requestIdleCallback:e=>setTimeout(e,1))(()=>vd(he,t,n,g));return()=>{typeof cancelIdleCallback==`function`?cancelIdleCallback(r):clearTimeout(r)}},[W,he,i,g]),(0,l.useEffect)(()=>{if(pe||Vf())return;let e=ie.current;if(!e)return;let t=!0,n=null,r=t=>{let n=G.current;if(n){if(ve.current&&!Number.isNaN(Of.x)){let t=e.getBoundingClientRect(),r=t.width/1.5||1,i=(Of.x-(t.left+t.width/2))/r,a=(Of.y-(t.top+t.height/2+Xd*r))/r,o=Math.hypot(i,a),s=o<1?1:o>3?0:1-(o-1)/2;n.setPointer(i/Math.max(1,o),a/Math.max(1,o),s)}else n.setPointer(0,0,0);n.update(t*K.current),be()}},i=()=>{n||=If(r)},a=()=>{n&&n(),n=null},o=null;return typeof IntersectionObserver==`function`?(o=new IntersectionObserver(e=>{t=e[0]?.isIntersecting??!0,t?i():a()}),o.observe(e)):i(),()=>{a(),o&&o.disconnect()}},[pe]);let xe=typeof i==`number`?`${i*Yd}px`:`calc(${i} * ${Yd})`,Se=e=>typeof i==`number`?`${-i*e}px`:`calc(${i} * ${-e})`,Ce=.5/2,we={display:`inline-block`,verticalAlign:`middle`,width:xe,height:xe,marginLeft:Se(Ce),marginRight:Se(Ce),marginTop:Se(.35),marginBottom:Se(.15),flex:`none`,...ne},Te=e=>{var t,n;b&&!pe&&((t=G.current)==null||t.poke()),(n=U.onClick)==null||n.call(U,e)};return(0,Q.jsx)(`canvas`,{ref:ie,className:te?`ba ${te}`:`ba`,"data-bot-avatar":e,"data-face":se,"data-state":fe,role:`img`,"aria-label":H??`${oe.label} bot, ${eu[fe]}`,style:we,...U,onClick:Te})}),Uf=137.508,Wf=e=>(e*Uf%360).toFixed(3);function Gf(e){let t=e.avatarIndex;return{type:$l[t%$l.length],color:`hsl(${Wf(t)} 72% 58%)`,seed:t*.61803398875%1}}var Kf=2e3,qf=0;function Jf(e){let[t,n]=(0,l.useState)(!e);return(0,l.useEffect)(()=>{if(e){n(!1);return}let t=setTimeout(()=>n(!0),Kf);return()=>clearTimeout(t)},[e]),t}function Yf({thread:e,working:t,size:n}){let r=Jf(t),i=r?`rest`:`moving`;return(0,Q.jsx)(Hf,{...Gf(e),state:t?`working`:`default`,size:n,paused:r,turn:t?void 0:qf},i)}var Xf={nextThread:`Next thread`,previousThread:`Previous thread`,nextPane:`Next pane`,previousPane:`Previous pane`,toggleSidebar:`Toggle sidebar`,newThread:`New thread`,openTerminal:`New terminal`,closePane:`Close pane`},Zf={nextThread:`ctrl+j`,previousThread:`ctrl+k`,nextPane:`ctrl+l`,previousPane:`ctrl+h`,toggleSidebar:`meta+b`,newThread:`ctrl+x`,openTerminal:`ctrl+e`,closePane:`ctrl+q`};function Qf(){try{let e=JSON.parse(localStorage.getItem(`webr-shortcuts`)??`{}`);return{...Zf,...Object.fromEntries(Object.entries(e).filter(([e])=>Object.hasOwn(Zf,e)))}}catch{return Zf}}function $f(e){let t={ctrl:`⌃`,alt:`⌥`,meta:`⌘`,shift:`⇧`,space:`Space`,escape:`Esc`};return e.split(`+`).map(e=>t[e]??e.toUpperCase())}function ep(e){return $f(e).join(``)}function tp(e){let t=[e.ctrlKey&&`ctrl`,e.altKey&&`alt`,e.metaKey&&`meta`,e.shiftKey&&`shift`].filter(Boolean),n=e.key.toLowerCase()===` `?`space`:e.key.toLowerCase();return[`control`,`alt`,`meta`,`shift`].includes(n)?``:[...t,n].join(`+`)}function np(e){return/^(meta\+(w|t|r|l|n)|ctrl\+(w|t|r|n))$/.test(e)||!/(ctrl|alt|meta)\+/.test(e)}function rp(e){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;document.documentElement.dataset.theme=e===`system`?t?`dark`:`light`:e}function ip({expanded:e=!1}){let[t,n]=(0,l.useState)(`system`);(0,l.useEffect)(()=>{let e=localStorage.getItem(`webr-theme`),t=e===`light`||e===`dark`?e:`system`;n(t),rp(t);let r=window.matchMedia(`(prefers-color-scheme: dark)`),i=()=>{let e=localStorage.getItem(`webr-theme`)||`system`;n(e),rp(e)};return r.addEventListener(`change`,i),window.addEventListener(`webr-theme-change`,i),()=>{r.removeEventListener(`change`,i),window.removeEventListener(`webr-theme-change`,i)}},[]);let r=e=>{n(e),localStorage.setItem(`webr-theme`,e),rp(e)};return(0,Q.jsx)(`div`,{className:e?`theme-control theme-control--expanded`:`theme-control`,role:`group`,"aria-label":`Color theme`,children:[[`system`,V],[`light`,ue],[`dark`,ee]].map(([n,i])=>(0,Q.jsx)(Zl,{label:`${n[0].toUpperCase()}${n.slice(1)} theme`,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`${n} theme`,"aria-pressed":t===n,className:t===n?`theme-option is-selected`:`theme-option`,onClick:()=>r(n),children:[(0,Q.jsx)(i,{size:15,strokeWidth:1.8}),e&&(0,Q.jsx)(`span`,{children:n})]})},n))})}var ap={machine_disconnected:`The machine is not connected.`,launch_in_progress:`Wait for the launch to finish, then try again.`,thread_not_found:`This thread does not exist anymore.`};async function op(e,t={}){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(ap[r.error??``]??`Herdr could not complete this action.`);return r}var sp=(e,t)=>op(`/api/threads/${encodeURIComponent(e.id)}/archive`,{machineId:e.machineId,archived:t}),cp=(e,t)=>op(`/api/threads/${encodeURIComponent(e.id)}/rename`,{machineId:e.machineId,title:t}),lp=(e,t)=>op(`/api/projects/rename`,{machineId:e.machineId??`local`,logicalId:e.logicalId??e.id,name:t}),up=e=>`/api/projects/icon?machineId=${encodeURIComponent(e.machineId??`local`)}&logicalId=${encodeURIComponent(e.logicalId??e.id)}`;async function dp(e,t){if(!(await fetch(up(e),{method:`PUT`,headers:{"Content-Type":`image/png`},body:t})).ok)throw Error(`Could not save this icon.`)}async function fp(e){let t=await fetch(`/api/projects/${encodeURIComponent(e.machineId??`local`)}/${encodeURIComponent(e.id)}/icon-candidates`);return t.ok?await t.json():[]}async function pp(e){if(!(await fetch(up(e),{method:`DELETE`})).ok)throw Error(`Could not reset this icon.`)}var mp=(e,t)=>op(`/api/threads/${encodeURIComponent(e.id)}/panes/terminal`,{machineId:e.machineId,afterPaneId:t}),hp=(e,t,n)=>op(`/api/threads/${encodeURIComponent(e.id)}/panes/close`,{machineId:e.machineId,paneId:t,force:n}),gp=e=>op(`/api/threads/${encodeURIComponent(e.id)}/delete`,{machineId:e.machineId}),_p=()=>op(`/api/archive/delete`),vp=(e,t,n)=>e===1?t:n;function yp(e){let t=e.length,n=e.filter(e=>e.ownsWorktree).length,r=vp(t,`Delete this thread`,`Delete ${t} threads`),i=vp(t,`its terminal`,`their terminals`);return n?`${r} permanently? This closes ${i} and removes ${n===t?vp(t,`its worktree`,`their worktrees`):`${n} ${vp(n,`worktree`,`worktrees`)}`}, including uncommitted changes.`:`${r} permanently? This closes ${i}. Your project files stay untouched.`}var bp=(e,t)=>e.panes.length>1&&e.panes.some(e=>e.id===t&&e.kind!==`agent`),xp=(e,t)=>e[t-1]??e[t+1];function Sp(e,t,n){let r=e.findIndex(e=>e.id===n);return e.slice(t,t+2).find(e=>e.id!==n)??xp(e,r)}function Cp(e,t,n,r=2){let i=n<0?t:n<t?n:n>=t+r?n-r+1:t;return Math.max(0,Math.min(i,e-r))}function wp(e){let t=performance.now();return()=>performance.now()-t}var Tp=()=>performance.now();function Ep(){}var Dp=e=>cl(e instanceof Error?e.message:`Herdr could not complete this action.`);function Op({open:e,onClose:t,projects:n,threads:r,thread:i,focusedPane:o,mode:s,onModeChange:c,onToggleSidebar:u,onFocusPane:d,onTerminalAction:v,onOpenTerminal:y,onClosePane:b}){let[x,S]=(0,l.useState)(``),[C,w]=(0,l.useState)(0),[T,E]=(0,l.useState)(Zf),D=(0,l.useRef)(null);(0,l.useEffect)(()=>{e&&(S(``),w(0),E(Qf()),requestAnimationFrame(()=>D.current?.focus()))},[e]);let k=e=>{let t=r.findIndex(e=>e.id===i?.id),n=r[((t===-1&&e<0?0:t)+e+r.length)%r.length];n&&a(`/threads/${encodeURIComponent(n.id)}`)},A=e=>{i?.panes.length&&d(i.panes[(i.panes.findIndex(e=>e.id===o)+e+i.panes.length)%i.panes.length].id)},j=(0,l.useMemo)(()=>[{label:`New thread`,icon:(0,Q.jsx)(se,{size:16}),shortcut:`newThread`,run:()=>{a(`/new${i?`?project=${encodeURIComponent(i.projectId)}`:``}`)}},{label:`Settings`,icon:(0,Q.jsx)(oe,{size:16}),run:()=>{a(`/settings`)}},{label:`Toggle sidebar`,icon:(0,Q.jsx)(H,{size:16}),shortcut:`toggleSidebar`,run:u},...r.length?[{label:`Next thread`,icon:(0,Q.jsx)(m,{size:16}),shortcut:`nextThread`,run:()=>k(1)},{label:`Previous thread`,icon:(0,Q.jsx)(_,{size:16}),shortcut:`previousThread`,run:()=>k(-1)}]:[],{label:`Group threads by project`,icon:(0,Q.jsx)(M,{size:16}),detail:s===`projects`?`Selected`:void 0,run:()=>c(`projects`)},{label:`Show all threads`,icon:(0,Q.jsx)(L,{size:16}),detail:s===`threads`?`Selected`:void 0,run:()=>c(`threads`)},...[`system`,`light`,`dark`].map(e=>({label:`${e[0].toUpperCase()}${e.slice(1)} theme`,icon:e===`system`?(0,Q.jsx)(V,{size:16}):e===`light`?(0,Q.jsx)(ue,{size:16}):(0,Q.jsx)(ee,{size:16}),run:()=>{localStorage.setItem(`webr-theme`,e),rp(e),window.dispatchEvent(new Event(`webr-theme-change`))}})),...i?[{label:i.archivedAt?`Unarchive thread`:`Archive thread`,icon:i.archivedAt?(0,Q.jsx)(f,{size:16}):(0,Q.jsx)(p,{size:16}),run:()=>{sp(i,!i.archivedAt).catch(Dp)}},{label:`Copy thread link`,icon:(0,Q.jsx)(O,{size:16}),run:()=>{navigator.clipboard.writeText(location.href)}},...i.bindingState===`attached`?[{label:`New terminal`,icon:(0,Q.jsx)(ce,{size:16}),shortcut:`openTerminal`,run:y},...bp(i,o)?[{label:`Close pane`,icon:(0,Q.jsx)(pe,{size:16}),shortcut:`closePane`,run:b}]:[]]:[],...i.bindingState===`attached`?[{label:`Request terminal control`,icon:(0,Q.jsx)(ce,{size:16}),run:()=>v(`control`)},{label:`Release terminal control`,icon:(0,Q.jsx)(ce,{size:16}),run:()=>v(`release`)},{label:`Take over terminal control`,icon:(0,Q.jsx)(ce,{size:16}),run:()=>{sl(`Replace the active controller of this terminal?`,{confirmLabel:`Take over`}).then(e=>{e&&v(`takeover`)})}}]:[],{label:`Next pane`,icon:(0,Q.jsx)(g,{size:16}),shortcut:`nextPane`,run:()=>A(1)},{label:`Previous pane`,icon:(0,Q.jsx)(h,{size:16}),shortcut:`previousPane`,run:()=>A(-1)},...i.panes.map((e,t)=>({label:`Focus ${e.title}`,icon:(0,Q.jsx)(ce,{size:16}),detail:`Pane ${t+1}`,run:()=>d(e.id)}))]:[],...r.map(e=>({label:e.title,icon:(0,Q.jsx)(Yf,{thread:e,working:e.status===`working`,size:22}),detail:n.find(t=>t.id===e.projectId)?.name,run:()=>{a(`/threads/${encodeURIComponent(e.id)}`)}}))],[n,r,i,o,s,c,u,d,v,y,b]).filter(e=>`${e.label} ${e.detail??``}`.toLowerCase().includes(x.toLowerCase().trim()));if(!e)return null;let N=e=>{t(),e.run()};return(0,Q.jsx)(`div`,{className:`palette-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,Q.jsxs)(`div`,{className:`palette`,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),t()),e.key===`ArrowDown`&&(e.preventDefault(),w(e=>(e+1)%(j.length||1))),e.key===`ArrowUp`&&(e.preventDefault(),w(e=>(e-1+(j.length||1))%(j.length||1))),e.key===`Enter`&&j.length&&(e.preventDefault(),N(j[Math.min(C,j.length-1)])),e.key===`Tab`&&(e.preventDefault(),D.current?.focus())},children:[(0,Q.jsx)(`input`,{ref:D,"aria-label":`Search commands and threads`,placeholder:`Search threads and actions…`,value:x,onChange:e=>{S(e.target.value),w(0)}}),(0,Q.jsxs)(`div`,{className:`palette-results`,role:`listbox`,"aria-label":`Results`,children:[j.map((e,t)=>(0,Q.jsxs)(`button`,{role:`option`,"aria-selected":C===t,className:C===t?`is-selected`:``,onMouseEnter:()=>w(t),onClick:()=>N(e),children:[(0,Q.jsx)(`span`,{className:`palette-icon`,"aria-hidden":`true`,children:e.icon}),(0,Q.jsx)(`span`,{className:`palette-label`,children:e.label}),e.detail&&(0,Q.jsx)(`small`,{children:e.detail}),e.shortcut&&(0,Q.jsx)(Zl,{label:T[e.shortcut],children:(0,Q.jsx)(`kbd`,{children:ep(T[e.shortcut])})})]},`${e.label}-${t}`)),!j.length&&(0,Q.jsx)(`p`,{children:`No results`})]}),(0,Q.jsxs)(`div`,{className:`palette-help`,children:[`↑↓ Navigate `,(0,Q.jsx)(`span`,{children:`↵ Select`}),` `,(0,Q.jsx)(`span`,{children:`Esc Close`})]})]})})}var kp=2e3,Ap=e=>fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});async function jp(){let e=await Ap(`/api/pair/invites`);if(!e.ok)throw Error(`Webr could not create a code.`);return e.json()}async function Mp(){let e=await fetch(`/api/devices`);if(!e.ok)throw Error(`Webr could not list devices.`);return e.json()}async function Np(){let e=await fetch(`/api/audit`);if(!e.ok)throw Error(`Webr could not load recent activity.`);return e.json()}async function Pp(){let e=await fetch(`/api/remote/tailscale`);return e.ok?(await e.json()).status:`unavailable`}var Fp=e=>Ap(`/api/devices/${encodeURIComponent(e)}/revoke`),Ip=(e,t)=>Ap(`/api/pair/${encodeURIComponent(e)}/${t}`);async function Lp(){try{let e=await fetch(`/api/pair/pending`);return e.ok?await e.json():[]}catch{return[]}}var Rp=()=>typeof Notification<`u`&&Notification.permission===`granted`,zp=()=>document.visibilityState===`visible`||Rp();function Bp(e,t){if(document.visibilityState!==`visible`&&Rp())for(let n of e)t.has(n.id)||(t.add(n.id),new Notification(`A device wants to connect to Webr`,{body:`${n.deviceName} · ${n.source}`,tag:n.id}))}function Vp(){let[e,t]=(0,l.useState)([]),n=(0,l.useRef)(new Set),r=(0,l.useCallback)(async()=>{if(!zp())return;let e=await Lp();Bp(e,n.current),t(e)},[]);return(0,l.useEffect)(()=>{r();let e=setInterval(()=>void r(),kp);return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(e),document.removeEventListener(`visibilitychange`,r)}},[r]),{pending:e,decide:(0,l.useCallback)(async(e,n)=>{t(t=>t.filter(t=>t.id!==e)),await Ip(e,n).catch(()=>void 0),await r()},[r])}}function Hp(e,t=Date.now()){let n=Math.round((e-t)/1e3),[r,i]=[[`day`,86400],[`hour`,3600],[`minute`,60]].find(([,e])=>Math.abs(n)>=e)??[`second`,1];return Math.abs(n)<45?`just now`:new Intl.RelativeTimeFormat(`en`,{numeric:`auto`}).format(Math.round(n/i),r)}var Up=()=>typeof Notification<`u`,Wp=()=>Up()?Notification.permission:`denied`,Gp=()=>Notification.requestPermission();function Kp({kind:e,deviceName:t,source:n}){let r=t??`A device`,i=n?` from ${n}`:``;return{pair_requested:`${r} asked to connect${i}`,pair_approved:`${r} was approved${i}`,pair_denied:`${r} was declined${i}`,invite_created:`A connection code was created${i}`,invite_redeemed:`${r} connected with a code${i}`,device_revoked:`${r} was disconnected`,session_expired:`${r} was signed out after being idle`}[e]}function qp(e,t=Date.now()){return e<=t?`expired`:new Intl.RelativeTimeFormat(`en`,{numeric:`auto`}).format(...Jp(e-t))}function Jp(e){let t=Math.round(e/864e5);return t>=1?[t,`day`]:[Math.max(1,Math.round(e/36e5)),`hour`]}function Yp(){let{pending:e,decide:t}=Vp(),n=e[0];return(0,Q.jsx)(kc,{open:!!n,onOpenChange:e=>{!e&&n&&t(n.id,`deny`)},children:(0,Q.jsxs)(Xc,{children:[(0,Q.jsx)(Ac,{className:`dialog-backdrop`}),(0,Q.jsx)(qc,{className:`dialog pairing-prompt`,children:n&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Zc,{className:`pairing-title`,children:[`Allow `,n.deviceName,` to connect?`]}),(0,Q.jsxs)(Bc,{className:`dialog-message`,children:[`Requested from `,n.source,`. Only approve if this code matches the one shown on that device.`]}),(0,Q.jsx)(`div`,{className:`pairing-code`,"aria-label":`Code ${n.code}`,children:n.code}),e.length>1&&(0,Q.jsxs)(`p`,{className:`settings-note`,children:[e.length-1,` more waiting`]}),(0,Q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,onClick:()=>void t(n.id,`deny`),children:`Deny`}),(0,Q.jsx)(`button`,{type:`button`,autoFocus:!0,className:`dialog-button is-primary`,onClick:()=>void t(n.id,`approve`),children:`Approve`})]})]})})]})})}var Xp=({children:e})=>(0,Q.jsx)(Q.Fragment,{children:e}),Zp=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],Qp={image_too_large:`This image is larger than 20 MB.`,file_too_large:`This file is larger than 5 MB.`,empty_file:`This file is empty.`,unsupported_image:`Only PNG, JPEG, GIF and WebP images can be attached.`,uploads_unsupported_target:`Files cannot be attached on this machine yet.`,upload_failed:`The file could not be sent to the machine.`,machine_disconnected:`The machine is not connected.`},$p=e=>Zp.includes(e.type),em=e=>e?.files?[...e.files].filter($p):[],tm=e=>e?.files?[...e.files]:[],nm=e=>!!e?.types&&[...e.types].includes(`Files`),rm=e=>e.replace(/([\s\\'"()&;$`!*?[\]{}<>|#~])/g,`\\$1`);async function im(e,t){if(!$p(t))throw Error(Qp.unsupported_image);if(t.size>20971520)throw Error(Qp.image_too_large);let n=await fetch(`/api/uploads?machineId=${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":t.type},body:t}),r=await n.json().catch(()=>({}));if(!n.ok||!r.path)throw Error(Qp[r.error??``]??`The image could not be attached.`);return r.path}async function am(e,t){if($p(t))return im(e,t);if(t.size>5242880)throw Error(Qp.file_too_large);let n=await fetch(`/api/uploads?machineId=${encodeURIComponent(e)}&name=${encodeURIComponent(t.name)}`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:t}),r=await n.json().catch(()=>({}));if(!n.ok||!r.path)throw Error(Qp[r.error??``]??`The file could not be attached.`);return r.path}var om=160,sm=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)});async function cm(e){if(typeof createImageBitmap!=`function`)return sm(e);let t=await createImageBitmap(e),n=Math.min(1,om/Math.max(t.width,t.height)),r=document.createElement(`canvas`);return r.width=Math.max(1,Math.round(t.width*n)),r.height=Math.max(1,Math.round(t.height*n)),r.getContext(`2d`)?.drawImage(t,0,0,r.width,r.height),t.close(),r.toDataURL(`image/jpeg`,.8)}async function lm(e,t){let n=[];for(let r of t)n.push(await am(e,r));return n.map(rm).join(` `)+` `}var um=e=>Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);function dm(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=um(e);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var fm=`Nothing to attach.`,pm=e=>$p(e)?cm(e):Promise.resolve(``),mm=(e,t)=>[e.trim(),...t.map(e=>rm(e.path))].filter(Boolean).join(` `);function hm({machineId:e}){let[t,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)([]),[a,o]=(0,l.useState)(0),[s,c]=(0,l.useState)(``),u=(0,l.useRef)(0),d=async t=>{if(!t.length){c(fm);return}c(``),o(e=>e+t.length);for(let n of t)try{let t=await am(e,n),r=await pm(n);i(e=>[...e,{id:dm(),name:n.name||`file`,preview:r,path:t}])}catch(e){c(e instanceof Error?e.message:`The file could not be attached.`)}finally{o(e=>e-1)}};return{dragging:t,attachments:r,setAttachments:i,uploading:a,error:s,remove:e=>i(t=>t.filter(t=>t.id!==e)),handlers:{onDragEnter:e=>{nm(e.dataTransfer)&&(e.preventDefault(),u.current+=1,n(!0))},onDragOver:e=>{nm(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:e=>{nm(e.dataTransfer)&&(u.current=Math.max(0,u.current-1),u.current||n(!1))},onDrop:e=>{nm(e.dataTransfer)&&(e.preventDefault(),u.current=0,n(!1),d(tm(e.dataTransfer)))},onPaste:e=>{let t=em(e.clipboardData);t.length&&(e.preventDefault(),d(t))}}}}function gm({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=l.useRef(e!==void 0),[a,o]=l.useState(t);return[i&&e!==void 0?e:a,l.useCallback(e=>{i||o(e)},[])]}function _m(e){let t=l.useRef(!0);t.current&&(t.current=!1,e())}function vm(e,t,n,r,i,a,o,s,c,l=2){let u=Fr(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return jr(n.current,u)?void 0:u}var ym=l.createContext(void 0),bm=l.createContext(void 0),xm=l.createContext(void 0),Sm=l.createContext(!1),Cm=l.createContext(``);function wm(){let e=l.useContext(ym);if(!e)throw Error(Mi(22));return e}function Tm(){let e=l.useContext(bm);if(!e)throw Error(Mi(23));return e}function Em(){let e=l.useContext(xm);if(!e)throw Error(Mi(24));return e}function Dm(){return l.useContext(Cm)}function Om(){return l.useContext(Sm)}function km(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var Am=(e,t)=>Object.is(e,t);function jm(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Mm(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!km(e,t,(e,t)=>jm(e,t,n)):e!==t}function Nm(e,t,n){return e?e.some(e=>e!==void 0&&jm(t,e,n)):!1}function Pm(e,t,n){return e?e.findIndex(e=>e!==void 0&&jm(e,t,n)):-1}function Fm(e,t){if(t!==Am)return n=>Nm(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Im(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Fm(t,n)):Pm(e,t,n);return i===-1?null:i}function Lm(e,t,n,r,i,a){return Nm(r,t,i)?a!=null&&e>a&&Nm(r,n[a],i)?a:e:e===a?Im(n,r,i,!0):a}function Rm(e,t,n){return e.filter(e=>!jm(t,e,n))}function zm(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function Bm(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function Vm(e){return Bm(e?.[0])}function Hm(e){return Vm(e)?e.flatMap(e=>e.items):e}function Um(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(Vm(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Wm(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return zm(e)}function Gm(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?zm(e.value):zm(e)}var Km={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?Um(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>jm(t,e,n)):jm(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemProps:e=>e.itemProps,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight},qm=`data-valid`,Jm=`data-invalid`,Ym={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Xm={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Zm={disabled:!1,...Xm},Qm={valid(e){return e===null?null:e?{[qm]:``}:{[Jm]:``}}},$m={invalid:void 0,name:void 0,validityData:{state:Ym,errors:[],error:``,value:``,initialValue:null},setValidityData:et,disabled:void 0,setTouched:et,setDirty:et,setFilled:et,setFocused:et,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:Zm,registerFieldControl:et,validation:{getValidationProps:(e,t=nt)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:et,getInputControl:()=>null,commit:async()=>{},change:et}},eh=l.createContext($m);function th(e=!0){let t=l.useContext(eh);if(t.setValidityData===et&&!e)throw Error(Mi(28));return t}function nh(e,t,n,r,i=!0,a){let{registerFieldControl:o}=th(),s=$e(()=>Symbol());W(()=>{let c=s.current;if(!i){o(c,void 0);return}o(c,{controlRef:e,getValue:r,id:t,name:a,value:n})},[e,i,r,t,a,o,s,n]),W(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var rh=l.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:et,validationMode:`onSubmit`,submitCountRef:{current:0}});function ih(){return l.useContext(rh)}var ah=l.createContext({controlId:void 0,registerControlId:et,resetControlId:et,labelId:void 0,setLabelId:et,messageIds:[],setMessageIds:et,getDescriptionProps:e=>e});function oh(){return l.useContext(ah)}function sh(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=oh(),o=zc(),s=$e(()=>Symbol()),c=l.useRef(!1),u=l.useRef(!1),d=$(()=>{c.current&&i!==et&&(c.current=!1,i(s.current,void 0))});return W(()=>{if(!n||i===et){d();return}let e;if(t!==void 0)u.current=!0,e=t;else if(u.current)e=o;else{a();return}if(e===void 0){d();return}c.current=!0,i(s.current,e)},[t,n,i,a,o,s,d]),W(()=>d,[d]),(n?r:void 0)??t??o}function ch(e){return e==null?void 0:`${e}-popup`}function lh(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function uh(e){return Array.isArray(e)?e.map(e=>uh(e)).join(`,`):e==null?``:String(e)}var dh=new Map;function fh(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${uh(e.locale)}|${JSON.stringify(t)}`,r=dh.get(n);if(r)return r;let i=new Intl.Collator(e.locale,t),a={contains(e,t,n){if(!t)return!0;let r=Wm(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(i.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Wm(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Wm(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return dh.set(n,a),a}var ph=fh;function mh(e,t=!1){let{overflowY:n}=je(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}var hh=Symbol(`none`),gh={value:hh,index:-1};function _h(e,t,n){let r=e.get(t);if(r!==void 0||n===Am)return r;for(let[r,i]of e)if(jm(r,t,n))return i}function vh(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:u=!1,selectionMode:d,onItemHighlighted:f,name:p,form:m,disabled:h=!1,readOnly:g=!1,required:_=!1,inputRef:v,grid:y=!1,items:b,filteredItems:x,filter:S,filterQuery:C,openOnInputClick:w=!0,autoHighlight:T=!1,keepHighlight:E=!1,highlightItemOnHover:D=!0,loopFocus:O=!0,itemToStringLabel:k,itemToStringValue:A,isItemEqualToValue:j=Am,virtualized:M=!1,inline:N=!1,fillInputOnItemPress:P=!0,modal:F=!1,limit:I=-1,autoComplete:L=`list`,formAutoComplete:R,locale:z,submitOnItemClick:B=!1}=e,{clearErrors:V}=ih(),{setDirty:ee,validityData:te,setFilled:ne,name:H,disabled:U,setTouched:re,setFocused:ie,validationMode:ae,validation:oe}=th(),se=Al(),ce=sh({id:t}),le=ph({locale:z}),ue=Array.isArray(b)?null:b;if(ue&&typeof ue.label!=`function`)throw Error(Mi(100));let de=ue?ue.data:b,fe=ue?.value,pe=fe?void 0:de,me=l.useMemo(()=>{if(!x||!fe)return;let e=Hm(x),t=e.map(fe),n;return{values:t,findItem(r,i){if(!n){n=new Map;for(let r=0;r<t.length;r+=1)n.has(t[r])||n.set(t[r],e[r])}return _h(n,r,i)}}},[x,fe]),he=l.useMemo(()=>ue?e=>ue.label(e,j,e=>{let t=me?.findItem(e,j);return t==null?Wm(e,k):ue.itemLabel(t)}):k,[ue,k,me,j]),G=l.useMemo(()=>ue?Object.assign(e=>ue.itemLabel(e),{selected:e=>Wm(e,he)}):k,[ue,he,k]);function ge(e){return Wm(e,he)}let[_e,K]=l.useState(!1),[ye,be]=l.useState(null),xe=l.useRef(ye),Se=l.useRef([]),Ce=l.useRef([]),we=l.useRef(null),Te=l.useRef(null),Ee=l.useRef(null),De=l.useRef(null),Oe=l.useRef(null),ke=l.useRef(!0),Ae=l.useRef(!1),je=l.useRef(null),Me=l.useRef(null),Ne=l.useRef(null),Pe=l.useRef(gh),Ie=l.useRef(null),q=l.useRef([]),Le=l.useRef(null),Re=U||h,ze=H??p,Be=d===`multiple`,Ve=d===`single`,He=s!==void 0||o!==void 0,Ue=de!==void 0,We=x!==void 0,Ge;Ge=T===`always`?`always`:T?`input-change`:!1;let[Ke,qe]=gm({controlled:i,default:Be?r??tt:r,name:`Combobox`,state:`selectedValue`}),Je=l.useMemo(()=>S===null?()=>!0:S===void 0?lh(le,G):S,[S,le,G]),Ye=$e(()=>He?o??``:Ve?ge(Ke):``).current,[Xe,Ze]=gm({controlled:s,default:Ye,name:`Combobox`,state:`inputValue`}),[J,Qe]=gm({controlled:c,default:u,name:`Combobox`,state:`open`}),rt=Vm(de),it=!J&&ye!==null?ye:String(Xe).trim(),at=Ve?ge(Ke):``,ot=Ve&&!_e&&it!==``&&at.length===it.length&&le.contains(at,it),st=ot?``:C??it,ct=Ue&&We&&ot&&(!ue||ue.hasValue(Ke,j)),lt=l.useMemo(()=>de?Hm(de):tt,[de]),ut=l.useMemo(()=>{if(x&&!ct)return x;if(!de)return tt;if(rt){let e=de,t=[],n=0;for(let r of e){if(I>-1&&n>=I)break;let e=I>-1?I-n:1/0,i=st===``?r.items.slice(0,e):[];if(st!==``)for(let t of r.items){if(i.length>=e)break;Je(t,st,G)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(st===``)return I>-1?lt.slice(0,I):lt;let e=[];for(let t of lt){if(I>-1&&e.length>=I)break;Je(t,st,G)&&e.push(t)}return e},[x,ct,de,rt,st,I,Je,G,lt]),dt=l.useMemo(()=>{if(me&&ut===x)return me.values;let e=Hm(ut);return fe?e.map(e=>fe(e)):e},[ut,x,me,fe]),Y=$e(()=>{let e=null;return N&&J&&Ue&&d!==`none`&&(e=Im(dt,Ke,j,Be)),new ps({id:ce,labelId:void 0,selectedValue:Ke,open:J,items:pe,selectionMode:d,name:ze,form:m,disabled:Re,readOnly:g,required:_,grid:y,virtualized:M,openOnInputClick:w,itemToStringLabel:he,isItemEqualToValue:j,modal:F,autoHighlight:Ge,submitOnItemClick:B,hasInputValue:He,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:N,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemProps:nt,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:d===`none`},{onOpenChangeComplete:et,setOpen:et,setInputValue:et,setSelectedValue:et,setIndices:et,handleSelection:et,forceMount:et,requestSubmit:et,listRef:Se,labelsRef:Ce,popupRef:we,emptyRef:Oe,inputRef:Te,startDismissRef:Ee,endDismissRef:De,keyboardActiveRef:ke,chipsContainerRef:je,clearRef:Me,valuesRef:q,pointerDownItemRef:Le,selectionEventRef:Ne},Km)}).current,ft=d===`none`?Xe:Ke,pt=l.useMemo(()=>d===`none`?ft:Array.isArray(Ke)?Ke.map(e=>Gm(e,A)):Gm(Ke,A),[ft,A,d,Ke]),mt=$(f),ht=$(n),gt=Y.useState(`activeIndex`),_t=Y.useState(`selectedIndex`),vt=Y.useState(`positionerElement`),yt=Y.useState(`listElement`),bt=Y.useState(`triggerElement`),xt=Y.useState(`inputElement`),St=Y.useState(`inputGroupElement`),Ct=Y.useState(`inline`),wt=Y.useState(`inputInsidePopup`),Tt=Y.useState(`inputOwnsFormValue`),Et=Ve&&!wt&&Xe===at,Dt=Kn(bt),{mounted:kt,setMounted:At,transitionStatus:jt}=_s(J),{openMethod:Mt,triggerProps:Nt}=tl(J),Pt=$(()=>pt);nh(wt?Dt:Te,ce,ft,Pt,!Re,p);let Ft=$(()=>{de?Ce.current=dt.map(ge):Y.set(`forceMounted`,!0)}),It=$((e,t,n)=>{if(t===-1){if(Pe.current===gh)return;Pe.current=gh}else Pe.current={value:e,index:t};mt(e,Pn(n,void 0,{index:t}))}),Lt=$(e=>{let t={};e.activeIndex!==void 0&&(t.activeIndex=e.activeIndex),e.selectedIndex!==void 0&&(t.selectedIndex=e.selectedIndex),Y.update(t);let n=e.activeIndex;if(n===void 0)return;let r=e.type||`none`;n===null?It(void 0,-1,r):It(q.current[n],n,r)}),Rt=$((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(Ae.current=n.reason===Cn,n.reason===`input-change`){J&&ye!==null&&be(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&K(!0),Ie.current={hasQuery:e};let n=Y.state.listElement;if(!Y.state.virtualized&&n){let e=we.current;for(let t of Fe(n.firstElementChild??n)){if(!ve(t)||(e?!X(e,t):t.getAttribute(`role`)===`dialog`))break;if(mh(t)){t.scrollTop=0;break}}}e&&Ge&&Y.state.activeIndex==null&&(J||Ct)&&Y.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&Y.state.inputInsidePopup&&(Ie.current={hasQuery:!1,selection:!0});Ze(t)}}),zt=$(e=>{let t=!e&&wt&&!Ct&&Xe!==``&&(String(Xe).trim()===ye||Xe===at);!e&&(t||Xe===``||Et)&&K(!1),be(null),t&&Rt(``,Z(Cn))}),Bt=$((t,n)=>{if(J!==t&&(n.reason===`escape-key`&&Ue&&dt.length===0&&!Oe.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&ye!==null&&zt(n.reason===Sn),!t&&_e&&(Ve?(Ct||be(it),it===``&&K(!1)):Be&&(Ct||be(it),wt&&Lt({activeIndex:null}),(!wt||Ct)&&Rt(``,Z(Cn,n.event,void 0,{isItemPress:n.reason===bn})))),Qe(t),!t&&wt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(re(!0),ie(!1),ae===`onBlur`)))){let e=d===`none`?Xe:Ke;oe.commit(e)}}),Vt=$((e,t)=>{a?.(e,t),!t.isCanceled&&(qe(e),(d===`none`&&we.current&&P||Ve&&!Y.state.inputInsidePopup)&&Rt(ge(e),Z(t.reason,t.event)))}),Ht=$((e,t)=>{let n=Ot(e),r=Ne.current??e;Ne.current=null;let i=Z(bn,r),a=n?.closest(`a`)?.getAttribute(`href`);if(a){a.startsWith(`#`)&&Bt(!1,i);return}if(Be){let e=Array.isArray(Ke)?Ke:[],n=Nm(e,t,j),r=n?Rm(e,t,j):[...e,t];if(Vt(r,i),i.isCanceled||!(Te.current&&Te.current.value.trim()!==``))return;if(Y.state.inputInsidePopup){Rt(``,Z(Cn,i.event,void 0,{isItemPress:!0}));let e=Ie.current;e&&!n&&(e.toggledValue=t)}else Bt(!1,i)}else{if(Vt(t,i),i.isCanceled)return;Bt(!1,i)}}),Ut=$(()=>{let e=oe.inputRef.current?.form??Y.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),Wt=$(()=>{if(At(!1),ht?.(!1),K(!1),be(null),Lt(d===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Be&&Te.current&&Te.current.value!==``&&!Ae.current&&Rt(``,Z(Cn)),Ve){if(Y.state.inputInsidePopup)Te.current&&Te.current.value!==``&&Rt(``,Z(Cn));else{let e=ge(Ke);Te.current&&Te.current.value!==e&&Rt(e,Z(e===``?Cn:hn))}}}),Gt=l.useMemo(()=>Ct&&vt?{current:vt.closest(`[role="dialog"]`)}:we,[Ct,vt]);xs({enabled:!e.actionsRef,open:J,ref:Gt,onComplete(){J||Wt()}}),l.useImperativeHandle(e.actionsRef,()=>({unmount:Wt}),[Wt]),W(function(){let e=xe.current!==null&&ye===null;if(xe.current=ye,J&&(!e||!Ue)||(J||(Le.current=null),d===`none`))return;let t=Ue?dt:q.current;Lt({selectedIndex:Im(t,Ke,j,Be)})},[J,ye,Ke,d,Be,Ue,dt,j,Lt]),W(()=>{de&&(q.current=dt,Se.current.length=dt.length)},[de,dt]),W(()=>{let e=Ie.current;if(e){let t=J||Ct||Y.state.positionerElement?.hidden===!1;if(e.hasQuery)Ge&&t&&Y.set(`activeIndex`,0),Ie.current=null;else if(String(Xe).trim()===``&&(Ie.current=null,t)){let t=e.selection;Ge===`always`&&!t&&Y.state.selectionMode===`none`&&Y.set(`activeIndex`,0),queueMicrotask(()=>{if(!Y.state.open&&!Y.state.inline||Te.current&&Te.current.value.trim()!==``)return;let n=Y.state.selectedValue,r=Y.state.selectionMode===`multiple`;if(r&&Array.isArray(n)?n.length>0:Y.state.selectionMode!==`none`&&n!=null){let t=Ue||We?dt:q.current,i=Pm(t,e.toggledValue,Y.state.isItemEqualToValue);Y.set(`activeIndex`,i===-1?Im(t,n,Y.state.isItemEqualToValue,r):i)}else t?Y.set(`activeIndex`,null):Ge===`always`&&Y.set(`activeIndex`,0)})}}if(!J&&!Ct)return;let t=Ue||We?dt:q.current,n=Y.state.activeIndex;if(n==null){if(Ge===`always`&&t.length>0){Y.set(`activeIndex`,0);return}It(void 0,-1,hn);return}if(n>=t.length){It(void 0,-1,hn),Y.set(`activeIndex`,null);return}let r=t[n],i=Pe.current.value,a=i!==hh&&jm(r,i,Y.state.isItemEqualToValue);(Pe.current.index!==n||!a)&&It(r,n,hn)},[gt,Ge,It,We,Ue,dt,Ct,J,Y,Xe]),W(()=>{if(d===`none`){ne(String(Xe)!==``);return}ne(Be?Array.isArray(Ke)&&Ke.length>0:Ke!=null)},[ne,d,Xe,Ke,Be]),l.useEffect(()=>{Ue&&Ge&&dt.length===0&&Lt({activeIndex:null})},[Ue,Ge,dt.length,Lt]);function Kt(){J&&it!==``&&it!==String(Ye)&&!Et&&K(!0)}function qt(){J&&ye!==null&&zt(!1)}let Jt=!1;function Yt(){!Jt&&Xe!==at&&(Jt=!0,Rt(at,Z(hn)))}function Xt(){d!==`none`&&(V(ze),ee(Mm(Ke,te.initialValue,j)),oe.change(Ke),Ve&&!He&&!wt&&Yt())}function Zt(){Ve&&!He&&!wt&&!_e&&Yt()}function Qt(){d===`none`&&(V(ze),ee(Xe!==te.initialValue),oe.change(Xe))}$c(it,Kt),$c(J,qt),$c(Ke,Xt),$c(at,Zt),$c(de,Zt),$c(Xe,Qt);let $t=Gs({open:Ct?!0:J,onOpenChange:Bt,elements:{reference:wt?bt:xt,floating:vt}}),en=y?`grid`:`listbox`,tn=J||Ct,nn=tn?`true`:`false`,rn=l.useMemo(()=>{let e=xt?.tagName===`INPUT`,t=xt==null||e,n=t||tn,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=nn,r[`aria-haspopup`]=en,r[`aria-controls`]=tn?yt?.id:void 0,r[`aria-autocomplete`]=g?`none`:L),{reference:r,floating:{role:`presentation`}}},[xt,tn,nn,en,yt?.id,L,g]),an=La($t,{enabled:!Re&&w,event:`mousedown-only`,toggle:!1,touchOpenDelay:wt?0:100,reason:wn}),on=Ua($t,{enabled:!Re&&!Ct,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:Ct?!0:void 0,outsidePress(e){let t=Ot(e);return!X(bt,t)&&!X(Me.current,t)&&!X(je.current,t)&&!X(St,t)}}),sn=dc($t,{enabled:!Re,id:ce,listRef:Se,activeIndex:gt,selectedIndex:_t,virtual:!0,loopFocus:O,allowEscape:O&&!Ge,focusItemOnOpen:_e||d===`none`&&!Ge?!1:`auto`,focusItemOnHover:D,resetOnPointerLeave:!E,orientation:y?`horizontal`:void 0,rtl:se===`rtl`,disabledIndices:tt,grid:y?vm:void 0,onNavigate(e,t){(t||J)&&jt!==`ending`&&Lt(t?{activeIndex:e,type:ke.current?On:kn}:{activeIndex:e})}}),cn=l.useMemo(()=>Vi(sn.reference,{onKeyDown(e){y&&Y.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},on.reference,an.reference,rn.reference),[sn.reference,on.reference,an.reference,rn.reference,y,Y]),ln=l.useMemo(()=>Vi(Ss,on.floating),[on.floating]),un=l.useMemo(()=>Vi(sn.floating,rn.floating),[sn.floating,rn.floating]),dn=l.useMemo(()=>{let e=sn.item;return e?{...e,onFocus:void 0}:nt},[sn.item]);Y.useContextCallback(`setOpen`,Bt),Y.useContextCallback(`setInputValue`,Rt),Y.useContextCallback(`setSelectedValue`,Vt),Y.useContextCallback(`setIndices`,Lt),Y.useContextCallback(`handleSelection`,Ht),Y.useContextCallback(`forceMount`,Ft),Y.useContextCallback(`requestSubmit`,Ut),Y.useContextCallback(`onOpenChangeComplete`,n),_m(()=>{Y.update({inline:N,popupProps:ln,listProps:un,inputProps:cn,triggerProps:Nt,itemProps:dn})});let fn={id:ce,selectedValue:Ke,open:J,mounted:kt,transitionStatus:jt,items:pe,inline:N,popupProps:ln,listProps:un,inputProps:cn,triggerProps:Nt,itemProps:dn,openMethod:Mt,selectionMode:d,name:ze,form:m,disabled:Re,readOnly:g,required:_,grid:y,virtualized:M,openOnInputClick:w,itemToStringLabel:he,modal:F,autoHighlight:Ge,isItemEqualToValue:j,submitOnItemClick:B,hasInputValue:He};W(()=>{Y.update({...fn,inputOwnsFormValue:d===`none`&&(N||!Y.state.inputInsidePopup)})},[Y,...Object.values(fn)]);let pn=Bn(v,oe.inputRef),mn=l.useMemo(()=>({query:it,hasItems:Ue,filteredItems:ut,flatFilteredValues:dt}),[it,Ue,ut,dt]),gn=l.useMemo(()=>Array.isArray(ft)?``:Gm(ft,A),[ft,A]),_n=Be&&Array.isArray(Ke)&&Ke.length>0,vn=Be||d===`none`&&Tt?void 0:ze,yn=l.useMemo(()=>!Be||!Array.isArray(Ke)||!ze?null:Ke.map(e=>{let t=Gm(e,A);return(0,Q.jsx)(`input`,{type:`hidden`,form:m,name:ze,value:t,disabled:Re},t)}),[Be,Ke,m,ze,A,Re]),xn=(0,Q.jsxs)(l.Fragment,{children:[e.children,(0,Q.jsx)(`input`,{...oe.getValidationProps(Re,{onFocus(){if(wt){bt?.focus();return}(Te.current||bt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||Re||g)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=Z(hn,e.nativeEvent),i=()=>q.current.findIndex(e=>Gm(e,A).toLowerCase()===n||ge(e).toLowerCase()===n);function a(){if(Be)return;if(d===`none`){Rt(t,r);return}let e=i();e===-1&&(e=q.current.findIndex((e,t)=>{let r=Ce.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:q.current[e];a!=null&&Vt?.(a,r)}Ve&&(Ft(),de&&i()===-1&&Y.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:ce&&vn==null?`${ce}-hidden-input`:void 0,form:m,name:vn,autoComplete:R,disabled:Re,required:_&&!_n,readOnly:g,value:gn,ref:pn,style:vn?tr:er,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),yn]});return(0,Q.jsx)(ym.Provider,{value:Y,children:(0,Q.jsx)(bm.Provider,{value:$t,children:(0,Q.jsx)(Sm.Provider,{value:Ue,children:(0,Q.jsx)(xm.Provider,{value:mn,children:(0,Q.jsx)(Cm.Provider,{value:Xe,children:xn})})})})})}function yh(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,Q.jsx)(vh,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}function bh(e,t){return e??t}var xh=`data-popup-side`,Sh=`data-list-empty`,Ch={...Zt,...Qm,popupSide:e=>e?{[xh]:e}:null,listEmpty:e=>e?{[Sh]:``}:null},wh=l.createContext(void 0);function Th(){return l.useContext(wh)}var Eh=l.createContext(void 0);function Dh(e){let t=l.useContext(Eh);if(t===void 0&&!e)throw Error(Mi(21));return t}var Oh=l.forwardRef(function(e,t){let n=wm(),{buttonRef:r,getButtonProps:i}=Fc({native:!1}),a=Bn(t,r);function o(e){n.context.setOpen(!1,Z(xn,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return(0,Q.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:tr})});function kh(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function Ah(){return Em().filteredItems.length===0}function jh(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function Mh(e,t){let n=e>=t-1?t-2:e;return n>=0?n:void 0}function Nh(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}var Ph=l.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:u,setTouched:d,setFocused:f,validationMode:p,validation:m}=th(),{labelId:h}=oh(),g=Th(),_=!!Dh(!0),v=wm(),y=Dm(),b=Al(),x=v.useState(`required`),S=v.useState(`disabled`),C=v.useState(`readOnly`),w=v.useState(`name`),T=v.useState(`form`),E=v.useState(`selectionMode`),D=v.useState(`autoHighlight`),O=v.useState(`inputProps`),k=v.useState(`triggerProps`),A=v.useState(`open`),j=v.useState(`mounted`),M=v.useState(`selectedValue`),N=v.useState(`id`),P=v.useState(`inline`),F=v.useState(`modal`),I=!!D,L=kh(v),R=u||S||i,z=Ah(),B=_||P,V=!B||F,ee=zc(a??(B?void 0:N)),te=_?Xm:c,[ne,H]=l.useState(null),U=l.useRef(!1),re=l.useRef(null),ie=l.useRef(!1),ae=E===`none`&&!_,oe=$(e=>{let t=_||v.state.inline;t&&!v.state.hasInputValue&&v.context.setInputValue(``,Z(hn)),v.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:ae})}),se=_?s:m.getValidationProps(R,s);function ce(){v.context.setIndices({activeIndex:null,selectedIndex:null,type:v.context.keyboardActiveRef.current?On:kn})}function le(){v.context.keyboardActiveRef.current=!1}let ue={...te,open:A,disabled:R,readOnly:C,popupSide:L,listEmpty:z};function de(e){if(!g)return;let t,{highlightedChipIndex:n}=g,r=g.chipsRef.current.length,[i,a]=jh(b);return n===void 0?(e.key===i&&(e.currentTarget.selectionStart??0)===0&&M.length>0&&(e.preventDefault(),t=r>0?r-1:void 0),t):(e.key===i?(e.preventDefault(),t=n>0?n-1:void 0):e.key===a?(e.preventDefault(),t=n<r-1?n+1:void 0):(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),t=Mh(n,M.length),ce()),t)}let fe=ta(`input`,e,{state:ue,ref:[t,v.context.inputRef,oe],props:[O,k,{value:ne??y,"aria-readonly":C||void 0,"aria-required":x||void 0,"aria-labelledby":h,disabled:R,readOnly:C,required:E===`none`?x:void 0,form:T,...ae&&w&&{name:w},id:ee,onFocus(){if(f(!0),!P||!ie.current)return;ie.current=!1;let e=re.current;e!=null&&Object.hasOwn(v.context.valuesRef.current,e)&&v.context.setIndices({activeIndex:e})},onBlur(){d(!0),f(!1);let e=v.state.activeIndex;if(P&&e!==null&&D!==`always`&&(re.current=e,ie.current=!0,v.context.setIndices({activeIndex:null})),p===`onBlur`){let e=E===`none`?y:M;m.commit(e)}},onCompositionStart(e){Ge||(U.current=!0,H(e.currentTarget.value))},onCompositionEnd(e){U.current=!1;let t=e.currentTarget.value;H(null),v.context.setInputValue(t,Z(Sn,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=U.current||!r;function a(e){!C&&!R&&e&&i&&(v.context.setOpen(!0,Z(Sn,t)),I||ce())}if(U.current){let n=e.currentTarget.value;H(n),n===``&&!v.state.openOnInputClick&&!v.state.inputInsidePopup&&v.context.setOpen(!1,Z(Cn,t));let r=n.trim(),i=I&&r!==``;a(r),A&&v.state.activeIndex!==null&&!i&&ce();return}let o=Z(Sn,t);if(v.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=Z(Cn,t);s&&!v.state.inputInsidePopup&&(E===`single`&&v.context.setSelectedValue(null,c),v.state.openOnInputClick||v.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),A&&v.state.activeIndex!==null&&!I&&ce()},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(v.context.keyboardActiveRef.current=!0,R||C){C&&e.key===`Enter`&&A&&v.state.activeIndex!==null&&xt(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=b===`rtl`;if(e.key===`Home`){xt(e);let n=Ye&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){xt(e);let i=Ye&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!j&&e.key===`Escape`){let t=E===`multiple`&&Array.isArray(M)?M.length===0:M===null,n=Z(En,e.nativeEvent),r=E===`multiple`?[]:null;v.context.setInputValue(``,n),v.context.setSelectedValue(r,n),!t&&!v.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(g&&e.key===`Backspace`&&t.value===``&&g.highlightedChipIndex===void 0&&Array.isArray(M)&&M.length>0){let t=g.chipsRef.current.length,n=t>0?t-1:M.length-1,r=M.filter((e,t)=>t!==n);ce(),v.context.setSelectedValue(r,Z(hn,e.nativeEvent));return}let i=g?.highlightedChipIndex!==void 0,a=de(e);if(g?.setHighlightedChipIndex(a),a===void 0?i&&v.context.inputRef.current?.focus():g?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&A){let t=v.state.activeIndex,n=e.nativeEvent;if(t===null){if(P)return;v.context.setOpen(!1,Z(hn,n));return}xt(e),Nh(v,t,n)}},onPointerMove:le,onPointerDown:le},se],stateAttributesMapping:Ch}),pe=_?(0,Q.jsx)(eh.Provider,{value:$m,children:fe}):fe;return(0,Q.jsxs)(l.Fragment,{children:[A&&V&&(0,Q.jsx)(Oh,{ref:v.context.startDismissRef}),pe]})}),Fh=5;function Ih(e,t){let n=Lh(t);return e.clientX>=n.left-Fh&&e.clientX<=n.right+Fh&&e.clientY>=n.top-Fh&&e.clientY<=n.bottom+Fh}function Lh(e){let t=e.getBoundingClientRect(),n=G(e);if(Ze)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}var Rh=l.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:u,disabled:d,setTouched:f,setFocused:p,validationMode:m,validation:h}=th(),{labelId:g}=oh(),_=wm(),v=_.useState(`selectionMode`),y=_.useState(`disabled`),b=_.useState(`readOnly`),x=_.useState(`required`),S=_.useState(`positionerElement`),C=_.useState(`listElement`),w=_.useState(`popupId`),T=_.useState(`triggerProps`),E=_.useState(`inputInsidePopup`),D=_.useState(`id`),O=_.useState(`labelId`),k=_.useState(`open`),A=_.useState(`selectedValue`),j=_.useState(`activeIndex`),M=_.useState(`selectedIndex`),N=_.useState(`hasSelectedValue`),P=Tm(),F=Dm(),I=ot(),L=d||y||a,R=Ah(),z=kh(_);sh({id:E?o:void 0});let B=E?o??D:o,V=bh(g,O),ee;k&&E?ee=w??ch(D):k&&(ee=C?.id);let te=l.useRef(``);function ne(e){te.current=e.pointerType}let{reference:H}=fc(P,{enabled:!k&&!b&&!y&&v===`single`,listRef:_.context.labelsRef,activeIndex:j,selectedIndex:M,onMatch(e){let t=_.context.valuesRef.current[e];t!==void 0&&_.context.setSelectedValue(t,Z(hn))}}),{reference:U}=La(P,{enabled:!y,event:`mousedown`}),{buttonRef:re,getButtonProps:ie}=Fc({native:i,disabled:L}),ae={...u,readOnly:b,open:k,disabled:L,popupSide:z,listEmpty:R,placeholder:v!==`none`&&!N};return ta(`button`,e,{ref:[t,re,$(e=>{_.set(`triggerElement`,e)})],state:ae,props:[T,U,H,{id:B,tabIndex:E?0:-1,role:E?`combobox`:void 0,"aria-expanded":k,"aria-haspopup":E?`dialog`:`listbox`,"aria-controls":ee,"aria-required":E&&x||void 0,"aria-readonly":E&&b||void 0,"aria-labelledby":V,onPointerDown:ne,onPointerEnter:ne,onFocus(){p(!0),!L&&I.start(0,_.context.forceMount)},onBlur(e){if(!X(S,e.relatedTarget)&&(f(!0),p(!1),m===`onBlur`)){let e=v===`none`?F:A;h.commit(e)}},onMouseDown(e){if(L||(E||P.set(`domReferenceElement`,e.currentTarget),_.context.forceMount(),te.current!==`touch`&&(_.context.inputRef.current?.focus(),E||e.preventDefault()),k))return;let t=J(e.currentTarget);function n(e){let t=_.state.triggerElement;if(!t)return;let n=Ot(e),r=_.state.positionerElement,i=_.state.listElement;X(t,n)||X(r,n)||X(i,n)||Ih(e,t)||_.context.setOpen(!1,Z(An,e))}E&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(xt(e),_.context.setOpen(!0,Z(Dn,e.nativeEvent)),_.context.inputRef.current?.focus())}},h.getValidationProps(L,c),ie],stateAttributesMapping:Ch})}),zh=l.createContext(null);function Bh(){return l.useContext(zh)}function Vh(e){let{children:t}=e,{filteredItems:n}=Em(),r=Bh(),i=r?r.items:n;return(0,Q.jsx)(l.Fragment,{children:i.map(t)})}var Hh=l.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Uh(){return l.useContext(Hh)}function Wh(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=$(i),[,o]=l.useState(!1),s=$e(Kh).current,c=$e(Gh).current,u=l.useRef(0),d=l.useRef(!0),f=l.useRef(null),p=l.useRef(null),m=$(()=>{d.current||(d.current=!0,o(e=>!e))}),h=$((e,t)=>{c.set(e,t),m()}),g=$(e=>{c.delete(e),m()}),_=$(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),u.current=n.current.length,t});function v(e){if(p.current?.disconnect(),p.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!Yh(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&Xh(r,n)>0){t.disconnect(),m();return}r=n}});p.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=Jh(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let y=$(()=>{let[e,t]=qh(c),n=_(e),r=f.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});v(t),f.current=e,d.current=!1,i&&(s.forEach(e=>e(n)),a(n))});W(()=>(!d.current&&f.current&&_(f.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,_]),W(()=>{d.current&&y()}),W(()=>()=>{p.current?.disconnect(),d.current=!0},[]);let b=$(e=>(s.add(e),()=>{s.delete(e)})),x=l.useMemo(()=>({register:h,unregister:g,subscribeMapChange:b,nextIndexRef:u}),[h,g,b,u]);return(0,Q.jsx)(Hh.Provider,{value:x,children:t})}function Gh(){return new Map}function Kh(){return new Set}function qh(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>Xh(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function Jh(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function Yh(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function Xh(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var Zh=l.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=wm(),u=Tm(),d=!!Dh(!0),{filteredItems:f,hasItems:p}=Em(),m=c.useState(`selectionMode`),h=c.useState(`grid`),g=c.useState(`readOnly`),_=c.useState(`listProps`),v=c.useState(`virtualized`),y=c.useState(`forceMounted`),b=m===`multiple`,x=f.length===0,S=$(e=>{c.set(`positionerElement`,e)}),C=$(e=>{c.set(`listElement`,e)}),w=l.useMemo(()=>typeof o==`function`?n||=(0,Q.jsx)(Vh,{children:o}):o,[o]),T={empty:x},E=u.useState(`floatingId`),D=ta(`div`,e,{state:T,ref:[t,C,d?null:S],props:[_,{children:w,tabIndex:-1,id:E,role:h?`grid`:`listbox`,"aria-multiselectable":b?`true`:void 0,"aria-readonly":!h&&g?!0:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;xt(e),Nh(c,t,e.nativeEvent)}},onKeyDownCapture(){c.context.keyboardActiveRef.current=!0},onPointerMoveCapture(){c.context.keyboardActiveRef.current=!1}},s]});if(v)return D;let O=p&&!y?void 0:c.context.labelsRef;return(0,Q.jsx)(Wh,{elementsRef:c.context.listRef,labelsRef:O,children:D})}),Qh=``;function $h(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function eg(){let e=ot(),t=l.useRef(null);return l.useEffect(()=>{if(Ue)return;let n=t.current;if(n==null)return;let r=$h(n);if(r==null)return;let i=r.data,a=`${i}${Qh}`;return r.nodeValue=a,e.start(200,()=>{r.nodeValue===a&&(r.nodeValue=i)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=i)}},[t,e]),t}var tg=l.createContext(void 0);function ng(){let e=l.useContext(tg);if(e===void 0)throw Error(Mi(20));return e}var rg=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=wm(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?(0,Q.jsx)(tg.Provider,{value:n,children:(0,Q.jsx)(_a,{ref:t,...r})}):null}),ig=20;function ag(e,t,n,r){let[i,a]=l.useState(!1);W(()=>{if(!e||!t||n==null){a(!1);return}let r=J(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-ig)},[e,t,n]),bt(e&&(!t||i),r)}var og=l.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m=!1,collisionAvoidance:h=la,style:g,..._}=e,v=wm(),y=Tm(),b=ng(),x=v.useState(`modal`),S=v.useState(`open`),C=v.useState(`mounted`),w=v.useState(`openMethod`),T=v.useState(`positionerElement`),E=v.useState(`triggerElement`),D=v.useState(`inputElement`),O=v.useState(`inputGroupElement`),k=v.useState(`inputInsidePopup`),A=v.useState(`transitionStatus`),j=Ah(),M=Wl({anchor:i??(k?E:O??D),floatingRootContext:y,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});ag(S&&x,w===`touch`,T,E);let N={open:S,side:M.side,align:M.align,anchorHidden:M.anchorHidden,empty:j};W(()=>{v.set(`popupSide`,M.side)},[v,M.side]);let P=$(e=>{v.set(`positionerElement`,e)}),F=Jl(e,N,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,P],hidden:!C,inert:!S});return(0,Q.jsxs)(Eh.Provider,{value:M,children:[C&&x&&(0,Q.jsx)(Yc,{inert:Jc(!S),cutout:O??D??E}),F]})}),sg={...Qt,...zt},cg=l.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=wm(),u=Dh(),d=Tm(),f=c.useState(`mounted`),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`popupProps`),g=c.useState(`transitionStatus`),_=c.useState(`inputInsidePopup`),v=c.useState(`inputElement`),y=c.useState(`modal`),b=c.useState(`id`),x=Ah(),S=s.id??(_?ch(b):void 0);W(()=>(c.set(`popupId`,c.context.popupRef.current?.id||S),()=>{c.set(`popupId`,void 0)}),[c,S]),xs({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete(!0)}});let C=ta(`div`,e,{state:{open:p,side:u.side,align:u.align,anchorHidden:u.anchorHidden,transitionStatus:g,empty:x},ref:[t,c.context.popupRef],props:[h,{id:S,role:_?`dialog`:`presentation`,onFocus(e){let t=Ot(e.nativeEvent);m!==`touch`&&(X(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},ql(g),s],stateAttributesMapping:sg}),w=a===void 0?_?e=>e===`touch`?c.context.popupRef.current:v:!1:a,T;T=o??(_?void 0:!1);let E=!_||y;return(0,Q.jsx)(Ia,{context:d,disabled:!f,modal:E,openInteractionType:m,initialFocus:w,returnFocus:T,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:(0,Q.jsxs)(l.Fragment,{children:[C,E&&(0,Q.jsx)(Oh,{ref:c.context.endDismissRef})]})})});function lg(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:u}=Uh(),d=l.useRef(-1),[f,p]=l.useState(a==null&&t?()=>{if(d.current===-1){let e=u.current;u.current+=1,d.current=e}return d.current}:-1),m=a??f,h=l.useRef(null),g=l.useCallback(e=>{let t=h.current;t&&s(t),h.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return W(()=>{if(a==null)return c(e=>{let t=h.current?e.get(h.current)?.index:null;t!=null&&p(t)})},[a,c]),{ref:g,index:m}}var ug=l.createContext(void 0);function dg(){let e=l.useContext(ug);if(!e)throw Error(Mi(19));return e}var fg=l.createContext(!1);function pg(){return l.useContext(fg)}function mg(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:u,disabled:d=!1,nativeButton:f=!1,...p}=t,m=l.useRef(null),h=lg({guess:!0,index:u,textRef:m}),g=wm(),_=pg(),v=Om(),y=g.useState(`selectionMode`),b=g.useState(`disabled`),x=g.useState(`readOnly`),S=g.useState(`isItemEqualToValue`),C=b||d,w=y!==`none`,T=u??i??h.index,E=T!==-1,D=g.useState(`id`),O=g.useState(`isActive`,T),k=g.useState(`isSelected`,c),A=g.useState(`itemProps`),j=l.useRef(null),M=D!=null&&E?`${D}-${T}`:void 0,N=k&&w;W(()=>{if(!E||!r&&u==null)return;let e=g.context.listRef.current;return e[T]=j.current,()=>{delete e[T]}},[E,r,T,u,g]),W(()=>{if(!E||v)return;let e=g.context.valuesRef.current;return e[T]=c,()=>{delete e[T]}},[E,v,T,c,g]),W(()=>{if(!E||v)return;let e=g.state.selectedValue,t=g.state.selectedIndex;g.state.selectionMode===`multiple`&&Array.isArray(e)?t=Lm(T,c,g.context.valuesRef.current,e,S,t):jm(c,e,S)&&(t=T),g.set(`selectedIndex`,t)},[E,v,g,T,c,S]);let{getButtonProps:P,buttonRef:F}=Fc({disabled:C,focusableWhenDisabled:!0,native:f,composite:!0}),I={disabled:C,selected:N,highlighted:O};function L(e){function t(){g.context.handleSelection(e,c)}g.state.submitOnItemClick?(fa.flushSync(t),g.context.requestSubmit()):t()}let R={id:M,role:_?`gridcell`:`option`,"aria-selected":w?N:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(g.context.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){C||x||L(e.nativeEvent)},onMouseUp(e){let t=g.context.pointerDownItemRef.current===e.currentTarget;g.context.pointerDownItemRef.current=null,!(C||x||e.button!==0||t||!O)&&L(e.nativeEvent)}},z=ta(`div`,t,{ref:[F,n,h.ref,j],state:I,props:[A,R,p,P]}),B=l.useMemo(()=>({selected:N,textRef:m}),[N,m]);return(0,Q.jsx)(ug.Provider,{value:B,children:z})}function hg(e){let{componentProps:t,forwardedRef:n}=e,r=wm().useState(`isItemEqualToValue`),{flatFilteredValues:i}=Em(),a=Pm(i,t.value??null,r);return(0,Q.jsx)(mg,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}var gg=l.memo(l.forwardRef(function(e,t){let n=wm().useState(`virtualized`);return n&&e.index==null?(0,Q.jsx)(hg,{componentProps:e,forwardedRef:t}):(0,Q.jsx)(mg,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),_g=l.forwardRef(function(e,t){let{selected:n}=dg();return e.keepMounted||n?(0,Q.jsx)(vg,{...e,ref:t}):null}),vg=l.memo(l.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=dg(),c=l.useRef(null),{transitionStatus:u,setMounted:d}=_s(s),f=ta(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:u},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:zt});return xs({batch:!0,enabled:!s,open:s,ref:c,onComplete(){s||d(!1)}}),f})),yg=l.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=Em(),c=wm(),l=eg(),u=s.length===0?a:null;return ta(`div`,e,{ref:[t,c.context.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})});function bg({label:e,value:t,options:n,onChange:r,icon:i,allowCustom:a=!1,action:o}){let[s,c]=(0,l.useState)(``),u=n.find(e=>e.value===t)??{value:t,label:t},d=s.trim(),f=n.filter(e=>e.label.toLowerCase().includes(d.toLowerCase())),p=a&&d&&!n.some(e=>e.value===d)?{value:d,label:`Use “${d}”`}:null;return(0,Q.jsxs)(yh,{items:p?[...f,p]:f,value:u,filter:null,inputValue:s,onInputValueChange:c,onOpenChange:()=>c(``),itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:e=>{e&&!e.disabled&&r(e.value)},children:[(0,Q.jsx)(Zl,{label:`${e}: ${u.label}`,children:(0,Q.jsxs)(Rh,{className:`composer-select`,"aria-label":`${e}: ${u.label}`,children:[(0,Q.jsx)(`span`,{className:`composer-select-icon`,"aria-hidden":`true`,children:u.icon??i}),(0,Q.jsx)(`span`,{className:`composer-select-label`,children:u.shortLabel??(u.label||e)}),(0,Q.jsx)(b,{className:`composer-select-caret`,size:11,"aria-hidden":`true`})]})}),(0,Q.jsx)(rg,{children:(0,Q.jsx)(og,{className:`composer-select-positioner`,sideOffset:6,align:`start`,collisionPadding:12,children:(0,Q.jsxs)(cg,{className:`composer-select-popup`,"aria-label":`${e} options`,children:[(0,Q.jsxs)(`div`,{className:`composer-select-search`,children:[(0,Q.jsx)(ie,{size:14,"aria-hidden":`true`}),(0,Q.jsx)(Ph,{"aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}…`,maxLength:a?120:void 0})]}),(0,Q.jsx)(yg,{className:`composer-select-empty`,children:`No matches`}),(0,Q.jsx)(Zh,{className:`composer-select-list`,children:e=>(0,Q.jsxs)(gg,{value:e,disabled:e.disabled,className:`composer-select-option`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`composer-select-option-icon`,"aria-hidden":`true`,children:e.icon}),(0,Q.jsx)(`span`,{className:`composer-select-option-label`,children:e.label}),(0,Q.jsx)(_g,{className:`composer-select-check`,children:(0,Q.jsx)(y,{size:14})})]},e.value)}),o&&(0,Q.jsxs)(`button`,{type:`button`,className:`composer-select-action`,onClick:o.onClick,children:[o.icon,(0,Q.jsx)(`span`,{children:o.label})]})]})})})]})}var xg={claude:(0,Q.jsx)(`svg`,{viewBox:`0 0 256 257`,fill:`#D97757`,children:(0,Q.jsx)(`path`,{d:`m50.228 170.321 50.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0 125.796l.583-3.759 5.12-3.434 7.324.648 16.202 1.101 24.304 1.685 17.629 1.037 26.118 2.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758 7-7.713 9.397.649 2.398.648 9.527 7.323 20.35 15.75L94.817 91.9l3.889 3.24 1.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42 0 82.05 1.426l4.472 3.888 6.61 15.101 10.694 23.786 16.591 32.34 4.861 9.592 2.592 8.879.973 2.722h1.685v-1.556l1.36-18.211 2.528-22.36 2.463-28.776.843-8.1 4.018-9.722 7.971-5.25 6.222 2.981 5.12 7.324-.713 4.73-3.046 19.768-5.962 30.98-3.889 20.739h2.268l2.593-2.593 10.499-13.934 17.628-22.036 7.778-8.749 9.073-9.657 5.833-4.601h11.018l8.1 12.055-3.628 12.443-11.342 14.388-9.398 12.184-13.48 18.147-8.426 14.518.778 1.166 2.01-.194 30.46-6.481 16.462-2.982 19.637-3.37 8.88 4.148.971 4.213-3.5 8.62-20.998 5.184-24.628 4.926-36.682 8.685-.454.324.519.648 16.526 1.555 7.065.389h17.304l32.21 2.398 8.426 5.574 5.055 6.805-.843 5.184-12.962 6.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666 11.406 21.387 19.314 26.767 24.887 1.36 6.157-3.434 4.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73 6.935 25.017 37.59 1.296 11.536-1.814 3.76-6.481 2.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194 77.448-3.37 3.953-7.778 2.981-6.48-4.925-3.436-7.972 3.435-15.749 4.148-20.544 3.37-16.333 3.046-20.285 1.815-6.74-.13-.454-1.49.194-15.295 20.999-23.267 31.433-18.406 19.702-4.407 1.75-7.648-3.954.713-7.064 4.277-6.286 25.47-32.405 15.36-20.092 9.917-11.6-.065-1.686h-.583L44.07 198.125l-12.055 1.555-5.185-4.86.648-7.972 2.463-2.593 20.35-13.999-.064.065Z`})}),codex:(0,Q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`currentColor`,fillRule:`evenodd`,children:(0,Q.jsx)(`path`,{d:`M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z`})}),opencode:(0,Q.jsxs)(`svg`,{viewBox:`96 96 320 320`,fill:`currentColor`,fillRule:`evenodd`,children:[(0,Q.jsx)(`path`,{d:`M320 224V352H192V224H320Z`,opacity:`.4`}),(0,Q.jsx)(`path`,{d:`M384 416H128V96H384V416ZM320 160H192V352H320V160Z`})]}),pi:(0,Q.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.4`,strokeLinecap:`round`,children:(0,Q.jsx)(`path`,{d:`M4 7h16M9 7v11M15 7v9.5a1.5 1.5 0 0 0 1.5 1.5H18`})})};function Sg({harness:e,size:t=14}){return(0,Q.jsx)(`span`,{className:`harness-icon`,style:{width:t,height:t},"aria-hidden":`true`,children:xg[e]??(0,Q.jsx)(`span`,{className:`harness-icon-letter`,children:e.charAt(0).toUpperCase()})})}var Cg={macos:`M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701`,linux:`M12.504 0c-.155 0-.315.008-.48.021-4.226.333-3.105 4.807-3.17 6.298-.076 1.092-.3 1.953-1.05 3.02-.885 1.051-2.127 2.75-2.716 4.521-.278.832-.41 1.684-.287 2.489a.424.424 0 00-.11.135c-.26.268-.45.6-.663.839-.199.199-.485.267-.797.4-.313.136-.658.269-.864.68-.09.189-.136.394-.132.602 0 .199.027.4.055.536.058.399.116.728.04.97-.249.68-.28 1.145-.106 1.484.174.334.535.47.94.601.81.2 1.91.135 2.774.6.926.466 1.866.67 2.616.47.526-.116.97-.464 1.208-.946.587-.003 1.23-.269 2.26-.334.699-.058 1.574.267 2.577.2.025.134.063.198.114.333l.003.003c.391.778 1.113 1.132 1.884 1.071.771-.06 1.592-.536 2.257-1.306.631-.765 1.683-1.084 2.378-1.503.348-.199.629-.469.649-.853.023-.4-.2-.811-.714-1.376v-.097l-.003-.003c-.17-.2-.25-.535-.338-.926-.085-.401-.182-.786-.492-1.046h-.003c-.059-.054-.123-.067-.188-.135a.357.357 0 00-.19-.064c.431-1.278.264-2.55-.173-3.694-.533-1.41-1.465-2.638-2.175-3.483-.796-1.005-1.576-1.957-1.56-3.368.026-2.152.236-6.133-3.544-6.139zm.529 3.405h.013c.213 0 .396.062.584.198.19.135.33.332.438.533.105.259.158.459.166.724 0-.02.006-.04.006-.06v.105a.086.086 0 01-.004-.021l-.004-.024a1.807 1.807 0 01-.15.706.953.953 0 01-.213.335.71.71 0 00-.088-.042c-.104-.045-.198-.064-.284-.133a1.312 1.312 0 00-.22-.066c.05-.06.146-.133.183-.198.053-.128.082-.264.088-.402v-.02a1.21 1.21 0 00-.061-.4c-.045-.134-.101-.2-.183-.333-.084-.066-.167-.132-.267-.132h-.016c-.093 0-.176.03-.262.132a.8.8 0 00-.205.334 1.18 1.18 0 00-.09.4v.019c.002.089.008.179.02.267-.193-.067-.438-.135-.607-.202a1.635 1.635 0 01-.018-.2v-.02a1.772 1.772 0 01.15-.768c.082-.22.232-.406.43-.533a.985.985 0 01.594-.2zm-2.962.059h.036c.142 0 .27.048.399.135.146.129.264.288.344.465.09.199.14.4.153.667v.004c.007.134.006.2-.002.266v.08c-.03.007-.056.018-.083.024-.152.055-.274.135-.393.2.012-.09.013-.18.003-.267v-.015c-.012-.133-.04-.2-.082-.333a.613.613 0 00-.166-.267.248.248 0 00-.183-.064h-.021c-.071.006-.13.04-.186.132a.552.552 0 00-.12.27.944.944 0 00-.023.33v.015c.012.135.037.2.08.334.046.134.098.2.166.268.01.009.02.018.034.024-.07.057-.117.07-.176.136a.304.304 0 01-.131.068 2.62 2.62 0 01-.275-.402 1.772 1.772 0 01-.155-.667 1.759 1.759 0 01.08-.668 1.43 1.43 0 01.283-.535c.128-.133.26-.2.418-.2zm1.37 1.706c.332 0 .733.065 1.216.399.293.2.523.269 1.052.468h.003c.255.136.405.266.478.399v-.131a.571.571 0 01.016.47c-.123.31-.516.643-1.063.842v.002c-.268.135-.501.333-.775.465-.276.135-.588.292-1.012.267a1.139 1.139 0 01-.448-.067 3.566 3.566 0 01-.322-.198c-.195-.135-.363-.332-.612-.465v-.005h-.005c-.4-.246-.616-.512-.686-.71-.07-.268-.005-.47.193-.6.224-.135.38-.271.483-.336.104-.074.143-.102.176-.131h.002v-.003c.169-.202.436-.47.839-.601.139-.036.294-.065.466-.065zm2.8 2.142c.358 1.417 1.196 3.475 1.735 4.473.286.534.855 1.659 1.102 3.024.156-.005.33.018.513.064.646-1.671-.546-3.467-1.089-3.966-.22-.2-.232-.335-.123-.335.59.534 1.365 1.572 1.646 2.757.13.535.16 1.104.021 1.67.067.028.135.06.205.067 1.032.534 1.413.938 1.23 1.537v-.043c-.06-.003-.12 0-.18 0h-.016c.151-.467-.182-.825-1.065-1.224-.915-.4-1.646-.336-1.77.465-.008.043-.013.066-.018.135-.068.023-.139.053-.209.064-.43.268-.662.669-.793 1.187-.13.533-.17 1.156-.205 1.869v.003c-.02.334-.17.838-.319 1.35-1.5 1.072-3.58 1.538-5.348.334a2.645 2.645 0 00-.402-.533 1.45 1.45 0 00-.275-.333c.182 0 .338-.03.465-.067a.615.615 0 00.314-.334c.108-.267 0-.697-.345-1.163-.345-.467-.931-.995-1.788-1.521-.63-.4-.986-.87-1.15-1.396-.165-.534-.143-1.085-.015-1.645.245-1.07.873-2.11 1.274-2.763.107-.065.037.135-.408.974-.396.751-1.14 2.497-.122 3.854a8.123 8.123 0 01.647-2.876c.564-1.278 1.743-3.504 1.836-5.268.048.036.217.135.289.202.218.133.38.333.59.465.21.201.477.335.876.335.039.003.075.006.11.006.412 0 .73-.134.997-.268.29-.134.52-.334.74-.4h.005c.467-.135.835-.402 1.044-.7zm2.185 8.958c.037.6.343 1.245.882 1.377.588.134 1.434-.333 1.791-.765l.211-.01c.315-.007.577.01.847.268l.003.003c.208.199.305.53.391.876.085.4.154.78.409 1.066.486.527.645.906.636 1.14l.003-.007v.018l-.003-.012c-.015.262-.185.396-.498.595-.63.401-1.746.712-2.457 1.57-.618.737-1.37 1.14-2.036 1.191-.664.053-1.237-.2-1.574-.898l-.005-.003c-.21-.4-.12-1.025.056-1.69.176-.668.428-1.344.463-1.897.037-.714.076-1.335.195-1.814.12-.465.308-.797.641-.984l.045-.022zm-10.814.049h.01c.053 0 .105.005.157.014.376.055.706.333 1.023.752l.91 1.664.003.003c.243.533.754 1.064 1.189 1.637.434.598.77 1.131.729 1.57v.006c-.057.744-.48 1.148-1.125 1.294-.645.135-1.52.002-2.395-.464-.968-.536-2.118-.469-2.857-.602-.369-.066-.61-.2-.723-.4-.11-.2-.113-.602.123-1.23v-.004l.002-.003c.117-.334.03-.752-.027-1.118-.055-.401-.083-.71.043-.94.16-.334.396-.4.69-.533.294-.135.64-.202.915-.47h.002v-.002c.256-.268.445-.601.668-.838.19-.201.38-.336.663-.336zm7.159-9.074c-.435.201-.945.535-1.488.535-.542 0-.97-.267-1.28-.466-.154-.134-.28-.268-.373-.335-.164-.134-.144-.333-.074-.333.109.016.129.134.199.2.096.066.215.2.36.333.292.2.68.467 1.167.467.485 0 1.053-.267 1.398-.466.195-.135.445-.334.648-.467.156-.136.149-.267.279-.267.128.016.034.134-.147.332a8.097 8.097 0 01-.69.468zm-1.082-1.583V5.64c-.006-.02.013-.042.029-.05.074-.043.18-.027.26.004.063 0 .16.067.15.135-.006.049-.085.066-.135.066-.055 0-.092-.043-.141-.068-.052-.018-.146-.008-.163-.065zm-.551 0c-.02.058-.113.049-.166.066-.047.025-.086.068-.14.068-.05 0-.13-.02-.136-.068-.01-.066.088-.133.15-.133.08-.031.184-.047.259-.005.019.009.036.03.03.05v.02h.003z`,windows:`M0,0H11.377V11.372H0ZM12.623,0H24V11.372H12.623ZM0,12.623H11.377V24H0Zm12.623,0H24V24H12.623`},wg={macos:`0 2 24 24`,linux:`0 0 24 24`,windows:`0 0 24 24`};function Tg({os:e,size:t=14}){return(0,Q.jsx)(`svg`,{viewBox:wg[e],width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:Cg[e]})})}function Eg({project:e}){let t=(0,l.useRef)(null),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{a(!1),t.current?.complete&&(r(t.current.naturalWidth>0),a(t.current.naturalWidth===0))},[e.iconUrl]),(0,Q.jsxs)(`span`,{className:`thread-project ${n?`has-icon`:``}`,style:{"--project-color":e.color},"aria-hidden":`true`,children:[(0,Q.jsx)(`span`,{className:`thread-project-letter`,children:e.initial}),e.iconUrl&&!i&&(0,Q.jsx)(`img`,{ref:t,src:e.iconUrl,alt:``,decoding:`async`,onLoad:()=>r(!0),onError:()=>a(!0)})]})}function Dg({projects:e,projectId:t,onChange:n,onAddProject:r}){return(0,Q.jsx)(bg,{label:`Project`,value:t,onChange:n,icon:(0,Q.jsx)(N,{size:14}),action:r?{label:`Add project`,icon:(0,Q.jsx)(re,{size:14}),onClick:r}:void 0,options:e.map(e=>({value:e.id,label:e.name,icon:(0,Q.jsx)(Eg,{project:e},e.id)}))})}var Og=e=>e.os?(0,Q.jsx)(Tg,{os:e.os}):e.id===`local`?(0,Q.jsx)(V,{size:14}):(0,Q.jsx)(ae,{size:14});function kg({machine:e,machines:t,projects:n,projectId:r,harness:i,model:a,onMachineChange:o,onProjectChange:s,onHarnessChange:c,onModelChange:l,onAddProject:u}){let d=e.harnesses.find(e=>e.id===i)?.models??[];return(0,Q.jsxs)(`div`,{className:`composer-selectors`,children:[(0,Q.jsx)(bg,{label:`Machine`,value:e.id,onChange:o,icon:Og(e),options:t.map(e=>({icon:Og(e),value:e.id,label:`${e.name}${e.connected?``:` · Not connected`}`,shortLabel:e.name,disabled:!e.connected}))}),(0,Q.jsx)(Dg,{projects:n,projectId:r,onChange:s,onAddProject:u},e.id),(0,Q.jsx)(bg,{label:`Harness`,value:i,onChange:c,icon:(0,Q.jsx)(ce,{size:14}),options:e.harnesses.map(e=>({value:e.id,label:e.name,shortLabel:e.name===`Claude Code`?`Claude`:e.name,icon:(0,Q.jsx)(Sg,{harness:e.id})}))}),(0,Q.jsx)(bg,{label:`Model`,value:a,onChange:l,icon:(0,Q.jsx)(k,{size:14}),allowCustom:e.harnesses.find(e=>e.id===i)?.customModels??!1,options:d.map(e=>({value:e,label:e,shortLabel:e.split(`/`).at(-1)}))},`${e.id}:${i}`)]})}var Ag=l.createContext(void 0),jg=e=>{let t=l.useContext(Ag);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Mg=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Q.jsx)(Ag.Provider,{value:e,children:t})),Ng={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Pg=new class{#e=Ng;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 Fg(e){setTimeout(e,0)}var Ig=typeof window>`u`||`Deno`in globalThis;function Lg(){}function Rg(e,t){return typeof e==`function`?e(t):e}function zg(e){return typeof e==`number`&&e>=0&&e!==1/0}function Bg(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Vg(e,t){return typeof e==`function`?e(t):e}function Hg(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Wg(o,t.options))return!1}else if(!Kg(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 Ug(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Gg(t.options.mutationKey)!==Gg(a))return!1}else if(!Kg(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Wg(e,t){return(t?.queryKeyHashFn||Gg)(e)}function Gg(e){return JSON.stringify(e,(e,t)=>Zg(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Kg(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!Kg(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Kg(e[r],t[r]))return!1;return!0}return!1}var qg=Object.prototype.hasOwnProperty;function Jg(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Xg(e)&&Xg(t);if(!r&&!(Zg(e)&&Zg(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:qg.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Jg(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Yg(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 Xg(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Zg(e){if(!Qg(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!Qg(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function Qg(e){return Object.prototype.toString.call(e)===`[object Object]`}function $g(e){return new Promise(t=>{Pg.setTimeout(t,e)})}function e_(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Jg(e,t)}function t_(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function n_(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var r_=Symbol();function i_(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===r_?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function a_(e,t){return typeof e==`function`?e(...t):!!e}function o_(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var s_=()=>Ig,c_=()=>s_(),l_=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(){}},u_=new class extends l_{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&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`}},d_=Fg;function f_(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=d_,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 p_=f_(),m_=new class extends l_{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&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 h_(e){return Math.min(1e3*2**e,3e4)}function g_(e){return(e??`online`)!==`online`||m_.isOnline()}var __=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function v_(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(Lg);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new __(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>u_.isFocused()&&(e.networkMode===`always`||m_.isOnline())&&e.canRun(),p=()=>g_(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())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(m).catch(r=>{if(c())return;let i=e.retry??(c_()?0:3),a=e.retryDelay??h_,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),$g(o).then(()=>f()?void 0:g()).then(()=>{t?h(r):_()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g().then(_),s)}}var y_=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),zg(this.gcTime)&&(this.#e=Pg.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(c_()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Pg.clearTimeout(this.#e),this.#e=void 0)}};function b_(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=>{o_(e,()=>t.signal,()=>n=!0)},u=i_(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);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?n_:t_;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?S_:x_,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:x_(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 x_(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 S_(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var C_=class extends y_{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=E_(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=E_(this.options);e.data!==void 0&&(this.setState(T_(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=e_(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Lg).catch(Lg):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Vg(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===r_||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Vg(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:!Bg(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.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.#s=!0,n.signal)})},i=()=>{let e=i_(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!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.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?b_(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=v_({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof __&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof __){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(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,...w_(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...T_(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=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`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),p_.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function w_(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:g_(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function T_(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function E_(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 D_=class extends l_{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),k_(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return A_(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return A_(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 Vg(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&&!Yg(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&j_(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||Vg(this.options.enabled,this.#t)!==Vg(t.enabled,this.#t)||Vg(this.options.staleTime,this.#t)!==Vg(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Vg(this.options.enabled,this.#t)!==Vg(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Yg(this.getCurrentResult(),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),Reflect.get(e,n))})}trackProp(e){this.#p.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),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Lg)),t}#h(e){return!c_()&&Vg(this.options.enabled,this.#t)!==!1&&zg(e)}#g(){this.#b();let e=Vg(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=Bg(this.#r.dataUpdatedAt,e)+1;this.#u=Pg.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return Vg(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=Pg.setInterval(()=>{(this.options.refetchIntervalInBackground||u_.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(Pg.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(Pg.clearInterval(this.#d),this.#d=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&&k_(e,t),o=i&&j_(e,n,t,r);(a||o)&&(l={...l,...w_(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.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=e_(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=e_(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{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:e.isFetched(),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:M_(e,t),refetch:this.refetch,isEnabled:Vg(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),Yg(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);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)})})();p_.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#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()}};function O_(e,t){return Vg(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Vg(t.retryOnMount,e)!==!1)}function k_(e,t){return O_(e,t)||e.state.data!==void 0&&A_(e,t,t.refetchOnMount)}function A_(e,t,n){if(Vg(t.enabled,e)!==!1&&Vg(t.staleTime,e)!==`static`){let r=Vg(n,e);return r===`always`||r!==!1&&M_(e,t)}return!1}function j_(e,t,n,r){return(e!==t||Vg(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&M_(e,n)}function M_(e,t){return Vg(t.enabled,e)!==!1&&e.isStaleByTime(Vg(t.staleTime,e))}var N_=class extends y_{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||P_(),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.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=v_({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(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),p_.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function P_(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var F_=class extends l_{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new N_({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=I_(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=I_(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=I_(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=I_(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){p_.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=>Ug(t,e))}findAll(e={}){return this.getAll().filter(t=>Ug(e,t))}notify(e){p_.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return p_.batch(()=>Promise.all(e.map(e=>e.continue().catch(Lg))))}};function I_(e){return e.options.scope?.id}var L_=class extends l_{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??Wg(r,t),a=this.get(i);return a||(a=new C_({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){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){p_.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=>Hg(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Hg(e,t)):t}notify(e){p_.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){p_.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){p_.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},R_=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new L_,this.#t=e.mutationCache||new F_,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=u_.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=m_.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(Vg(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=Rg(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return p_.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;p_.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return p_.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=p_.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Lg).catch(Lg)}invalidateQueries(e,t={}){return p_.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=p_.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(Lg)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Lg)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(Vg(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Vg(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Lg).catch(Lg)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Lg).catch(Lg)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return m_.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(Gg(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Kg(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Gg(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Kg(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||=Wg(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===r_&&(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()}},z_=l.createContext(!1),B_=()=>l.useContext(z_);z_.Provider;function V_(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var H_=l.createContext(V_()),U_=()=>l.useContext(H_),W_=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?a_(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},G_=e=>{l.useEffect(()=>{e.clearReset()},[e])},K_=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||a_(n,[e.error,r])),q_=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))}},J_=(e,t)=>e?.suspense&&t.isPending,Y_=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function X_(e,t,n){let r=B_(),i=U_(),a=jg(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,q_(o),W_(o,i,s),G_(i);let[u]=l.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(l.useSyncExternalStore(l.useCallback(e=>{let t=f?u.subscribe(p_.batchCalls(e)):Lg;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),l.useEffect(()=>{u.setOptions(o)},[o,u]),J_(o,d))throw Y_(o,u,i);if(K_({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return o.notifyOnChangeProps?d:u.trackResult(d)}function Z_(e,t){return X_(e,D_,t)}var Q_=1e3,$_=e=>`webr-catalog:${e}`,ev=e=>{try{return JSON.parse(localStorage.getItem($_(e))??`null`)??void 0}catch{return}},tv=(e,t)=>{try{localStorage.setItem($_(e),JSON.stringify(t))}catch{}};function nv(e,t,n=1,r=``,i=``){return Z_({queryKey:[`machine-catalog`,e,r,n,i],enabled:!!e&&t,placeholderData:()=>ev(e),refetchInterval:e=>e.state.data?.modelsPending?Q_:!1,queryFn:async({signal:t})=>{let n=await fetch(`/api/catalog/`+encodeURIComponent(e)+(i?`?projectId=`+encodeURIComponent(i):``),{signal:t});if(!n.ok)throw Error(`Machine catalog is not available.`);let r=await n.json();return tv(e,r),r}})}var rv=e=>e.startsWith(`/`)||e.startsWith(`~`),iv=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[];function av(e,t){let[n,r]=(0,l.useState)([]);return(0,l.useEffect)(()=>{if(!rv(t)){r([]);return}let n=new AbortController;return fetch(`/api/directories?machineId=${encodeURIComponent(e)}&prefix=${encodeURIComponent(t)}`,{signal:n.signal}).then(e=>e.ok?e.json():[]).then(e=>r(iv(e))).catch(()=>{}),()=>n.abort()},[e,t]),n}var ov=e=>e.startsWith(`/`)||e.startsWith(`~/`);function sv({machineId:e,onCreated:t}){let[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(!1),[c,u]=(0,l.useState)(``),[d,f]=(0,l.useState)(0),[p,m]=(0,l.useState)(!1),h=av(e,n),g=p&&h.length>0&&(h.length!==1||h[0]!==n),_=e=>{r(e),f(0),m(!0)},v=e=>{g&&(e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),f(t=>(t+(e.key===`ArrowDown`?1:h.length-1))%h.length)):e.key===`Tab`?(e.preventDefault(),_(h[d]??h[0])):e.key===`Enter`?(e.preventDefault(),_(h[d]??h[0]),m(!1)):e.key===`Escape`&&m(!1))},y=(0,l.useRef)(null);return(0,Q.jsxs)(`form`,{className:`thread-composer workspace-composer`,onSubmit:async r=>{r.preventDefault(),s(!0),u(``);let a=JSON.stringify({machineId:e,path:n,label:i});y.current?.payload!==a&&(y.current={payload:a,key:dm()});try{let e=await fetch(`/api/workspaces`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":y.current.key},body:a}),n=await e.json();if(!e.ok)throw Error(n.error??`Could not create workspace`);if(n.state===`unknown`)throw Error(`The result is not known; check Herdr before you create another workspace.`);t()}catch(e){u(e instanceof Error?e.message:`Could not create workspace`)}finally{s(!1)}},"aria-label":`Create workspace`,"aria-busy":o,children:[(0,Q.jsxs)(`label`,{className:`path-field`,children:[`Project folder`,(0,Q.jsx)(`input`,{value:n,onChange:e=>{r(e.target.value),f(0),m(!0)},onKeyDown:v,onBlur:()=>m(!1),placeholder:`/absolute/path/to/project`,autoComplete:`off`,spellCheck:!1,role:`combobox`,"aria-expanded":g,"aria-autocomplete":`list`,required:!0,pattern:`(/|~/).*`}),g&&(0,Q.jsx)(`ul`,{className:`path-suggestions`,role:`listbox`,children:h.map((e,t)=>(0,Q.jsx)(`li`,{role:`option`,"aria-selected":t===d,"data-highlighted":t===d||void 0,onMouseDown:t=>{t.preventDefault(),_(e)},children:e},e))})]}),(0,Q.jsxs)(`label`,{children:[`Workspace name`,(0,Q.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),required:!0,maxLength:80})]}),(0,Q.jsx)(`button`,{type:`submit`,disabled:o||!ov(n)||!i.trim(),children:o?`Creating…`:`Create workspace`}),c&&(0,Q.jsx)(`p`,{className:`form-error`,role:`alert`,children:c})]})}var cv={main:`Main checkout`,worktree:`New worktree`,remember:`Remember by project`},lv=`webr-new-session-behavior`,uv=`webr-new-worktree`,dv=(e,t)=>`webr-last-worktree:${e}:${t}`,fv=e=>e===`main`||e===`worktree`||e===`remember`,pv=()=>{let e=localStorage.getItem(uv);return e===null?`remember`:e===`false`?`main`:`worktree`};function mv(){let e=localStorage.getItem(lv);return fv(e)?e:pv()}function hv(e){localStorage.setItem(lv,e)}function gv(e,t,n){localStorage.setItem(dv(e,t),String(n))}var _v=(e,t)=>localStorage.getItem(dv(e,t))!==`false`;function vv(e,t){let n=mv();return n===`remember`?_v(e,t):n===`worktree`}var yv=`webr-new-thread-draft`,bv=e=>!!e&&typeof e==`object`&&[`id`,`name`,`preview`,`path`].every(t=>typeof e[t]==`string`);function xv(){try{let e=JSON.parse(localStorage.getItem(yv)??`{}`);return{prompt:typeof e.prompt==`string`?e.prompt:``,images:Array.isArray(e.images)?e.images.filter(bv):[]}}catch{return{prompt:``,images:[]}}}function Sv(e){try{!e.prompt&&!e.images.length?localStorage.removeItem(yv):localStorage.setItem(yv,JSON.stringify(e))}catch{}}var Cv=()=>Sv({prompt:``,images:[]}),wv=(e,t)=>`webr-last-harness:${e}:${t}`;function Tv({projects:e,machines:t,selectedProjectId:n,onOpenSidebar:r}){let[i,o]=(0,l.useState)(e.find(e=>e.id===n)?.id??e[0]?.id??``),[s,c]=(0,l.useState)(t.find(e=>n&&Object.hasOwn(e.projectPaths,n))?.id??t[0]?.id??``),[u,d]=(0,l.useState)(``),[f,p]=(0,l.useState)(`Default`),[m,h]=(0,l.useState)(!0),[g,v]=(0,l.useState)(``),[y,b]=(0,l.useState)(!1),[x,S]=(0,l.useState)(``),[C,w]=(0,l.useState)(!1),T=(0,l.useRef)(null),E=(0,l.useRef)(null),D=hm({machineId:s}),O=t.find(e=>e.id===s)??{id:``,name:`No target`,connected:!1,session:``,projectPaths:{},harnesses:[]},k=nv(s,O.connected,O.configVersion,O.session,i),A={...O,harnesses:O.connected?k.data?.harnesses??[]:[]},M=e.filter(e=>Object.hasOwn(A.projectPaths,e.id)).map(e=>({...e,path:A.projectPaths[e.id]})),N=k.data?.isGitRepo===!0,F=A.harnesses.find(e=>e.id===u),I=!!(g.trim()&&!D.uploading&&f.trim()&&A.connected&&M.some(e=>e.id===i)&&F?.launchEnabled)&&!y,L=k.data?.harnesses.map(e=>e.id).join(`,`),R=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let e=xv();v(e.prompt),D.setAttachments(e.images),R.current=!0},[]),(0,l.useEffect)(()=>{R.current&&Sv({prompt:g,images:D.attachments})},[g,D.attachments]),(0,l.useEffect)(()=>{h(vv(s,i))},[s,i]),(0,l.useEffect)(()=>{if(!i||!k.data)return;let e=k.data.harnesses,t=localStorage.getItem(wv(s,i));d(e.find(e=>e.id===t)?.id??e.find(e=>e.launchEnabled)?.id??e[0]?.id??``),p(`Default`)},[s,i,L]),(0,l.useEffect)(()=>{let e=T.current,t=e&&M.find(t=>!e.has(t.id));t&&(T.current=null,B(t.id))},[M]),(0,l.useEffect)(()=>{!s&&t.length&&c(t.find(e=>e.id===`local`)?.id??t[0].id),!i&&M.length&&o(M[0].id)},[t,s,M,i]);let z=n=>{let r=t.find(e=>e.id===n);r?.connected&&(c(n),Object.hasOwn(r.projectPaths,i)||o(e.find(e=>Object.hasOwn(r.projectPaths,e.id))?.id??``),d(``),p(`Default`),S(``))},B=e=>{o(e),d(``),p(`Default`),S(``)},V=e=>{d(e),p(`Default`),i&&localStorage.setItem(wv(s,i),e)};return(0,Q.jsxs)(`main`,{className:`new-thread-page`,"aria-label":`New thread`,children:[(0,Q.jsx)(`button`,{className:`mobile-menu`,onClick:r,children:`Threads`}),(0,Q.jsx)(`h1`,{children:`What do you want to build today?`}),A.connected&&A.writable&&(!M.length||C)?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:M.length?`Add a project to this Herdr session.`:`This Herdr session has no projects yet.`}),(0,Q.jsx)(sv,{machineId:A.id,onCreated:()=>{T.current=new Set(M.map(e=>e.id)),w(!1)}}),!!M.length&&(0,Q.jsx)(`button`,{className:`workspace-cancel`,onClick:()=>w(!1),children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`form`,{className:`thread-composer ${D.dragging?`is-dropping`:``}`,onSubmit:async e=>{if(e.preventDefault(),!I)return;b(!0),S(``);let t=JSON.stringify({prompt:mm(g,D.attachments),projectId:i,machineId:s,agent:u,model:f.trim(),worktree:m&&N});E.current?.payload!==t&&(E.current={payload:t,key:dm()});try{let e=await fetch(`/api/threads`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":E.current.key},body:t}),n=await e.json();if(!e.ok)throw Error(n.error||`Could not create thread`);gv(s,i,m),Cv(),await a(`/threads/${encodeURIComponent(n.id)}`)}catch(e){S(e instanceof Error?e.message:`Could not create thread`),b(!1)}},"aria-busy":y,...D.handlers,children:[(D.attachments.length>0||D.uploading>0)&&(0,Q.jsxs)(`ul`,{className:`composer-images`,"aria-label":`Attached files`,children:[D.attachments.map(e=>(0,Q.jsxs)(`li`,{className:e.preview?void 0:`is-file`,children:[e.preview?(0,Q.jsx)(`img`,{src:e.preview,alt:e.name}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{size:18,strokeWidth:1.8}),(0,Q.jsx)(`span`,{children:e.name})]}),(0,Q.jsx)(Zl,{label:`Remove file`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,onClick:()=>D.remove(e.id),children:(0,Q.jsx)(pe,{size:12,strokeWidth:2.4})})})]},e.id)),Array.from({length:D.uploading},(e,t)=>(0,Q.jsx)(`li`,{className:`is-uploading`,"aria-label":`Uploading file`},`uploading-`+t))]}),(0,Q.jsx)(`textarea`,{autoFocus:!0,required:!0,maxLength:8e3,value:g,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},"aria-label":`Thread prompt`,placeholder:`Write a prompt, or drop an image…`}),(0,Q.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,Q.jsx)(kg,{machine:A,machines:t,projects:M,projectId:i,harness:u,model:f,onMachineChange:z,onProjectChange:B,onHarnessChange:V,onModelChange:p,onAddProject:A.connected&&A.writable?()=>w(!0):void 0}),N&&(0,Q.jsx)(Zl,{label:m?`new worktree`:`current checkout`,children:(0,Q.jsxs)(`label`,{className:`worktree-option`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked),"aria-label":`Create a new worktree`}),(0,Q.jsx)(P,{size:15,"aria-hidden":`true`})]})}),(0,Q.jsx)(`div`,{className:`composer-actions`,children:(0,Q.jsx)(Zl,{label:`Create thread`,children:(0,Q.jsx)(`button`,{className:`composer-send`,type:`submit`,disabled:!I,"aria-label":`Create thread`,children:y?`…`:(0,Q.jsx)(_,{size:18,strokeWidth:2.2})})})})]})]}),(F?.reason||!t.length||A.error||k.isError)&&(0,Q.jsx)(`p`,{className:`composer-preview-note`,children:F?.reason??(t.length?A.error?`Machine is not connected: ${A.error.replaceAll(`_`,` `)}.`:`The machine catalog is not available.`:`No target is configured.`)}),D.error&&(0,Q.jsx)(`p`,{className:`form-error`,role:`alert`,children:D.error}),x&&(0,Q.jsx)(`p`,{className:`form-error`,role:`alert`,children:x})]})]})}var Ev=ns(function(e){return Oc(`dialog`,e)}),Dv=52,Ov=`?`;function kv(e){let t=e.slice(e.indexOf(`;`)+1);if(e.includes(`;`)&&t&&t!==Ov)try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(Uint8Array.from(atob(t),e=>e.charCodeAt(0)))}catch{return}}function Av(e){let t=t=>{t.clipboardData?.setData(`text/plain`,e),t.preventDefault()};document.addEventListener(`copy`,t,!0);try{return document.execCommand(`copy`)}catch{return!1}finally{document.removeEventListener(`copy`,t,!0)}}async function jv(e){try{return await navigator.clipboard.writeText(e),!0}catch{return Av(e)}}var Mv=e=>(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.selectionStart!==e.selectionEnd||!!document.getSelection()?.toString();function Nv(e,t,n,r){let i=e=>r(e?`copied`:`blocked`),a,o=()=>{let e=a;a=void 0,e!==void 0&&jv(e).then(i)},s=e=>void jv(e).then(t=>{if(t)return i(!0);a=e,r(`waiting-for-click`)}),c=()=>{t.hasSelection()&&jv(t.getSelection()).then(i)},l=e=>{e.defaultPrevented||!t.hasSelection()||Mv(e.target)||(e.clipboardData?.setData(`text/plain`,t.getSelection()),e.preventDefault(),i(!0))},u=t.parser.registerOscHandler(Dv,e=>{let t=kv(e);return t!==void 0&&n()&&s(t),!0});return e.addEventListener(`mouseup`,c),window.addEventListener(`copy`,l),window.addEventListener(`pointerdown`,o,!0),window.addEventListener(`keydown`,o,!0),()=>{u.dispose(),window.removeEventListener(`pointerdown`,o,!0),window.removeEventListener(`keydown`,o,!0),e.removeEventListener(`mouseup`,c),window.removeEventListener(`copy`,l)}}var Pv=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(Pv||{}),Fv=[0,1],Iv=[1,0],Lv=[2,3],Rv=[3,2],zv={L:Fv,M:Iv,Q:Lv,H:Rv},Bv=/^\d*$/,Vv=/^[A-Z0-9 $%*+./:-]*$/,Hv=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,Uv=1,Wv=40,Gv=3,Kv=3,qv=40,Jv=10,Yv=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],Xv=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],Zv=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<Uv||e>Wv)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,Pv.Timing),this.setFunctionModule(e,6,e%2==0,Pv.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,$v(r,e));this.setFunctionModule(8,7,$v(r,6)),this.setFunctionModule(8,8,$v(r,7)),this.setFunctionModule(7,8,$v(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,$v(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,$v(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,$v(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=$v(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,Pv.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,Pv.Alignment)}setFunctionModule(e,t,n,r=Pv.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==my(t,n))throw RangeError(`Invalid argument`);let r=Xv[n[0]][t],i=Yv[n[0]][t],a=Math.floor(py(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=hy(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=gy(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(py(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=$v(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=Gv:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*qv),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*qv}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=Gv:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*qv),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*qv}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=Kv)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*Jv,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Qv(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function $v(e,t){return!!(e>>>t&1)}var ey=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},ty=[1,10,12,14],ny=[2,9,11,13],ry=[4,8,16,16];function iy(e,t){return e[Math.floor((t+7)/17)+1]}function ay(e){let t=[];for(let n of e)Qv(n,8,t);return new ey(ry,e.length,t)}function oy(e){if(!ly(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);Qv(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new ey(ty,e.length,t)}function sy(e){if(!uy(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Hv.indexOf(e.charAt(n))*45;r+=Hv.indexOf(e.charAt(n+1)),Qv(r,11,t)}return n<e.length&&Qv(Hv.indexOf(e.charAt(n)),6,t),new ey(ny,e.length,t)}function cy(e){return e===``?[]:ly(e)?[oy(e)]:uy(e)?[sy(e)]:[ay(fy(e))]}function ly(e){return Bv.test(e)}function uy(e){return Vv.test(e)}function dy(e,t){let n=0;for(let r of e){let e=iy(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function fy(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function py(e){if(e<Uv||e>Wv)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function my(e,t){return Math.floor(py(e)/8)-Yv[t[0]][e]*Xv[t[0]][e]}function hy(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=_y(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=_y(n,2)}return t}function gy(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=_y(t,e))}return n}function _y(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function vy(e,t,n=1,r=40,i=-1,a=!0){if(!(Uv<=n&&n<=r&&r<=Wv)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=my(o,t)*8,i=dy(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Iv,Lv,Rv])a&&s<=my(o,e)*8&&(t=e);let c=[];for(let t of e){Qv(t.mode[0],4,c),Qv(t.numChars,iy(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=my(o,t)*8;Qv(0,Math.min(4,l-c.length),c),Qv(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Qv(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new Zv(o,t,u,i)}function yy(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?cy(e):Array.isArray(e)?[ay(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=vy(c,zv[n],i,a,o,r),u=by({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function by(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=Pv.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}var xy=2;function Sy({value:e,label:t}){let{data:n,size:r}=yy(e),i=n.flatMap((e,t)=>e.flatMap((e,n)=>e?[`M${n+xy} ${t+xy}h1v1h-1z`]:[])),a=r+4;return(0,Q.jsxs)(`svg`,{className:`qr-code`,role:`img`,"aria-label":t,viewBox:`0 0 ${a} ${a}`,shapeRendering:`crispEdges`,children:[(0,Q.jsx)(`rect`,{width:a,height:a,fill:`#fff`}),(0,Q.jsx)(`path`,{d:i.join(``),fill:`#000`})]})}function Cy(){let[e,t]=(0,l.useState)(Wp);return!Up()||e!=="default"?null:(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsxs)(`span`,{children:[`Notify me about new requests`,(0,Q.jsx)(`small`,{className:`device-meta`,children:`Shown when Webr is open in a hidden tab.`})]}),(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,onClick:()=>void Gp().then(t),children:`Turn on`})]})}var wy=8;function Ty({refreshKey:e}){let[t,n]=(0,l.useState)([]);return(0,l.useEffect)(()=>{Np().then(n,()=>void 0)},[e]),t.length?(0,Q.jsxs)(`div`,{className:`remote-activity`,children:[(0,Q.jsx)(`h3`,{className:`settings-subtitle`,children:`Recent activity`}),t.slice(0,wy).map(e=>(0,Q.jsxs)(`p`,{className:`activity-row`,children:[(0,Q.jsx)(`span`,{children:Kp(e)}),(0,Q.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:Hp(e.at)})]},e.id))]}):null}function Ey({invite:e,onClose:t}){let[n,r]=(0,l.useState)(0),[i,a]=(0,l.useState)(!1),o=e.urls[n],s=e=>jv(e).then(e=>{e&&(a(!0),setTimeout(()=>a(!1),1500))}),c=()=>s(e.token),u=t=>{r(t),s(e.urls[t])};return(0,Q.jsx)(Ev,{open:!0,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(Xc,{children:[(0,Q.jsx)(Ac,{className:`dialog-backdrop`}),(0,Q.jsxs)(qc,{className:`dialog pairing-invite`,children:[(0,Q.jsx)(Zc,{className:`pairing-title`,children:`Connect a device`}),o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Bc,{className:`dialog-message`,children:`Scan with the device’s camera, or open Webr there and enter the code.`}),(0,Q.jsx)(Sy,{value:o,label:`QR code to connect a device`}),e.urls.length>1&&(0,Q.jsx)(`div`,{className:`theme-control theme-control--labels`,role:`group`,"aria-label":`Address`,children:e.urls.map((e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":t===n,className:t===n?`theme-option is-selected`:`theme-option`,onClick:()=>u(t),children:new URL(e).host},e))})]}):(0,Q.jsxs)(Bc,{className:`dialog-message`,children:[`No network address was found for other devices. Start Webr with `,(0,Q.jsx)(`code`,{children:`--origin <url>`}),` if you reach it through a proxy.`]}),(0,Q.jsxs)(`div`,{className:`pairing-token`,children:[(0,Q.jsx)(`code`,{children:e.token}),(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,onClick:()=>void c(),"aria-label":`Copy code`,children:i?(0,Q.jsx)(y,{size:14}):(0,Q.jsx)(O,{size:14})})]}),(0,Q.jsx)(`p`,{className:`settings-note`,children:`Works once and expires in 5 minutes.`}),(0,Q.jsx)(`div`,{className:`dialog-actions`,children:(0,Q.jsx)(Rc,{className:`dialog-button is-primary`,children:`Done`})})]})]})})}var Dy={unavailable:`Install Tailscale on this computer and your other devices to get a private, secure HTTPS address for Webr. HTTPS unlocks features browsers only allow on secure pages, such as the microphone.`,"https-disabled":`Tailscale is installed, but HTTPS certificates are off. Turn them on in the Tailscale admin console under DNS, then restart Webr to unlock features that need a secure address, such as the microphone.`};function Oy(){let[e,t]=(0,l.useState)(`ready`);return(0,l.useEffect)(()=>{Pp().then(t,()=>void 0)},[]),e===`ready`?null:(0,Q.jsx)(`p`,{className:`tailscale-callout`,role:`note`,children:Dy[e]})}function ky(){let[e,t]=(0,l.useState)([]),[n,r]=(0,l.useState)(),[i,a]=(0,l.useState)(``),o=(0,l.useCallback)(()=>Mp().then(t,()=>void 0),[]);(0,l.useEffect)(()=>{o()},[o]);let s=()=>jp().then(e=>{a(``),r(e)},e=>a(e.message)),c=async e=>{await sl(`Disconnect ${e.name}? It will need to be approved again.`,{confirmLabel:`Disconnect`,danger:!0})&&(await Fp(e.id),e.current?location.reload():await o())};return(0,Q.jsxs)(`section`,{id:`remote-access`,children:[(0,Q.jsx)(`div`,{className:`settings-section-title`,children:(0,Q.jsx)(`h2`,{children:`Remote access`})}),(0,Q.jsx)(`p`,{className:`settings-note`,children:`Other devices ask to connect and you approve them here. This computer never needs a code.`}),(0,Q.jsx)(Oy,{}),(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsx)(`span`,{children:`Connect a device`}),(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,onClick:()=>void s(),children:`Show code`})]}),(0,Q.jsx)(Cy,{}),i&&(0,Q.jsx)(`p`,{role:`alert`,className:`form-error`,children:i}),e.map(e=>(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.current&&(0,Q.jsx)(`em`,{className:`device-tag`,children:`This device`}),(0,Q.jsxs)(`small`,{className:`device-meta`,children:[`Active `,Hp(e.lastSeenAt),` · Signs out `,qp(e.expiresAt),` if unused`]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,onClick:()=>void c(e),children:`Disconnect`})]},e.id)),(0,Q.jsx)(Ty,{refreshKey:e}),n&&(0,Q.jsx)(Ey,{invite:n,onClose:()=>r(void 0)})]})}var Ay=9e5,jy=2e3,My=18e4,Ny=async e=>{let t=await fetch(`/api/update`,{signal:e});if(!t.ok)throw Error(`Updates are not available.`);return await t.json()},Py=async()=>{let e=await fetch(`/api/update/check`,{method:`POST`});if(!e.ok)throw Error(`Updates are not available.`);return await e.json()},Fy=500,Iy=`Restart the Webr server? This page reloads and every open terminal reconnects. Running agents keep working.`,Ly=e=>new Promise(t=>setTimeout(t,e)),Ry=async()=>(await fetch(`/api/update`,{cache:`no-store`}).catch(()=>void 0))?.ok===!0;async function zy(){let e=!1;for(let t=Date.now()+My;Date.now()<t;await Ly(Fy))if(!await Ry())e=!0;else if(e)return!0;return!1}var By=({current:e,latest:t})=>`Update Webr from ${e} to ${t}? Webr restarts and this page reloads. Running agents keep working.`;function Vy(){let[e,t]=(0,l.useState)(),n=Z_({queryKey:[`update`],queryFn:({signal:e})=>Ny(e),refetchInterval:e?jy:Ay,refetchOnWindowFocus:!e}).data,r=(0,l.useCallback)(e=>{t(void 0),cl(e)},[]);(0,l.useEffect)(()=>{e&&n&&(n.current===e?n.state===`failed`&&r(n.error??`The update failed.`):window.location.reload())},[e,n,r]),(0,l.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>r(`Webr did not come back after the update. Reload this page, or restart Herdr.`),My);return()=>clearTimeout(t)},[e,r]);let i=jg(),[a,o]=(0,l.useState)(!1),s=(0,l.useCallback)(async()=>{o(!0);try{i.setQueryData([`update`],await Py())}catch{await cl(`Webr could not check for updates.`)}finally{o(!1)}},[i]),c=(0,l.useCallback)(async()=>{n&&await sl(By(n),{confirmLabel:`Update`})&&((await fetch(`/api/update`,{method:`POST`}).catch(()=>void 0))?.status===202?t(n.current):await cl(`Webr could not start the update.`))},[n]),[u,d]=(0,l.useState)(!1),f=(0,l.useCallback)(async()=>{if(await sl(Iy,{confirmLabel:`Restart`,danger:!0})){if((await fetch(`/api/restart`,{method:`POST`}).catch(()=>void 0))?.status!==202)return void await cl(`Webr could not restart.`);d(!0),await zy()?window.location.reload():(d(!1),await cl(`Webr did not come back. Reload this page, or restart Herdr.`))}},[]);return{status:n,updating:!!e,checking:a,checkNow:s,requestUpdate:c,restarting:u,requestRestart:f}}function Hy(){let{status:e,updating:t,checking:n,checkNow:r,requestUpdate:i,restarting:a,requestRestart:o}=Vy(),s=e&&!e.available;return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h2`,{children:`Updates`}),(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsxs)(`span`,{children:[e?`Webr ${e.current}`:`Webr`,(0,Q.jsx)(`small`,{className:`device-meta`,children:e?.available?`Version ${e.latest} is available.`:s?`You are on the latest version.`:`Checking for updates…`})]}),(0,Q.jsxs)(`span`,{className:`settings-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button is-primary is-danger`,disabled:a||t,onClick:()=>void o(),children:a?`Restarting…`:`Restart server`}),e?.available?(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button is-primary`,disabled:t,onClick:()=>void i(),children:t?`Updating…`:`Update to ${e.latest}`}):(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,disabled:n||!e,onClick:()=>void r(),children:n?`Checking…`:`Check for updates`})]})]})]})}function Uy({onOpenSidebar:e}){let[t,n]=(0,l.useState)(`worktree`),[r,i]=(0,l.useState)(Zf),[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(``);(0,l.useEffect)(()=>{n(mv()),i(Qf())},[]);let u=(e,t)=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){o(null),c(``);return}let n=tp(e);if(!n)return;if(np(n)||n===`meta+k`){c(`Choose a shortcut with a modifier that does not conflict with the browser or ⌘K.`);return}if(Object.entries(r).some(([e,r])=>e!==t&&r===n)){c(`That shortcut is already in use.`);return}let a={...r,[t]:n};i(a),localStorage.setItem(`webr-shortcuts`,JSON.stringify(a)),o(null),c(``)};return(0,Q.jsxs)(`main`,{className:`form-page settings-page`,children:[(0,Q.jsx)(`button`,{className:`mobile-menu`,onClick:e,children:`Threads`}),(0,Q.jsx)(`h1`,{children:`Settings`}),(0,Q.jsx)(Hy,{}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h2`,{children:`Appearance`}),(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsx)(`span`,{children:`Theme`}),(0,Q.jsx)(ip,{expanded:!0})]})]}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h2`,{children:`New threads`}),(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsx)(`span`,{children:`New session behavior`}),(0,Q.jsx)(`div`,{className:`theme-control theme-control--labels`,role:`group`,"aria-label":`New session behavior`,children:Object.keys(cv).map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":t===e,className:t===e?`theme-option is-selected`:`theme-option`,onClick:()=>{n(e),hv(e)},children:cv[e]},e))})]})]}),(0,Q.jsx)(ky,{}),(0,Q.jsxs)(`section`,{id:`shortcuts`,children:[(0,Q.jsxs)(`div`,{className:`settings-section-title`,children:[(0,Q.jsx)(`h2`,{children:`Keyboard shortcuts`}),(0,Q.jsx)(`button`,{onClick:()=>{i(Zf),localStorage.removeItem(`webr-shortcuts`),o(null),c(``)},children:`Reset`})]}),(0,Q.jsx)(`p`,{className:`settings-note`,children:`Press ⌘K for all actions and threads.`}),Object.keys(Xf).map(e=>(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsx)(`span`,{children:Xf[e]}),(0,Q.jsx)(`button`,{className:`shortcut-key`,"data-recording":a===e,onClick:()=>{o(e),c(``)},onKeyDown:t=>a===e&&u(t,e),"aria-label":`Change ${Xf[e]} shortcut`,children:a===e?`Press keys…`:$f(r[e]).map((e,t)=>(0,Q.jsx)(`kbd`,{children:e},t))})]},e)),s&&(0,Q.jsx)(`p`,{role:`alert`,className:`form-error`,children:s})]})]})}var Wy=l.createContext(void 0);function Gy(e=!0){let t=l.useContext(Wy);if(t===void 0&&!e)throw Error(Mi(25));return t}var Ky=l.createContext(void 0);function qy(e){let t=l.useContext(Ky);if(t===void 0&&!e)throw Error(Mi(33));return t}var Jy=l.createContext(void 0);function Yy(e){let t=l.useContext(Jy);if(t===void 0&&!e)throw Error(Mi(36));return t}function Xy(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:u}=a.useState(`floatingTreeRoot`),d=a.useState(`open`),f=Gy(!0),p=f!==void 0;return l.useMemo(()=>({id:r,role:`menuitem`,tabIndex:d&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&u.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&u.emit(`close`,{domEvent:e,reason:bn})},onMouseUp(e){if(f){let t=f.initialCursorPointRef.current;if(f.initialCursorPointRef.current=null,p&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||p&&!Ke&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!p||e.button===2)&&c.type===`regular-item`&&Pc(s.current,e,{detail:1})}}),[t,n,r,u,i,d,a,o,s,f,p,c])}var Zy={type:`regular-item`};function Qy(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:u}=e,d=l.useRef(null),{getButtonProps:f,buttonRef:p}=Fc({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),m=Xy({closeOnClick:t,highlighted:r,id:i,nodeId:u,store:a,typingRef:o,itemRef:d,itemMetadata:c}),h=l.useCallback(e=>Vi(m,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,f),[m,f,c]),g=Bn(d,p);return l.useMemo(()=>({getItemProps:h,itemRef:g}),[h,g])}var $y=l.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=lg({guess:!0,label:a}),f=qy(!0),p=zc(i),{store:m}=Yy(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Qy({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:Zy});return ta(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),eb=l.createContext(void 0);function tb(e){let t=l.useContext(eb);if(t===void 0&&!e)throw Error(Mi(69));return t}var nb=l.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=Yy(),{side:c,align:u}=qy(),d=tb(!0)!=null,f=s.useState(`open`),p=s.useState(`transitionStatus`),m=s.useState(`popupProps`),h=s.useState(`mounted`),g=s.useState(`instantType`),_=s.useState(`activeTriggerElement`),v=s.useState(`parent`),y=s.useState(`lastOpenChangeReason`),b=s.useState(`rootId`),x=s.useState(`floatingRootContext`),S=s.useState(`floatingTreeRoot`),C=s.useState(`closeDelay`),w=s.useState(`hoverEnabled`),T=s.useState(`disabled`),E=s.useState(`openMethod`),D=v.type===`context-menu`;xs({open:f,ref:s.context.popupRef,onComplete(){f&&s.context.onOpenChangeComplete?.(!0)}}),l.useEffect(()=>{function e(e){s.setOpen(!1,Z(e.reason,e.domEvent))}return S.events.on(`close`,e),()=>{S.events.off(`close`,e)}},[S.events,s]),tc(x,{enabled:w&&!T&&!D&&v.type!==`menubar`,closeDelay:C});let O=s.useStateSetter(`popupElement`),k=ta(`div`,e,{state:{transitionStatus:p,side:c,align:u,open:f,nested:v.type===`menu`,instant:g},ref:[t,s.context.popupRef,O],stateAttributesMapping:$t,props:[m,{onKeyDown(e){d&&Uc.has(e.key)&&e.stopPropagation()}},ql(p),o,{"data-rootownerid":b}]}),A=v.type===void 0||D;return(_||v.type===`menubar`&&y!==`outside-press`)&&(A=!0),(0,Q.jsx)(Ia,{context:x,openInteractionType:E,modal:D,disabled:!h,returnFocus:a===void 0?A:a,initialFocus:v.type!==`menu`,restoreFocus:!0,externalTree:v.type===`menubar`?void 0:S,previousFocusableElement:_,nextFocusableElement:v.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:v.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:k})}),rb=l.createContext(void 0);function ib(){let e=l.useContext(rb);if(e===void 0)throw Error(Mi(32));return e}var ab=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Yy();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Q.jsx)(rb.Provider,{value:n,children:(0,Q.jsx)(_a,{ref:t,...r,portalOwnerRole:o})})}),ob=l.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:u=0,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f=5,arrowPadding:p=5,sticky:m=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=la,style:_,...v}=e,{store:y}=Yy(),b=ib(),x=Gy(!0),S=y.useState(`parent`),C=y.useState(`floatingRootContext`),w=y.useState(`floatingTreeRoot`),T=y.useState(`mounted`),E=y.useState(`open`),D=y.useState(`modal`),O=y.useState(`openMethod`),k=y.useState(`activeTriggerElement`),A=y.useState(`transitionStatus`),j=y.useState(`positionerElement`),M=y.useState(`instantType`),N=y.useState(`adaptiveOrigin`),P=y.useState(`lastOpenChangeReason`),F=y.useState(`floatingNodeId`),I=y.useState(`floatingParentNodeId`),L=C.useState(`domReferenceElement`),R=l.useRef(null),z=bs(j),B=n,V=c,ee=u,te=s,ne=g;S.type===`context-menu`&&(B=n??S.context?.anchor,te??=`start`,!o&&te!==`center`&&(ee=e.alignOffset??2,V=e.sideOffset??-5));let H=o,U=te;S.type===`menu`?(H??=`inline-end`,U??=`start`,ne=e.collisionAvoidance??ua):S.type===`menubar`&&(H??=S.context.orientation===`vertical`?`inline-end`:`bottom`,U??=`start`);let re=S.type===`context-menu`,ie=Wl({anchor:B,floatingRootContext:C,positionMethod:x?`fixed`:r,mounted:T,side:H,sideOffset:V,align:U,alignOffset:ee,arrowPadding:re?0:p,collisionBoundary:d,collisionPadding:f,sticky:m,nodeId:F,keepMounted:b,disableAnchorTracking:h,collisionAvoidance:ne,shift:re?{crossAxis:!(`side`in ne&&ne.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:w,adaptiveOrigin:N});l.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===F&&y.set(`hoverEnabled`,!1),e.nodeId!==F&&e.parentNodeId===y.select(`floatingParentNodeId`)&&y.setOpen(!1,Z(jn)))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[y,w.events,F]),l.useEffect(()=>{if(y.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==y.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;y.setOpen(!1,Z(t))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[w.events,y]);let ae=ot();l.useEffect(()=>{E||ae.clear()},[E,ae]),l.useEffect(()=>{function e(e){if(E&&e.nodeId===y.select(`floatingParentNodeId`)){if(e.target&&k&&k!==e.target){let e=y.select(`closeDelay`);e>0?ae.isStarted()||ae.start(e,()=>{y.setOpen(!1,Z(jn))}):y.setOpen(!1,Z(jn))}else ae.clear()}}return w.events.on(`itemhover`,e),()=>{w.events.off(`itemhover`,e)}},[w.events,E,k,y,ae]),l.useEffect(()=>{let e={open:E,nodeId:F,parentNodeId:I,reason:y.select(`lastOpenChangeReason`)};w.events.emit(`menuopenchange`,e)},[w.events,E,y,F,I]),W(()=>{let e=L,t=R.current;if(e&&(R.current=e),t&&e&&e!==t){y.set(`instantType`,void 0);let e=new AbortController;return z(()=>{y.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[L,z,y]);let oe={open:E,side:ie.side,align:ie.align,anchorHidden:ie.anchorHidden,nested:S.type===`menu`,instant:M},se=S.type===`menubar`&&S.context.modal;ag(E&&(se||D&&P!==`trigger-hover`),O===`touch`,j,k);let ce=Jl(e,oe,{styles:ie.positionerStyles,transitionStatus:A,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!T,inert:!E}),le=T&&S.type!==`menu`&&(S.type!==`menubar`&&D&&P!==`trigger-hover`||S.type===`menubar`&&S.context.modal),ue=null;return S.type===`menubar`?ue=S.context.contentElement:S.type===void 0&&(ue=k),(0,Q.jsxs)(Ky.Provider,{value:ie,children:[le&&(0,Q.jsx)(Yc,{ref:S.type===`context-menu`||S.type===`nested-context-menu`?S.context.internalBackdropRef:null,inert:Jc(!E),cutout:ue}),(0,Q.jsx)(Ta,{id:F,children:(0,Q.jsx)(Wh,{elementsRef:y.context.itemDomElements,labelsRef:y.context.itemLabels,children:ce})})]})}),sb=l.createContext(null);function cb(e){let t=l.useContext(sb);if(t===null&&!e)throw Error(Mi(5));return t}var lb={...Us,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},ub=class extends ps{constructor(e,t,n=!1){let r=new Is,i=fb(r,t,n,e);super(i,db(r),lb),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function db(e){return{positionerRef:l.createRef(),popupRef:l.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:l.createRef(),beforeContentFocusGuardRef:l.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function fb(e,t,n=!1,r){return{...Ls(e,t,n),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new ya,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:nt,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var pb=l.createContext(void 0);function mb(){return l.useContext(pb)}var hb=ns(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0}=e,_=Gy(!0),v=Yy(!0),y=cb(!0),b=mb(),x=l.useMemo(()=>b&&v?{type:`menu`,store:v.store}:y?{type:`menubar`,context:y}:_&&!v?{type:`context-menu`,context:_}:{type:void 0},[_,v,y,b]),S=Ai(),C=Ai(),w=Sa(),T=x.type===`menu`?x.store:void 0,E=(n??a)&&T?.state.transitionStatus===`starting`,D=$e(()=>E?T?.state.instantType:void 0).current,O=gb({open:a,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:x,disabled:o,highlightItemOnHover:g,modal:x.type===void 0?s:void 0,rootId:S,instantType:D},C,w!=null);O.useControlledProp(`openProp`,n),O.useControlledProp(`triggerIdProp`,m),O.useContextCallback(`onOpenChangeComplete`,i);let k=O.useState(`floatingTreeRoot`),A=wa(k),j=O.useState(`open`),M=O.useState(`activeTriggerElement`),N=O.useState(`positionerElement`),P=O.useState(`hoverEnabled`),F=O.useState(`disabled`),I=O.useState(`lastOpenChangeReason`),L=O.useState(`parent`),R=O.useState(`activeIndex`),z=O.useState(`payload`),B=O.useState(`floatingParentNodeId`),V=l.useRef(null),ee=l.useRef(L.type!==`context-menu`),te=ot(),ne=l.useRef(!0),H=ot(),U=B!=null,{openMethod:re,triggerProps:ie}=tl(j);O.useSyncedValues({disabled:o,highlightItemOnHover:g,modal:L.type===void 0?s:void 0,openMethod:re,rootId:S}),Ms(O);let{forceUnmount:ae,transitionStatus:oe}=Ns(j,O,()=>{O.set(`allowMouseEnter`,!1)},E),se=bs(O.context.popupRef);l.useEffect(()=>{if(D===void 0)return;let e=()=>{O.state.instantType===D&&O.set(`instantType`,void 0)};if(!j){e();return}if(oe!==void 0)return;if(O.context.popupRef.current==null){e();return}let t=new AbortController;return se(e,t.signal),()=>{t.abort()}},[D,j,oe,se,O]),W(()=>{_&&!v?O.update({parent:{type:`context-menu`,context:_},floatingNodeId:A,floatingParentNodeId:w}):v&&O.update({floatingNodeId:A,floatingParentNodeId:w})},[_,v,A,w,O]),l.useEffect(()=>{if(j||(V.current=null),L.type===`context-menu`){if(!j){te.clear(),ee.current=!1;return}te.start(500,()=>{ee.current=!0})}},[te,j,L.type]),W(()=>{!j&&!P&&O.set(`hoverEnabled`,!0)},[j,P,O]);let ce=$((e,t)=>{let n=t.reason;if(!e&&!O.select(`open`)||j===e&&t.trigger===M&&I===n)return;let i=ks(t);if(!e&&t.trigger==null&&(t.trigger=M??void 0),r?.(e,t),t.isCanceled)return;O.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!ne.current)return;e&&n===`trigger-focus`?(ne.current=!1,H.start(300,()=>{ne.current=!0})):(ne.current=!0,H.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null);V.current=t.event;let c=Os(O.state,e,t.trigger,i());c.openChangeReason=n,c.instantType=L.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:o||s?o?`click`:`dismiss`:void 0,O.update(c)}),le=gs({popupStore:O,floatingRootContext:O.state.floatingRootContext,floatingId:C,nested:w!=null,onOpenChange:ce}),ue=le.context.events;W(()=>{let e=({open:e,eventDetails:t})=>ce(e,t);return ue.on(`setOpen`,e),()=>{ue?.off(`setOpen`,e)}},[ue,ce]);let de=l.useCallback(()=>{O.setOpen(!1,Z(Nn))},[O]);l.useImperativeHandle(d,()=>({unmount:ae,close:de}),[ae,de]);let fe;L.type===`context-menu`&&(fe=L.context),l.useImperativeHandle(fe?.positionerRef,()=>N,[N]),l.useImperativeHandle(fe?.actionsRef,()=>({setOpen:ce}),[ce]);let pe=Ua(le,{enabled:!F,bubbles:{escapeKey:f&&L.type===`menu`},outsidePress(){return L.type!==`context-menu`||V.current?.type===`contextmenu`||ee.current},externalTree:U?k:void 0}),me=Al(),he=l.useCallback(e=>{O.select(`activeIndex`)!==e&&O.set(`activeIndex`,e)},[O]),G=dc(le,{enabled:!F,listRef:O.context.itemDomElements,activeIndex:R,nested:L.type!==void 0,loopFocus:c,orientation:u,parentOrientation:L.type===`menubar`?L.context.orientation:void 0,rtl:me===`rtl`,disabledIndices:tt,onNavigate:he,openOnArrowKeyDown:L.type!==`context-menu`,externalTree:U?k:void 0,focusItemOnHover:g}),ge=l.useCallback(e=>{O.context.typingRef.current=e},[O]),_e=fc(le,{enabled:!F,listRef:O.context.itemLabels,elementsRef:O.context.itemDomElements,activeIndex:R,resetMs:500,onMatch:e=>{j&&e!==R&&O.set(`activeIndex`,e)},onTyping:ge}),K=l.useMemo(()=>{let e=Vi(_e.reference,G.reference,pe.reference,{onMouseMove(){O.set(`allowMouseEnter`,!0)}},ie);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=j,e},[O,_e.reference,G.reference,pe.reference,ie,j]),ve=l.useMemo(()=>{let e=Vi(G.trigger,pe.trigger,ie);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[G.trigger,pe.trigger,ie]);$e(()=>(O.update({inactiveTriggerProps:ve}),null)),Ps(O,{floatingRootContext:le,activeTriggerProps:K,inactiveTriggerProps:ve,popupProps:l.useMemo(()=>Vi(Ss,{id:C,role:`menu`,"aria-orientation":u===`horizontal`?`horizontal`:void 0,"aria-labelledby":M?.id,onMouseMove(){O.set(`allowMouseEnter`,!0),L.type===`menu`&&O.set(`hoverEnabled`,!1)},onClick(){O.select(`hoverEnabled`)&&O.set(`hoverEnabled`,!1)},onKeyDown(e){let t=O.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},_e.floating,G.floating,pe.floating),[M,C,u,L.type,O,_e.floating,G.floating,pe.floating]),itemProps:G.item??nt});let ye=l.useMemo(()=>({store:O,parent:x}),[O,x]),be=(0,Q.jsxs)(Jy.Provider,{value:ye,children:[p&&(0,Q.jsx)(Ts,{handle:p,store:O}),typeof t==`function`?t({payload:z}):t]});return L.type===void 0||L.type===`context-menu`?(0,Q.jsx)(Ea,{externalTree:k,children:be}):be});function gb(e,t,n){return $e(()=>new ub(e,t,n)).current}function _b(e){let t=Yy().store,n=l.useMemo(()=>({parentMenu:t}),[t]);return(0,Q.jsx)(pb.Provider,{value:n,children:(0,Q.jsx)(hb,{...e})})}function vb(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Mc(),{ref:i,index:a}=lg(e),o=n===a,s=l.useRef(null),c=Bn(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function yb(e){let{render:t,className:n,style:r,state:i=nt,props:a=tt,refs:o=tt,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=vb({metadata:s});return ta(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function bb(e){if(ve(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Ae(e))return bb(Ne(e))}function xb(e,t){let n=l.useRef(null);function r(t){fa.flushSync(()=>{e.setOpen(!1,Z(Tn,t.nativeEvent,t.currentTarget))}),oi(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&si(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{fa.flushSync(()=>{e.setOpen(!1,Z(Tn,n.nativeEvent,n.currentTarget))});let i=ai(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&X(r,i);){let e=i;if(i=ni(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Sb(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=l.useRef(!1);return l.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,J(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:nt,[t,n,r])}var Cb=rs(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:u=100,closeDelay:d=0,handle:f,payload:p,...m}=e,h=Yy(!0),g=Ws(f)??h?.store;if(!g)throw Error(Mi(85));let _=zc(s),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),b=g.useState(`isOpenedByTrigger`,_),x=g.useState(`triggerPopupId`,_),S=l.useRef(null),C=Tb(),w=Mc(!0),T=Ca(),E=l.useMemo(()=>T??new ya,[T]),{registerTrigger:D,isMountedByThisTrigger:O}=js(_,S,g,{payload:p,closeDelay:d,parent:C,floatingTreeRoot:E,floatingNodeId:wa(E),floatingParentNodeId:Sa(),keyboardEventRelay:w?.relayKeyboardEvent}),k=C.type===`menubar`,A=g.useState(`disabled`),j=a||A||k&&C.context.disabled,{getButtonProps:M,buttonRef:N}=Fc({disabled:j,native:o});l.useEffect(()=>{!b&&C.type===void 0&&(g.context.allowMouseUpTriggerRef.current=!1)},[g,b,C.type]);let P=l.useRef(null),F=ot(),I=$(e=>{if(!P.current)return;F.clear(),g.context.allowMouseUpTriggerRef.current=!1;let t=e.target;X(P.current,t)||X(g.select(`positionerElement`),t)||t===P.current||(t==null||bb(t)!==g.select(`rootId`))&&(Ih(e,P.current)||E.events.emit(`close`,{domEvent:e,reason:An}))});l.useEffect(()=>{b&&g.select(`lastOpenChangeReason`)===`trigger-hover`&&J(P.current).addEventListener(`mouseup`,I,{once:!0})},[b,I,g]);let L=k&&C.context.hasSubmenuOpen,R=rc(y,{enabled:(c??L)&&!j&&(!k||L&&!O),handleClose:bc({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:C.type===void 0?u:void 0,delay:{close:d},triggerElementRef:S,externalTree:E,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),z=wb(b,g.select(`lastOpenChangeReason`)),B=La(y,{enabled:!j,event:b&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:C.type===void 0&&z}),V=Ys(y,{enabled:!j&&L}),ee=Sb({open:b,enabled:k,mouseDownAction:`open`}),te=l.useMemo(()=>Vi(V.reference,B.reference),[V.reference,B.reference]),ne=g.useState(`triggerProps`,O),{preFocusGuardRef:H,handlePreFocusGuardFocus:U,handleFocusTargetFocus:re}=xb(g,S),ie={disabled:j,open:b},ae=[P,t,N,D,S],oe=[te,R??nt,ne,{"aria-haspopup":`menu`,"aria-controls":x,id:_,onMouseDown:e=>{g.select(`open`)||(F.start(200,()=>{g.context.allowMouseUpTriggerRef.current=!0}),J(e.currentTarget).addEventListener(`mouseup`,I,{once:!0}))}},k?{role:`menuitem`}:{},ee,m,M],se=ta(`button`,e,{enabled:!k,stateAttributesMapping:Zt,state:ie,ref:ae,props:oe});return k?(0,Q.jsx)(yb,{tag:`button`,render:n,className:r,style:i,state:ie,refs:ae,props:oe,stateAttributesMapping:Zt}):b?(0,Q.jsxs)(l.Fragment,{children:[(0,Q.jsx)(nr,{ref:H,onFocus:U},`${_}-pre-focus-guard`),(0,Q.jsx)(l.Fragment,{children:se},_),(0,Q.jsx)(nr,{ref:g.context.triggerFocusTargetRef,onFocus:re},`${_}-post-focus-guard`)]}):(0,Q.jsx)(l.Fragment,{children:se},_)});function wb(e,t){let n=ot(),[r,i]=l.useState(!1);return W(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function Tb(){let e=cb(!0);return l.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var Eb={"aria-expanded":void 0},Db=l.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:u=100,closeDelay:d=0,disabled:f=!1,...p}=e,m=mb();if(!m?.parentMenu)throw Error(Mi(37));let h=lg({guess:!0,label:a}),g=qy(),{store:_}=Yy(),v=zc(o),y=_.useState(`open`),b=_.useState(`floatingRootContext`),x=_.useState(`floatingTreeRoot`),S=_.useState(`triggerPopupId`,v),C=Ds(v,_),w=$(e=>{C(e),e!==null&&_.select(`open`)&&_.select(`activeTriggerId`)==null&&_.update({activeTriggerId:v??null,activeTriggerElement:e,closeDelay:d})}),T=l.useRef(null),E=l.useCallback(e=>{T.current=e,_.set(`activeTriggerElement`,e)},[_]);W(()=>(w(T.current),()=>w(null)),[w,v,_]),_.useSyncedValue(`closeDelay`,d);let D=m.parentMenu,O=_.useState(`disabled`),k=D.useState(`disabled`),A=f||O||k,j=D.useState(`itemProps`),M=D.useState(`isActive`,h.index),N=l.useMemo(()=>({type:`submenu-trigger`,setActive(){D.select(`highlightItemOnHover`)&&D.set(`activeIndex`,h.index)}}),[D,h.index]),{getItemProps:P,itemRef:F}=Qy({closeOnClick:!1,disabled:A,highlighted:M,id:v,store:_,typingRef:D.context.typingRef,nativeButton:s,itemMetadata:N,nodeId:g?.context.nodeId}),I=rc(b,{enabled:_.useState(`hoverEnabled`)&&c&&!A,handleClose:bc({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:u,delay:{open:u,close:d},shouldOpen:u>0?()=>D.select(`allowMouseEnter`):void 0,triggerElementRef:T,externalTree:x,isClosing:()=>_.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),L=La(b,{enabled:!A,event:`mousedown`,toggle:!c,ignoreMouse:c,stickIfOpen:!1}).reference??nt,R=_.useState(`triggerProps`,!0);delete R.id;let z={disabled:A,highlighted:M,open:y},B=_.useState(`openMethod`),V=_.useState(`lastOpenChangeReason`)===`list-navigation`||B===`keyboard`;return ta(`div`,e,{state:z,stateAttributesMapping:Xt,props:[L,I,R,j,y&&V&&Xe?Eb:void 0,{"aria-controls":S,tabIndex:y||M?0:-1,onBlur(){M&&D.set(`activeIndex`,null)}},p,P],ref:[t,h.ref,F,w,E]})});function Ob(e){let[t,n]=l.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=l.useRef(null),i=l.useRef(null),a=l.useRef(null),o=l.useRef(null),s=l.useRef(!0),c=l.useRef(null),u=Ai(),d=l.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:u}),[t,u]);return(0,Q.jsx)(Wy.Provider,{value:d,children:(0,Q.jsx)(Jy.Provider,{value:void 0,children:(0,Q.jsx)(hb,{...e})})})}var kb=500,Ab=l.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:u,positionerRef:d,allowMouseUpTriggerRef:f,initialCursorPointRef:p,rootId:m}=Gy(!1),{store:h}=Yy(!1),g=h.useState(`open`),_=h.useState(`disabled`),v=l.useRef(null),y=l.useRef(null),b=ot(),x=ot(),S=l.useRef(!1),C=l.useRef(null);function w(e,t,n){let r=n.type.startsWith(`touch`);p.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),S.current=!1,s.current?.setOpen(!0,Z(gn,n)),x.start(kb,()=>{S.current=!0})}function T(e){if(_)return;f.current=!0,xt(e),w(e.clientX,e.clientY,e.nativeEvent);let t=J(v.current);C.current?.abort();let n=new AbortController;C.current=n,t.addEventListener(`mouseup`,e=>{if(f.current=!1,!S.current)return;x.clear(),S.current=!1;let t=Ot(e);X(d.current,t)||m&&t&&bb(t)===m||s.current?.setOpen(!1,Z(An,e))},{once:!0,signal:n.signal})}function E(){b.clear(),y.current=null}function D(e){if(_){E();return}if(f.current=!1,e.touches.length!==1){E();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};y.current=n,b.start(kb,()=>{w(n.x,n.y,e.nativeEvent)})}function O(e){if(e.touches.length!==1){E();return}if(b.isStarted()&&y.current){let t=e.touches[0],n=Math.abs(t.clientX-y.current.x),r=Math.abs(t.clientY-y.current.y);(n>10||r>10)&&E()}}return l.useEffect(()=>()=>{C.current?.abort()},[]),l.useEffect(()=>{function e(e){if(_)return;let t=Ot(e);(X(v.current,t)||X(c.current,t)||X(u.current,t))&&e.preventDefault()}return q(J(v.current),`contextmenu`,e)},[u,_,c]),ta(`div`,e,{state:{open:g},ref:[v,t],props:[{onContextMenu:T,onTouchStart:D,onTouchMove:O,onTouchEnd:E,onTouchCancel:E,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:Zt})}),jb=ob,Mb={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`Pi`};function Nb(e){return Object.hasOwn(Mb,e)?Mb[e]:e}function Pb(e){let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/6e4));return t<1?`now`:t<60?`${t}m`:t<1440?`${Math.floor(t/60)}h`:`${Math.floor(t/1440)}d`}var Fb=[{id:`validate`,label:`Checking the machine`,active:`Checking the machine…`},{id:`checkout`,label:`Creating the worktree`,active:`Creating the worktree…`},{id:`start`,label:`Starting the agent`,active:`Starting the agent…`},{id:`prompt`,label:`Sending your prompt`,active:`Sending your prompt…`}],Ib=6e5,Lb=e=>e===`checkout_complete`?2:Math.max(0,Fb.findIndex(t=>t.id===e)),Rb=e=>[`pending`,`running`].includes(e.operation?.state??``)&&!e.panes.some(e=>e.kind===`agent`),zb=e=>[`failed`,`unknown`].includes(e.operation?.state??``)&&!e.panes.some(e=>e.kind===`agent`),Bb=e=>Fb[Lb(e.operation?.step??`validate`)].active,Vb=(e,t)=>t-Date.parse(e.updatedAt)<Ib,Hb=(e,t=Date.now())=>e.panes.some(e=>e.kind===`agent`)||Rb(e)||zb(e)&&Vb(e,t),Ub=e=>new URLSearchParams({machineId:e.machineId??`local`,projectId:e.id}),Wb=e=>e.branch??e.label,Gb=e=>e.path.split(`/`).at(-1)??``,Kb=(e,t)=>`${Wb(e)} ${Gb(e)}`.toLowerCase().includes(t.trim().toLowerCase()),qb=async(e,t)=>{let n=await fetch(`/api/worktrees?${Ub(e)}`,{signal:t});if(!n.ok)throw Error(`Could not list worktrees.`);return await n.json()},Jb=async(e,t)=>{let n=await fetch(`/api/worktrees/open`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({machineId:e.machineId??`local`,projectId:e.id,path:t.path})});if(!n.ok)throw Error(`Could not open this worktree.`);return(await n.json()).id},Yb=async(e,t)=>{try{await a(`/threads/${encodeURIComponent(await Jb(e,t))}`)}catch(e){cl(e instanceof Error?e.message:`Could not open this worktree.`)}},Xb=e=>{(e.key.length===1||e.key===`Backspace`)&&e.stopPropagation()};function Zb({project:e}){let[t,n]=(0,l.useState)(``),r=Z_({queryKey:[`worktrees`,e.machineId,e.id],queryFn:({signal:t})=>qb(e,t),staleTime:0,gcTime:0}),i=(r.data??[]).filter(e=>Kb(e,t));return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`composer-select-search`,children:[(0,Q.jsx)(ie,{size:14,"aria-hidden":`true`}),(0,Q.jsx)(`input`,{autoFocus:!0,"aria-label":`Search worktrees`,placeholder:`Search worktrees…`,value:t,onChange:e=>n(e.target.value),onKeyDown:Xb})]}),(0,Q.jsxs)(`div`,{className:`worktree-menu-list`,children:[i.map(t=>(0,Q.jsx)(Zl,{label:t.path,side:`right`,children:(0,Q.jsxs)($y,{className:`thread-menu-item`,onClick:()=>void Yb(e,t),children:[(0,Q.jsx)(P,{size:14,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{className:`worktree-menu-name`,children:[Wb(t),(0,Q.jsx)(`small`,{children:Gb(t)})]})]})},t.path)),r.isError&&(0,Q.jsx)(`p`,{className:`worktree-menu-note`,role:`alert`,children:`Could not list worktrees.`}),r.data&&!i.length&&(0,Q.jsx)(`p`,{className:`worktree-menu-note`,children:r.data.length?`No matches`:`Every worktree already has a thread`})]})]})}function Qb({projects:e}){return(0,Q.jsxs)(hb,{children:[(0,Q.jsx)(Zl,{label:`Open existing worktree`,children:(0,Q.jsx)(Cb,{className:`sidebar-open-worktree`,"aria-label":`Open existing worktree`,disabled:!e.length,children:(0,Q.jsx)(ie,{size:16,"aria-hidden":`true`})})}),(0,Q.jsx)(ab,{children:(0,Q.jsx)(ob,{className:`thread-menu-positioner`,sideOffset:6,align:`start`,children:(0,Q.jsx)(nb,{className:`thread-menu`,children:e.map(e=>(0,Q.jsxs)(_b,{children:[(0,Q.jsxs)(Db,{className:`thread-menu-item`,children:[(0,Q.jsx)(Eg,{project:e}),(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(x,{size:14,"aria-hidden":`true`,className:`worktree-menu-chevron`})]}),(0,Q.jsx)(ab,{children:(0,Q.jsx)(ob,{className:`thread-menu-positioner`,sideOffset:4,alignOffset:-4,children:(0,Q.jsx)(nb,{className:`thread-menu worktree-menu`,children:(0,Q.jsx)(Zb,{project:e})})})})]},`${e.machineId}:${e.id}`))})})})]})}function $b({thread:e,onDone:t,onError:n}){let[r,i]=(0,l.useState)(e.title),a=(0,l.useRef)(null),o=(0,l.useRef)(!1);(0,l.useEffect)(()=>{a.current?.focus(),a.current?.select()},[]);let s=i=>{if(o.current)return;o.current=!0,t();let a=r.trim();i&&a&&a!==e.title&&cp(e,a).catch(n)};return(0,Q.jsx)(`input`,{ref:a,className:`thread-name-input`,"aria-label":`Rename ${e.title}`,value:r,maxLength:90,onChange:e=>i(e.target.value),onBlur:()=>s(!0),onClick:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&s(!0),e.key===`Escape`&&s(!1)}})}function ex({project:e,onDone:t,onError:n}){let[r,i]=(0,l.useState)(e.name),a=(0,l.useRef)(null),o=(0,l.useRef)(!1);(0,l.useEffect)(()=>{a.current?.focus(),a.current?.select()},[]);let s=i=>{if(o.current)return;o.current=!0,t();let a=r.trim();i&&a&&a!==e.name&&lp(e,a).catch(n)};return(0,Q.jsx)(`input`,{ref:a,className:`thread-name-input group-name-input`,"aria-label":`Rename ${e.name}`,value:r,maxLength:90,onChange:e=>i(e.target.value),onBlur:()=>s(!0),onClick:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&s(!0),e.key===`Escape`&&s(!1)}})}var tx=128;async function nx(e){let t=await createImageBitmap(e),n=document.createElement(`canvas`);n.width=n.height=tx;let r=Math.min(tx/t.width,tx/t.height),i=t.width*r,a=t.height*r;return n.getContext(`2d`).drawImage(t,(tx-i)/2,(tx-a)/2,i,a),new Promise((e,t)=>n.toBlob(n=>n?e(n):t(Error(`Could not read this image.`)),`image/png`))}function rx({project:e,open:t,onClose:n,onError:r}){let i=(0,l.useRef)(null),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(!1),[u,d]=(0,l.useState)([]);(0,l.useEffect)(()=>{if(!t)return;let n=!0;return fp(e).then(e=>{n&&d(e)}).catch(()=>{}),()=>{n=!1,d([])}},[t,e.id,e.machineId]);let f=async e=>{c(!0);try{await e(),n()}catch(e){r(e)}finally{c(!1)}},p=t=>{t&&f(async()=>dp(e,await nx(t)))},m=t=>void f(async()=>dp(e,await nx(await(await fetch(t.url)).blob())));return(0,Q.jsx)(Ev,{open:t,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(Xc,{children:[(0,Q.jsx)(Ac,{className:`dialog-backdrop`}),(0,Q.jsxs)(qc,{className:`dialog`,children:[(0,Q.jsxs)(Zc,{className:`dialog-message`,children:[`Change icon for `,e.name]}),(0,Q.jsxs)(`div`,{className:`icon-current`,children:[(0,Q.jsx)(Eg,{project:e}),(0,Q.jsx)(`span`,{children:`Current icon`})]}),(0,Q.jsxs)(`button`,{type:`button`,className:`icon-dropzone ${a?`is-dragging`:``}`,disabled:s,onClick:()=>i.current?.click(),onDragOver:e=>{e.preventDefault(),o(!0)},onDragLeave:()=>o(!1),onDrop:e=>{e.preventDefault(),o(!1),p(e.dataTransfer.files[0])},children:[(0,Q.jsx)(I,{size:22,"aria-hidden":`true`}),`Drop an image here, or click to choose`]}),(0,Q.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,hidden:!0,onChange:e=>{p(e.target.files?.[0]),e.target.value=``}}),u.length>0&&(0,Q.jsx)(`div`,{className:`icon-candidates`,role:`group`,"aria-label":`Images found in this project`,children:u.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`icon-candidate`,disabled:s,title:e.name,"aria-label":`Use ${e.name}`,onClick:()=>m(e),children:(0,Q.jsx)(`img`,{src:e.url,alt:``,loading:`lazy`})},e.url))}),(0,Q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,disabled:s,onClick:()=>void f(()=>pp(e)),children:`Reset to default`}),(0,Q.jsx)(Rc,{className:`dialog-button`,children:`Cancel`})]})]})]})})}var ix=220,ax=`[data-flip-id]`,ox=e=>{let t=e.getBoundingClientRect().top-e.scrollTop;return new Map([...e.querySelectorAll(ax)].map(e=>[e.dataset.flipId,{element:e,top:e.getBoundingClientRect().top-t}]))};function sx(e){let t=(0,l.useRef)(new Map);(0,l.useLayoutEffect)(()=>{if(!e.current)return;let n=ox(e.current);for(let[e,{element:r,top:i}]of n){let n=t.current.get(e);n===void 0||Math.abs(n-i)<1||r.animate([{transform:`translateY(${n-i}px)`},{transform:`none`}],{duration:ix,easing:`cubic-bezier(.2, .8, .2, 1)`})}t.current=new Map([...n].map(([e,{top:t}])=>[e,t]))})}function cx(e,t){let n=new Map;for(let r of e){let e=r.logicalId??r.id,i=n.get(e);i?(i.locations.push(r.id),r.id===t&&(i.project=r)):n.set(e,{id:e,project:r,locations:[r.id]})}return[...n.values()]}var lx=/^\/(?:Users|home)\/[^/]+/,ux=e=>e.replace(lx,`~`),dx={working:`Working`,blocked:`Needs input`,done:`Done`,idle:`Idle`,unknown:`Unknown`},fx={blocked:z,done:w,unknown:T},px=e=>cl(e instanceof Error?e.message:`Herdr could not complete this action.`),mx=async e=>{await sl(yp([e]),{confirmLabel:`Delete`,danger:!0})&&await gp(e).catch(px)},hx=(0,l.memo)(function({thread:e,project:t,machineName:n,current:r,showProject:i}){let a=!!e.archivedAt,o=a?f:p,s=a?`Unarchive ${e.title}`:`Archive ${e.title}`,[c,u]=(0,l.useState)(!1),d=c?(0,Q.jsx)($b,{thread:e,onDone:()=>u(!1),onError:px}):void 0;return(0,Q.jsxs)(Ob,{children:[(0,Q.jsxs)(Ab,{className:`thread-item`,"data-flip-id":e.id,onDoubleClick:e=>{e.preventDefault(),u(!0)},children:[(0,Q.jsx)(gx,{thread:e,project:t,machineName:n,current:r,showProject:i,editor:d}),(0,Q.jsx)(Zl,{label:a?`Unarchive`:`Archive`,children:(0,Q.jsx)(`button`,{type:`button`,className:`thread-archive`,"aria-label":s,onClick:()=>void sp(e,!a).catch(px),children:(0,Q.jsx)(o,{size:15,strokeWidth:1.8,"aria-hidden":`true`})})})]}),(0,Q.jsx)(ab,{children:(0,Q.jsx)(jb,{className:`thread-menu-positioner`,children:(0,Q.jsx)(nb,{className:`thread-menu`,children:(0,Q.jsxs)($y,{className:`thread-menu-item is-danger`,onClick:()=>void mx(e),children:[(0,Q.jsx)(de,{size:14,"aria-hidden":`true`}),`Delete permanently`]})})})})]})});function gx({thread:e,project:t,machineName:n,current:r,showProject:i,editor:a}){let o=Rb(e),s=zb(e),c=s?fe:o?void 0:fx[e.status],l=s||e.status===`blocked`||e.status===`done`,u=o?Bb(e):s?`Launch stopped`:dx[e.status],d=o||s?u:i?t?.name:Nb(e.agent),f=a?`div`:`a`;return(0,Q.jsx)(Zl,{label:`${e.title} · ${t?.name??``} · ${n} · ${Nb(e.agent)} · ${e.model} · ${u}`,side:`right`,children:(0,Q.jsxs)(f,{className:`thread-row ${r?`is-current`:``} ${l?`needs-attention status-${s?`blocked`:e.status}`:``}`,href:a?void 0:`/threads/${encodeURIComponent(e.id)}`,"aria-current":r?`page`:void 0,"aria-label":`${e.title} · ${t?.name??``} · ${n} · ${u}`,children:[(0,Q.jsxs)(`span`,{className:`thread-avatar`,"aria-hidden":`true`,children:[(0,Q.jsx)(Yf,{thread:e,working:e.status===`working`||o,size:24}),c&&(0,Q.jsx)(c,{className:`thread-status status-${s?`blocked`:e.status}`,size:14,strokeWidth:2.2}),(0,Q.jsx)(`span`,{className:`thread-avatar-harness`,children:(0,Q.jsx)(Sg,{harness:e.agent,size:14})})]}),(0,Q.jsxs)(`span`,{className:`thread-copy`,children:[(0,Q.jsxs)(`span`,{className:`thread-context`,children:[i&&t&&!o&&!s&&(0,Q.jsx)(Eg,{project:t}),e.worktree&&!o&&!s&&(0,Q.jsx)(P,{className:`thread-worktree`,size:11,"aria-label":`Worktree`}),d]}),a??(0,Q.jsx)(`span`,{className:`thread-name`,children:e.title})]}),(0,Q.jsx)(`span`,{className:`thread-time`,children:Pb(e.updatedAt)})]})})}function _x({project:e,closed:t,onToggle:n}){let[r,i]=(0,l.useState)(!1),[o,s]=(0,l.useState)(!1),c=r?`div`:`button`,u=r?(0,Q.jsx)(ex,{project:e,onDone:()=>i(!1),onError:px}):(0,Q.jsx)(`span`,{className:`group-name`,children:e.name});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Ob,{children:[(0,Q.jsx)(Ab,{className:`group-header`,children:(0,Q.jsxs)(c,{className:`group-title`,onClick:r?void 0:n,"aria-expanded":r?void 0:!t,children:[(0,Q.jsx)(`span`,{className:`group-chevron`,"aria-hidden":`true`,children:t?(0,Q.jsx)(x,{size:14}):(0,Q.jsx)(b,{size:14})}),(0,Q.jsx)(Eg,{project:e}),u]})}),(0,Q.jsx)(ab,{children:(0,Q.jsx)(jb,{className:`thread-menu-positioner`,children:(0,Q.jsxs)(nb,{className:`thread-menu`,children:[(0,Q.jsxs)($y,{className:`thread-menu-item`,onClick:()=>void a(`/new?project=${encodeURIComponent(e.id)}`),children:[(0,Q.jsx)(re,{size:14,"aria-hidden":`true`}),`New thread`]}),(0,Q.jsxs)($y,{className:`thread-menu-item`,onClick:()=>i(!0),children:[(0,Q.jsx)(U,{size:14,"aria-hidden":`true`}),`Rename project`]}),(0,Q.jsxs)($y,{className:`thread-menu-item`,onClick:()=>s(!0),children:[(0,Q.jsx)(I,{size:14,"aria-hidden":`true`}),`Change icon`]}),(0,Q.jsx)(`div`,{className:`thread-menu-path`,title:e.path,children:ux(e.path)})]})})})]}),(0,Q.jsx)(rx,{project:e,open:o,onClose:()=>s(!1),onError:px})]})}function vx({threads:e,renderThread:t}){let[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1),o=async()=>{if(await sl(yp(e),{confirmLabel:`Delete all`,danger:!0})){a(!0);try{let e=await _p();e.failed.length&&await cl(`${e.failed.length} archived ${e.failed.length===1?`thread`:`threads`} could not be deleted.`)}catch(e){px(e)}finally{a(!1)}}};return(0,Q.jsxs)(`section`,{className:`thread-group archived-threads`,"aria-label":`Archived threads`,children:[(0,Q.jsxs)(`div`,{className:`group-header`,children:[(0,Q.jsxs)(`button`,{className:`group-title`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[(0,Q.jsx)(`span`,{className:`group-chevron`,"aria-hidden":`true`,children:n?(0,Q.jsx)(b,{size:14}):(0,Q.jsx)(x,{size:14})}),(0,Q.jsx)(p,{size:14,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`group-name`,children:`Archived`}),(0,Q.jsx)(`span`,{className:`group-count`,children:e.length})]}),(0,Q.jsx)(`button`,{type:`button`,className:`archived-delete-all`,onClick:()=>void o(),disabled:i,children:i?`Deleting…`:`Delete all`})]}),n&&e.map(t)]})}function yx({projects:e,threads:t,archived:n=[],machines:r,currentId:i,mode:a,onModeChange:o,collapsed:s,mobileOpen:c,onCollapse:u,onCloseMobile:d,onOpenPalette:f,updateAction:p}){let[m,h]=(0,l.useState)([]),g=t.find(e=>e.id===i)?.projectId,_=cx(e,g),v=(0,l.useRef)(null);sx(v);let y=(t,n)=>{let a=e.find(e=>e.id===t.projectId);return(0,Q.jsx)(hx,{thread:t,project:a,machineName:r.find(e=>e.id===t.machineId)?.name??t.machineId,current:i===t.id,showProject:n},t.id)};return(0,Q.jsxs)(Q.Fragment,{children:[c&&(0,Q.jsx)(`button`,{className:`sidebar-scrim`,"aria-label":`Close sidebar`,onClick:d}),(0,Q.jsxs)(`aside`,{className:`sidebar ${s?`is-collapsed`:``} ${c?`is-mobile-open`:``}`,"aria-label":`Threads`,onClick:e=>{c&&e.target.closest(`a[href]`)&&d()},children:[(0,Q.jsxs)(`div`,{className:`sidebar-header`,children:[!s&&(0,Q.jsxs)(`span`,{className:`brand`,children:[(0,Q.jsx)(`img`,{src:`/brand-mark.png`,alt:``,width:20,height:20}),`webr`]}),(0,Q.jsx)(`button`,{className:`icon-button sidebar-collapse`,"aria-label":s?`Expand sidebar`:`Collapse sidebar`,onClick:u,children:s?(0,Q.jsx)(ne,{size:16}):(0,Q.jsx)(te,{size:16})}),(0,Q.jsx)(`button`,{className:`icon-button mobile-close`,"aria-label":`Close sidebar`,onClick:d,children:(0,Q.jsx)(pe,{size:16})})]}),(0,Q.jsxs)(`div`,{className:`sidebar-actions`,children:[(0,Q.jsx)(Zl,{label:`New thread`,children:(0,Q.jsxs)(`a`,{className:`sidebar-new-thread`,href:`/new${g?`?project=${encodeURIComponent(g)}`:``}`,"aria-label":`New thread`,children:[(0,Q.jsx)(se,{size:16,"aria-hidden":`true`}),!s&&(0,Q.jsx)(`span`,{children:`New thread`})]})}),(0,Q.jsx)(Qb,{projects:e}),!s&&(0,Q.jsxs)(`div`,{className:`sidebar-view-switch`,role:`group`,"aria-label":`Sidebar layout`,children:[(0,Q.jsx)(Zl,{label:`Show threads`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Show threads`,"aria-pressed":a===`threads`,onClick:()=>o(`threads`),children:(0,Q.jsx)(L,{size:16,"aria-hidden":`true`})})}),(0,Q.jsx)(Zl,{label:`Group by project`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Group by project`,"aria-pressed":a===`projects`,onClick:()=>o(`projects`),children:(0,Q.jsx)(M,{size:16,"aria-hidden":`true`})})})]})]}),!s&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`nav`,{ref:v,className:`thread-navigation`,"aria-label":`Agent threads`,children:[a===`projects`?_.filter(e=>t.some(t=>e.locations.includes(t.projectId))).sort((e,n)=>(t.find(e=>n.locations.includes(e.projectId))?.updatedAt??``).localeCompare(t.find(t=>e.locations.includes(t.projectId))?.updatedAt??``)).map(({id:e,project:n,locations:r})=>(0,Q.jsxs)(`section`,{className:`thread-group`,children:[(0,Q.jsx)(_x,{project:n,closed:m.includes(e),onToggle:()=>h(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}),!m.includes(e)&&t.filter(e=>r.includes(e.projectId)).map(e=>y(e,!1))]},e)):t.map(e=>y(e,!0)),!t.length&&!n.length&&(0,Q.jsx)(`p`,{className:`sidebar-empty`,children:`No agents yet. Press ⌘K to start one.`})]}),!!n.length&&(0,Q.jsx)(vx,{threads:n,renderThread:e=>y(e,!0)}),(0,Q.jsxs)(`div`,{className:`sidebar-footer`,children:[(0,Q.jsxs)(`a`,{className:`sidebar-settings`,href:`/settings`,children:[(0,Q.jsx)(oe,{size:15}),` Settings`]}),p,(0,Q.jsx)(Zl,{label:`Open command palette`,children:(0,Q.jsx)(`button`,{type:`button`,className:`sidebar-palette`,"aria-label":`Open command palette`,onClick:f,children:(0,Q.jsx)(`kbd`,{children:`⌘K`})})})]})]})]})]})}function bx(){let{status:e,updating:t,requestUpdate:n}=Vy();return!e||!(e.available||t)?null:(0,Q.jsx)(Zl,{label:`Webr ${e.latest} is available`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`sidebar-update`,disabled:t,onClick:()=>void n(),children:[(0,Q.jsx)(C,{size:14,"aria-hidden":`true`}),t?`Updating…`:`Update`]})})}var xx=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},Sx=(e=>e?xx(e):xx),Cx=e=>e;function wx(e,t=Cx){let n=l.useSyncExternalStore(e.subscribe,l.useCallback(()=>t(e.getState()),[e,t]),l.useCallback(()=>t(e.getInitialState()),[e,t]));return l.useDebugValue(n),n}var Tx=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Ex=(e,t)=>e&&Tx(e,t)?e:t;function Dx(e){let t=new Map,n=new Set,r=Sx((e,r)=>({projections:{},threads:{},projects:{},threadIds:[],projectIds:[],connected:!1,connection:t=>e(e=>{if(t)return{connected:t};for(let t of Object.keys(e.projections))n.add(t);return{connected:t,projections:Object.fromEntries(Object.entries(e.projections).map(([e,t])=>[e,{...t,connected:!1,freshAt:null}])),threads:Object.fromEntries(Object.entries(e.threads).map(([e,t])=>[e,{...t,status:`unknown`,bindingState:`detached`}]))}}),install:i=>{let a=r(),o=a.projections[i.machineId],s=t.get(i.machineId)??new Set;if(s.has(i.generation)||!n.has(i.machineId)&&o?.generation===i.generation&&o.revision>=i.revision)return;n.delete(i.machineId),o&&o.generation!==i.generation&&s.add(o.generation),s.size>8&&s.delete(s.values().next().value),t.set(i.machineId,s);let c=Object.fromEntries(Object.entries(a.threads).filter(([,e])=>e.machineId!==i.machineId));for(let e of i.threads)c[e.id]=Ex(a.threads[e.id],{...e,panes:e.panes.map(t=>Ex(a.threads[e.id]?.panes.find(e=>e.id===t.id&&e.terminalId===t.terminalId),t))});let l={...a.projections,[i.machineId]:i},u={};for(let e of Object.values(l))for(let t of e.projects)u[t.id]=Ex(a.projects[t.id],t);let d=Object.values(c).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)).map(e=>e.id),f=Object.keys(u);e({projections:l,threads:c,projects:u,threadIds:Ex(a.threadIds,d),projectIds:Ex(a.projectIds,f)})}}));for(let t of e.projections)r.getState().install(t);return r}var Ox=()=>Sx(e=>({focusedPanes:{},paneWindows:{},focus:(t,n)=>e(e=>({focusedPanes:{...e.focusedPanes,[t]:n}})),showWindow:(t,n)=>e(e=>({paneWindows:{...e.paneWindows,[t]:n}}))}));function kx(e){if(e.length<32)throw Error(`short_frame`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=Number(t.getBigUint64(12));if(t.getUint32(0)!==1212437041||t.getUint32(24)!==e.length-32||e.length-32>262144||!Number.isSafeInteger(n)||t.getUint8(28)>1||t.getUint8(29)||t.getUint16(30))throw Error(`invalid_frame`);let r={streamId:t.getUint32(4),generation:t.getUint32(8),seq:n,width:t.getUint16(20),height:t.getUint16(22),full:!!t.getUint8(28),bytes:e.subarray(32)};if(!r.streamId||!r.generation||!r.width||r.width>500||!r.height||r.height>300)throw Error(`invalid_dimensions`);return r}var Ax=class{seq;accept(e){if(this.seq===void 0&&!e.full)throw Error(`baseline_required`);if(this.seq!==void 0&&e.seq!==this.seq+1)throw Error(`sequence_gap`);this.seq=e.seq}},jx=class{terminal;acknowledge;budget;frames=[];bytes=0;writing=!1;closed=!1;constructor(e,t,n=524288){this.terminal=e,this.acknowledge=t,this.budget=n}push(e){if(!this.closed){if(this.bytes+e.bytes.length>this.budget)throw Error(`renderer_overload`);this.bytes+=e.bytes.length,this.frames.push(e),this.frames.length,this.bytes/1024,this.flush()}}close(){this.closed=!0,this.frames=[],this.bytes=0}flush(){if(this.closed||this.writing||!this.frames.length)return;this.writing=!0;let e=this.frames.shift();this.terminal.resize(e.width,e.height);let t=e.full?new Uint8Array(e.bytes.length+2):e.bytes;e.full&&(t.set([27,99]),t.set(e.bytes,2));let n=Tp();this.terminal.write(t,()=>{this.closed||(Tp()-n,this.bytes-=e.bytes.length,this.writing=!1,this.acknowledge(e),this.flush())})}},Mx=(e,t=Math.random)=>Math.min(3e4,Math.round(Math.min(25e3,1e3*2**Math.min(e,5))*(.8+t()*.4))),Nx=`Another controller owns this terminal.`,Px=class{install;onConnection;metadata;binary;stopped=!0;epoch=0;nextId=1;panes=new Map;reconnect;instance=``;failures=0;connectedAt=0;scrollSentAt=new Map;inputSentAt=new Map;openedAt=new Map;constructor(e,t){this.install=e,this.onConnection=t}start(){this.stopped=!1,this.connect()}stop(){this.stopped=!0,clearTimeout(this.reconnect),this.disconnect()}mount(e){let t=this.nextId++;return this.panes.set(t,{...e,generation:1,sequence:new Ax,writable:!1,accepted:!1,baseline:!1,pending:0,resizing:!1,attempts:0}),this.open(t),{close:()=>{let e=this.panes.get(t);e&&(this.send({type:`release`,streamId:t,generation:e.generation}),e.renderer?.close()),this.panes.delete(t)},input:(e,n=!1)=>{let r=this.panes.get(t);r?.writable&&(this.inputSentAt.set(t,Tp()),this.send({type:`input`,streamId:t,generation:r.generation,text:e,paste:n}))},control:(e=!1)=>{let n=this.panes.get(t);n&&(n.mode!==`control`||e)&&(this.send({type:`release`,streamId:t,generation:n.generation}),n.reason=void 0,n.mode=`control`,++n.generation,n.sequence=new Ax,this.open(t,e))},observe:()=>{let e=this.panes.get(t);e&&e.mode!==`observe`&&(this.send({type:`release`,streamId:t,generation:e.generation}),e.mode=`observe`,++e.generation,e.sequence=new Ax,this.open(t))},resize:(e,n,r=!1)=>{let i=this.panes.get(t);i&&(e!==i.cols||n!==i.rows||r&&i.mode===`control`&&i.accepted)&&(i.cols=e,i.rows=n,i.mode===`control`&&i.accepted?(i.writable=!1,i.baseline=!1,i.resizing=!0,i.onState(`Waiting for the resized full baseline.`,!1),this.send({type:`resize`,streamId:t,generation:i.generation,cols:e,rows:n})):(this.send({type:`release`,streamId:t,generation:i.generation}),++i.generation,i.sequence=new Ax,this.open(t)))},scroll:(e,n,r,i)=>{let a=this.panes.get(t);a?.writable&&(this.scrollSentAt.set(t,Tp()),this.send({type:`scroll`,streamId:t,generation:a.generation,direction:e,lines:n,column:r,row:i}))},mouse:(e,n,r,i,a)=>{let o=this.panes.get(t);o?.writable&&this.send({type:`mouse`,streamId:t,generation:o.generation,action:e,button:n,column:r,row:i,modifiers:a})}}}command(e,t,n,r){let i=[...this.panes.entries()].find(([,r])=>r.machineId===e&&r.threadId===t&&r.terminalId===n);if(!i)return;let[a,o]=i;o.writable=!1,o.reason=void 0,this.send({type:`release`,streamId:a,generation:o.generation}),o.mode=r===`release`?`observe`:`control`,++o.generation,o.sequence=new Ax,this.open(a,r===`takeover`)}send(e){return this.binary?.readyState!==WebSocket.OPEN||this.metadata?.readyState!==WebSocket.OPEN?!1:this.binary.bufferedAmount>32768?(this.disconnect(),!1):(this.binary.send(JSON.stringify(e)),!0)}open(e,t=!1){let n=this.panes.get(e);n&&(n.writable=!1,n.accepted=!1,n.baseline=!1,n.pending=0,n.resizing=!1,n.renderer?.close(),n.renderer=new jx(n.terminal,t=>{if(this.panes.get(e)!==n||n.generation!==t.generation||!this.send({type:`ack`,streamId:e,generation:t.generation,seq:t.seq}))return;if(--n.pending,t.full&&(!n.resizing||t.width===n.cols&&t.height===n.rows)){n.baseline=!0,n.resizing=!1;let t=this.openedAt.get(e);t!==void 0&&(Tp()-t,this.openedAt.delete(e))}let r=n.mode===`control`&&n.accepted&&n.baseline;n.writable=r,t.full&&n.onState(r?`Input control is active.`:n.reason??`Read-only`,r)}),n.onState(n.mode===`control`?`Waiting for terminal control.`:n.reason??`Read-only`,!1),this.openedAt.set(e,Tp()),this.send({type:`open`,streamId:e,generation:n.generation,machineId:n.machineId,threadId:n.threadId,terminalId:n.terminalId,mode:n.mode,cols:n.cols,rows:n.rows,takeover:t}))}connect(){if(this.stopped)return;this.instance=dm();let e=++this.epoch,t=(location.protocol===`https:`?`wss://`:`ws://`)+location.host,n=new WebSocket(t+`/api/ws/metadata?instance=`+this.instance),r=new WebSocket(t+`/api/ws/terminal?instance=`+this.instance);this.metadata=n,this.binary=r,r.binaryType=`arraybuffer`;let i=()=>{if(e===this.epoch&&n.readyState===1&&r.readyState===1){this.connectedAt=Date.now(),this.onConnection(!0);for(let[e,t]of this.panes)++t.generation,t.sequence=new Ax,t.attempts=0,this.open(e)}};n.onopen=i,r.onopen=i,n.onmessage=t=>{if(e===this.epoch)try{let e=JSON.parse(t.data);e.type===`projection`&&this.install(e.projection)}catch{this.disconnect()}},r.onmessage=t=>{if(e===this.epoch)try{if(typeof t.data==`string`){let e=JSON.parse(t.data),n=this.panes.get(e.streamId);if(!n||n.generation!==e.generation)return;if(e.type===`stream.opened`&&(n.accepted=!!e.writable&&n.mode===`control`,n.accepted&&(n.baseline=!1,n.resizing=!0,this.send({type:`resize`,streamId:e.streamId,generation:e.generation,cols:n.cols,rows:n.rows})),n.writable=n.accepted&&n.baseline,n.onState(n.writable?`Input control is active.`:n.reason??(n.accepted?`Waiting for the full baseline; input is disabled.`:`Read-only`),n.writable)),e.type===`stream.closed`||e.type===`stream.error`){if(n.writable=!1,n.accepted=!1,n.baseline=!1,n.renderer?.close(),n.onState(e.reason===`controller_conflict`?Nx:String(e.reason).replaceAll(`_`,` `),!1),e.type===`stream.error`&&n.mode===`control`){n.reason=e.reason===`controller_conflict`?Nx:String(e.reason).replaceAll(`_`,` `),n.mode=`observe`,++n.generation,n.sequence=new Ax,this.open(e.streamId);return}e.reason===`stream_resync_required`&&n.attempts++<2&&(++n.generation,n.sequence=new Ax,n.mode=`observe`,this.open(e.streamId))}return}let e=Tp(),n=kx(new Uint8Array(t.data));t.data.byteLength,Tp()-e;let r=this.inputSentAt.get(n.streamId);r!==void 0&&(Tp()-r,this.inputSentAt.delete(n.streamId));let i=this.scrollSentAt.get(n.streamId);i!==void 0&&(Tp()-i,this.scrollSentAt.delete(n.streamId));let a=this.panes.get(n.streamId);if(!a||a.generation!==n.generation)return;a.sequence.accept(n),++a.pending,a.pending,a.renderer?.push(n)}catch{this.disconnect()}};let a=()=>{e===this.epoch&&this.disconnect()};n.onclose=a,n.onerror=a,r.onclose=a,r.onerror=a}disconnect(){this.connectedAt&&Date.now()-this.connectedAt>=3e4&&(this.failures=0),this.connectedAt=0,++this.epoch,this.metadata?.close(),this.binary?.close(),this.metadata=void 0,this.binary=void 0,this.onConnection(!1);for(let e of this.panes.values())e.renderer?.close(),e.writable=!1,e.mode=`observe`,e.onState(`Disconnected; input was not saved.`,!1);clearTimeout(this.reconnect),this.stopped||(this.reconnect=setTimeout(()=>this.connect(),Mx(this.failures++)))}},Fx=(0,l.createContext)(null);function Ix({bootstrap:e,children:t}){let[n]=(0,l.useState)(()=>{let t=Dx(e);return{runtime:t,ui:Ox(),terminals:new Px(e=>{let n=wp(`projectionInstallMs`);t.getState().install(e),n()},e=>t.getState().connection(e))}}),[r]=(0,l.useState)(()=>new R_({defaultOptions:{queries:{staleTime:15e3,retry:!1}}}));return(0,l.useEffect)(()=>(n.terminals.start(),()=>n.terminals.stop()),[n]),(0,Q.jsx)(Fx.Provider,{value:n,children:(0,Q.jsx)(Mg,{client:r,children:t})})}function Lx(){let e=(0,l.useContext)(Fx);if(!e)throw Error(`Runtime provider is missing`);return e}function Rx(e){return wx(Lx().runtime,e)}var zx={Enter:`\r`,Backspace:``,Tab:` `,Escape:`\x1B`,ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`};function Bx(e){let t=e.ctrlKey&&/^[a-z]$/i.test(e.key)?String.fromCharCode(e.key.toUpperCase().charCodeAt(0)-64):zx[e.key],n=e.key===`Enter`&&e.shiftKey;return t&&(e.altKey||n?`\x1B`+t:t)}var Vx=e=>/^[a-z@\[\\\]^_]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)&31):void 0;function Hx({onInput:e,onFocusChange:t}){let[n,r]=(0,l.useState)(``),i=(0,l.useRef)(!1),a=(0,l.useRef)(null);return(0,Q.jsx)(`textarea`,{className:`terminal-input-capture`,value:n,"aria-label":`Terminal input`,rows:1,onFocus:()=>t?.(!0),onBlur:()=>t?.(!1),onCompositionStart:()=>{i.current=!0,a.current=null},onCompositionEnd:t=>{i.current=!1;let n=t.data;a.current=n,n&&e(n),r(``),t.currentTarget.value=``},onChange:t=>{if(i.current){r(t.target.value);return}let n=t.target.value;n&&n!==a.current&&e(n),a.current=null,r(``),t.currentTarget.value=``},onPaste:t=>{t.preventDefault(),a.current=null;let n=t.clipboardData.getData(`text/plain`);n&&e(n,!0)},onKeyDown:t=>{if(t.defaultPrevented||t.nativeEvent.isComposing||i.current||t.metaKey)return;a.current=null;let n=Bx(t);n&&(t.preventDefault(),e(n))}})}var Ux=[{label:`Tab`,key:`Tab`},{label:(0,Q.jsx)(h,{size:16}),key:`ArrowLeft`,name:`Left`},{label:(0,Q.jsx)(m,{size:16}),key:`ArrowDown`,name:`Down`},{label:(0,Q.jsx)(_,{size:16}),key:`ArrowUp`,name:`Up`},{label:(0,Q.jsx)(g,{size:16}),key:`ArrowRight`,name:`Right`}],Wx=e=>e.preventDefault(),Gx=e=>({onPointerDown:t=>{Wx(t),e()},onMouseDown:Wx,onTouchStart:Wx,onClick:t=>{t.detail===0&&e()}}),Kx={idle:`Dictate`,preparing:`Preparing voice input`,recording:`Stop dictation`,transcribing:`Transcribing`},qx=e=>e===`recording`?(0,Q.jsx)(le,{size:14,fill:`currentColor`}):e===`idle`?(0,Q.jsx)(B,{size:16}):(0,Q.jsx)(R,{size:16,className:`is-spinning`});function Jx({voice:e}){return(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":Kx[e.phase],"aria-pressed":e.phase===`recording`,className:`terminal-voice is-${e.phase}`,...Gx(e.toggle),children:qx(e.phase)})}function Yx({ctrl:e,onToggleCtrl:t,onBytes:n,voice:r}){return(0,Q.jsxs)(`div`,{className:`terminal-key-bar`,role:`toolbar`,"aria-label":`Terminal keys`,children:[(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-pressed":e,className:e?`is-armed`:``,...Gx(t),children:`Ctrl`}),Ux.map(({label:e,key:t,name:r})=>(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":r??t,...Gx(()=>{let e=Bx({key:t,ctrlKey:!1,altKey:!1});e&&n(e)}),children:e},t)),r?.available&&(0,Q.jsx)(Jx,{voice:r})]})}var Xx=`(pointer: coarse)`,Zx=120,Qx=350;function $x(){let e=window.visualViewport;if(!e||!matchMedia(Xx).matches)return()=>{};let t=document.documentElement,n=e.height,r=()=>{t.style.setProperty(`--app-height`,`${e.height}px`),t.style.setProperty(`--app-top`,`${e.offsetTop}px`)},i=()=>{t.style.removeProperty(`--app-height`),t.style.removeProperty(`--app-top`)},a=()=>{n=Math.max(n,e.height,window.innerHeight);let a=n-e.height>Zx;a?r():i(),t.toggleAttribute(`data-keyboard-open`,a)};a();let o,s=()=>{clearTimeout(o),o=setTimeout(a,Qx)},c=()=>{n=0,a()};return e.addEventListener(`resize`,a),e.addEventListener(`scroll`,a),window.addEventListener(`orientationchange`,c),window.addEventListener(`focusout`,s),window.addEventListener(`focusin`,s),()=>{clearTimeout(o),window.removeEventListener(`focusout`,s),window.removeEventListener(`focusin`,s),window.removeEventListener(`orientationchange`,c),e.removeEventListener(`resize`,a),e.removeEventListener(`scroll`,a),i(),t.removeAttribute(`data-keyboard-open`)}}function eS(){return typeof matchMedia==`function`&&matchMedia(Xx).matches}var tS=100,nS=20,rS=10,iS=e=>rS*(1+Math.min(2,Math.abs(e)/60));function aS(e,t,n,r){let i=e=>{if(!r()||!e.altKey||e.shiftKey)return;let{element:i,cols:a,rows:o}=t(),s=i?.getBoundingClientRect();if(!s?.width||!s.height)return;let c=Math.floor((e.clientX-s.left)/s.width*a),l=Math.floor((e.clientY-s.top)/s.height*o);if(c<0||l<0||c>=a||l>=o)return;e.preventDefault();let u=e.button===2||e.buttons&2?`right`:e.button===1||e.buttons&4?`middle`:`left`;n()?.mouse(e.type===`pointerdown`?`down`:e.type===`pointerup`?`up`:e.buttons?`drag`:`move`,u,c,l,e.ctrlKey?2:0)},a=0,o=0,s,c=e=>{let{element:n,cols:r,rows:i}=t(),a=n?.getBoundingClientRect();if(a?.width&&a.height)return{column:Math.min(r,Math.max(1,Math.floor((e.clientX-a.left)/a.width*r)+1)),row:Math.min(i,Math.max(1,Math.floor((e.clientY-a.top)/a.height*i)+1))}},l=()=>{let{element:e,rows:n}=t(),r=e?.getBoundingClientRect().height;return r&&n?r/n:nS},u=()=>{o=0;let e=l(),t=Math.trunc(a/e);t&&(a-=t*e,n()?.scroll(t<0?`up`:`down`,Math.min(tS,Math.abs(t)),s?.column,s?.row))},d=e=>{if(!r()||!e.deltaY)return;s=c(e),e.preventDefault();let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*l():e.deltaY;t*a<0&&(a=0),a+=t*iS(t),o||=requestAnimationFrame(u)};for(let t of[`pointerdown`,`pointerup`,`pointermove`])e.addEventListener(t,i);return e.addEventListener(`wheel`,d,{passive:!1}),()=>{for(let t of[`pointerdown`,`pointerup`,`pointermove`])e.removeEventListener(t,i);e.removeEventListener(`wheel`,d),cancelAnimationFrame(o)}}var oS=e=>e.target instanceof Element&&!!e.target.closest(`[role="dialog"]`),sS=`Nothing to attach.`,cS=e=>e===1?`Attaching file…`:`Attaching ${e} files…`,lS=e=>e===1?`File attached`:`${e} files attached`;function uS({machineId:e,active:t,writable:n,send:r,show:i}){let[a,o]=(0,l.useState)(!1),s=(0,l.useRef)(r);s.current=r;let c=(0,l.useCallback)(async t=>{if(!t.length){i(sS,`error`,4e3);return}if(!n.current){i(`Wait until the terminal accepts input, then attach the file again.`,`error`,4e3);return}i(cS(t.length),`info`);try{s.current(await lm(e,t)),i(lS(t.length),`info`,1500)}catch(e){i(e instanceof Error?e.message:`The file could not be attached.`,`error`,5e3)}},[e,i,n]);return(0,l.useEffect)(()=>{if(!t)return;let e=0,n=t=>{nm(t.dataTransfer)&&!oS(t)&&(t.preventDefault(),e+=1,o(!0))},r=e=>{nm(e.dataTransfer)&&!oS(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`))},i=t=>{nm(t.dataTransfer)&&!oS(t)&&(e=Math.max(0,e-1),e||o(!1))},a=t=>{nm(t.dataTransfer)&&!oS(t)&&(t.preventDefault(),e=0,o(!1),c(tm(t.dataTransfer)))};return window.addEventListener(`dragenter`,n),window.addEventListener(`dragover`,r),window.addEventListener(`dragleave`,i),window.addEventListener(`drop`,a),()=>{window.removeEventListener(`dragenter`,n),window.removeEventListener(`dragover`,r),window.removeEventListener(`dragleave`,i),window.removeEventListener(`drop`,a),o(!1)}},[t,c]),{dragging:a,attach:c}}var dS=/https?:\/\/[^\s"'<>`]+/g,fS=/[.,;:!?)\]}]+$/,pS=e=>e.metaKey||e.ctrlKey;function mS(e,t){let n=e.buffer.active,r=t;for(;r>0&&n.getLine(r)?.isWrapped;)r--;let i=``,a=r;for(let t=r;n.getLine(t)&&(t===r||n.getLine(t).isWrapped);t++)i+=n.getLine(t).translateToString(!1,0,e.cols),a=t;return{text:i,offset:(t-r)*e.cols,last:a}}function hS(e,t,n){let{text:r,offset:i}=mS(e,n),a=i+t;for(let e of r.matchAll(dS)){let t=e[0].replace(fS,``);if(a>=e.index&&a<e.index+t.length)return t}}var gS=/^https?:\/\/[^\s"'<>`]+$/,_S=/https?:\/\//,vS=e=>e.trim().split(/\s+/)[0]??``;function yS(e){let t=e.getSelectionPosition();if(!t)return;let n=e.buffer.active,r=t=>n.getLine(t)?.translateToString(!1,0,e.cols)??``,i=r(t.start.y).slice(t.start.x,t.start.y===t.end.y?t.end.x:void 0).search(_S);if(i<0)return;let a=t.start.x+i,o=[];for(let e=t.start.y;e<=t.end.y;e++){let i=e>t.start.y&&n.getLine(e)?.isWrapped?0:a,s=vS(r(e).slice(i,e===t.end.y?t.end.x:void 0));if(!s)break;o.push(s)}let s=o.join(``).replace(fS,``);return gS.test(s)?s:void 0}var bS=e=>{window.open(e,`_blank`,`noopener,noreferrer`)};function xS(e,t){let n=(e.element?.querySelector(`.xterm-screen`))?.getBoundingClientRect();if(!pS(t)||!n?.width||!n.height)return;let r=hS(e,Math.floor((t.clientX-n.left)/n.width*e.cols),Math.floor((t.clientY-n.top)/n.height*e.rows)+e.buffer.active.viewportY);r&&bS(r)}var SS=e=>{e.preventDefault(),e.stopPropagation()};function CS({selected:e,onDone:t,onCopied:n}){return(0,Q.jsxs)(`div`,{className:`terminal-url-actions`,role:`toolbar`,"aria-label":`Selected link`,style:{left:e.x,top:e.y},onMouseDown:SS,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{bS(e.url),t()},children:[(0,Q.jsx)(A,{size:14,strokeWidth:1.8}),`Open link`]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{jv(e.url).then(n),t()},children:[(0,Q.jsx)(O,{size:14,strokeWidth:1.8}),`Copy link`]})]})}function wS(){let[e,t]=(0,l.useState)(null),n=(0,l.useRef)(void 0),r=(0,l.useCallback)((e,r,i)=>{clearTimeout(n.current),t({text:e,tone:r}),i&&(n.current=setTimeout(()=>t(null),i))},[]);return(0,l.useEffect)(()=>()=>clearTimeout(n.current),[]),{notice:e,show:r}}var TS=16e3,ES=`registerProcessor('webr-capture', class extends AudioWorkletProcessor {
|
|
2
|
+
import{a as e,i as t,n,r,t as i}from"./client.CLSsMr2g.js";import{t as a}from"./client.Bbg9OBwT.js";var o=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),s=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),c={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},l=e(r()),u=(0,l.forwardRef)(({color:e=`currentColor`,size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...u},d)=>(0,l.createElement)(`svg`,{ref:d,...c,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:s(`lucide`,i),...u},[...o.map(([e,t])=>(0,l.createElement)(e,t)),...Array.isArray(a)?a:[a]])),d=(e,t)=>{let n=(0,l.forwardRef)(({className:n,...r},i)=>(0,l.createElement)(u,{ref:i,iconNode:t,className:s(`lucide-${o(e)}`,n),...r}));return n.displayName=`${e}`,n},f=d(`ArchiveRestore`,[[`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`}]]),p=d(`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`}]]),m=d(`ArrowDown`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),h=d(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),g=d(`ArrowRight`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),_=d(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),v=d(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),y=d(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),b=d(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),x=d(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),S=d(`CircleAlert`,[[`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`}]]),C=d(`CircleArrowUp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),w=d(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),T=d(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),E=d(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),D=d(`Command`,[[`path`,{d:`M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3`,key:`11bfej`}]]),O=d(`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`}]]),k=d(`Cpu`,[[`rect`,{width:`16`,height:`16`,x:`4`,y:`4`,rx:`2`,key:`14l7u7`}],[`rect`,{width:`6`,height:`6`,x:`9`,y:`9`,rx:`1`,key:`5aljv4`}],[`path`,{d:`M15 2v2`,key:`13l42r`}],[`path`,{d:`M15 20v2`,key:`15mkzm`}],[`path`,{d:`M2 15h2`,key:`1gxd5l`}],[`path`,{d:`M2 9h2`,key:`1bbxkp`}],[`path`,{d:`M20 15h2`,key:`19e6y8`}],[`path`,{d:`M20 9h2`,key:`19tzq7`}],[`path`,{d:`M9 2v2`,key:`165o2o`}],[`path`,{d:`M9 20v2`,key:`i2bqo8`}]]),A=d(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),j=d(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),M=d(`FolderTree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),N=d(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]);d(`Gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]);var P=d(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),F=d(`ImagePlus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),I=d(`ImageUp`,[[`path`,{d:`M10.3 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10l-3.1-3.1a2 2 0 0 0-2.814.014L6 21`,key:`9csbqa`}],[`path`,{d:`m14 19.5 3-3 3 3`,key:`9vmjn0`}],[`path`,{d:`M17 22v-5.5`,key:`1aa6fl`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),L=d(`LayoutList`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}],[`path`,{d:`M14 4h7`,key:`3xa0d5`}],[`path`,{d:`M14 9h7`,key:`1icrd9`}],[`path`,{d:`M14 15h7`,key:`1mj8o2`}],[`path`,{d:`M14 20h7`,key:`11slyb`}]]),R=d(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),z=d(`MessageCircleQuestion`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),B=d(`Mic`,[[`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`,key:`131961`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),V=d(`Monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),ee=d(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),te=d(`PanelLeftClose`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),ne=d(`PanelLeftOpen`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),H=d(`PanelLeft`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),U=d(`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`}]]),re=d(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),ie=d(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),ae=d(`Server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),oe=d(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),se=d(`SquarePen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),ce=d(`SquareTerminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),le=d(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ue=d(`Sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),de=d(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),fe=d(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),pe=d(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),W=typeof document<`u`?l.useLayoutEffect:()=>{};function me(){return typeof window<`u`}function he(e){return _e(e)?(e.nodeName||``).toLowerCase():`#document`}function G(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ge(e){return((_e(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function _e(e){return me()?e instanceof Node||e instanceof G(e).Node:!1}function K(e){return me()?e instanceof Element||e instanceof G(e).Element:!1}function ve(e){return me()?e instanceof HTMLElement||e instanceof G(e).HTMLElement:!1}function ye(e){return!me()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof G(e).ShadowRoot}function be(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=je(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function xe(e){return/^(table|td|th)$/.test(he(e))}function Se(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ce=/transform|translate|scale|rotate|perspective|filter/,we=/paint|layout|strict|content/,Te=e=>!!e&&e!==`none`,Ee;function De(e){let t=K(e)?je(e):e;return Te(t.transform)||Te(t.translate)||Te(t.scale)||Te(t.rotate)||Te(t.perspective)||!ke()&&(Te(t.backdropFilter)||Te(t.filter))||Ce.test(t.willChange||``)||we.test(t.contain||``)}function Oe(e){let t=Ne(e);for(;ve(t)&&!Ae(t);){if(De(t))return t;if(Se(t))return null;t=Ne(t)}return null}function ke(){return Ee??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Ee}function Ae(e){return/^(html|body|#document)$/.test(he(e))}function je(e){return G(e).getComputedStyle(e)}function Me(e){return K(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ne(e){if(he(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ye(e)&&e.host||ge(e);return ye(t)?t.host:t}function Pe(e){let t=Ne(e);return Ae(t)?(e.ownerDocument||e).body:ve(t)&&be(t)?t:Pe(t)}function Fe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Pe(e),i=r===e.ownerDocument?.body,a=G(r);if(i){let e=Ie(a);return t.concat(a,a.visualViewport||[],be(r)?r:[],e&&n?Fe(e):[])}return t.concat(r,Fe(r,[],n))}function Ie(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function q(e,t,n,r){return e.addEventListener(t,n,r),()=>{e.removeEventListener(t,n,r)}}function Le(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:Re,platform:ze,maxTouchPoints:Be}=Le(),Ve=Re.toLowerCase(),He=ze.toLowerCase(),Ue=/^i(os$|p)/.test(He)||He===`macintel`&&Be>1,We=`android`,Ge=He===We||Ve.includes(We),Ke=!Ue&&He.startsWith(`mac`);He.startsWith(`win`),!Ge&&/^(linux|chrome os)/.test(He);var qe=Ke||Ue,Je=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`),Ye=!Je&&Ve.includes(`firefox`);!Je&&Ve.includes(`chrom`);var Xe=qe,Ze=/jsdom|happydom/.test(Ve);function J(e){return e?.ownerDocument||document}var Qe={};function $e(e,t){let n=l.useRef(Qe);return n.current===Qe&&(n.current=e(t)),n}function et(){}var tt=Object.freeze([]),nt=Object.freeze({});function rt(e){l.useEffect(e,tt)}var it=0,at=class e{static create(){return new e}currentId=it;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=it,t()},e)}isStarted(){return this.currentId!==it}clear=()=>{this.currentId!==it&&(clearTimeout(this.currentId),this.currentId=it)};disposeEffect=()=>this.clear};function ot(){let e=$e(at.create).current;return rt(e.disposeEffect),e}var st=null;globalThis.requestAnimationFrame;var ct=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||this.callbacks[t]!==null&&(this.callbacks[t]=null,--this.callbacksCount)}},lt=class e{static create(){return new e}static request(e){return ct.request(e)}static cancel(e){return ct.cancel(e)}currentId=st;request(e){this.cancel(),this.currentId=ct.request(()=>{this.currentId=st,e()})}cancel=()=>{this.currentId!==st&&(ct.cancel(this.currentId),this.currentId=st)};disposeEffect=()=>this.cancel};function ut(){let e=$e(lt.create).current;return rt(e.disposeEffect),e}var dt={},Y={},ft=``;function pt(e,t){return be(e)?e:t}function mt(e,t,n){return/hidden|clip/.test(e.getComputedStyle(pt(t,n)).overflowY)}function ht(e){if(typeof document>`u`)return!1;let t=J(e);return G(t).innerWidth-t.documentElement.clientWidth>0}function gt(e){if(!(typeof CSS<`u`&&CSS.supports&&CSS.supports(`scrollbar-gutter`,`stable`))||typeof document>`u`)return!1;let t=J(e),n=t.documentElement,r=t.body,i=pt(n,r),a=i.style.overflowY,o=n.style.scrollbarGutter;n.style.scrollbarGutter=`stable`,i.style.overflowY=`scroll`;let s=i.offsetWidth;i.style.overflowY=`hidden`;let c=i.offsetWidth;return i.style.overflowY=a,n.style.scrollbarGutter=o,s===c}function _t(e){let t=J(e),n=t.documentElement,r=t.body,i=pt(n,r),a={overflowY:i.style.overflowY,overflowX:i.style.overflowX};return Object.assign(i.style,{overflowY:`hidden`,overflowX:`hidden`}),()=>{Object.assign(i.style,a)}}function vt(e){let t=J(e),n=t.documentElement,r=t.body,i=G(n),a=0,o=0,s=!1,c=lt.create();if(Je&&(i.visualViewport?.scale??1)!==1)return()=>{};function l(){let t=i.getComputedStyle(n),c=i.getComputedStyle(r),l=(t.scrollbarGutter||``).includes(`both-edges`)?`stable both-edges`:`stable`;a=n.scrollTop,o=n.scrollLeft,dt={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},ft=n.style.scrollBehavior,Y={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};let u=n.scrollHeight>n.clientHeight,d=n.scrollWidth>n.clientWidth,f=t.overflowY===`scroll`||c.overflowY===`scroll`,p=t.overflowX===`scroll`||c.overflowX===`scroll`,m=Math.max(0,i.innerWidth-r.clientWidth),h=Math.max(0,i.innerHeight-r.clientHeight),g=parseFloat(c.marginTop)+parseFloat(c.marginBottom),_=parseFloat(c.marginLeft)+parseFloat(c.marginRight),v=pt(n,r);if(s=gt(e),s){n.style.scrollbarGutter=l,v.style.overflowY=`hidden`,v.style.overflowX=`hidden`;return}Object.assign(n.style,{scrollbarGutter:l,overflowY:`hidden`,overflowX:`hidden`}),(u||f)&&(n.style.overflowY=`scroll`),(d||p)&&(n.style.overflowX=`scroll`),Object.assign(r.style,{position:`relative`,height:g||h?`calc(100dvh - ${g+h}px)`:`100dvh`,width:_||m?`calc(100vw - ${_+m}px)`:`100vw`,boxSizing:`border-box`,overflowY:`hidden`,overflowX:`hidden`,scrollBehavior:`unset`}),r.scrollTop=a,r.scrollLeft=o,n.setAttribute(`data-base-ui-scroll-locked`,``),n.style.scrollBehavior=`unset`}function u(){Object.assign(n.style,dt),Object.assign(r.style,Y),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=ft)}function d(){u(),c.request(l)}l();let f=q(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var yt=new class{lockCount=0;restore=null;timeoutLock=at.create();timeoutUnlock=at.create();acquire(e){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(e)),this.release}release=()=>{--this.lockCount,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(e){if(this.lockCount===0||this.restore!==null)return;let t=J(e),n=t.documentElement,r=t.body,i=G(n);if(mt(i,n,r)){let t=new i.MutationObserver(()=>{mt(i,n,r)||(t.disconnect(),this.restore=null,this.lock(e))}),a={attributes:!0};t.observe(n,a),t.observe(r,a),this.restore=()=>t.disconnect();return}let a=Ue||!ht(e);this.restore=a?_t(e):vt(e)}};function bt(e=!0,t=null){W(()=>{if(e)return yt.acquire(t)},[e,t])}function xt(e){e.preventDefault(),e.stopPropagation()}function St(e){return`nativeEvent`in e}function Ct(e){return e.pointerType===``&&e.isTrusted?!0:Ge&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function wt(e){return Ze?!1:!Ge&&e.width===0&&e.height===0||Ge&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`||e.width<1&&e.height<1&&e.pressure===0&&e.detail===0&&e.pointerType===`touch`}function Tt(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function Et(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function Dt(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function X(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&ye(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function Ot(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var kt=`data-base-ui-focusable`,At=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,jt=`ArrowLeft`,Mt=`ArrowRight`,Nt=`ArrowUp`,Pt=`ArrowDown`,Ft=`data-starting-style`,It=`data-ending-style`,Lt={[Ft]:``},Rt={[It]:``},zt={transitionStatus(e){return e===`starting`?Lt:e===`ending`?Rt:null}},Bt=`data-open`,Vt=`data-closed`,Ht=`data-anchor-hidden`,Ut=`data-popup-open`,Wt=`data-pressed`,Gt={[Ut]:``},Kt={[Ut]:``,[Wt]:``},qt={[Bt]:``},Jt={[Vt]:``},Yt={[Ht]:``},Xt={open(e){return e?Gt:null}},Zt={open(e){return e?Kt:null}},Qt={open(e){return e?qt:Jt},anchorHidden(e){return e?Yt:null}},$t={...Qt,...zt},en=`data-trigger-disabled`;function tn(e,t){if(!K(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(en);for(let[,e]of t.entries())if(X(e,n))return!e.hasAttribute(en);return!1}function nn(e,t){if(t==null)return!1;if(`composedPath`in e)return e.composedPath().includes(t);let n=e;return n.target!=null&&t.contains(n.target)}function rn(e){return e.matches(`html,body`)}function an(e){return ve(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function on(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${At}`)!=null}function sn(e){return e?e.getAttribute(`role`)===`combobox`&&an(e):!1}function cn(e){if(!e||Ze)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function ln(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function un(e,t){return t!=null&&!Tt(t)?0:typeof e==`function`?e():e}function dn(e,t,n){let r=un(e,n);return typeof r==`number`?r:r?.[t]}function fn(e){return typeof e==`function`?e():e}function pn(e,t){return t||e===`click`||e===`mousedown`}function mn(e){return e?.includes(`mouse`)&&e!==`mousedown`}var hn=`none`,gn=`trigger-press`,_n=`trigger-hover`,vn=`trigger-focus`,yn=`outside-press`,bn=`item-press`,xn=`close-press`,Sn=`input-change`,Cn=`input-clear`,wn=`input-press`,Tn=`focus-out`,En=`escape-key`,Dn=`list-navigation`,On=`keyboard`,kn=`pointer`,An=`cancel-open`,jn=`sibling-open`,Mn=`disabled`,Nn=`imperative-action`;function Z(e,t,n,r){let i=!1,a=!1,o=r??nt;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function Pn(e,t,n){let r=n??nt;return{reason:e,event:t??new Event(`base-ui`),...r}}var Fn=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),Q=t(((e,t)=>{t.exports=Fn()}))(),In=l.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new at,currentIdRef:{current:null},currentContextRef:{current:null}});function Ln(e,t){e.current=t.current}function Rn(e,t={open:!1}){let{open:n}=t,r=`rootStore`in e?e.rootStore:e,i=r.useState(`floatingId`),{currentIdRef:a,delayRef:o,timeoutMs:s,initialDelayRef:c,currentContextRef:u,hasProvider:d,timeout:f}=l.useContext(In),[p,m]=l.useState(!1),h=l.useRef(n);return W(()=>{h.current=n},[n]),W(()=>{function e(){u.current?.setIsInstantPhase(!1),a.current=null,u.current=null,o.current=c.current,f.clear()}if(a.current&&!n&&a.current===i){if(m(!1),s){let t=i;return f.start(s,()=>{r.select(`open`)||a.current&&a.current!==t||e()}),()=>{(h.current||a.current!==t)&&f.clear()}}e()}},[n,i,a,o,s,c,u,f,r]),W(()=>{if(!n)return;let e=u.current,t=a.current;f.clear(),u.current={onOpenChange:r.setOpen,setIsInstantPhase:m},a.current=i,o.current={open:0,close:dn(c.current,`close`)},t!==null&&t!==i?(m(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,Z(hn))):(m(!1),e?.setIsInstantPhase(!1))},[n,i,r,a,o,c,u,f]),W(()=>()=>{if(a.current===i){if(u.current=null,!h.current)return;a.current=null,Ln(o,c),f.clear()}},[u,a,o,i,c,f]),l.useMemo(()=>({activeIdRef:a,hasProvider:d,delayRef:o,isInstantPhase:p}),[a,d,o,p])}function zn(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function Bn(e,t,n,r){let i=$e(Hn).current;return Un(i,e,t,n,r)&&Gn(i,[e,t,n,r]),i.callback}function Vn(e){let t=$e(Hn).current;return Wn(t,e)&&Gn(t,e),t.callback}function Hn(){return{callback:null,cleanup:null,refs:[]}}function Un(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Wn(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Gn(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null}}}}}}function Kn(e){let t=$e(qn,e).current;return t.next=e,W(t.effect),t}function qn(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Jn={...l},Yn=Jn.useInsertionEffect,Xn=Yn&&Yn!==Jn.useLayoutEffect?Yn:e=>e();function $(e){let t=$e(Zn).current;return t.next=e,Xn(t.effect),t.trampoline}function Zn(){let e={next:void 0,callback:Qn,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Qn(){}var $n={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},er={...$n,position:`fixed`,top:0,left:0},tr={...$n,position:`absolute`},nr=l.forwardRef(function(e,t){let[n,r]=l.useState();W(()=>{Xe&&Je&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,Q.jsx)(`span`,{...e,ref:t,style:er,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),rr=Math.min,ir=Math.max,ar=Math.round,or=Math.floor,sr=e=>({x:e,y:e}),cr={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function lr(e,t,n){return ir(e,rr(t,n))}function ur(e,t){return typeof e==`function`?e(t):e}function dr(e){return e.split(`-`)[0]}function fr(e){return e.split(`-`)[1]}function pr(e){return e===`x`?`y`:`x`}function mr(e){return e===`y`?`height`:`width`}function hr(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function gr(e){return pr(hr(e))}function _r(e,t,n){n===void 0&&(n=!1);let r=fr(e),i=gr(e),a=mr(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=Er(o)),[o,Er(o)]}function vr(e){let t=Er(e);return[yr(e),t,yr(t)]}function yr(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var br=[`left`,`right`],xr=[`right`,`left`],Sr=[`top`,`bottom`],Cr=[`bottom`,`top`];function wr(e,t,n){switch(e){case`top`:case`bottom`:return n?t?xr:br:t?br:xr;case`left`:case`right`:return t?Sr:Cr;default:return[]}}function Tr(e,t,n,r){let i=fr(e),a=wr(dr(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(yr)))),a}function Er(e){let t=dr(e);return cr[t]+e.slice(t.length)}function Dr(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function Or(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:Dr(e)}function kr(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 Ar(e,t,n){return Math.floor(e/t)!==n}function jr(e,t){return t<0||t>=e.length}function Mr(e,t){return Pr(e.current,{disabledIndices:t})}function Nr(e,t){return Pr(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Pr(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:r,amount:i=1}={}){let a=t;do a+=n?-i:i;while(a>=0&&a<=e.length-1&&Ir(e,a,r));return a}function Fr(e,{event:t,orientation:n,loopFocus:r,onLoop:i,rtl:a,cols:o,disabledIndices:s,minIndex:c,maxIndex:l,prevIndex:u,stopEvent:d=!1}){let f=u,p;if(t.key===`ArrowUp`?p=`up`:t.key===`ArrowDown`&&(p=`down`),p){let n=[],a=[],m=!1,h=0;{let t=null,r=-1;e.forEach((e,i)=>{if(e==null)return;h+=1;let o=e.closest(`[role="row"]`);o&&(m=!0),(o!==t||r===-1)&&(t=o,r+=1,n[r]=[]),n[r].push(i),a[i]=r})}let g=!1,_=0;if(m)for(let e of n){let t=e.length;t>_&&(_=t),t!==o&&(g=!0)}let v=g&&h<e.length,y=_||o,b=o=>{if(!g||u===-1)return;let c=a[u];if(c==null)return;let l=n[c].indexOf(u),d=o===`up`?-1:1;for(let o=c+d,f=0;f<n.length;f+=1,o+=d){if(o<0||o>=n.length){if(!r||v)return;if(o=o<0?n.length-1:0,i){let e=Math.min(l,n[o].length-1),r=i(t,u,n[o][e]??n[o][0]);o=a[r]??o}}let c=n[o];for(let t=Math.min(l,c.length-1);t>=0;--t){let n=c[t];if(!Ir(e,n,s))return n}}},x=t=>{if(!v||u===-1)return;let n=u%y,i=t===`up`?-y:y,a=l-l%y,o=or(l/y)+1;for(let t=u-n+i,c=0;c<o;c+=1,t+=i){if(t<0||t>l){if(!r)return;t=t<0?a:0}let i=Math.min(t+y-1,l);for(let r=Math.min(t+n,i);r>=t;--r)if(!Ir(e,r,s))return r}};d&&xt(t);let S=b(p)??x(p);if(S!==void 0)f=S;else if(u===-1)f=p===`up`?l:c;else if(f=Pr(e,{startingIndex:u,amount:y,decrement:p===`up`,disabledIndices:s}),r){if(p===`up`&&(u-y<c||f<0)){let e=u%y,n=l%y,r=l-(n-e);f=n===e?l:n>e?r:r-y,i&&(f=i(t,u,f))}p===`down`&&u+y>l&&(f=Pr(e,{startingIndex:u%y-y,amount:y,disabledIndices:s}),i&&(f=i(t,u,f)))}jr(e,f)&&(f=u)}if(n===`both`){let n=or(u/o);t.key===(a?`ArrowLeft`:`ArrowRight`)&&(d&&xt(t),u%o===o-1?r&&(f=Pr(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):(f=Pr(e,{startingIndex:u,disabledIndices:s}),r&&Ar(f,o,n)&&(f=Pr(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f)))),Ar(f,o,n)&&(f=u)),t.key===(a?`ArrowRight`:`ArrowLeft`)&&(d&&xt(t),u%o===0?r&&(f=Pr(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f))):(f=Pr(e,{startingIndex:u,decrement:!0,disabledIndices:s}),r&&Ar(f,o,n)&&(f=Pr(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f)))),Ar(f,o,n)&&(f=u));let c=or(l/o)===n;jr(e,f)&&(r&&c?(f=t.key===(a?`ArrowRight`:`ArrowLeft`)?l:Pr(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):f=u)}return f}function Ir(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!Rr(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function Lr(e){return e.visibility===`hidden`||e.visibility===`collapse`}function Rr(e,t=e?je(e):null){return!e||!e.isConnected||!t||Lr(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var zr=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function Br(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return ye(n)?n.host:null}function Vr(e){for(let t of Array.from(e.children))if(he(t)===`summary`)return t;return null}function Hr(e,t){let n=Vr(t);return!!n&&(e===n||X(n,e))}function Ur(e){let t=e?he(e):``;return e!=null&&e.matches(zr)&&(t!==`summary`||e.parentElement!=null&&he(e.parentElement)===`details`&&Vr(e.parentElement)===e)&&(t!==`details`||Vr(e)==null)&&(t!==`input`||e.type!==`hidden`)}function Wr(e){if(!Ur(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=Br(t)){let n=t!==e,r=he(t)===`slot`;if(t.hasAttribute(`inert`)||n&&he(t)===`details`&&!t.open&&!Hr(e,t)||t.hasAttribute(`hidden`)||!r&&!Gr(t,n))return!1}return!0}function Gr(e,t){let n=je(e);return t?n.display!==`none`:Rr(e,n)}function Kr(e){let t=e.tabIndex;if(t<0){let t=he(e);if(t===`details`||t===`audio`||t===`video`||ve(e)&&e.isContentEditable)return 0}return t}function qr(e){if(he(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function Jr(e,t){let n=qr(e);if(!n)return!0;let r=t.find(e=>{let t=qr(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=qr(e);return t?.name===n.name&&t.form===n.form})===n}function Yr(e){if(ve(e)&&he(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return ve(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Xr(e,t){Yr(e).forEach(e=>{Ur(e)&&t.push(e),Xr(e,t)})}function Zr(e,t,n){Yr(e).forEach(e=>{ve(e)&&e.matches(t)&&n.push(e),Zr(e,t,n)})}function Qr(e){return Wr(e)&&Kr(e)>=0}function $r(e){let t=[];return Xr(e,t),t.filter(Wr)}function ei(e){let t=$r(e);return t.filter(e=>Kr(e)>=0&&Jr(e,t))}function ti(e,t){let n=ei(e),r=n.length;if(r===0)return;let i=Dt(J(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function ni(e){return ti(J(e).body,1)||e}function ri(e){return ti(J(e).body,-1)||e}function ii(e,t){if(!e)return null;let n=ei(J(e).body),r=n.length;if(r===0)return null;let i=n.indexOf(e);return i===-1?null:n[(i+t+r)%r]}function ai(e){return ii(e,1)}function oi(e){return ii(e,-1)}function si(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!X(n,r)}function ci(e){ei(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function li(e){let t=[];Zr(e,`[data-tabindex]`,t),t.forEach(e=>{let t=e.dataset.tabindex;delete e.dataset.tabindex,t?e.setAttribute(`tabindex`,t):e.removeAttribute(`tabindex`)})}function ui(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...ui(e,t.id,n)])}function di(e,t){let n=[],r=e.find(e=>e.id===t)?.parentId;for(;r;){let t=e.find(e=>e.id===r);r=t?.parentId,t&&(n=n.concat(t))}return n}function fi(e){return`data-base-ui-${e}`}var pi=0;function mi(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(pi);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),et;let o=requestAnimationFrame(a);return pi=o,()=>{pi===o&&(cancelAnimationFrame(o),pi=0)}}var hi={inert:new WeakMap,"aria-hidden":new WeakMap},gi=`data-base-ui-inert`,_i={inert:new WeakSet,"aria-hidden":new WeakSet},vi=new WeakMap,yi=0;function bi(e){return _i[e]}function xi(e){return e?ye(e)?e.host:xi(e.parentNode):null}var Si=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=xi(t);return e.contains(n)?n:null}).filter(e=>e!=null),Ci=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},wi=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{he(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function Ti(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=Si(t,e),l=i?wi(t,Ci(c),new Set(c)):[],u=[],d=[];if(a){let e=hi[a],n=bi(a);s=n,o=e;let r=Si(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);wi(t,Ci(i),new Set(i)).forEach(t=>{let r=t.getAttribute(a),i=r!==null&&r!==`false`,o=(e.get(t)||0)+1;e.set(t,o),u.push(t),o===1&&i&&n.add(t),i||t.setAttribute(a,a===`inert`?``:`true`)})}return i&&l.forEach(e=>{let t=(vi.get(e)||0)+1;vi.set(e,t),d.push(e),t===1&&e.setAttribute(gi,``)}),yi+=1,()=>{o&&u.forEach(e=>{let t=(o.get(e)||0)-1;o.set(e,t),t||(!s?.has(e)&&a&&e.removeAttribute(a),s?.delete(e))}),i&&d.forEach(e=>{let t=(vi.get(e)||0)-1;vi.set(e,t),t||e.removeAttribute(gi)}),--yi,yi||(hi.inert=new WeakMap,hi[`aria-hidden`]=new WeakMap,_i.inert=new WeakSet,_i[`aria-hidden`]=new WeakSet,vi=new WeakMap)}}function Ei(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=J(e[0]).body;return Ti(e,a,n,r,{mark:i})}var Di=0;function Oi(e,t=`mui`){let[n,r]=l.useState(e),i=e||n;return l.useEffect(()=>{n??(Di+=1,r(`${t}-${Di}`))},[n,t]),i}var ki=Jn.useId;function Ai(e,t){if(ki!==void 0){let n=ki();return e??(t?`${t}-${n}`:n)}return Oi(e,t)}function ji(e,t){return function(n,...r){let i=new URL(e);return i.searchParams.set(`code`,n.toString()),r.forEach(e=>i.searchParams.append(`args[]`,e)),`${t} error #${n}; visit ${i} for the full message.`}}var Mi=ji(`https://base-ui.com/production-error`,`Base UI`),Ni=19;function Pi(e){return Ni>=e}function Fi(e){if(!l.isValidElement(e))return null;let t=e,n=t.props;return(Pi(19)?n?.ref:t.ref)??null}function Ii(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function Li(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Ri(e,t){return typeof e==`function`?e(t):e}function zi(e,t){return typeof e==`function`?e(t):e}var Bi={};function Vi(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Ui(t);let a=Ui(e);return t&&(a=Wi(a,t)),n&&(a=Wi(a,n)),r&&(a=Wi(a,r)),i&&(a=Wi(a,i)),a}function Hi(e){if(e.length===0)return Bi;if(e.length===1)return Ui(e[0]);let t=Ui(e[0]);for(let n=1;n<e.length;n+=1)t=Wi(t,e[n]);return t}function Ui(e){return Ji(e)?{...Yi(e,Bi)}:Gi(e)}function Wi(e,t){return Ji(t)?Yi(t,e):Ki(e,t)}function Gi(e){let t={...e};for(let e in t){let n=t[e];qi(e,n)&&(t[e]=Zi(n))}return t}function Ki(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Ii(e.style,r);break;case`className`:e[n]=$i(e.className,r);break;default:e[n]=qi(n,r)?Xi(e[n],r):r}}return e}function qi(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Ji(e){return typeof e==`function`}function Yi(e,t){return Ji(e)?e(t):e??Bi}function Xi(e,t){return t?e?(...n)=>{let r=n[0];if(ea(r)){let i=r;Qi(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:Zi(t):e}function Zi(e){return e&&((...t)=>{let n=t[0];return ea(n)&&Qi(n),e(...t)})}function Qi(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function $i(e,t){return t?e?t+` `+e:t:e}function ea(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function ta(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=aa(r));let i=na(t,n,r);if(n.enabled===!1)return null;let a=n.state??nt;return oa(e,r,i,a)}function na(e,t,n){let{className:r,style:i}=e,{state:a=nt,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Ri(r,a):void 0,d=l?zi(i,a):void 0,f=l?Li(a,c):nt,p=l&&s?ra(s):void 0,m=l?Ii(f,p)??{}:nt;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?Vn([m.ref,Fi(n),...o]):Bn(m.ref,Fi(n),o):Bn(null,null)),l?(u!==void 0&&(m.className=$i(m.className,u)),d!==void 0&&(m.style=Ii(m.style,d)),m):nt}function ra(e){return Array.isArray(e)?Hi(e):Vi(void 0,e)}var ia=Symbol.for(`react.lazy`);function aa(e){if(e?.$$typeof!==ia)return e;let t=l.Children.toArray(e)[0];return l.isValidElement(t)?t:e}function oa(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Vi(n,t.props);return e.ref=n.ref,l.cloneElement(t,e)}if(e&&typeof e==`string`)return sa(e,n);throw Error(Mi(8))}function sa(e,t){return e===`button`?(0,l.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,l.createElement)(`img`,{alt:``,...t,key:t.key}):l.createElement(e,t)}var ca={style:{transition:`none`}},la={fallbackAxisSide:`none`},ua={fallbackAxisSide:`end`},da={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},fa=e(n(),1),pa=l.createContext(null),ma=()=>l.useContext(pa),ha=fi(`portal`);function ga(e={}){let{ref:t,container:n,componentProps:r=nt,elementProps:i}=e,a=Ai(),o=ma()?.portalNode,[s,c]=l.useState(null),[u,d]=l.useState(null),f=$(e=>{e!==null&&d(e)}),p=l.useRef(null);W(()=>{if(n===null){p.current&&(p.current=null,d(null),c(null));return}let e=(n&&(_e(n)?n:n.current))??o??document.body;if(e==null){p.current&&(p.current=null,d(null),c(null));return}p.current!==e&&(p.current=e,d(null),c(e))},[n,o]);let m=ta(`div`,r,{ref:[t,f],props:[{id:a,[ha]:``},i]}),h=s&&m?fa.createPortal(m,s):null;return{node:u,nodeId:l.isValidElement(m)?m.props.id:void 0,subtree:h}}var _a=l.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,container:o,portalOwnerRole:s,...c}=e,{node:u,nodeId:d,subtree:f}=ga({container:o,ref:t,componentProps:e,elementProps:c}),p=l.useRef(null),m=l.useRef(null),h=l.useRef(null),g=l.useRef(null),[_,v]=l.useState(null),y=l.useRef(!1),b=_?.modal,x=_?.open,S=!!_&&!_.modal&&_.open&&!!u;l.useEffect(()=>{if(!u||b)return;function e(e){u&&e.relatedTarget&&si(e)&&(e.type===`focusin`?y.current&&=(li(u),!1):(ci(u),y.current=!0))}return zn(q(u,`focusin`,e,!0),q(u,`focusout`,e,!0))},[u,b]),W(()=>{u&&x===!0&&y.current&&(li(u),y.current=!1)},[x,u]);let C=l.useMemo(()=>({beforeOutsideRef:p,afterOutsideRef:m,beforeInsideRef:h,afterInsideRef:g,portalNode:u,setFocusManagerState:v}),[u]);return(0,Q.jsxs)(l.Fragment,{children:[f,(0,Q.jsxs)(pa.Provider,{value:C,children:[S&&u&&(0,Q.jsx)(nr,{"data-type":`outside`,ref:p,onFocus:e=>{si(e,u)?h.current?.focus():ri(_?_.domReference:null)?.focus()}}),S&&u&&(0,Q.jsx)(`span`,{role:s,"aria-owns":d,style:da}),u&&fa.createPortal(a,u),S&&u&&(0,Q.jsx)(nr,{"data-type":`outside`,ref:m,onFocus:e=>{si(e,u)?g.current?.focus():(ni(_?_.domReference:null)?.focus(),_?.closeOnFocusOut&&_?.onOpenChange(!1,Z(`focus-out`,e.nativeEvent)))}})]})]})});function va(){let e=new Map;return{emit(t,n){e.get(t)?.forEach(e=>e(n))},on(t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)},off(t,n){e.get(t)?.delete(n)}}}var ya=class{nodesRef={current:[]};events=va();addNode(e){this.nodesRef.current.push(e)}removeNode(e){let t=this.nodesRef.current.findIndex(t=>t===e);t!==-1&&this.nodesRef.current.splice(t,1)}},ba=l.createContext(null),xa=l.createContext(null),Sa=()=>l.useContext(ba)?.id||null,Ca=e=>{let t=l.useContext(xa);return e??t};function wa(e){let t=Ai(),n=Ca(e),r=Sa();return W(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function Ta(e){let{children:t,id:n}=e,r=Sa();return(0,Q.jsx)(ba.Provider,{value:l.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function Ea(e){let{children:t,externalTree:n}=e,r=$e(()=>n??new ya).current;return(0,Q.jsx)(xa.Provider,{value:r,children:t})}function Da(e){return e==null?e:`current`in e?e.current:e}function Oa(e,t){let n=G(Ot(e));return e instanceof n.KeyboardEvent?`keyboard`:e instanceof n.FocusEvent?t||`keyboard`:`pointerType`in e?e.pointerType||`keyboard`:`touches`in e?`touch`:e instanceof n.MouseEvent?t||(e.detail===0?`keyboard`:`mouse`):``}var ka=20,Aa=[];function ja(){Aa=Aa.filter(e=>e.deref()?.isConnected)}function Ma(e){ja(),e&&he(e)!==`body`&&(Aa.push(new WeakRef(e)),Aa.length>ka&&(Aa=Aa.slice(-20)))}function Na(){return ja(),Aa[Aa.length-1]?.deref()}function Pa(e){return e?Qr(e)?e:ei(e)[0]||e:null}function Fa(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=$r(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Qr(e)||e.hasAttribute(`data-tabindex`)&&!t.startsWith(`-`)}),n=e.getAttribute(`tabindex`);t.length===0?n!==`0`&&(e.setAttribute(`tabindex`,`0`),e.setAttribute(`data-tabindex`,`0`)):(n!==`-1`||e.hasAttribute(`data-tabindex`)&&e.getAttribute(`data-tabindex`)!==`-1`)&&(e.setAttribute(`tabindex`,`-1`),e.setAttribute(`data-tabindex`,`-1`))}function Ia(e){let{context:t,children:n,disabled:r=!1,initialFocus:i=!0,returnFocus:a=!0,restoreFocus:o=!1,modal:s=!0,closeOnFocusOut:c=!0,openInteractionType:u=``,nextFocusableElement:d,previousFocusableElement:f,beforeContentFocusGuardRef:p,externalTree:m,getInsideElements:h}=e,g=`rootStore`in t?t.rootStore:t,_=g.useState(`open`),v=g.useState(`domReferenceElement`),y=g.useState(`floatingElement`),{events:b,dataRef:x}=g.context,S=$(()=>x.current.floatingContext?.nodeId),C=i===!1,w=sn(v)&&C,T=Kn(i),E=Kn(a),D=Kn(u),O=Kn(_),k=Ca(m),A=ma(),j=l.useRef(!1),M=l.useRef(!1),N=l.useRef(!1),P=l.useRef(null),F=l.useRef(``),I=l.useRef(``),L=l.useRef(null),R=l.useRef(null),z=Bn(L,p,A?.beforeInsideRef),B=Bn(R,A?.afterInsideRef),V=ot(),ee=ot(),te=ut(),ne=A!=null,H=ln(y),U=$((e=H)=>e?ei(e):[]),re=$(()=>h?.().filter(e=>e!=null)??[]);l.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&X(H,Dt(J(H)))&&U().length===0&&!w&&xt(e)}return q(J(H),`keydown`,e)},[r,H,s,w,U]),l.useEffect(()=>{if(r||!_)return;let e=J(H);function t(){N.current=!1}function n(e){let t=Ot(e),n=re(),r=X(y,t)||X(v,t)||X(A?.portalNode,t)||n.some(e=>e===t||X(e,t));N.current=!r,I.current=e.pointerType||`keyboard`,t?.closest(`[data-base-ui-click-trigger]`)&&(M.current=!0,ee.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return zn(q(e,`pointerdown`,n,!0),q(e,`pointerup`,t,!0),q(e,`pointercancel`,t,!0),q(e,`keydown`,i,!0),t)},[r,y,v,H,_,A,ee,re]),l.useEffect(()=>{if(r||!c)return;let e=J(H);function t(){M.current=!0,ee.start(0,()=>{M.current=!1})}function n(e){let t=Ot(e);Qr(t)&&(P.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=Ot(t);s&&n==null&&i!=null&&X(y,i)&&Ma(i),queueMicrotask(()=>{let a=S(),c=g.context.triggerElements,l=re(),u=n?.hasAttribute(fi(`focus-guard`))&&[L.current,R.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,Da(f),Da(d)].includes(n),p=!(X(v,n)||X(y,n)||X(n,y)||X(A?.portalNode,n)||l.some(e=>e===n||X(e,n))||c.hasMatchingElement(e=>X(e,n))||u||k&&(ui(k.nodesRef.current,a).find(e=>X(e.context?.elements.floating,n)||X(e.context?.elements.domReference,n))||di(k.nodesRef.current,a).find(e=>[e.context?.elements.floating,ln(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===v&&H&&Fa(H),o&&r!==v&&!Rr(i)&&Dt(e)===e.body){if(ve(H)&&(H.focus(),o===`popup`)){te.request(()=>{H.focus()});return}let e=U(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||H;ve(n)&&n.focus()}if(x.current.insideReactTree){x.current.insideReactTree=!1;return}(w||!s)&&n&&p&&!M.current&&(w||n!==Na())&&(j.current=!0,g.setOpen(!1,Z(Tn,t)))})}function a(){N.current||(x.current.insideReactTree=!0,V.start(0,()=>{x.current.insideReactTree=!1}))}let l=ve(v)?v:null;if(y||l)return zn(l&&q(l,`focusout`,i),l&&q(l,`pointerdown`,t),y&&q(y,`focusin`,n),y&&q(y,`focusout`,i),y&&A&&q(y,`focusout`,a,!0))},[r,v,y,H,s,k,A,g,c,o,U,w,S,x,V,ee,te,d,f,re]),l.useEffect(()=>{if(r||!y||!_)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${fi(`portal`)}]`)||[]),t=(k?di(k.nodesRef.current,S()):[]).find(e=>sn(e.context?.elements.domReference||null))?.context?.elements.domReference,n=Ei([y,...e,L.current,R.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...re(),t,Da(f),Da(d),w?v:null].filter(e=>e!=null),{ariaHidden:s||w,mark:!1}),i=Ei([y,...e].filter(e=>e!=null));return()=>{i(),n()}},[_,r,v,y,s,A,w,k,S,d,f,re]),W(()=>{if(!_||r||!ve(H))return;F.current=``,I.current=``;let e=J(H),t=Dt(e);queueMicrotask(()=>{let n=T.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||X(H,t))return;let i=null,a=()=>(i??=U(H),i[0]||H),o;o=r===!0||r===null?a():Da(r),o||=a();let s=X(H,Dt(e));mi(o,{preventScroll:o===H,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=Dt(e);return!(t!==o&&X(H,t))}})})},[r,_,H,U,T,D,O]),W(()=>{if(r||!H)return;let e=J(H),t=Dt(e),n=D.current==null;Ma(t);function i(e){if(e.open||(F.current=Oa(e.nativeEvent,I.current)),e.reason===`trigger-hover`&&e.nativeEvent.type===`mouseleave`&&(j.current=!0),e.reason===`outside-press`){if(e.nested)j.current=!1;else if(Ct(e.nativeEvent)||wt(e.nativeEvent))j.current=!1;else{let e=!1;J(H).createElement(`div`).focus({get preventScroll(){return e=!0,!1}}),e?j.current=!1:j.current=!0}}}b.on(`openchange`,i);function a(e){let r=E.current,i=typeof r==`function`?r(e):r;if(i===void 0||i===!1)return null;i===null&&(i=!0);let a=v?.isConnected?v:null,o=t?.isConnected&&he(t)!==`body`?t:null,s=n?o||a:a||o;return s||=Na()||null,typeof i==`boolean`?s:Da(i)||s||null}return()=>{b.off(`openchange`,i);let t=Dt(e),n=re(),r=X(y,t)||n.some(e=>e===t||X(e,t))||k&&ui(k.nodesRef.current,S(),!1).some(e=>X(e.context?.elements.floating,t)),o=E.current,s=F.current,c=a(s);queueMicrotask(()=>{let n=Pa(c),i=typeof o!=`boolean`;if(o&&!j.current&&ve(n)&&(i||n===t||t===e.body||r)){let e={preventScroll:!0};s===`keyboard`&&(e.focusVisible=!0),n.focus(e)}j.current=!1})}},[r,y,H,E,D,b,k,v,S,re]),W(()=>{if(!Je||_||!y)return;let e=Dt(J(y));ve(e)&&an(e)&&X(y,e)&&e.blur()},[_,y]),W(()=>{if(!r&&A)return A.setFocusManagerState({modal:s,closeOnFocusOut:c,open:_,onOpenChange:g.setOpen,domReference:v}),()=>{A.setFocusManagerState(null)}},[r,A,s,_,g,c,v]),W(()=>{if(!r&&H)return Fa(H),()=>{queueMicrotask(ja)}},[r,H]);let ie=!r&&(!s||!w)&&(ne||s);return(0,Q.jsxs)(l.Fragment,{children:[ie&&(0,Q.jsx)(nr,{"data-type":`inside`,ref:z,onFocus:e=>{if(s){let e=U();mi(e[e.length-1])}else A?.portalNode&&(j.current=!1,si(e,A.portalNode)?ni(v)?.focus():Da(f??A.beforeOutsideRef)?.focus())}}),n,ie&&(0,Q.jsx)(nr,{"data-type":`inside`,ref:B,onFocus:e=>{s?mi(U()[0]):A?.portalNode&&(c&&(j.current=!0),si(e,A.portalNode)?ri(v)?.focus():Da(d??A.afterOutsideRef)?.focus())}})]})}function La(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=gn}=t,u=`rootStore`in e?e.rootStore:e,d=u.context.dataRef,f=l.useRef(void 0),p=ut(),m=ot(),h=l.useMemo(()=>{function e(e,t,n,r){let i=Z(c,t,n);e&&r===`touch`&&s>0?m.start(s,()=>{u.setOpen(!0,i)}):u.setOpen(e,i)}function t(e,t,n){let r=d.current.openEvent,a=u.select(`domReferenceElement`)!==t;return e&&a||!e||!i?!0:r&&o?!n(r.type):!1}return{onPointerDown(e){f.current=Tt(e.pointerType,!0)&&wt(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=f.current,o=n.nativeEvent,s=u.select(`open`);if(n.button!==0||r===`click`||Tt(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),l=Ot(o);if(an(l)){e(c,o,l,i);return}let d=n.currentTarget;p.request(()=>{e(c,o,d,i)})},onClick(n){if(r===`mousedown-only`)return;let i=f.current;if(r===`mousedown`&&i){f.current=void 0;return}Tt(i,!0)&&a||e(t(u.select(`open`),n.currentTarget,e=>e===`click`||e===`mousedown`||e===`keydown`||e===`keyup`),n.nativeEvent,n.currentTarget,i)},onKeyDown(){f.current=void 0}}},[d,r,a,c,u,o,i,p,m,s]);return l.useMemo(()=>n?{reference:h}:nt,[n,h])}function Ra(e,t){let n=null,r=null,i=!1;return{contextElement:e||void 0,getBoundingClientRect(){let a=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},o=t.axis===`x`||t.axis===`both`,s=t.axis===`y`||t.axis===`both`,c=[`mouseenter`,`mousemove`].includes(t.dataRef.current.openEvent?.type||``)&&t.pointerType!==`touch`,l=a.width,u=a.height,d=a.x,f=a.y;return n==null&&t.x&&o&&(n=a.x-t.x),r==null&&t.y&&s&&(r=a.y-t.y),d-=n||0,f-=r||0,l=0,u=0,!i||c?(l=t.axis===`y`?a.width:0,u=t.axis===`x`?a.height:0,d=o&&t.x!=null?t.x:d,f=s&&t.y!=null?t.y:f):i&&!c&&(u=t.axis===`x`?a.height:u,l=t.axis===`y`?a.width:l),i=!0,{width:l,height:u,x:d,y:f,top:f,right:d+l,bottom:f+u,left:d}}}}function za(e){return e!=null&&e.clientX!=null}function Ba(e,t={}){let{enabled:n=!0,axis:r=`both`}=t,i=`rootStore`in e?e.rootStore:e,a=i.useState(`open`),o=i.useState(`floatingElement`),s=i.useState(`domReferenceElement`),c=i.context.dataRef,u=l.useRef(!1),d=l.useRef(null),[f,p]=l.useState(),[m,h]=l.useState([]),g=$(e=>{i.set(`positionReference`,e)}),_=$((e,t,n)=>{u.current||(!c.current.openEvent||za(c.current.openEvent))&&i.set(`positionReference`,Ra(n??s,{x:e,y:t,axis:r,dataRef:c,pointerType:f}))}),v=$(e=>{a?d.current||(_(e.clientX,e.clientY,e.currentTarget),h([])):_(e.clientX,e.clientY,e.currentTarget)}),y=Tt(f)?o:a;l.useEffect(()=>{if(!n){g(s);return}if(!y)return;function e(){d.current?.(),d.current=null}let t=G(o);function r(t){let n=Ot(t);X(o,n)?e():_(t.clientX,t.clientY)}return!c.current.openEvent||za(c.current.openEvent)?d.current=q(t,`mousemove`,r):g(s),e},[y,n,o,c,s,i,_,g,m]),l.useEffect(()=>()=>{i.set(`positionReference`,null)},[i]),l.useEffect(()=>{n&&!o&&(u.current=!1)},[n,o]),l.useEffect(()=>{!n&&a&&(u.current=!0)},[n,a]);let b=l.useMemo(()=>{function e(e){p(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:v,onMouseEnter:v}},[v]);return l.useMemo(()=>n?{reference:b,trigger:b}:{},[n,b])}function Va(){return!1}function Ha(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Ua(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Va,bubbles:s,externalTree:c}=t,u=`rootStore`in e?e.rootStore:e,d=u.useState(`open`),f=u.useState(`floatingElement`),{dataRef:p,events:m}=u.context,h=Ca(c),g=$(typeof i==`function`?i:()=>!1),_=typeof i==`function`?g:i,v=_!==!1,y=$(()=>a),{escapeKey:b,outsidePress:x}=Ha(s),S=l.useRef(!1),C=l.useRef(!1),w=l.useRef(!1),T=l.useRef(!1),E=l.useRef(!1),D=l.useRef(``),O=l.useRef(null),k=ot(),A=ot(),j=$(()=>{A.clear(),p.current.insideReactTree=!1}),M=$(e=>{let t=p.current.floatingContext?.nodeId;return(h?ui(h.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),N=$(e=>nn(e,u.select(`floatingElement`))||nn(e,u.select(`domReferenceElement`))),P=$(e=>{o()&&u.setOpen(!1,Z(gn,e.nativeEvent))}),F=$(e=>{if(!d||!n||!r||e.key!==`Escape`||E.current||!b&&M(`__escapeKeyBubbles`))return;let t=Z(En,St(e)?e.nativeEvent:e);u.setOpen(!1,t),t.isCanceled||e.preventDefault(),!b&&!t.isPropagationAllowed&&e.stopPropagation()}),I=$(()=>{p.current.insideReactTree=!0,A.start(0,j)}),L=$(e=>{if(!d||!n||e.button!==0)return;let t=Ot(e.nativeEvent);X(u.select(`floatingElement`),t)&&(S.current||(S.current=!0,C.current=!1))}),R=$(e=>{d&&n&&(e.defaultPrevented||e.nativeEvent.defaultPrevented)&&S.current&&(C.current=!0)});l.useEffect(()=>{function e(e){e.open||(T.current=!1)}return m.on(`openchange`,e),()=>{m.off(`openchange`,e)}},[m]),l.useEffect(()=>{if(!d||!n)return d||(T.current=!1),j;p.current.__escapeKeyBubbles=b,p.current.__outsidePressBubbles=x;let e=new at,t=new at,i=J(f);function a(){e.clear(),E.current=!0}function o(){e.start(Je?5:0,()=>{E.current=!1})}function s(){w.current=!0,t.start(0,()=>{w.current=!1})}function c(){S.current=!1,C.current=!1}function l(){let e=D.current,t=e===`pen`||!e?`mouse`:e,n=y(),r=typeof n==`function`?n():n;return typeof r==`string`?r:r[t]}function m(e){let t=l();return t===`intentional`&&e.type!==`click`||t===`sloppy`&&e.type===`click`}function g(e){let t=p.current.floatingContext?.nodeId,n=h&&ui(h.nodesRef.current,t).some(t=>nn(e,t.context?.elements.floating));return N(e)||n}function A(e){if(m(e)){e.type!==`click`&&!N(e)&&(t.clear(),w.current=!1),j();return}if(p.current.insideReactTree){j();return}let n=Ot(e),r=`[${fi(`inert`)}]`,i=K(n)?n.getRootNode():null,a=Array.from((ye(i)?i:J(u.select(`floatingElement`))).querySelectorAll(r)),o=u.context.triggerElements;if(n&&(o.hasElement(n)||o.hasMatchingElement(e=>X(e,n))))return;let s=K(n)?n:null;for(;s&&!Ae(s);){let e=Ne(s);if(Ae(e)||!K(e))break;s=e}if(!(a.length&&K(n)&&!rn(n)&&!X(n,u.select(`floatingElement`))&&a.every(e=>!X(s,e)))){if(ve(n)&&!(`touches`in e)){let t=Ae(n),r=je(n),i=/auto|scroll/,a=t||i.test(r.overflowX),o=t||i.test(r.overflowY),s=a&&n.clientWidth>0&&n.scrollWidth>n.clientWidth,c=o&&n.clientHeight>0&&n.scrollHeight>n.clientHeight,l=r.direction===`rtl`,u=c&&(l?e.offsetX<=n.offsetWidth-n.clientWidth:e.offsetX>n.clientWidth),d=s&&e.offsetY>n.clientHeight;if(u||d)return}if(!g(e)){if(l()===`intentional`){if(e.detail!==0&&!Ct(e)&&!T.current)return;if(w.current){t.clear(),w.current=!1;return}}(typeof _!=`function`||_(e))&&(M(`__outsidePressBubbles`)||(u.setOpen(!1,Z(yn,e)),j()))}}}function P(e){l()===`sloppy`&&e.pointerType!==`touch`&&u.select(`open`)&&n&&!N(e)&&A(e)}function I(e){if(l()!==`sloppy`||!u.select(`open`)||!n||N(e))return;let t=e.touches[0];t&&(O.current={startTime:Date.now(),startX:t.clientX,startY:t.clientY,dismissOnTouchEnd:!1,dismissOnMouseDown:!0},k.start(1e3,()=>{O.current&&(O.current.dismissOnTouchEnd=!1,O.current.dismissOnMouseDown=!1)}))}function L(e,t){let n=Ot(e);if(!n)return;let r=q(n,e.type,()=>{t(e),r()})}function R(e){D.current=`touch`,L(e,I)}function z(e){k.clear(),e.type===`pointerdown`&&(e.button===0&&(T.current=!0),D.current=e.pointerType),(e.type!==`mousedown`||!O.current||O.current.dismissOnMouseDown)&&L(e,e=>{e.type===`pointerdown`?P(e):A(e)})}function B(e){if(e.type===`pointercancel`&&(T.current=!1),!S.current)return;let n=C.current;if(c(),l()===`intentional`){if(e.type===`pointercancel`){n&&s();return}if(!g(e)){if(n){s();return}(typeof _!=`function`||_(e))&&(t.clear(),w.current=!0,j())}}}function V(e){if(l()!==`sloppy`||!O.current||N(e))return;let t=e.touches[0];if(!t)return;let n=Math.abs(t.clientX-O.current.startX),r=Math.abs(t.clientY-O.current.startY),i=Math.sqrt(n*n+r*r);i>5&&(O.current.dismissOnTouchEnd=!0),i>10&&(A(e),k.clear(),O.current=null)}function ee(e){L(e,V)}function te(e){l()===`sloppy`&&O.current&&!N(e)&&(O.current.dismissOnTouchEnd&&A(e),k.clear(),O.current=null)}function ne(e){L(e,te)}let H=zn(r&&zn(q(i,`keydown`,F),q(i,`compositionstart`,a),q(i,`compositionend`,o)),v&&zn(q(i,`click`,z,!0),q(i,`pointerdown`,z,!0),q(i,`pointerup`,B,!0),q(i,`pointercancel`,B,!0),q(i,`mousedown`,z,!0),q(i,`mouseup`,B,!0),q(i,`touchstart`,R,{capture:!0,passive:!0}),q(i,`touchmove`,ee,{capture:!0,passive:!0}),q(i,`touchend`,ne,{capture:!0,passive:!0})));return()=>{H(),e.clear(),t.clear(),c(),w.current=!1,j()}},[p,f,r,v,_,d,n,b,x,F,j,y,M,N,h,u,k]);let z=l.useMemo(()=>({onKeyDown:F,onPointerDown:P,onClick:P}),[F,P]),B=l.useMemo(()=>({onKeyDown:F,onPointerDown:R,onMouseDown:R,onClickCapture:I,onMouseDownCapture(e){I(),L(e)},onPointerDownCapture(e){I(),L(e)},onMouseUpCapture:I,onTouchEndCapture:I,onTouchMoveCapture:I}),[F,I,L,R]);return l.useMemo(()=>n?{reference:z,floating:B,trigger:z}:{},[n,z,B])}function Wa(e,t,n){let{reference:r,floating:i}=e,a=hr(t),o=gr(t),s=mr(o),c=dr(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=fr(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Ga(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}=ur(t,e),p=Or(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=kr(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=kr(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 Ka=50,qa=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Ga},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Wa(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<Ka&&(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}=Wa(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Ja=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}=ur(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=dr(r),_=hr(o),v=dr(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[Er(o)]:vr(o)),x=p!==`none`;!d&&x&&b.push(...Tr(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=_r(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`||_===hr(t)||T.every(e=>hr(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=hr(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{}}}},Ya=new Set([`left`,`top`]);async function Xa(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=dr(n),s=fr(n),c=hr(n)===`y`,l=Ya.has(o)?-1:1,u=a&&c?-1:1,d=ur(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 Za=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 Xa(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}}}}},Qa=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}=ur(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=hr(i),p=pr(f),m=u[p],h=u[f],g=(e,t)=>lr(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}}}}}},$a=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}=ur(e,t),u={x:n,y:r},d=hr(i),f=pr(d),p=u[f],m=u[d],h=ur(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=Ya.has(dr(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}}}},eo=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}=ur(e,t),c=await i.detectOverflow(t,s),l=dr(n),u=fr(n),d=hr(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=rr(p-c[m],g),y=rr(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*ir(c.left,c.right):S=p-2*ir(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 to(e){let t=je(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ve(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=ar(n)!==a||ar(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function no(e){return K(e)?e:e.contextElement}function ro(e){let t=no(e);if(!ve(t))return sr(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=to(t),o=(a?ar(n.width):n.width)/r,s=(a?ar(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var io=sr(0);function ao(e){let t=G(e);return!ke()||!t.visualViewport?io:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function oo(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===G(e)}function so(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=no(e),o=sr(1);t&&(r?K(r)&&(o=ro(r)):o=ro(e));let s=oo(a,n,r)?ao(a):sr(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=G(a),t=K(r)?G(r):r,n=e,i=Ie(n);for(;i&&t!==n;){let e=ro(i),t=i.getBoundingClientRect(),r=je(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=G(i),i=Ie(n)}}return kr({width:u,height:d,x:c,y:l})}function co(e,t){let n=Me(e).scrollLeft;return t?t.left+n:so(ge(e)).left+n}function lo(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-co(e,n),y:n.top+t.scrollTop}}function uo(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=ge(r),s=t?Se(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=sr(1),u=sr(0),d=ve(r);if((d||!a)&&((he(r)!==`body`||be(o))&&(c=Me(r)),d)){let e=so(r);l=ro(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?lo(o,c):sr(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 fo(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function po(e){let t=Me(e),n=e.ownerDocument.body,r=ir(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=ir(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+co(e),o=-t.scrollTop;return je(n).direction===`rtl`&&(a+=ir(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var mo=25;function ho(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=G(e),a=ge(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!ke()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(co(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 go(e,t){let n=so(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=ro(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function _o(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=ho(e,n,t);else if(t===`document`)r=po(ge(e));else if(K(t))r=go(t,n);else{let n=ao(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return kr(r)}function vo(e,t){let n=t.get(e);if(n)return n;let r=Fe(e,[],!1).filter(e=>K(e)&&he(e)!==`body`),i=null,a=je(e).position===`fixed`,o=a?Ne(e):e;for(;K(o)&&!Ae(o);){let e=je(o),t=De(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ne(o)}return t.set(e,r),r}function yo(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Se(t)?[]:vo(t,this._c):[].concat(n),r],o=_o(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=_o(t,a[e],i);s=ir(n.top,s),c=rr(n.right,c),l=rr(n.bottom,l),u=ir(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function bo(e){let{width:t,height:n}=to(e);return{width:t,height:n}}function xo(e,t,n){let r=ve(t),i=ge(t),a=n===`fixed`,o=so(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=sr(0);if((r||!a)&&((he(t)!==`body`||be(i))&&(s=Me(t)),r)){let e=so(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=co(i));let l=i&&!r&&!a?lo(i,s):sr(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 So(e){return je(e).position===`static`}function Co(e,t){if(!ve(e)||je(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return ge(e)===n&&(n=n.ownerDocument.body),n}function wo(e,t){let n=G(e);if(Se(e))return n;if(!ve(e)){let t=Ne(e);for(;t&&!Ae(t);){if(K(t)&&!So(t))return t;t=Ne(t)}return n}let r=Co(e,t);for(;r&&xe(r)&&So(r);)r=Co(r,t);return r&&Ae(r)&&So(r)&&!De(r)?n:r||Oe(e)||n}var To=async function(e){let t=this.getOffsetParent||wo,n=this.getDimensions,r=await n(e.floating);return{reference:xo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Eo(e){return je(e).direction===`rtl`}var Do={convertOffsetParentRelativeRectToViewportRelativeRect:uo,getDocumentElement:ge,getClippingRect:yo,getOffsetParent:wo,getElementRects:To,getClientRects:fo,getDimensions:bo,getScale:ro,isElement:K,isRTL:Eo};function Oo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ko(e,t,n){let r=null,i,a=ge(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=or(d),h=or(a.clientWidth-(u+f)),g=or(a.clientHeight-(d+p)),_=or(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:ir(0,rr(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!Oo(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=G(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Ao(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=no(e),u=i||a?[...l?Fe(l):[],...t?Fe(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?ko(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?so(e):null;c&&g();function g(){let t=so(e);h&&!Oo(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 jo=Za,Mo=Qa,No=Ja,Po=eo,Fo=$a,Io=(e,t,n)=>{let r=new Map,i=n??{},a={...Do,...i.platform,_c:r};return qa(e,t,{...i,platform:a})},Lo=typeof document<`u`?l.useLayoutEffect:function(){};function Ro(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(!Ro(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)&&!Ro(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function zo(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bo(e,t){let n=zo(e);return Math.round(t*n)/n}function Vo(e){let t=l.useRef(e);return Lo(()=>{t.current=e}),t}function Ho(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:u}=e,[d,f]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=l.useState(r);Ro(p,r)||m(r);let[h,g]=l.useState(null),[_,v]=l.useState(null),y=l.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=l.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=l.useRef(null),w=l.useRef(null),T=l.useRef(d),E=c!=null,D=Vo(c),O=Vo(i),k=Vo(u),A=l.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),Io(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Ro(T.current,t)&&(T.current=t,fa.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);Lo(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[u]);let j=l.useRef(!1);Lo(()=>(j.current=!0,()=>{j.current=!1}),[]),Lo(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=l.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=l.useMemo(()=>({reference:x,floating:S}),[x,S]),P=l.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Bo(N.floating,d.x),r=Bo(N.floating,d.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...zo(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,d.x,d.y]);return l.useMemo(()=>({...d,update:A,refs:M,elements:N,floatingStyles:P}),[d,A,M,N,P])}var Uo=(e,t)=>{let n=jo(e);return{name:n.name,fn:n.fn,options:[e,t]}},Wo=(e,t)=>{let n=Mo(e);return{name:n.name,fn:n.fn,options:[e,t]}},Go=(e,t)=>({fn:Fo(e).fn,options:[e,t]}),Ko=(e,t)=>{let n=No(e);return{name:n.name,fn:n.fn,options:[e,t]}},qo=(e,t)=>{let n=Po(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jo=t((e=>{var t=r();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:n,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),Yo=t(((e,t)=>{t.exports=Jo()})),Xo=t((e=>{var t=r(),n=Yo();function i(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var a=typeof Object.is==`function`?Object.is:i,o=n.useSyncExternalStore,s=t.useRef,c=t.useEffect,l=t.useMemo,u=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var d=s(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=l(function(){function e(e){if(!o){if(o=!0,s=e,e=r(e),i!==void 0&&f.hasValue){var t=f.value;if(i(t,e))return c=t}return c=e}if(t=c,a(s,e))return t;var n=r(e);return i!==void 0&&i(t,n)?(s=e,t):(s=e,c=n)}var o=!1,s,c,l=n===void 0?null:n;return[function(){return e(t())},l===null?void 0:function(){return e(l())}]},[t,n,r,i]);var p=o(e,d[0],d[1]);return c(function(){f.hasValue=!0,f.value=p},[p]),u(p),p}})),Zo=t(((e,t)=>{t.exports=Xo()})),Qo=[],$o=void 0;function es(){return $o}function ts(e){Qo.push(e)}function ns(e){let t=(t,n)=>{let r=$e(is).current,i;try{$o=r;for(let e of Qo)e.before(r);i=e(t,n);for(let e of Qo)e.after(r);r.didInitialize=!0}finally{$o=void 0}return i};return t.displayName=e.displayName||e.name,t}function rs(e){return l.forwardRef(ns(e))}function is(){return{didInitialize:!1}}var as=Yo(),os=Zo(),ss=Pi(19)?us:ds;function cs(e,t,n,r,i){return ss(e,t,n,r,i)}function ls(e,t,n,r,i){let a=l.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,as.useSyncExternalStore)(e.subscribe,a,a)}ts({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);Object.is(r.value,i)||(t=!0,r.value=i)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,as.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function us(e,t,n,r,i){let a=es();if(!a)return ls(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.value=t(e.getSnapshot(),n,r,i))):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i)},a.syncHooks.push(s)),s.value}function ds(e,t,n,r,i){return(0,os.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var fs=class{static create(e){return new this(e)}constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return cs(this,e,t,n,r)}},ps=class extends fs{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){l.useDebugValue(e);let n=this;W(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;W(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;W(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){l.useDebugValue(e);let n=this,r=t!==void 0;W(()=>{r&&!Object.is(n.state[e],t)&&n.setState({...n.state,[e]:t})},[n,e,t,r])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return l.useDebugValue(e),cs(this,this.selectors[e],t,n,r)}useContextCallback(e,t){l.useDebugValue(e);let n=$(t??et);this.context[e]=n}useStateSetter(e){let t=l.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},ms={open:e=>e.open,transitionStatus:e=>e.transitionStatus,domReferenceElement:e=>e.domReferenceElement,referenceElement:e=>e.positionReference??e.referenceElement,floatingElement:e=>e.floatingElement,floatingId:e=>e.floatingId},hs=class extends ps{constructor(e){let{syncOnly:t,nested:n,onOpenChange:r,triggerElements:i,...a}=e;super({...a,positionReference:a.referenceElement,domReferenceElement:a.referenceElement},{onOpenChange:r,dataRef:{current:{}},events:va(),nested:n,triggerElements:i},ms),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&Et(t))&&(this.context.dataRef.current.openEvent=e?t:void 0)};dispatchOpenChange=(e,t)=>{this.syncOpenEvent(e,t.event);let n={open:e,reason:t.reason,nativeEvent:t.event,nested:this.context.nested,triggerElement:t.trigger};this.context.events.emit(`openchange`,n)};setOpen=(e,t)=>{if(this.syncOnly){this.context.onOpenChange?.(e,t);return}this.dispatchOpenChange(e,t),this.context.onOpenChange?.(e,t)}};function gs(e){let{popupStore:t,treatPopupAsFloatingElement:n=!1,floatingRootContext:r,floatingId:i,nested:a,onOpenChange:o}=e,s=t.useState(`open`),c=t.useState(`activeTriggerElement`),u=t.useState(n?`popupElement`:`positionerElement`),d=t.context.triggerElements,f=o,p=l.useRef(null);r===void 0&&p.current===null&&(p.current=new hs({open:s,transitionStatus:void 0,referenceElement:c,floatingElement:u,triggerElements:d,onOpenChange:f,floatingId:i,syncOnly:!0,nested:a}));let m=r??p.current;return t.useSyncedValue(`floatingId`,i),W(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:u};K(c)&&(e.domReferenceElement=c),m.state.positionReference===m.state.referenceElement&&(e.positionReference=c),m.update(e)},[s,i,c,u,m]),m.context.onOpenChange=f,m.context.nested=a,m}function _s(e,t=!1,n=!1,r=!1){let[i,a]=l.useState(e&&t?`idle`:void 0),[o,s]=l.useState(e&&!r);return e&&!o&&(s(!0),a(`starting`)),!e&&o&&i!==`ending`&&!n&&a(`ending`),!e&&!o&&i===`ending`&&a(void 0),W(()=>{if(!e&&o&&i!==`ending`&&n){let e=lt.request(()=>{a(`ending`)});return()=>{lt.cancel(e)}}},[e,o,i,n]),W(()=>{if(!e||t)return;let n=lt.request(()=>{a(void 0)});return()=>{lt.cancel(n)}},[t,e]),W(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=lt.request(()=>{a(`idle`)});return()=>{lt.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}var vs=null;function ys(e){if(!vs){let e=[];vs=e,queueMicrotask(()=>{vs=null,fa.flushSync(()=>{for(let t of e)t()})})}vs.push(e)}function bs(e,t=!1,n=!1){let r=ut();return $((i,a=null)=>{r.cancel();let o=Da(e);if(o==null)return;let s=o,c=()=>{if(!n){fa.flushSync(i);return}ys(()=>{a?.aborted||i()})};if(typeof s.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED){i();return}function l(){Promise.all(s.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||c()},()=>{if(!a?.aborted){if(s.getAnimations().some(e=>e.pending||e.playState!==`finished`)){l();return}c()}})}if(t){let e=Ft;if(!s.hasAttribute(e)){r.request(l);return}let t=new MutationObserver(()=>{s.hasAttribute(e)||(t.disconnect(),l())});t.observe(s,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0});return}r.request(l)})}function xs(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=$(a),s=bs(r,n,i);l.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}var Ss={tabIndex:-1,[kt]:``};function Cs(e){return t=>t!==`touch`||e.current}function ws(e,t=!1){let n=Ai(),r=Sa()!=null,i=$e(()=>e(n,r)).current;return gs({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function Ts({handle:e,store:t}){return W(()=>e.attachStore(t),[e,t]),null}function Es(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function Ds(e,t){let n=l.useRef(null);return $(r=>{let i=n.current;if(i!==null){if(i.element===r&&i.store===t&&i.id===e)return;n.current=null;let a=i.store;a.context.triggerElements.getById(i.id)===i.element&&(a.context.triggerElements.delete(i.id),Es(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),Es(t))})}function Os(e,t,n,r=!1){let i=e.preventUnmountingOnClose;t?i=!1:r&&(i=!0);let a=n?.id??null,o=e.activeTriggerId,s=e.activeTriggerElement;return(a||t)&&(o=a,s=n??null),{open:t,preventUnmountingOnClose:i,activeTriggerId:o,activeTriggerElement:s}}function ks(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function As(e,t,n,r={}){let i=n.reason,a=i===_n,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=ks(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=Os(e.state,t,n.trigger,c()),l={...r.extraState,...i};o?l.instantType=`focus`:s?l.instantType=`dismiss`:a&&(l.instantType=void 0),e.update(l)};a?fa.flushSync(l):l()}function js(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=Ds(e,n),o=$(t=>{let i=n.select(`open`),a=n.select(`activeTriggerId`);if(a===e){let e={activeTriggerElement:t,...i?r:null};n.update(e);return}if(a==null&&i){let i={activeTriggerId:e??null,activeTriggerElement:t,...r};n.update(i)}}),s=$(e=>{a(e),e&&o(e)});return W(()=>(s(t.current),()=>s(null)),[s,t,n,e]),W(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Ms(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=l.useRef(null),i=e.useState(`open`);W(()=>{if(!i){r.current=null,e.state.triggerCount!==0&&e.set(`triggerCount`,0);return}let t=e.context.triggerElements.size,a={};e.state.triggerCount!==t&&(a.triggerCount=t);let o=e.select(`activeTriggerId`),s=null;if(o){let t=e.context.triggerElements.getById(o);if(t)r.current=o,t!==e.state.activeTriggerElement&&(a.activeTriggerElement=t);else{for(let[t,n]of e.context.triggerElements.entries())if(n===e.state.activeTriggerElement){a.activeTriggerId=t,a.activeTriggerElement=n,r.current=t;break}a.activeTriggerId===void 0&&(r.current===o?s=o:r.current=null)}}else r.current=null;if(!s&&!o&&t===1){let t=e.context.triggerElements.entries().next();if(!t.done){let[e,n]=t.value;a.activeTriggerId=e,a.activeTriggerElement=n,r.current=e}}(a.triggerCount!==void 0||a.activeTriggerId!==void 0||a.activeTriggerElement!==void 0)&&e.update(a),s&&n&&queueMicrotask(()=>{if(e.select(`open`)&&e.select(`activeTriggerId`)===s&&!e.context.triggerElements.getById(s)){let t=Z(hn);e.setOpen(!1,t),t.isCanceled||e.update({activeTriggerId:null,activeTriggerElement:null})}})},[i,e,e.useState(`triggerCount`),e.useState(`activeTriggerId`),e.useState(`activeTriggerElement`),n])}function Ns(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=_s(e,!1,!1,r),s=t.useState(`preventUnmountingOnClose`),c=!e&&s;t.useSyncedValues({mounted:i,transitionStatus:o,preventUnmountingOnClose:c});let l=$(()=>{a(!1),t.update({activeTriggerId:null,activeTriggerElement:null,mounted:!1,preventUnmountingOnClose:!1}),n?.(),t.context.onOpenChangeComplete?.(!1)});return xs({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function Ps(e,t){e.useSyncedValues(t),W(()=>()=>{e.update({activeTriggerProps:nt,inactiveTriggerProps:nt,popupProps:nt})},[e])}function Fs(e,t){W(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),W(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var Is=class{constructor(){this.idMap=new Map}add(e,t){this.idMap.set(e,t)}delete(e){this.idMap.delete(e)}hasElement(e){for(let t of this.idMap.values())if(t===e)return!0;return!1}hasMatchingElement(e){for(let t of this.idMap.values())if(e(t))return!0;return!1}getById(e){return this.idMap.get(e)}entries(){return this.idMap.entries()}elements(){return this.idMap.values()}get size(){return this.idMap.size}};function Ls(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new hs({open:!1,transitionStatus:void 0,floatingElement:null,referenceElement:null,triggerElements:e,floatingId:t,syncOnly:!0,nested:n,onOpenChange:void 0}),floatingId:t,triggerCount:0,preventUnmountingOnClose:!1,payload:void 0,activeTriggerId:null,activeTriggerElement:null,triggerIdProp:void 0,popupElement:null,positionerElement:null,activeTriggerProps:nt,inactiveTriggerProps:nt,popupProps:nt}}var Rs=e=>e.triggerIdProp??e.activeTriggerId,zs=e=>e.openProp??e.open,Bs=e=>(e.popupElement?.id??e.floatingId)||void 0;function Vs(e,t){return t!==void 0&&zs(e)&&Rs(e)===t}function Hs(e,t){return Vs(e,t)?!0:t!==void 0&&zs(e)&&Rs(e)==null&&e.triggerCount===1}var Us={open:zs,mounted:e=>e.mounted,transitionStatus:e=>e.transitionStatus,floatingRootContext:e=>e.floatingRootContext,triggerCount:e=>e.triggerCount,preventUnmountingOnClose:e=>e.preventUnmountingOnClose,payload:e=>e.payload,activeTriggerId:Rs,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Bs,isTriggerActive:(e,t)=>t!==void 0&&Rs(e)===t,isOpenedByTrigger:(e,t)=>Vs(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&Rs(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Hs(e,t)?Bs(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Ws(e){let t=l.useCallback(t=>e===void 0?et:e.subscribeStore(t),[e]),n=l.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,as.useSyncExternalStore)(t,n,()=>e?.serverStore)}function Gs(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Ai(),a=Sa()!=null,o=$e(()=>new hs({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new Is,floatingId:i,syncOnly:!1,nested:a})).current;return W(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=K(r.reference)?r.reference:null),r.floating!==void 0&&(e.floatingElement=r.floating),o.update(e)},[t,i,r.reference,r.floating,o]),o.context.onOpenChange=n,o.context.nested=a,o}function Ks(e){return qs(e,e.rootContext)}function qs(e,t){let{nodeId:n,externalTree:r}=e,i=t.useState(`referenceElement`),a=t.useState(`floatingElement`),o=t.useState(`domReferenceElement`),s=t.useState(`open`),c=t.useState(`floatingId`),[u,d]=l.useState(null),[f,p]=l.useState(void 0),[m,h]=l.useState(void 0),g=l.useRef(null),_=Ca(r),v=l.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),y=Ho({...e,elements:{...v,...u&&{reference:u}}}),b=K(f)?f:null,x=m===void 0?t.state.floatingElement:m;t.useSyncedValue(`referenceElement`,f??null),t.useSyncedValue(`domReferenceElement`,f===void 0?o:b),t.useSyncedValue(`floatingElement`,x);let S=l.useCallback(e=>{let t=K(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;d(t),y.refs.setReference(t)},[y.refs]),C=l.useCallback(e=>{(K(e)||e===null)&&(g.current=e,p(e)),(K(y.refs.reference.current)||y.refs.reference.current===null||e!==null&&!K(e))&&y.refs.setReference(e)},[y.refs,p]),w=l.useCallback(e=>{h(e),y.refs.setFloating(e)},[y.refs]),T=l.useMemo(()=>({...y.refs,setReference:C,setFloating:w,setPositionReference:S,domReference:g}),[y.refs,C,w,S]),E=l.useMemo(()=>({...y.elements,domReference:o}),[y.elements,o]),D=l.useMemo(()=>({...y,dataRef:t.context.dataRef,open:s,onOpenChange:t.setOpen,events:t.context.events,floatingId:c,refs:T,elements:E,nodeId:n,rootStore:t}),[y,T,E,n,t,s,c]);return W(()=>{o&&(g.current=o)},[o]),W(()=>{t.context.dataRef.current.floatingContext=D;let e=_?.nodesRef.current.find(e=>e.id===n);e&&(e.context=D)}),l.useMemo(()=>({...y,context:D,refs:T,elements:E,rootStore:t}),[y,T,E,D,t])}var Js=Ke&&Je;function Ys(e,t={}){let{enabled:n=!0,delay:r}=t,i=`rootStore`in e?e.rootStore:e,{events:a,dataRef:o}=i.context,s=l.useRef(!1),c=l.useRef(null),u=l.useRef(!0),d=ot();l.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=G(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&ve(e)&&e===Dt(J(e))&&(s.current=!0,c.current=e)}function a(){u.current=!0}function o(){u.current=!1}return zn(q(t,`blur`,r),Js&&q(t,`keydown`,a,!0),Js&&q(t,`pointerdown`,o,!0))},[i,n]),l.useEffect(()=>{if(!n)return;function e(e){if(e.reason===`trigger-press`||e.reason===`escape-key`){let e=i.select(`domReferenceElement`);K(e)&&(c.current=e,s.current=!0)}}return a.on(`openchange`,e),()=>{a.off(`openchange`,e)}},[a,n,i]);let f=l.useMemo(()=>{function e(){s.current=!1,c.current=null}return{onMouseLeave(){e()},onFocus(t){let n=t.currentTarget;if(s.current){if(c.current===n)return;e()}let a=Ot(t.nativeEvent);if(K(a)){if(Js&&!t.relatedTarget){if(!u.current&&!an(a))return}else if(!cn(a))return}let o=tn(t.relatedTarget,i.context.triggerElements),{nativeEvent:l,currentTarget:f}=t,p=typeof r==`function`?r():r;if(i.select(`open`)&&o||p===0||p===void 0){i.setOpen(!0,Z(vn,l,f));return}d.start(p,()=>{s.current||i.setOpen(!0,Z(vn,l,f))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=K(n)&&n.hasAttribute(fi(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;d.start(0,()=>{let e=i.select(`domReferenceElement`),t=Dt(J(e));(n||t!==e)&&(X(o.current.floatingContext?.refs.floating.current,t)||X(e,t)||a||tn(n??t,i.context.triggerElements)||i.setOpen(!1,Z(vn,r)))})}}},[o,r,i,d]);return l.useMemo(()=>n?{reference:f,trigger:f}:{},[n,f])}var Xs=class e{constructor(){this.pointerType=void 0,this.interactedInside=!1,this.handler=void 0,this.blockMouseMove=!0,this.performedPointerEventsMutation=!1,this.pointerEventsScopeElement=null,this.pointerEventsReferenceElement=null,this.pointerEventsFloatingElement=null,this.restTimeoutPending=!1,this.openChangeTimeout=new at,this.restTimeout=new at,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},Zs=new WeakMap;function Qs(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&Zs.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),Zs.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function $s(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=Zs.get(n);a&&a!==e&&Qs(a),Qs(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,Zs.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function ec(e){let t=e.context.dataRef.current,n=$e(()=>t.hoverInteractionState??Xs.create()).current;return t.hoverInteractionState||=n,rt(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function tc(e,t={}){let{enabled:n=!0,closeDelay:r=0,nodeId:i}=t,a=`rootStore`in e?e.rootStore:e,o=a.useState(`open`),s=a.useState(`floatingElement`),c=a.useState(`domReferenceElement`),{dataRef:u}=a.context,d=Ca(),f=Sa(),p=ec(a),m=ot(),h=$(()=>pn(u.current.openEvent?.type,p.interactedInside)),g=$(()=>mn(u.current.openEvent?.type)),_=$(()=>{Qs(p)});W(()=>{o||(p.pointerType=void 0,p.restTimeoutPending=!1,p.interactedInside=!1,_())},[o,p,_]),l.useEffect(()=>_,[_]),W(()=>{if(n&&o&&p.handleCloseOptions?.blockPointerEvents&&g()&&K(c)&&s){let e=c,t=s,n=J(s),r=d?.nodesRef.current.find(e=>e.id===f)?.context?.elements.floating;r&&(r.style.pointerEvents=``);let i=p.pointerEventsScopeElement===t?null:p.pointerEventsScopeElement,a=r===t?null:r,o=p.handleCloseOptions?.getScope?.()??i??a??e.closest(`[data-rootownerid]`)??n.body;return $s(p,{scopeElement:o,referenceElement:e,floatingElement:t}),()=>{_()}}},[n,o,c,s,p,g,d,f,_]),l.useEffect(()=>{if(!n)return;function e(){return!!(d&&f&&ui(d.nodesRef.current,f).length>0)}function t(e){let t=dn(r,`close`,p.pointerType),n=()=>{a.setOpen(!1,Z(_n,e)),d?.events.emit(`floating.closed`,e)};t?p.openChangeTimeout.start(t,n):(p.openChangeTimeout.clear(),n())}function o(e){let t=Ot(e);if(!on(t)){p.interactedInside=!1;return}p.interactedInside=t?.closest(`[aria-haspopup]`)!=null}function c(){p.openChangeTimeout.clear(),m.clear(),d?.events.off(`floating.closed`,v),_()}function l(n){if(e()&&d){d.events.on(`floating.closed`,v);return}if(tn(n.relatedTarget,a.context.triggerElements))return;let r=u.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(d&&r&&K(o)&&ui(d.nodesRef.current,r,!1).some(e=>X(e.context?.elements.floating,o)))){if(p.handler){p.handler(n);return}_(),g()&&!h()&&t(n)}}function v(t){d&&f&&!e()&&m.start(0,()=>{d.events.off(`floating.closed`,v),a.setOpen(!1,Z(_n,t)),d.events.emit(`floating.closed`,t)})}let y=s;return zn(y&&q(y,`mouseenter`,c),y&&q(y,`mouseleave`,l),y&&q(y,`pointerdown`,o,!0),()=>{d?.events.off(`floating.closed`,v)})},[n,s,a,u,r,i,g,h,_,p,d,f,m])}var nc={current:null};function rc(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=nc,externalTree:u,isActiveTrigger:d=!0,getHandleCloseContext:f,isClosing:p,shouldOpen:m,guardStaleOpen:h=!1}=t,g=`rootStore`in e?e.rootStore:e,{dataRef:_,events:v}=g.context,y=Ca(u),b=ec(g),x=l.useRef(!1),S=Kn(i),C=Kn(r),w=Kn(o),T=Kn(n),E=Kn(m),D=Kn(p),O=$(()=>pn(_.current.openEvent?.type,b.interactedInside)),k=$(()=>E.current?.()!==!1),A=$((e,t,n)=>{let r=g.context.triggerElements;if(r.hasElement(t))return!e||!X(e,t);if(!K(n))return!1;let i=n;return r.hasMatchingElement(e=>X(e,i))&&(!e||!X(e,i))}),j=$(()=>{b.handler&&=(J(g.select(`domReferenceElement`)).removeEventListener(`mousemove`,b.handler),void 0)}),M=$(()=>{Qs(b)});return d&&(b.handleCloseOptions=i?.__options),l.useEffect(()=>j,[j]),l.useEffect(()=>{if(!n)return;function e(e){e.open?x.current=!1:(x.current=e.reason===_n,j(),b.openChangeTimeout.clear(),b.restTimeout.clear(),b.blockMouseMove=!0,b.restTimeoutPending=!1)}return v.on(`openchange`,e),()=>{v.off(`openchange`,e)}},[n,v,b,j]),l.useEffect(()=>{if(!n)return;function e(e,t=!0){let n=dn(C.current,`close`,b.pointerType);n?b.openChangeTimeout.start(n,()=>{g.setOpen(!1,Z(_n,e)),y?.events.emit(`floating.closed`,e)}):t&&(b.openChangeTimeout.clear(),g.setOpen(!1,Z(_n,e)),y?.events.emit(`floating.closed`,e))}let t=c.current??(d?g.select(`domReferenceElement`):null);if(!K(t))return;function r(e){if(b.openChangeTimeout.clear(),b.blockMouseMove=!1,a&&!Tt(b.pointerType))return;let t=fn(w.current),n=dn(C.current,`open`,b.pointerType),r=Ot(e),i=e.currentTarget??null,o=g.select(`domReferenceElement`),s=i;if(K(r)&&!g.context.triggerElements.hasElement(r)){for(let e of g.context.triggerElements.elements())if(X(e,r)){s=e;break}}K(i)&&K(o)&&!g.context.triggerElements.hasElement(i)&&X(i,o)&&(s=o);let c=s!=null&&A(o,s,r),l=g.select(`open`),u=D.current?.()??g.select(`transitionStatus`)===`ending`,d=!l&&u&&x.current,f=!c&&K(s)&&K(o)&&X(o,s)&&d,p=t>0&&!n,m=c&&(l||d)||f,h=!l||c;if(m){k()&&g.setOpen(!0,Z(_n,e,s));return}p||(n?b.openChangeTimeout.start(n,()=>{h&&k()&&g.setOpen(!0,Z(_n,e,s))}):h&&k()&&g.setOpen(!0,Z(_n,e,s)))}function i(t){if(O()){M();return}j();let n=J(g.select(`domReferenceElement`));b.restTimeout.clear(),b.restTimeoutPending=!1;let r=_.current.floatingContext??f?.();if(!tn(t.relatedTarget,g.context.triggerElements)){if(S.current&&r){g.select(`open`)||b.openChangeTimeout.clear();let i=c.current;b.handler=S.current({...r,tree:y,x:t.clientX,y:t.clientY,onClose(){M(),j(),T.current&&!O()&&i===g.select(`domReferenceElement`)&&e(t,!0)}}),n.addEventListener(`mousemove`,b.handler),b.handler(t);return}(b.pointerType!==`touch`||!X(g.select(`floatingElement`),t.relatedTarget))&&e(t)}}function o(e){X(t,e.relatedTarget)||(b.openChangeTimeout.clear(),b.restTimeout.clear(),b.restTimeoutPending=!1)}let l=h?q(t,`mouseout`,o):void 0;return s?zn(q(t,`mousemove`,r,{once:!0}),q(t,`mouseenter`,r),q(t,`mouseleave`,i),l):zn(q(t,`mouseenter`,r),q(t,`mouseleave`,i),l)},[j,M,_,C,g,n,S,b,d,A,O,a,s,w,c,y,T,f,D,k,h]),l.useMemo(()=>{if(!n)return;function e(e){b.pointerType=e.pointerType}return{onPointerDown:e,onPointerEnter:e,onMouseMove(e){let{nativeEvent:t}=e,n=e.currentTarget,r=g.select(`domReferenceElement`),i=g.select(`open`),o=A(r,n,e.target);if(a&&!Tt(b.pointerType))return;if(i&&o&&b.handleCloseOptions?.blockPointerEvents){let e=g.select(`floatingElement`);if(e){let t=b.handleCloseOptions?.getScope?.()??n.ownerDocument.body;$s(b,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=fn(w.current);if(i&&!o||s===0||!o&&b.restTimeoutPending&&e.movementX**2+e.movementY**2<2)return;b.restTimeout.clear();function c(){if(b.restTimeoutPending=!1,O())return;let e=g.select(`open`);!b.blockMouseMove&&(!e||o)&&k()&&g.setOpen(!0,Z(_n,t,n))}b.pointerType===`touch`?fa.flushSync(()=>{c()}):o&&i?c():(b.restTimeoutPending=!0,b.restTimeout.start(s,c))}}},[n,b,O,A,a,g,w,k])}var ic=`Escape`;function ac(e){return Je&&e.movementX===0&&e.movementY===0}function oc(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function sc(e,t){return oc(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function cc(e,t,n){return oc(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function lc(e,t,n){return oc(t,n?e===jt:e===Mt,e===Pt)}function uc(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===ic:oc(t,n?e===Mt:e===jt,e===Nt)}function dc(e,t){let{listRef:n,activeIndex:r,onNavigate:i=()=>{},enabled:a=!0,selectedIndex:o=null,allowEscape:s=!1,loopFocus:c=!1,nested:u=!1,rtl:d=!1,virtual:f=!1,focusItemOnOpen:p=`auto`,focusItemOnHover:m=!0,openOnArrowKeyDown:h=!0,disabledIndices:g=void 0,orientation:_=`vertical`,parentOrientation:v,id:y,resetOnPointerLeave:b=!0,externalTree:x,grid:S}=t,C=S!=null,w=`rootStore`in e?e.rootStore:e,T=w.useState(`open`),E=w.useState(`floatingElement`),D=w.useState(`domReferenceElement`),O=w.context.dataRef,k=ln(E),A=sn(D),j=Kn(k),M=Sa(),N=Ca(x),P=l.useRef(p),F=l.useRef(o??-1),I=l.useRef(null),L=l.useRef(!0),R=$(e=>{i(F.current===-1?null:F.current,e)}),z=l.useRef(!!E),B=l.useRef(T),V=l.useRef(!1),ee=l.useRef(!1),te=l.useRef(null),ne=Kn(g),H=Kn(T),U=Kn(o),re=Kn(b),ie=ut(),ae=ut(),oe=$(()=>{function e(e){f?N?.events.emit(`virtualfocus`,e):te.current=mi(e,{sync:V.current,preventScroll:!0})}let t=n.current[F.current],r=ee.current;t&&e(t),(V.current?e=>e():e=>ie.request(e))(()=>{let i=n.current[F.current]||t;i&&(t||e(i),fe&&(r||!L.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});W(()=>{O.current.orientation=_},[O,_]),W(()=>{a&&(T&&E?(F.current=o??-1,P.current&&o!=null&&(ee.current=!0,R())):z.current&&(F.current=-1,R()))},[a,T,E,o,R]),W(()=>{if(a){if(!T){V.current=!1;return}if(E){if(r==null){if(V.current=!1,U.current!=null)return;if(z.current&&(F.current=-1,oe()),(!B.current||!z.current)&&P.current&&(I.current!=null||P.current===!0&&I.current==null)){let e=0,t=()=>{n.current[0]==null?(e<2&&(e?e=>ae.request(e):queueMicrotask)(t),e+=1):(F.current=I.current==null||cc(I.current,_,d)||u?Mr(n):Nr(n),I.current=null,R())};t()}}else jr(n.current,r)||(F.current=r,oe(),ee.current=!1)}}},[a,T,E,r,U,u,n,_,d,R,oe,ae]),W(()=>{if(!a||E||!N||f||!z.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=Dt(J(D??t??null)),r=e.some(e=>e.context&&X(e.context.elements.floating,n));t&&!r&&L.current&&t.focus({preventScroll:!0})},[a,E,D,N,M,f]),W(()=>{B.current=T,z.current=!!E}),W(()=>{T||(I.current=null,P.current=p)},[T,p]);let se=r!=null,ce=$(e=>{if(!H.current)return;let t=n.current.indexOf(e.currentTarget);t!==-1&&(F.current!==t||r!==t)&&(F.current=t,R(e))}),le=$(()=>v??N?.nodesRef.current.find(e=>e.id===M)?.context?.dataRef?.current.orientation),ue=$(()=>Mr(n,ne.current)),de=$(e=>{if(L.current=!1,V.current=!0,e.which===229||!H.current&&e.currentTarget===j.current)return;if(u&&uc(e.key,_,d,C)){sc(e.key,le())||xt(e),w.setOpen(!1,Z(Dn,e.nativeEvent)),ve(D)&&(f?N?.events.emit(`virtualfocus`,D):D.focus());return}let t=F.current,r=Mr(n,g),i=Nr(n,g);if(A||(e.key===`Home`&&(xt(e),F.current=r,R(e)),e.key===`End`&&(xt(e),F.current=i,R(e))),S!=null){let t=S(e,F.current,n,_,c,d,g,r,i);if(t!=null&&(F.current=t,R(e)),_===`both`)return}if(sc(e.key,_)){if(xt(e),T&&!f&&Dt(e.currentTarget.ownerDocument)===e.currentTarget){F.current=cc(e.key,_,d)?r:i,R(e);return}cc(e.key,_,d)?c?t>=i?s&&t!==n.current.length?F.current=-1:(V.current=!1,F.current=r):F.current=Pr(n.current,{startingIndex:t,disabledIndices:g}):F.current=Math.min(i,Pr(n.current,{startingIndex:t,disabledIndices:g})):c?t<=r?s&&t!==-1?F.current=n.current.length:(V.current=!1,F.current=i):F.current=Pr(n.current,{startingIndex:t,decrement:!0,disabledIndices:g}):F.current=Math.max(r,Pr(n.current,{startingIndex:t,decrement:!0,disabledIndices:g})),jr(n.current,F.current)&&(F.current=-1),R(e)}}),fe=l.useMemo(()=>({onFocus(e){V.current=!0,ce(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){ac(e)||(V.current=!0,ee.current=!1,m&&ce(e))},onPointerLeave(e){if(!H.current||!L.current||e.pointerType===`touch`)return;V.current=!0;let t=e.relatedTarget;if(m&&!n.current.includes(t)&&re.current&&(te.current?.(),te.current=null,F.current=-1,R(e),!f)){let e=j.current,t=Dt(J(e));e&&X(e,t)&&e.focus({preventScroll:!0})}}}),[ce,H,j,m,n,R,re,f]),pe=l.useMemo(()=>f&&T&&se&&{"aria-activedescendant":`${y}-${r}`},[f,T,se,y,r]),me=l.useMemo(()=>({...A?{}:pe,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&T&&!f){let t=Ot(e.nativeEvent);if(t&&!X(j.current,t))return;xt(e),w.setOpen(!1,Z(Tn,e.nativeEvent)),ve(D)&&D.focus();return}de(e)},onPointerMove(e){ac(e)||(L.current=!0)}}),[pe,de,j,A,w,T,f,D]),he=l.useMemo(()=>{function e(e){w.setOpen(!0,Z(Dn,e.nativeEvent,e.currentTarget))}function t(e){p===`auto`&&Ct(e.nativeEvent)&&(P.current=!f)}function n(e){P.current=p,p===`auto`&&wt(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(t){let n=w.select(`open`);L.current=!1;let r=t.key.startsWith(`Arrow`),i=lc(t.key,le(),d),a=sc(t.key,_),o=(u?i:a)||t.key===`Enter`||t.key.trim()===``;if(f&&n)return de(t);if(n||h||!r){if(o){let e=sc(t.key,le());I.current=u&&e?null:t.key}if(u){i&&(xt(t),n?(F.current=ue(),R(t)):e(t));return}a&&(U.current!=null&&(F.current=U.current),xt(t),!n&&h?e(t):de(t),n&&R(t))}},onFocus(e){w.select(`open`)&&!f&&(F.current=-1,R(e))},onPointerDown:n,onPointerEnter:n,onMouseDown:t,onClick:t}},[de,p,ue,u,R,w,h,_,le,d,U,f]),G=l.useMemo(()=>({...pe,...he}),[pe,he]);return l.useMemo(()=>a?{reference:G,floating:me,item:fe,trigger:he}:{},[a,G,me,he,fe])}function fc(e,t){let{listRef:n,elementsRef:r,activeIndex:i,onMatch:a,disabledIndices:o,onTyping:s,enabled:c=!0,resetMs:u=750,selectedIndex:d=null}=t,f=`rootStore`in e?e.rootStore:e,p=f.useState(`open`),m=ot(),h=l.useRef(``),g=l.useRef(d??i??-1),_=l.useRef(null),v=$(e=>{function t(e){return r?.current[e]}function c(e){let n=t(e);return n&&!Rr(n)||n?.matches(`:disabled`)?!1:o==null||!Ir(tt,e,o)}function l(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length,i=t.toLowerCase();for(let t=0;t<e.length;t+=1){let n=(r+t)%e.length;if(e[n]?.toLowerCase().startsWith(i)&&c(n))return n}return-1}let f=n.current;if(h.current.length>0&&e.key===` `&&(xt(e),s?.(!0)),h.current.length>0&&h.current[0]!==` `&&l(f,h.current)===-1&&e.key!==` `&&s?.(!1),f==null||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey)return;p&&e.key!==` `&&(xt(e),s?.(!0));let v=h.current===``;v&&(g.current=d??i??-1),f.every((e,t)=>e&&c(t)?e[0]?.toLowerCase()!==e[1]?.toLowerCase():!0)&&h.current===e.key&&(h.current=``,g.current=_.current),h.current+=e.key,m.start(u,()=>{h.current=``,g.current=_.current,s?.(!1)});let y=((v?d??i??-1:g.current)??0)+1,b=l(f,h.current,y);b===-1?e.key!==` `&&(h.current=``,s?.(!1)):(a?.(b),_.current=b)}),y=$(e=>{let t=e.relatedTarget,n=f.select(`domReferenceElement`),r=f.select(`floatingElement`);X(n,t)||X(r,t)||(m.clear(),h.current=``,g.current=_.current,s?.(!1))});W(()=>{(p||d===null)&&(m.clear(),_.current=null,h.current!==``&&(h.current=``))},[p,d,m]);let b=l.useMemo(()=>({onKeyDown:v,onBlur:y}),[v,y]);return l.useMemo(()=>c?{reference:b,floating:b}:{},[c,b])}var pc=.1,mc=pc*pc,hc=.5;function gc(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function _c(e,t,n,r,i,a,o,s,c,l){let u=!1;return gc(e,t,n,r,i,a)&&(u=!u),gc(e,t,i,a,o,s)&&(u=!u),gc(e,t,o,s,c,l)&&(u=!u),gc(e,t,c,l,n,r)&&(u=!u),u}function vc(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function yc(e,t,n,r,i,a){return e>=Math.min(n,i)&&e<=Math.max(n,i)&&t>=Math.min(r,a)&&t<=Math.max(r,a)}function bc(e={}){let{blockPointerEvents:t=!1}=e,n=new at,r=({x:e,y:t,placement:r,elements:i,onClose:a,nodeId:o,tree:s})=>{let c=r?.split(`-`)[0],l=!1,u=null,d=null,f=typeof performance<`u`?performance.now():0;function p(e,t){let n=performance.now(),r=n-f;if(u===null||d===null||r===0)return u=e,d=t,f=n,!1;let i=e-u,a=t-d,o=i*i+a*a,s=r*r*mc;return u=e,d=t,f=n,o<s}function m(){n.clear(),a()}return function(r){n.clear();let a=i.domReference,u=i.floating;if(!a||!u||c==null||e==null||t==null)return;let{clientX:d,clientY:f}=r,h=Ot(r),g=r.type===`mouseleave`,_=X(u,h),v=X(a,h);if(_&&(l=!0,!g))return;if(v&&(l=!1,!g)){l=!0;return}if(g&&K(r.relatedTarget)&&X(u,r.relatedTarget))return;function y(){return!!(s&&ui(s.nodesRef.current,o).length>0)}function b(){y()||m()}if(y())return;let x=a.getBoundingClientRect(),S=u.getBoundingClientRect(),C=e>S.right-S.width/2,w=t>S.bottom-S.height/2,T=S.width>x.width,E=S.height>x.height,D=(T?x:S).left,O=(T?x:S).right,k=(E?x:S).top,A=(E?x:S).bottom;if(c===`top`&&t>=x.bottom-1||c===`bottom`&&t<=x.top+1||c===`left`&&e>=x.right-1||c===`right`&&e<=x.left+1){b();return}let j=!1;switch(c){case`top`:j=yc(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=yc(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=yc(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=yc(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!vc(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?hc/2:hc*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+hc+1,o=C||T?S.bottom-hc:S.top,s=C?T?S.bottom-hc:S.top:S.bottom-hc;M=_c(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?hc/2:hc*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-hc,o=C||T?S.top+hc:S.bottom,s=C?T?S.top+hc:S.bottom:S.top+hc;M=_c(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?hc/2:hc*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+hc+1,o=w||E?S.right-hc:S.left,s=w?E?S.right-hc:S.left:S.right-hc;M=_c(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?hc/2:hc*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-hc,o=w||E?S.left+hc:S.right,s=w?E?S.left+hc:S.right:S.left+hc;M=_c(d,f,a,r,a,i,o,S.top,s,S.bottom);break}}M?l||n.start(40,b):b()}};return r.__options={...e,blockPointerEvents:t},r}function xc({store:e,parentContext:t,isDrawer:n}){let r=e.useState(`open`),i=e.useState(`disablePointerDismissal`),a=e.useState(`modal`),o=e.useState(`popupElement`),s=e.useState(`floatingRootContext`),[c,u]=l.useState(0),[d,f]=l.useState(0),p=c===0,m=Ua(s,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?`intentional`:{mouse:a===`trap-focus`?`sloppy`:`intentional`,touch:`sloppy`}},outsidePress(t){if(!e.context.outsidePressEnabledRef.current||`button`in t&&t.button!==0)return!1;if(`touches`in t){if(t.type===`touchend`){if(t.changedTouches.length!==1||t.touches.length!==0)return!1}else if(t.touches.length!==1)return!1}let n=Ot(t);if(p&&!i){if(a){let t=e.context.internalBackdropRef.current,r=e.context.backdropRef.current;return t||r?t===n||r===n||X(n,o)&&!n?.hasAttribute(`data-base-ui-portal`):!0}return!0}return!1},escapeKey:p});return bt(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{u(e),f(t)}),W(()=>(t?.onNestedDialogOpen&&(r?t.onNestedDialogOpen(c+1,d+ +!!n):t.onNestedDialogOpen(0,0)),()=>{t?.onNestedDialogOpen&&r&&t.onNestedDialogOpen(0,0)}),[n,r,c,d,t]),Ps(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:d}),null}var Sc=l.createContext(void 0);function Cc(e){let t=l.useContext(Sc);if(!e&&t===void 0)throw Error(Mi(27));return t}var wc={...Us,modal:e=>e.modal,nested:e=>e.nested,nestedOpenDialogCount:e=>e.nestedOpenDialogCount,nestedOpenDrawerCount:e=>e.nestedOpenDrawerCount,disablePointerDismissal:e=>e.disablePointerDismissal,openMethod:e=>e.openMethod,descriptionElementId:e=>e.descriptionElementId,titleElementId:e=>e.titleElementId,viewportElement:e=>e.viewportElement,role:e=>e.role},Tc=class extends ps{constructor(e,t,n){let r=new Is,i=Ec(e,r,t,n);super(i,Dc(r),wc)}setOpen=(e,t)=>{t.preventUnmountOnClose=()=>{this.set(`preventUnmountingOnClose`,!0)},!e&&t.trigger==null&&this.state.activeTriggerId!=null&&(t.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(e,t),!t.isCanceled&&(this.state.floatingRootContext.dispatchOpenChange(e,t),this.update(Os(this.state,e,t.trigger)))}};function Ec(e,t,n,r=!1){return{...Ls(t,n,r),modal:!0,disablePointerDismissal:!1,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:`dialog`,...e}}function Dc(e){return{popupRef:l.createRef(),backdropRef:l.createRef(),internalBackdropRef:l.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function Oc(e,t){let{children:n,open:r,defaultOpen:i=!1,onOpenChange:a,onOpenChangeComplete:o,disablePointerDismissal:s=!1,modal:c=!0,actionsRef:u,handle:d,triggerId:f,defaultTriggerId:p=null}=t,m=e===`drawer`,h=e===`alert-dialog`,g=h?!0:c,_=h||s,v=h?`alertdialog`:`dialog`,y=Cc(!0),b={modal:g,disablePointerDismissal:_,nested:y!=null,role:v},x=ws((e,t)=>new Tc({open:i,openProp:r,activeTriggerId:p,triggerIdProp:f,...b},e,t),!0);x.useControlledProp(`openProp`,r),x.useControlledProp(`triggerIdProp`,f),x.useSyncedValues(b),x.useContextCallback(`onOpenChange`,a),x.useContextCallback(`onOpenChangeComplete`,o);let S=x.useState(`open`),C=x.useState(`mounted`),w=x.useState(`payload`);Fs(x,S),Ms(x);let{forceUnmount:T}=Ns(S,x);l.useImperativeHandle(u,()=>({unmount:T,close:()=>x.setOpen(!1,Z(Nn))}),[T,x]);let E=S||C;return(0,Q.jsxs)(Sc.Provider,{value:x,children:[d&&(0,Q.jsx)(Ts,{handle:d,store:x}),E&&(0,Q.jsx)(xc,{store:x,parentContext:y?.context,isDrawer:m}),typeof n==`function`?n({payload:w}):n]})}function kc(e){return Oc(`alert-dialog`,e)}var Ac=l.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=Cc(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return ta(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:$t,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),jc=l.createContext(void 0);function Mc(e=!1){let t=l.useContext(jc);if(t===void 0&&!e)throw Error(Mi(16));return t}function Nc(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:l.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function Pc(e,t,{detail:n=0}={}){e.dispatchEvent(new(G(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Fc(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=l.useRef(null),s=Mc(!0),c=a??s!==void 0,{props:u}=Nc({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),d=l.useCallback(()=>{let e=o.current;Ic(e)&&c&&t&&u.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,u.disabled,c]);return W(d,[d]),{getButtonProps:l.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...l}=e;return Vi({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Qi(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=Ic(r),s=!i&&Lc(r),l=n&&(i?a:!s),u=e.key===`Enter`,d=e.key===` `,f=r.getAttribute(`role`),p=f?.startsWith(`menuitem`)||f===`option`||f===`gridcell`;if(n&&c&&d){if(e.defaultPrevented&&p)return;e.preventDefault(),(!i||a)&&(e.preventBaseUIHandler(),Pc(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),Pc(r,e)))},onKeyUp(e){if(!t){if(Qi(e),a?.(e),e.target===e.currentTarget&&i&&c&&Ic(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),Pc(e.currentTarget,e))}},onPointerDown(e){if(t){e.preventDefault();return}s?.(e)}},i?{type:`button`}:{role:`button`},u,l)},[t,u,c,i]),buttonRef:$(e=>{o.current=e,d()})}}function Ic(e){return ve(e)&&e.tagName===`BUTTON`}function Lc(e){return ve(e)&&e.tagName===`A`&&!!e.href}var Rc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=Cc(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=Fc({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Z(xn,e.nativeEvent))}return ta(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})});function zc(e){return Ai(e,`base-ui`)}var Bc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Cc(),c=zc(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),ta(`p`,e,{ref:t,props:[{id:c},o]})}),Vc=l.createContext(void 0);function Hc(){let e=l.useContext(Vc);if(e===void 0)throw Error(Mi(26));return e}var Uc=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),Wc=`--nested-dialogs`,Gc=`data-nested-dialog-open`,Kc={...Qt,...zt,nestedDialogOpen(e){return e?{[Gc]:``}:null}},qc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=Cc(),l=c.useState(`descriptionElementId`),u=c.useState(`disablePointerDismissal`),d=c.useState(`floatingRootContext`),f=c.useState(`popupProps`),p=c.useState(`modal`),m=c.useState(`mounted`),h=c.useState(`nested`),g=c.useState(`nestedOpenDialogCount`),_=c.useState(`open`),v=c.useState(`openMethod`),y=c.useState(`titleElementId`),b=c.useState(`transitionStatus`),x=c.useState(`role`),S=d.useState(`floatingId`);Hc(),xs({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?Cs(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=ta(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...Ss,hidden:!m,onKeyDown(e){Uc.has(e.key)&&e.stopPropagation()},style:{[Wc]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:Kc});return(0,Q.jsx)(Ia,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})});function Jc(e){return Pi(19)?e:e?`true`:void 0}var Yc=l.forwardRef(function(e,t){let{cutout:n,...r}=e,i;if(n){let e=n.getBoundingClientRect();i=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${e.left}px ${e.top}px,${e.left}px ${e.bottom}px,${e.right}px ${e.bottom}px,${e.right}px ${e.top}px,${e.left}px ${e.top}px)`}return(0,Q.jsx)(`div`,{ref:t,role:`presentation`,"data-base-ui-inert":``,...r,style:{position:`fixed`,inset:0,userSelect:`none`,WebkitUserSelect:`none`,clipPath:i}})}),Xc=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=Cc(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Q.jsx)(Vc.Provider,{value:n,children:(0,Q.jsxs)(_a,{ref:t,...r,children:[a&&o===!0&&(0,Q.jsx)(Yc,{ref:i.context.internalBackdropRef,inert:Jc(!s)}),e.children]})}):null}),Zc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=Cc(),c=zc(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),ta(`h2`,e,{ref:t,props:[{id:c},o]})});function Qc(e){let t=l.useRef(``),n=l.useCallback(n=>{n.defaultPrevented||(t.current=n.pointerType,e(n,n.pointerType))},[e]);return{onClick:l.useCallback(n=>{if(n.detail===0){e(n,`keyboard`);return}`pointerType`in n?e(n,n.pointerType):e(n,t.current),t.current=``},[e]),onPointerDown:n}}function $c(e,t){let n=l.useRef(e),r=$(t);W(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function el(e,t){let{onClick:n,onPointerDown:r}=Qc($((n,r)=>{(typeof e==`function`?e():e)||t(r||(Ue?`touch`:``))}));return l.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function tl(e){let[t,n]=l.useState(null),r=el(e,n);return $c(e,t=>{t&&!e&&n(null)}),l.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var nl=i(),rl,il,al=e=>{rl??=(0,nl.createRoot)(document.body.appendChild(document.createElement(`div`))),il?.resolve(!1),il=e,rl.render((0,Q.jsx)(ol,{request:e,settle:t=>{il===e&&(il=void 0,rl?.render(null),e.resolve(t))}}))};function ol({request:e,settle:t}){return(0,Q.jsx)(kc,{open:!0,onOpenChange:e=>{e||t(!1)},children:(0,Q.jsxs)(Xc,{children:[(0,Q.jsx)(Ac,{className:`dialog-backdrop`}),(0,Q.jsxs)(qc,{className:`dialog`,children:[(0,Q.jsx)(Bc,{className:`dialog-message`,children:e.message}),(0,Q.jsxs)(`div`,{className:`dialog-actions`,children:[e.cancelLabel&&(0,Q.jsx)(Rc,{className:`dialog-button`,children:e.cancelLabel}),(0,Q.jsx)(`button`,{type:`button`,autoFocus:!0,className:`dialog-button is-primary ${e.danger?`is-danger`:``}`,onClick:()=>t(!0),children:e.confirmLabel})]})]})]})})}var sl=(e,{confirmLabel:t=`Confirm`,danger:n=!1}={})=>new Promise(r=>al({message:e,confirmLabel:t,cancelLabel:`Cancel`,danger:n,resolve:r})),cl=e=>new Promise(t=>al({message:e,confirmLabel:`OK`,resolve:()=>t()})),ll=l.createContext(void 0);function ul(e){let t=l.useContext(ll);if(t===void 0&&!e)throw Error(Mi(72));return t}var dl={...Us,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin},fl=class extends ps{constructor(e,t,n){let r=new Is;super(pl(e,r,t,n),ml(r),dl)}setOpen=(e,t)=>{As(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,Z(gn,e))}};function pl(e,t,n,r=!1){return{...Ls(t,n,r),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:`none`,disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function ml(e){return{popupRef:l.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var hl=ns(function(e){let{disabled:t=!1,defaultOpen:n=!1,open:r,disableHoverablePopup:i=!1,trackCursorAxis:a=`none`,actionsRef:o,onOpenChange:s,onOpenChangeComplete:c,handle:u,triggerId:d,defaultTriggerId:f=null,children:p}=e,m=ws((e,t)=>new fl({open:n,openProp:r,activeTriggerId:f,triggerIdProp:d},e,t));m.useControlledProp(`openProp`,r),m.useControlledProp(`triggerIdProp`,d),m.useContextCallback(`onOpenChange`,s),m.useContextCallback(`onOpenChangeComplete`,c);let h=m.useState(`open`),g=!t&&h,_=m.useState(`activeTriggerId`),v=m.useState(`mounted`),y=m.useState(`payload`);m.useSyncedValues({trackCursorAxis:a,disableHoverablePopup:i,disabled:t}),Ms(m,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=Ns(g,m),S=m.useState(`isInstantPhase`),C=m.useState(`instantType`),w=m.useState(`lastOpenChangeReason`),T=l.useRef(null);W(()=>{h&&t&&m.setOpen(!1,Z(Mn))},[h,t,m]),W(()=>{x===`ending`&&w===`none`||x!==`ending`&&S?(C!==`delay`&&(T.current=C),m.set(`instantType`,`delay`)):T.current!==null&&(m.set(`instantType`,T.current),T.current=null)},[x,S,w,C,m]),W(()=>{g&&(_??m.set(`payload`,void 0))},[m,_,g]),l.useImperativeHandle(o,()=>({unmount:b,close:()=>m.setOpen(!1,Z(Nn))}),[b,m]);let E=g||v||!t&&a!==`none`;return(0,Q.jsxs)(ll.Provider,{value:m,children:[u&&(0,Q.jsx)(Ts,{handle:u,store:m}),E&&(0,Q.jsx)(gl,{store:m,disabled:t,trackCursorAxis:a}),typeof p==`function`?p({payload:y}):p]})});function gl({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=Ua(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=Ba(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=l.useMemo(()=>Vi(a.reference,i.reference),[a.reference,i.reference]);return Ps(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??nt}),null}var _l=l.createContext(void 0);function vl(){return l.useContext(_l)}var yl=`data-base-ui-tooltip-trigger`;function bl(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(K(n))return n}}let t=e.target;return K(t)?t:null}function xl(e){let t=e;for(;t;){let e=t.closest(`[${yl}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&K(n.host)?n.host:null}return null}var Sl=rs(function(e,t){let{render:n,className:r,style:i,handle:a,payload:o,disabled:s,delay:c,closeOnClick:u=!0,closeDelay:d,id:f,...p}=e,m=ul(!0),h=Ws(a)??m;if(!h)throw Error(Mi(82));let g=zc(f),_=h.useState(`isTriggerActive`,g),v=h.useState(`isOpenedByTrigger`,g),y=h.useState(`floatingRootContext`),b=l.useRef(null),x=d??0,{registerTrigger:S,isMountedByThisTrigger:C}=js(g,b,h,{payload:o,closeOnClick:u,closeDelay:x}),w=vl(),{activeIdRef:T,delayRef:E,isInstantPhase:D,hasProvider:O}=Rn(y,{open:v}),k=ec(y);h.useSyncedValue(`isInstantPhase`,D);let A=h.useState(`disabled`),j=s??A,M=Kn(j),N=h.useState(`trackCursorAxis`),P=h.useState(`disableHoverablePopup`),F=l.useRef(!1),I=ot(),L=l.useRef(void 0);function R(){return O&&T.current!=null?0:c??w??600}function z(e){let t=b.current;if(!t||!e)return!1;let n=xl(e);return n!==null&&n!==t&&X(t,n)}function B(e){let t=z(e);return F.current=t,t&&(k.openChangeTimeout.clear(),k.restTimeout.clear(),k.restTimeoutPending=!1,I.clear()),t}let V=rc(y,{enabled:!j,mouseOnly:!0,move:!1,handleClose:!P&&N!==`both`?bc():null,restMs:R,delay(){return d==null&&O?{close:dn(E.current,`close`)}:{close:x}},triggerElementRef:b,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`,shouldOpen(){return!F.current}}),ee=Ys(y,{enabled:!j}).reference,te=e=>{let t=F.current,n=bl(e),r=B(n),i=b.current,a=i&&n&&X(i,n);if(r&&h.select(`open`)&&h.select(`lastOpenChangeReason`)===`trigger-hover`){h.setOpen(!1,Z(_n,e));return}if(t&&!r&&a&&!M.current&&!h.select(`open`)&&i&&Tt(L.current)){let t=()=>{!F.current&&!M.current&&!h.select(`open`)&&h.setOpen(!0,Z(_n,e,i))},n=R();n===0?(I.clear(),t()):I.start(n,t)}},ne=h.useState(`triggerProps`,C);return ta(`button`,e,{state:{open:v},ref:[t,S,b],props:[V,ee,C||N!==`none`?ne:void 0,{onMouseOver(e){te(e.nativeEvent)},onFocus(e){z(bl(e.nativeEvent))&&e.preventBaseUIHandler()},onMouseLeave(){F.current=!1,I.clear(),L.current=void 0},onPointerEnter(e){L.current=e.pointerType},onPointerDown(e){L.current=e.pointerType,h.set(`closeOnClick`,u),u&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},onClick(e){u&&!h.select(`open`)&&h.cancelPendingOpen(e.nativeEvent)},id:g,[en]:j?``:void 0,[yl]:j?void 0:``},p],stateAttributesMapping:Xt})}),Cl=l.createContext(void 0);function wl(){let e=l.useContext(Cl);if(e===void 0)throw Error(Mi(70));return e}var Tl=l.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:u}=ga({container:r,ref:t,componentProps:e,elementProps:s});return!u&&!c?null:(0,Q.jsxs)(l.Fragment,{children:[u,c&&fa.createPortal(n,c)]})}),El=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return ul().useState(`mounted`)||n?(0,Q.jsx)(Cl.Provider,{value:n,children:(0,Q.jsx)(Tl,{ref:t,...r})}):null}),Dl=l.createContext(void 0);function Ol(){let e=l.useContext(Dl);if(e===void 0)throw Error(Mi(71));return e}var kl=l.createContext(void 0);function Al(){return l.useContext(kl)?.direction??`ltr`}var jl=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,offsetParent:d=`real`}=ur(e,t)||{};if(l==null)return{};let f=Or(u),p={x:n,y:r},m=gr(i),h=mr(m),g=await o.getDimensions(l),_=m===`y`,v=_?`top`:`left`,y=_?`bottom`:`right`,b=_?`clientHeight`:`clientWidth`,x=a.reference[h]+a.reference[m]-p[m]-a.floating[h],S=p[m]-a.reference[m],C=d===`real`?await o.getOffsetParent?.(l):s.floating,w=s.floating[b]||a.floating[h];(!w||!await o.isElement?.(C))&&(w=s.floating[b]||a.floating[h]);let T=x/2-S/2,E=w/2-g[h]/2-1,D=Math.min(f[v],E),O=Math.min(f[y],E),k=D,A=w-g[h]-O,j=w/2-g[h]/2+T,M=lr(k,j,A),N=!c.arrow&&fr(i)!=null&&j!==M&&a.reference[h]/2-(j<k?D:O)-g[h]/2<0,P=N?j<k?j-k:j-A:0;return{[m]:p[m]+P,data:{[m]:M,centerOffset:j-M-P,...N&&{alignmentOffset:P}},reset:N}}}),Ml=(e,t)=>{let{name:n,fn:r}=jl(e);return{name:n,fn:r,options:[e,t]}},Nl={name:`hide`,async fn(e){let{width:t,height:n,x:r,y:i}=e.rects.reference,a=t===0&&n===0&&r===0&&i===0,o=await e.platform.detectOverflow(e,{elementContext:`reference`});return{data:{referenceHidden:o.top-n>=0||o.right-t>=0||o.bottom-n>=0||o.left-t>=0||a}}}},Pl={sideX:`left`,sideY:`top`},Fl=`--available-width`,Il=`--available-height`,Ll=`--anchor-width`,Rl=`--anchor-height`,zl=`--transform-origin`,Bl=Fl,Vl=Il;function Hl(e,t,n){let r=e===`inline-start`||e===`inline-end`;return{top:`top`,right:r?n?`inline-start`:`inline-end`:`right`,bottom:`bottom`,left:r?n?`inline-end`:`inline-start`:`left`}[t]}function Ul(e,t,n){let{rects:r,placement:i}=e;return{side:Hl(t,dr(i),n),align:fr(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Wl(e){return Gl(e,Ks)}function Gl(e,t){let{anchor:n,positionMethod:r=`absolute`,side:i=`bottom`,sideOffset:a=0,align:o=`center`,alignOffset:s=0,collisionBoundary:c,collisionPadding:u=5,sticky:d=!1,arrowPadding:f=5,disableAnchorTracking:p=!1,inline:m,keepMounted:h=!1,floatingRootContext:g,mounted:_,collisionAvoidance:v,shift:y,nodeId:b,adaptiveOrigin:x,lazyFlip:S=!1,externalTree:C}=e,[w,T]=l.useState(null);!_&&w!==null&&T(null);let E=v.side||`flip`,D=v.align||`flip`,O=v.fallbackAxisSide||`end`,k=y?.crossAxis??!1,A=y?.rootBoundary,j=typeof n==`function`?n:void 0,M=$(j),N=j?M:n,P=Kn(n),F=Kn(_),I=Al()===`rtl`,L=w||{top:`top`,right:`right`,bottom:`bottom`,left:`left`,"inline-end":I?`left`:`right`,"inline-start":I?`right`:`left`}[i],R=o===`center`?L:`${L}-${o}`,z=u;typeof z==`number`?z={top:z,right:z,bottom:z,left:z}:z&&={top:z.top||0,right:z.right||0,bottom:z.bottom||0,left:z.left||0};let B=+(i===`bottom`),V=+(i===`top`),ee=+(i===`right`),te=+(i===`left`),ne={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:z},H=l.useRef(null),U=Kn(a),re=Kn(s),ie=typeof a==`function`?0:a,ae=typeof s==`function`?0:s,oe=[];m&&oe.push(m),oe.push(Uo(e=>{let t=Ul(e,i,I),n=typeof U.current==`function`?U.current(t):U.current,r=typeof re.current==`function`?re.current(t):re.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[ie,ae,I,i]));let se=D===`none`&&E!==`shift`,ce=!se&&(d||k||E===`shift`),le=E===`none`?null:Ko({...ne,padding:{top:z.top+1+B,right:z.right+1+te,bottom:z.bottom+1+V,left:z.left+1+ee},mainAxis:!k&&E===`flip`,crossAxis:D===`flip`&&`alignment`,fallbackAxisSideDirection:O}),ue=se?null:Wo({...ne,rootBoundary:A,mainAxis:D!==`none`,crossAxis:ce,limiter:d||k?void 0:Go(e=>{if(!H.current)return{};let{width:t,height:n}=H.current.getBoundingClientRect(),r=hr(dr(e.placement)),i=r===`y`?t:n,a=r===`y`?z.left+z.right:z.top+z.bottom;return{offset:i/2+a/2}})},[ne,d,k,A,z,D]);E===`shift`||D===`shift`||o===`center`?oe.push(ue,le):oe.push(le,ue),oe.push(qo({...ne,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!F.current)return;let i=e.style;i.setProperty(Bl,`${t}px`),i.setProperty(Vl,`${n}px`);let a=G(e).devicePixelRatio||1,{x:o,y:s,width:c,height:l}=r.reference,u=(Math.round((o+c)*a)-Math.round(o*a))/a,d=(Math.round((s+l)*a)-Math.round(s*a))/a;i.setProperty(Ll,`${u}px`),i.setProperty(Rl,`${d}px`)}}),Ml(e=>({element:H.current||J(e.elements.floating).createElement(`div`),padding:H.current?f:0,offsetParent:`floating`}),[f]),{name:`transformOrigin`,fn(e){let{elements:{floating:t},middlewareData:n,placement:r,platform:o,rects:s,y:c}=e,l=dr(r),u=fr(r),d=hr(l)===`y`,f=H.current,p=typeof a==`function`?a(Ul(e,i,I)):a,m;m=!f&&u&&Math.abs(d?n.shift?.x||0:n.shift?.y||0)<=1?u===`start`===(d&&o.isRTL?.(t)===!0)?`100%`:`0%`:`${(d?n.arrow?.x||0:n.arrow?.y||0)+(d?f?.clientWidth||0:f?.clientHeight||0)/2}px`;let h=l===`top`||l===`left`?`calc(100% + ${p}px)`:`${-p}px`;return ce&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(zl,d?`${m} ${h}`:`${h} ${m}`),{}}},Nl,x),W(()=>{!_&&g&&g.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[_,g]);let de=l.useMemo(()=>({ancestorScroll:!p,elementResize:!p&&typeof ResizeObserver<`u`,layoutShift:!p&&typeof IntersectionObserver<`u`}),[p]),{refs:fe,elements:pe,x:me,y:he,middlewareData:ge,update:_e,placement:K,context:ve,isPositioned:ye,floatingStyles:be}=t({rootContext:g,open:h?_:void 0,placement:R,middleware:oe,strategy:r,whileElementsMounted:h?void 0:(...e)=>Ao(...e,de),nodeId:b,externalTree:C}),{sideX:xe,sideY:Se}=ge.adaptiveOrigin||Pl,Ce=ye?r:`fixed`,we=l.useMemo(()=>{let e;return e=ye?x?{position:Ce,[xe]:me,[Se]:he}:{...be,position:Ce}:{position:Ce,top:0,left:0},e[Bl]=`100vw`,e[Vl]=`100vh`,ye||(e.opacity=0),e},[x,Ce,xe,me,Se,he,be,ye]),Te=l.useRef(null);W(()=>{if(!_)return;let e=P.current,t=typeof e==`function`?e():e,n=(Kl(t)?t.current:t)||null;n!==Te.current&&(fe.setPositionReference(n),Te.current=n)},[_,fe,N,P]),l.useEffect(()=>{if(!_)return;let e=P.current;typeof e!=`function`&&Kl(e)&&e.current!==Te.current&&(fe.setPositionReference(e.current),Te.current=e.current)},[_,fe,N,P]),l.useEffect(()=>{if(h&&_&&pe.reference&&pe.floating)return Ao(pe.reference,pe.floating,_e,de)},[h,_,pe,_e,de]);let Ee=dr(K),De=Hl(i,Ee,I),Oe=fr(K)||`center`,ke=!!ge.hide?.referenceHidden;W(()=>{S&&_&&ye&&Ee!==L&&T(Ee)},[S,_,ye,Ee,L]);let Ae=l.useMemo(()=>({position:`absolute`,top:ge.arrow?.y,left:ge.arrow?.x}),[ge.arrow]),je=ge.arrow?.centerOffset!==0;return l.useMemo(()=>({positionerStyles:we,arrowStyles:Ae,arrowRef:H,arrowUncentered:je,side:De,align:Oe,physicalSide:Ee,anchorHidden:ke,refs:fe,context:ve,isPositioned:ye,update:_e}),[we,Ae,H,je,De,Oe,Ee,ke,fe,ve,ye,_e])}function Kl(e){return e!=null&&`current`in e}function ql(e){return e===`starting`?ca:nt}function Jl(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),ta(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},ql(r),i],stateAttributesMapping:Qt})}var Yl=l.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a=`absolute`,side:o=`top`,align:s=`center`,sideOffset:c=0,alignOffset:u=0,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f=5,arrowPadding:p=5,sticky:m=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=ua,style:_,...v}=e,y=ul(),b=wl(),x=y.useState(`open`),S=y.useState(`mounted`),C=y.useState(`trackCursorAxis`),w=y.useState(`disableHoverablePopup`),T=y.useState(`floatingRootContext`),E=y.useState(`instantType`),D=y.useState(`transitionStatus`),O=Wl({anchor:i,positionMethod:a,floatingRootContext:T,mounted:S,side:o,sideOffset:c,align:s,alignOffset:u,collisionBoundary:d,collisionPadding:f,sticky:m,arrowPadding:p,disableAnchorTracking:h,keepMounted:b,collisionAvoidance:g,adaptiveOrigin:y.useState(`adaptiveOrigin`)}),k=Jl(e,l.useMemo(()=>({open:x,side:O.side,align:O.align,anchorHidden:O.anchorHidden,instant:C===`none`?E:`tracking-cursor`}),[x,O.side,O.align,O.anchorHidden,C,E]),{styles:O.positionerStyles,transitionStatus:D,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!S,inert:!x||C===`both`||w});return(0,Q.jsx)(Dl.Provider,{value:O,children:k})}),Xl=l.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=ul(),{side:s,align:c}=Ol(),l=o.useState(`open`),u=o.useState(`instantType`),d=o.useState(`transitionStatus`),f=o.useState(`popupProps`),p=o.useState(`floatingRootContext`),m=o.useState(`disabled`),h=o.useState(`closeDelay`);xs({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),tc(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return ta(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[Ss,f,ql(d),a],stateAttributesMapping:$t})});function Zl({label:e,side:t=`top`,children:n}){return(0,Q.jsxs)(hl,{children:[(0,Q.jsx)(Sl,{render:n}),(0,Q.jsx)(El,{children:(0,Q.jsx)(Yl,{className:`tooltip-positioner`,side:t,sideOffset:8,collisionPadding:8,children:(0,Q.jsx)(Xl,{className:`tooltip-popup`,children:e})})})]})}var Ql={clover:{label:`Clover`,color:`#35B8FF`,face:`eyes`,faceX:50,faceY:50,faceScale:1},flower:{label:`Flower`,color:`#2FCB7A`,face:`eyes`,faceX:50,faceY:51,faceScale:.95},triangle:{label:`Triangle`,color:`#DC48FF`,face:`eyes`,faceX:50,faceY:61,faceScale:.9},square:{label:`Square`,color:`#35B8FF`,face:`eyes`,faceX:50,faceY:50,faceScale:1},blob:{label:`Blob`,color:`#2FCB7A`,face:`eyes`,faceX:49.5,faceY:50,faceScale:1},ghost:{label:`Ghost`,color:`#F4F2FA`,face:`eyes`,faceX:50,faceY:48,faceScale:.95},circle:{label:`Circle`,color:`#9A62FF`,face:`eyes`,faceX:50,faceY:50,faceScale:1},drop:{label:`Drop`,color:`#1ED3C6`,face:`eyes`,faceX:50,faceY:62,faceScale:.9},star:{label:`Star`,color:`#FFD32B`,face:`eyes`,faceX:50,faceY:52,faceScale:.82},droid:{label:`Droid`,color:`#D5DBEA`,face:`eyes`,faceX:50,faceY:60,faceScale:.95},mech:{label:`Mech`,color:`#95A6C4`,face:`eyes`,faceX:50,faceY:59,faceScale:1},alien:{label:`Alien`,color:`#9BE85A`,face:`eyes`,faceX:50,faceY:45,faceScale:1.05},hexagon:{label:`Hexagon`,color:`#FF2A2A`,face:`eyes`,faceX:50,faceY:50,faceScale:.95},cat:{label:`Cat`,color:`#FF8C42`,face:`eyes`,faceX:50,faceY:58,faceScale:1},cloud:{label:`Cloud`,color:`#CFE6FF`,face:`eyes`,faceX:50,faceY:58,faceScale:.95},pill:{label:`Pill`,color:`#7B77F0`,face:`eyes`,faceX:50,faceY:50,faceScale:.9},pebble:{label:`Pebble`,color:`#2FCB7A`,face:`eyes`,faceX:50,faceY:50,faceScale:.95},puddle:{label:`Puddle`,color:`#FF2A2A`,face:`eyes`,faceX:50,faceY:50,faceScale:.95}},$l=Object.keys(Ql);Object.fromEntries($l.map(e=>[e,Ql[e].color]));var eu={default:`idle`,working:`working`,sleeping:`sleeping`},tu={clover:`M26.53 22.38A25 25 0 0 1 73.47 22.38A7 7 0 0 0 77.62 26.53A25 25 0 0 1 77.62 73.47A7 7 0 0 0 73.47 77.62A25 25 0 0 1 26.53 77.62A7 7 0 0 0 22.38 73.47A25 25 0 0 1 22.38 26.53A7 7 0 0 0 26.53 22.38Z`,flower:`M31.2 19.82A20.5 20.5 0 0 1 68.8 19.82A5 5 0 0 0 72.9 22.8A20.5 20.5 0 0 1 84.51 58.55A5 5 0 0 0 82.95 63.37A20.5 20.5 0 0 1 52.54 85.47A5 5 0 0 0 47.46 85.47A20.5 20.5 0 0 1 17.05 63.37A5 5 0 0 0 15.49 58.55A20.5 20.5 0 0 1 27.1 22.8A5 5 0 0 0 31.2 19.82Z`,triangle:`M38.75 27.43A13 13 0 0 1 61.25 27.43L82.7 64.49A13 13 0 0 1 71.45 84L28.55 84A13 13 0 0 1 17.3 64.49L38.75 27.43Z`,square:`M93 50C93 53.66 92.96 58.23 92.88 60.97C92.8 63.71 92.67 64.81 92.51 66.44C92.35 68.08 92.15 69.44 91.9 70.77C91.66 72.1 91.37 73.3 91.04 74.44C90.72 75.58 90.35 76.63 89.94 77.63C89.53 78.63 89.07 79.55 88.58 80.43C88.08 81.31 87.54 82.13 86.96 82.9C86.37 83.67 85.75 84.39 85.07 85.07C84.39 85.75 83.67 86.37 82.9 86.96C82.13 87.54 81.31 88.08 80.43 88.58C79.55 89.07 78.63 89.53 77.63 89.94C76.63 90.35 75.58 90.72 74.44 91.04C73.3 91.37 72.1 91.66 70.77 91.9C69.44 92.15 68.08 92.35 66.44 92.51C64.81 92.67 63.71 92.8 60.97 92.88C58.23 92.96 53.66 93 50 93C46.34 93 41.77 92.96 39.03 92.88C36.29 92.8 35.19 92.67 33.56 92.51C31.92 92.35 30.56 92.15 29.23 91.9C27.9 91.66 26.7 91.37 25.56 91.04C24.42 90.72 23.37 90.35 22.37 89.94C21.37 89.53 20.45 89.07 19.57 88.58C18.69 88.08 17.87 87.54 17.1 86.96C16.33 86.37 15.61 85.75 14.93 85.07C14.25 84.39 13.63 83.67 13.04 82.9C12.46 82.13 11.92 81.31 11.42 80.43C10.93 79.55 10.47 78.63 10.06 77.63C9.65 76.63 9.28 75.58 8.96 74.44C8.63 73.3 8.34 72.1 8.1 70.77C7.85 69.44 7.65 68.08 7.49 66.44C7.33 64.81 7.2 63.71 7.12 60.97C7.04 58.23 7 53.66 7 50C7 46.34 7.04 41.77 7.12 39.03C7.2 36.29 7.33 35.19 7.49 33.56C7.65 31.92 7.85 30.56 8.1 29.23C8.34 27.9 8.63 26.7 8.96 25.56C9.28 24.42 9.65 23.37 10.06 22.37C10.47 21.37 10.93 20.45 11.42 19.57C11.92 18.69 12.46 17.87 13.04 17.1C13.63 16.33 14.25 15.61 14.93 14.93C15.61 14.25 16.33 13.63 17.1 13.04C17.87 12.46 18.69 11.92 19.57 11.42C20.45 10.93 21.37 10.47 22.37 10.06C23.37 9.65 24.42 9.28 25.56 8.96C26.7 8.63 27.9 8.34 29.23 8.1C30.56 7.85 31.92 7.65 33.56 7.49C35.19 7.33 36.29 7.2 39.03 7.12C41.77 7.04 46.34 7 50 7C53.66 7 58.23 7.04 60.97 7.12C63.71 7.2 64.81 7.33 66.44 7.49C68.08 7.65 69.44 7.85 70.77 8.1C72.1 8.34 73.3 8.63 74.44 8.96C75.58 9.28 76.63 9.65 77.63 10.06C78.63 10.47 79.55 10.93 80.43 11.42C81.31 11.92 82.13 12.46 82.9 13.04C83.67 13.63 84.39 14.25 85.07 14.93C85.75 15.61 86.37 16.33 86.96 17.1C87.54 17.87 88.08 18.69 88.58 19.57C89.07 20.45 89.53 21.37 89.94 22.37C90.35 23.37 90.72 24.42 91.04 25.56C91.37 26.7 91.66 27.9 91.9 29.23C92.15 30.56 92.35 31.92 92.51 33.56C92.67 35.19 92.8 36.29 92.88 39.03C92.96 41.77 93 46.34 93 50Z`,blob:`M93.92 50C94.18 51.9 94.24 53.9 93.99 55.79C93.73 57.68 93.18 59.61 92.39 61.36C91.6 63.1 90.48 64.78 89.27 66.27C88.07 67.76 86.58 69.08 85.14 70.29C83.7 71.49 82.1 72.5 80.62 73.5C79.14 74.49 77.64 75.34 76.24 76.24C74.84 77.15 73.51 78 72.2 78.93C70.88 79.86 69.66 80.83 68.36 81.8C67.06 82.76 65.78 83.82 64.39 84.74C63 85.67 61.55 86.63 60.01 87.35C58.47 88.08 56.82 88.73 55.15 89.1C53.48 89.47 51.71 89.64 50 89.57C48.29 89.5 46.55 89.16 44.91 88.68C43.27 88.21 41.67 87.47 40.16 86.72C38.65 85.96 37.24 85.02 35.86 84.13C34.48 83.24 33.19 82.29 31.89 81.37C30.58 80.46 29.32 79.56 28.03 78.63C26.74 77.71 25.44 76.82 24.16 75.84C22.88 74.86 21.57 73.87 20.36 72.74C19.15 71.62 17.95 70.42 16.91 69.1C15.88 67.79 14.92 66.35 14.15 64.85C13.38 63.35 12.76 61.73 12.29 60.1C11.81 58.48 11.52 56.78 11.29 55.1C11.06 53.41 10.98 51.71 10.91 50C10.83 48.29 10.83 46.59 10.83 44.84C10.84 43.1 10.85 41.34 10.93 39.53C11.02 37.72 11.09 35.86 11.34 33.99C11.59 32.12 11.88 30.16 12.43 28.31C12.99 26.46 13.69 24.56 14.66 22.88C15.64 21.21 16.86 19.58 18.27 18.27C19.69 16.96 21.4 15.84 23.17 15.03C24.93 14.22 26.95 13.71 28.89 13.43C30.83 13.15 32.9 13.21 34.82 13.36C36.74 13.5 38.66 13.92 40.43 14.28C42.2 14.65 43.87 15.16 45.46 15.54C47.06 15.93 48.52 16.31 50 16.58C51.48 16.85 52.87 17.02 54.32 17.17C55.77 17.32 57.22 17.36 58.71 17.49C60.2 17.62 61.74 17.7 63.28 17.95C64.81 18.19 66.39 18.5 67.91 18.98C69.43 19.46 70.95 20.08 72.38 20.83C73.81 21.58 75.19 22.5 76.5 23.5C77.81 24.5 79.03 25.63 80.22 26.81C81.41 27.99 82.54 29.25 83.65 30.57C84.76 31.89 85.85 33.26 86.89 34.72C87.93 36.18 88.98 37.69 89.9 39.31C90.82 40.92 91.73 42.64 92.4 44.42C93.07 46.2 93.66 48.1 93.92 50Z`,ghost:`M17 50C17 31.78 31.78 17 50 17C68.22 17 83 31.78 83 50V81.5Q72 93.5 61 81.5Q50 93.5 39 81.5Q28 93.5 17 81.5Z`,circle:`M50 8A42 42 0 1 1 50 92A42 42 0 1 1 50 8Z`,drop:`M50 8.5C52.2 8.5 53.4 10.3 56.4 15.2C62.9 25.5 84 44.6 84 61.5C84 80.3 68.8 92 50 92C31.2 92 16 80.3 16 61.5C16 44.6 37.1 25.5 43.6 15.2C46.6 10.3 47.8 8.5 50 8.5Z`,star:`M45.77 9.7A5 5 0 0 1 54.23 9.7L65.02 26.81A4 4 0 0 0 67.42 28.55L87.02 33.53A5 5 0 0 1 89.63 41.57L76.7 57.12A4 4 0 0 0 75.78 59.94L77.11 80.12A5 5 0 0 1 70.26 85.09L51.48 77.59A4 4 0 0 0 48.52 77.59L29.74 85.09A5 5 0 0 1 22.89 80.12L24.22 59.94A4 4 0 0 0 23.3 57.12L10.37 41.57A5 5 0 0 1 12.98 33.53L32.58 28.55A4 4 0 0 0 34.98 26.81L45.77 9.7Z`,droid:`M16 50C16 38.95 24.95 30 36 30H64C75.05 30 84 38.95 84 50V70C84 81.05 75.05 90 64 90H36C24.95 90 16 81.05 16 70ZM4 62A7 7 0 1 1 18 62A7 7 0 1 1 4 62ZM82 62A7 7 0 1 1 96 62A7 7 0 1 1 82 62Z`,mech:`M10 48C10 38.06 18.06 30 28 30H72C81.94 30 90 38.06 90 48V70C90 79.94 81.94 88 72 88H28C18.06 88 10 79.94 10 70ZM3 54C3 51.79 4.79 50 7 50H11V72H7C4.79 72 3 70.21 3 68ZM89 50H93C95.21 50 97 51.79 97 54V68C97 70.21 95.21 72 93 72H89Z`,alien:`M50 10C70 10 83 27 83 46C83 65 64 92 50 92C36 92 17 65 17 46C17 27 30 10 50 10Z`,hexagon:`M91.4 45.5A9 9 0 0 1 91.4 54.5L74.6 83.61A9 9 0 0 1 66.8 88.11L33.2 88.11A9 9 0 0 1 25.4 83.61L8.6 54.5A9 9 0 0 1 8.6 45.5L25.4 16.39A9 9 0 0 1 33.2 11.89L66.8 11.89A9 9 0 0 1 74.6 16.39L91.4 45.5Z`,cat:`M50 20A36 36 0 1 1 50 92A36 36 0 1 1 50 20ZM24.72 44.64A4.5 4.5 0 0 1 17.35 40.67L20.21 16.66A4.5 4.5 0 0 1 26.86 13.26L42.3 21.83A4.5 4.5 0 0 1 43.02 29.21L24.72 44.64ZM82.65 40.67A4.5 4.5 0 0 1 75.28 44.64L56.98 29.21A4.5 4.5 0 0 1 57.7 21.83L73.14 13.26A4.5 4.5 0 0 1 79.79 16.66L82.65 40.67Z`,cloud:`M19 44A25 25 0 1 1 69 44A25 25 0 1 1 19 44ZM47 50A21 21 0 1 1 89 50A21 21 0 1 1 47 50ZM7 68A17 17 0 1 1 41 68A17 17 0 1 1 7 68ZM32 73A18 18 0 1 1 68 73A18 18 0 1 1 32 73ZM60 70A16 16 0 1 1 92 70A16 16 0 1 1 60 70Z`,pill:`M28 28H72C84.15 28 94 37.85 94 50C94 62.15 84.15 72 72 72H28C15.85 72 6 62.15 6 50C6 37.85 15.85 28 28 28Z`,pebble:`M94.6 50C94.71 51.92 94.56 53.93 94.17 55.82C93.79 57.7 93.13 59.6 92.28 61.33C91.44 63.06 90.32 64.72 89.1 66.19C87.87 67.67 86.41 69.01 84.92 70.16C83.42 71.31 81.75 72.29 80.11 73.1C78.47 73.92 76.73 74.55 75.06 75.06C73.39 75.58 71.7 75.91 70.1 76.2C68.5 76.48 66.93 76.62 65.45 76.76C63.96 76.9 62.55 76.94 61.2 77.03C59.84 77.11 58.57 77.16 57.31 77.26C56.05 77.36 54.86 77.48 53.64 77.63C52.42 77.79 51.24 77.98 50 78.18C48.76 78.39 47.52 78.64 46.2 78.85C44.89 79.06 43.53 79.3 42.11 79.46C40.69 79.61 39.2 79.75 37.67 79.77C36.14 79.78 34.54 79.74 32.95 79.54C31.35 79.33 29.7 79.03 28.1 78.55C26.49 78.07 24.86 77.45 23.33 76.67C21.8 75.88 20.29 74.94 18.92 73.85C17.54 72.77 16.23 71.51 15.08 70.16C13.94 68.8 12.9 67.29 12.04 65.72C11.17 64.16 10.45 62.46 9.91 60.74C9.36 59.03 8.98 57.22 8.76 55.43C8.55 53.64 8.5 51.8 8.6 50C8.71 48.2 8.98 46.39 9.38 44.65C9.79 42.91 10.35 41.19 11.02 39.56C11.7 37.92 12.52 36.34 13.43 34.85C14.34 33.37 15.39 31.96 16.5 30.66C17.61 29.36 18.84 28.15 20.11 27.07C21.39 25.98 22.76 25 24.15 24.15C25.54 23.3 27.01 22.56 28.48 21.95C29.94 21.33 31.46 20.85 32.95 20.46C34.44 20.08 35.95 19.83 37.43 19.66C38.91 19.48 40.38 19.43 41.81 19.43C43.24 19.43 44.64 19.53 46.01 19.66C47.37 19.78 48.7 19.98 50 20.18C51.3 20.39 52.57 20.63 53.83 20.87C55.1 21.11 56.34 21.37 57.6 21.62C58.87 21.87 60.13 22.12 61.43 22.39C62.74 22.66 64.07 22.93 65.45 23.24C66.83 23.56 68.25 23.88 69.72 24.3C71.19 24.72 72.71 25.17 74.25 25.75C75.78 26.34 77.37 27 78.91 27.81C80.46 28.63 82.04 29.56 83.5 30.66C84.97 31.75 86.43 33 87.7 34.38C88.98 35.77 90.19 37.32 91.17 38.97C92.14 40.62 92.98 42.43 93.56 44.27C94.13 46.1 94.5 48.08 94.6 50Z`,puddle:`M85.34 50C85.65 51.54 85.9 53.13 86.01 54.74C86.11 56.35 86.11 58 85.95 59.63C85.8 61.26 85.51 62.93 85.07 64.52C84.62 66.12 84.03 67.72 83.3 69.23C82.58 70.74 81.7 72.21 80.72 73.57C79.74 74.94 78.62 76.23 77.43 77.43C76.24 78.62 74.93 79.72 73.58 80.73C72.23 81.74 70.79 82.65 69.33 83.48C67.86 84.31 66.34 85.04 64.79 85.71C63.24 86.37 61.65 86.95 60.04 87.46C58.42 87.96 56.77 88.4 55.1 88.75C53.43 89.09 51.72 89.37 50 89.54C48.28 89.71 46.52 89.81 44.76 89.76C43.01 89.72 41.22 89.58 39.47 89.29C37.72 89 35.95 88.58 34.26 88C32.57 87.42 30.89 86.69 29.33 85.8C27.77 84.92 26.26 83.87 24.91 82.7C23.56 81.53 22.3 80.19 21.23 78.77C20.16 77.35 19.22 75.79 18.47 74.2C17.71 72.61 17.13 70.91 16.7 69.23C16.26 67.55 16.02 65.81 15.88 64.13C15.75 62.45 15.78 60.76 15.88 59.14C15.97 57.52 16.21 55.94 16.45 54.42C16.7 52.89 17.03 51.43 17.34 50C17.65 48.57 18 47.2 18.32 45.83C18.63 44.46 18.94 43.13 19.24 41.76C19.53 40.39 19.79 39.03 20.08 37.61C20.36 36.18 20.62 34.74 20.95 33.23C21.28 31.72 21.61 30.16 22.07 28.57C22.52 26.98 23.02 25.32 23.69 23.69C24.35 22.06 25.11 20.38 26.05 18.79C26.99 17.21 28.08 15.62 29.33 14.2C30.58 12.78 32 11.41 33.54 10.26C35.08 9.12 36.8 8.11 38.57 7.35C40.34 6.6 42.27 6.04 44.17 5.73C46.08 5.43 48.08 5.37 50 5.54C51.92 5.71 53.87 6.15 55.69 6.75C57.52 7.36 59.3 8.22 60.94 9.19C62.57 10.15 64.11 11.33 65.51 12.56C66.91 13.78 68.17 15.15 69.33 16.52C70.48 17.89 71.5 19.34 72.44 20.76C73.38 22.18 74.19 23.62 74.97 25.03C75.75 26.43 76.44 27.83 77.12 29.19C77.8 30.56 78.42 31.89 79.05 33.23C79.67 34.57 80.28 35.87 80.87 37.21C81.46 38.55 82.05 39.88 82.6 41.27C83.14 42.65 83.68 44.05 84.14 45.51C84.6 46.96 85.03 48.46 85.34 50Z`},nu={droid:`M47.5 14H52.5V32H47.5ZM43 11A7 7 0 1 1 57 11A7 7 0 1 1 43 11Z`,mech:`M19.5 32L24.5 32L17 13L12 13ZM75.5 32L80.5 32L88 13L83 13ZM10 11.5A4.5 4.5 0 1 1 19 11.5A4.5 4.5 0 1 1 10 11.5ZM81 11.5A4.5 4.5 0 1 1 90 11.5A4.5 4.5 0 1 1 81 11.5Z`};function ru(e){let t=e.trim(),n=t.match(/^hsla?\(\s*([\d.]+)(?:deg)?[,\s]+([\d.]+)%[,\s]+([\d.]+)%/i);if(n)return lu([Number(n[1])/360,Number(n[2])/100,Number(n[3])/100]);let r=t.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(r){let e=r[1];e.length===3&&(e=e.split(``).map(e=>e+e).join(``));let t=parseInt(e,16);return[t>>16&255,t>>8&255,t&255]}let i=t.match(/^rgba?\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);return i?[Number(i[1]),Number(i[2]),Number(i[3])]:null}function iu(e){let t=ru(e);if(!t)return .5;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4};return .2126*n(t[0])+.7152*n(t[1])+.0722*n(t[2])}var au=`#1E1A33`,ou=`#F7F5F2`;function su(e){return iu(e)<.13?ou:au}function cu([e,t,n]){e/=255,t/=255,n/=255;let r=Math.max(e,t,n),i=Math.min(e,t,n),a=(r+i)/2;if(r===i)return[0,0,a];let o=r-i,s=a>.5?o/(2-r-i):o/(r+i),c=0;return c=r===e?(t-n)/o+(t<n?6:0):r===t?(n-e)/o+2:(e-t)/o+4,[c/6,s,a]}function lu([e,t,n]){if(t===0)return[n*255,n*255,n*255];let r=n<.5?n*(1+t):n+t-n*t,i=2*n-r,a=e=>(e=(e%1+1)%1,e<1/6?i+(r-i)*6*e:e<1/2?r:e<2/3?i+(r-i)*(2/3-e)*6:i);return[a(e+1/3)*255,a(e)*255,a(e-1/3)*255]}function uu([e,t,n]){return`hsl(${(e*360).toFixed(1)} ${(t*100).toFixed(1)}% ${(n*100).toFixed(1)}%)`}var du=e=>Math.min(1,Math.max(0,e));function fu(e,t,n=0){let r=ru(e);if(!r)return e;let[i,a,o]=cu(r);return uu([i,du(a+n+(t<0?-t*.25:0)),du(o+t)])}var pu=[`default`,`working`,`sleeping`],mu=.68,hu=26,gu=.2,_u={height:hu,time:mu,stretch:1,squash:1.15,squashTime:.37,squashEase:`pulse`,groundTime:.11,groundEase:`pulse`,riseTime:.33,riseEase:`pulse`,clickSquashTime:.24,spin:1,lean:6,every:8,land:0},vu=(e,t)=>t?e.clickSquashTime:gu*e.time,yu=(e,t)=>vu(e,t)+e.time+bu[e.squashEase]*(t?e.clickSquashTime:e.squashTime)+Math.max(0,e.groundTime)+e.riseTime+Math.max(0,e.land)+.05,bu={sharp:0,pulse:2/7,soft:.5,bouncy:.144},xu=(e,t)=>{if(e<=0)return 1;if(e>=1)return 0;switch(t){case`sharp`:return(1-e)*(1-e);case`soft`:return .5+.5*Math.cos(Math.PI*e);case`bouncy`:return Math.exp(-3.2*e)*Math.cos(5.4*e)-e*e*e*.026;default:{let t=4.2*e;return(1+t)*Math.exp(-t)-e*e*e*.078}}},Su=(e,t)=>1+.25*Cu(e,t),Cu=(e,t)=>{if(e<=0||e>=1)return 0;let n;switch(t){case`sharp`:n=(1-e)*(1-e);break;case`soft`:n=Math.sin(Math.PI*e)**2;break;case`bouncy`:n=Math.exp(-3.15*e)*Math.sin(8.43*e)/.596;break;default:{let t=7*e;n=t*t*Math.exp(2-t)/4}}let r=e>.85?1-(e-.85)/.15:1;return n*r*r*(3-2*r)},wu=e=>Math.exp(-((Math.min(Math.abs(e),Math.abs(e-1))/.11)**2)),Tu=Math.PI/180,Eu=Math.PI*2,Du={default:1.2,working:.7,sleeping:1.4},Ou=1;function ku(e){let t=e*2654435761>>>0||1;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function Au(e,t,n,r){return e+(t-e)*(1-Math.exp(-n*r))}var ju=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,Mu=e=>.5-.5*Math.cos(Math.PI*e),Nu=class{constructor(e,t,n,r,i,a=!1){this.rand=e,this.amp=t,this.holdMin=n,this.holdMax=r,this.rate=i,this.spring=a,this.value=0,this.vel=0,this.target=0,this.next=0}update(e,t){if(e>=this.next&&(this.target=(this.rand()*2-1)*this.amp,this.next=e+this.holdMin+this.rand()*(this.holdMax-this.holdMin)),this.spring){let e=this.rate*1.6;this.vel+=(e*e*(this.target-this.value)-1.8*e*this.vel)*t,this.value+=this.vel*t}else this.value=Au(this.value,this.target,this.rate,t)}aim(e){this.target=e,this.next=1/0}set(e,t,n,r){this.amp=e,this.holdMin=t,this.holdMax=n,this.rate=r,this.next=0}},Pu=class{constructor(e){this.duration=e,this.p=-1}fire(){this.p=0}get active(){return this.p>=0}update(e){this.p<0||(this.p+=e/this.duration,this.p>=1&&(this.p=-1))}},Fu=35*Tu,Iu=14*Tu,Lu=3.2*Tu,Ru=2.6,zu={default:{pitch:0,roll:0,y:0,lookX:0,lookY:0},working:{pitch:5*Tu,roll:0,y:0,lookX:0,lookY:0},sleeping:{pitch:-16*Tu,roll:6*Tu,y:3,lookX:0,lookY:1}},Bu=class{constructor(e,t=`default`){this.pose={yaw:0,pitch:0,roll:0,x:0,y:0,sx:1,sy:1,eyeOpen:1,blinkL:0,blinkR:0,lookX:0,lookY:0,breath:0,laugh:0,whirl:0,whirlAngle:0,w:[1,0,0]},this.state=`default`,this.t=0,this.wFrom=[1,0,0],this.tr=1,this.trDuration=1.2,this.blink=new Pu(.17),this.blinkAgain=!1,this.dart=new Pu(.12),this.dartX=0,this.dartY=0,this.flip=new Pu(yu(_u,!1)),this.flipPoked=!1,this.jump={..._u},this.flipSide=1,this.nod=new Pu(1.7),this.hopPhase=0,this.hopCount=0,this.hopGain=0,this.laughEv=new Pu(.8),this.prevYaw=0,this.jelly=0,this.jellyV=0,this.gazeLead=0,this.gazeDir=[0,0],this.gazeAt=0,this.turnK=1,this.breathPhase=0,this.ptrX=0,this.ptrY=0,this.ptrS=0,this.ptrTargetX=0,this.ptrTargetY=0,this.ptrTargetS=0,this.baseYaw=0,this.rand=ku(Math.floor(e*1e6)+1);let n=this.rand;this.yawW=new Nu(n,36*Tu,1.1,2.6,3,!0),this.pitchW=new Nu(n,10*Tu,1.1,2.6,2.6,!0),this.rollW=new Nu(n,5*Tu,1.6,3.2,2,!0),this.lookXW=new Nu(n,3.6,.5,2,14),this.lookYW=new Nu(n,2.4,.5,2,14),this.t=n()*10,this.hopPhase=n(),this.breathPhase=n(),this.blinkAt=this.t+1+n()*3,this.flipAt=this.nextFlip(this.t,1),this.nodAt=this.t+3+n()*4,this.dartAt=this.t+1+n()*2,this.laughAt=this.t+.6+n()*1.5,this.setState(t,!0)}setState(e,t=!1){if(e===this.state&&!t)return;let n=this.state;this.state=e;let r=this.pose.w;if(t){for(let t=0;t<3;t++)r[t]=+(pu[t]===e);this.tr=1}else this.wFrom=[r[0],r[1],r[2]],this.tr=0,this.trDuration=n===`sleeping`?Ou:Du[e];switch(e){case`default`:this.yawW.set(Fu,2.6,5.4,2),this.pitchW.set(Iu,2.8,5.8,1.8),this.rollW.set(Lu,3.4,6.6,1.5),this.gazeAt=0,this.gazeDir=[0,0],this.lookXW.set(3.6,.6,2.2,13),this.lookYW.set(2.4,.6,2.2,13),this.flipAt=this.nextFlip(this.t,.6);break;case`working`:this.yawW.set(16*Tu,.9,1.8,4),this.pitchW.set(3*Tu,1.2,2.4,3),this.rollW.set(0,1,2,3),this.lookXW.set(2,.5,1.2,12),this.lookYW.set(1,.5,1.2,12),this.hopPhase=0,this.hopCount=0,this.laughAt=this.t+.5+this.rand()*1.2;break;case`sleeping`:this.yawW.set(7*Tu,3,6,.7),this.pitchW.set(3*Tu,3,6,.7),this.rollW.set(2*Tu,3,6,.6),this.lookXW.set(0,2,4,2),this.lookYW.set(0,2,4,2),this.nodAt=this.t+2.5+this.rand()*4}}setPointer(e,t,n){this.ptrTargetX=Math.max(-1.2,Math.min(1.2,e)),this.ptrTargetY=Math.max(-1.2,Math.min(1.2,t)),this.ptrTargetS=Math.max(0,Math.min(1,n))}poke(){this.flip.active&&this.flip.p<.6||(this.flipPoked=!0,this.flip.duration=yu(this.jump,!0),this.flipSide=this.rand()<.5?-1:1,this.flip.fire(),this.flipAt=this.nextFlip(this.t,1.1))}setTurn(e){let t=Math.max(0,e);t!==this.turnK&&(this.turnK=t,this.state==="default"&&(this.gazeAt=0))}setJump(e){let t=this.jump.every;Object.assign(this.jump,e),e.every!==void 0&&e.every!==t&&(this.flipAt=this.nextFlip(this.t,1))}nextGaze(){let e=this.rand,[t,n]=this.gazeDir;if(t!==0||n!==0){let r=e();return r<.66?[-t,-n]:r<.85?[-t,n]:[0,0]}let r=[[1,-1],[-1,1],[-1,-1],[1,1]];return r[Math.floor(e()*r.length)]}nextFlip(e,t){let n=this.jump.every;return n>0?e+n*t*(.625+this.rand()*.75):1/0}update(e){e=Math.min(e,.05),this.t+=e;let t=this.t,n=this.pose,r=n.w;if(this.tr<1){this.tr=Math.min(1,this.tr+e/this.trDuration);let t=Mu(this.tr);for(let e=0;e<3;e++){let n=+(pu[e]===this.state);r[e]=this.wFrom[e]+(n-this.wFrom[e])*t}}let[i,a,o]=r,s={pitch:0,roll:0,y:0,lookX:0,lookY:0};for(let e=0;e<3;e++){let t=zu[pu[e]];s.pitch+=t.pitch*r[e],s.roll+=t.roll*r[e],s.y+=t.y*r[e],s.lookX+=t.lookX*r[e],s.lookY+=t.lookY*r[e]}if(this.state==="default"&&t>=this.gazeAt){let[e,n]=this.nextGaze();this.gazeDir=[e,n];let r=.84+this.rand()*.16;this.yawW.aim(e*Fu*r*this.turnK),this.pitchW.aim(n*Iu*r),this.rollW.aim(e*Lu*r*this.turnK),this.gazeAt=t+Ru+this.rand()*1.8000000000000003}this.yawW.update(t,e),this.pitchW.update(t,e),this.rollW.update(t,e),this.lookXW.update(t,e),this.lookYW.update(t,e),this.ptrS=Au(this.ptrS,this.ptrTargetS,8,e),this.ptrX=Au(this.ptrX,this.ptrTargetX,14,e),this.ptrY=Au(this.ptrY,this.ptrTargetY,14,e);let c=this.ptrS,l=1-.75*c;this.baseYaw=Au(this.baseYaw,this.yawW.value*l+22*Tu*this.ptrX*c,5,e);let u=s.pitch+this.pitchW.value*l-12*Tu*this.ptrY*c,d=s.roll+this.rollW.value*l,f=s.y,p=s.lookX+this.lookXW.value*l+4.5*this.ptrX*c,m=s.lookY+this.lookYW.value*l+3*this.ptrY*c,h=0,g=0,_=1,v=1,y=0,b=0,x=0,S=0,C=0,w=0,T=0,E=0,D=(e,t,n)=>{let r=Math.min(1,Math.max(0,(n-e)/(t-e)));return r*r*(3-2*r)},O=e=>D(.1,.26,e)*(1-D(.66,.9,e)),k=e=>Eu*(1.5*e+.9*ju(e));if(t>=this.blinkAt&&!this.blink.active&&i+a>.5&&(this.blink.fire(),this.blinkAgain=!this.blinkAgain&&this.rand()<.22,this.blinkAt=t+(this.blinkAgain?.28:2.2+this.rand()*2.6)),this.blink.update(e),this.blink.active&&(x=Math.sin(Math.PI*this.blink.p)),t>=this.dartAt&&!this.dart.active&&i+a>.5&&(this.dart.fire(),this.dartX=(this.rand()*2-1)*4,this.dartY=(this.rand()*2-1)*2,this.dart.duration=.25+this.rand()*.45,this.dartAt=t+1.2+this.rand()*2.6),this.dart.update(e),this.dart.active){let e=this.dart.p,t=e<.15?e/.15:e>.8?(1-e)/.2:1;S+=this.dartX*t*(i+a),C+=this.dartY*t*(i+a)}if(this.state==="default"&&t>=this.flipAt&&!this.flip.active&&(this.flipPoked=!1,this.flip.duration=yu(this.jump,!1),this.flipSide=this.rand()<.5?-1:1,this.flip.fire(),this.flipAt=this.nextFlip(t,1)),this.flip.update(e),this.flip.active){let e=this.jump,t=vu(e,this.flipPoked),n=(this.flip.p*this.flip.duration-t)/e.time,r=Math.min(1,Math.max(0,n)),i=Math.sin(Math.PI*r);h+=Eu*e.spin*ju(r),g-=e.height*i;let a=(n-1)*e.time-e.land,o=this.flipPoked?e.clickSquashTime:e.squashTime,s=e=>this.flipPoked?e*e*(3-2*e):wu(e-1),c=Math.max(0,e.groundTime),l=bu[e.squashEase]*o,u=a-l-c,d=a<=l?Cu(a/o,e.squashEase):u<=0?Su((a-l)/c,e.groundEase):xu(u/e.riseTime,e.riseEase),f=(n<0?s(Math.max(0,1+n*e.time/t)):a>0?d:n<.2?wu(n):0)*e.squash;_+=.16*f-.06*i*e.stretch,v+=-.18*f+.09*i*e.stretch,b+=this.flipSide*e.lean*Tu*i,e.spin>0&&(w=Math.max(w,i),T=Math.max(T,O(r)),E=k(r))}let A=this.jump,j=Math.max(0,A.groundTime),M=j+A.riseTime;if(this.state===`working`&&(this.hopGain=a),this.hopGain>.02&&(this.state===`working`||this.hopPhase>0)){this.hopPhase+=e/mu,this.hopPhase>=1&&(this.state===`working`?(--this.hopPhase,this.hopCount+=1):(this.hopPhase-1)*mu>=M&&(this.hopPhase=0,this.hopGain=0));let t=this.hopGain,n=Math.min(1,this.hopPhase),r=Math.sin(Math.PI*n),i=this.hopCount%3==2;g-=(i?hu:18)*r*t;let a=this.state!==`working`&&this.hopPhase>1?(this.hopPhase-1)*mu:-1,o=a<0?wu(this.hopPhase):a<j?Su(a/j,A.groundEase):xu((a-j)/A.riseTime,A.riseEase);_+=(.16*o-.06*r)*t,v+=(-.18*o+.09*r)*t,i&&(h+=Eu*ju(n)*t,w=Math.max(w,r*t),O(n)*t>T&&(T=O(n)*t,E=k(n))),b+=(this.hopCount%2==0?1:-1)*6*Tu*r*t}if(this.state===`working`&&t>=this.laughAt&&!this.laughEv.active&&(this.laughEv.fire(),this.laughEv.duration=.6+this.rand()*.5,this.laughAt=t+1.6+this.rand()*2.2),this.laughEv.update(e),this.laughEv.active){let e=this.laughEv.p;w=Math.max(w,e<.18?e/.18:e>.78?(1-e)/.22:1)}if(this.state===`sleeping`&&t>=this.nodAt&&!this.nod.active&&(this.nod.fire(),this.nodAt=t+4+this.rand()*4),this.nod.update(e),this.nod.active){let e=this.nod.p,t=e<.72?ju(e/.72):1-ju((e-.72)/.28);y-=13*Tu*t*o}this.breathPhase+=e/(3.6+1.2*o);let N=Math.sin(this.breathPhase*Eu);n.breath=N,_+=N*(.008+.014*o),v+=N*(.012+.02*o);let P=Math.sin(t*Eu/3.4)*2*(1-o);n.yaw=this.baseYaw+h;let F=this.baseYaw-this.prevYaw;F=((F+Math.PI)%Eu+Eu)%Eu-Math.PI,this.prevYaw=this.baseYaw;let I=e>0?Math.abs(F)/e:0,L=e>0?Math.max(-2.2,Math.min(2.2,F/e*2.4)):0;this.gazeLead=Au(this.gazeLead,L,9,e);let R=Math.min(.22,.055*I);this.jellyV+=(256*(R-this.jelly)-14.4*this.jellyV)*e,this.jelly+=this.jellyV*e;let z=Math.max(-.08,Math.min(.28,this.jelly))*.6;_*=1+z,v*=1-.55*z,n.pitch=u+y,n.roll=d+b,n.x=0,n.y=f+g+P,n.sx=_,n.sy=v,n.eyeOpen=1,n.laugh=Au(n.laugh,w,30,e),n.blinkL=x,n.blinkR=x,n.lookX=p+S+this.gazeLead,n.lookY=m+C,n.whirl=T,n.whirlAngle=E}};function Vu(e){let t=zu[e];return{yaw:0,pitch:t.pitch,roll:t.roll,x:0,y:t.y,sx:1,sy:1,eyeOpen:1,blinkL:0,blinkR:0,lookX:t.lookX,lookY:t.lookY,breath:0,laugh:0,whirl:0,whirlAngle:0,w:pu.map(t=>+(t===e))}}var Hu=64,Uu=4096,Wu=24,Gu=0xe8d4a51000,Ku=48*Math.PI/180,qu=Math.cos(Ku),Ju=Math.sin(Ku),Yu=(e,t)=>t+(1-t)*Math.sqrt(Math.max(0,1-e*e));function Xu(e,t,n,r,i,a){let o=0;i[0]=0,a[0]=-1e30,a[1]=1e30;for(let n=1;n<t;n++){let t=0;for(;;){let r=i[o];if(t=(e[n]+n*n-e[r]-r*r)/(2*(n-r)),t>a[o])break;o--}o++,i[o]=n,a[o]=t,a[o+1]=1e30}o=0;for(let s=0;s<t;s++){for(;a[o+1]<s;)o++;let t=i[o];n[s]=(s-t)*(s-t)+e[t],r[s]=t}}function Zu(e,t,n,r,i){let a=new Float32Array(n),o=new Float32Array(n),s=new Int32Array(n),c=new Int32Array(n),l=new Float32Array(n+1),u=new Float32Array(n*n),d=new Int32Array(n*n);for(let r=0;r<n;r++){for(let i=0;i<n;i++)a[i]=e[i*n+r]===t?0:Gu;Xu(a,n,o,s,c,l);for(let e=0;e<n;e++)u[e*n+r]=o[e],d[e*n+r]=s[e]}for(let e=0;e<n;e++){let t=e*n;for(let e=0;e<n;e++)a[e]=u[t+e];Xu(a,n,o,s,c,l);for(let e=0;e<n;e++)r[t+e]=o[e],i&&(i[t+e]=d[t+s[e]]*n+s[e])}}function Qu(e,t,n){for(let r=0;r<t;r++){let i=r*t;for(let r=0;r<t;r++){let a=r<2?0:r-2,o=r<1?0:r-1,s=r>t-2?t-1:r+1,c=r>t-3?t-1:r+2;n[i+r]=(e[i+a]+4*e[i+o]+6*e[i+r]+4*e[i+s]+e[i+c])*.0625}}for(let r=0;r<t;r++)for(let i=0;i<t;i++){let a=i<2?0:i-2,o=i<1?0:i-1,s=i>t-2?t-1:i+1,c=i>t-3?t-1:i+2;e[i*t+r]=(n[a*t+r]+4*n[o*t+r]+6*n[i*t+r]+4*n[s*t+r]+n[c*t+r])*.0625}}function $u(e,t,n){let r=[];for(let n=t,i=1;i<=4&&n%2==0||i===1;n>>=1,i<<=1){let a=new Uint8Array(n*n);for(let r=0;r<n;r++)for(let o=0;o<n;o++){let s=0;for(let n=0;n<i;n++)for(let a=0;a<i;a++)s+=e[(r*i+n)*t+o*i+a];a[r*n+o]=+(s>=128*i*i)}if(r.push({n,mask:a,phi:new Float32Array(n*n)}),i===4)break}let i=(e,t,n,r)=>{let{n:i,mask:a,phi:o}=e,s=t*t;for(let e=0;e<n;e++)for(let e=1;e<i-1;e++){let t=e*i;for(let e=1;e<i-1;e++){let n=t+e;if(!a[n])continue;let c=(o[n-1]+o[n+1]+o[n-i]+o[n+i]+s)*.25;o[n]+=r*(c-o[n])}}};for(let e=r.length-1;e>=0;e--){let t=r[e],a=1<<e;if(e<r.length-1){let n=r[e+1],i=t.n,a=n.n;for(let e=0;e<i;e++){let r=Math.min(a-1,Math.max(0,(e+.5)/2-.5)),o=r|0,s=Math.min(a-1,o+1),c=r-o;for(let r=0;r<i;r++){let l=e*i+r;if(!t.mask[l])continue;let u=Math.min(a-1,Math.max(0,(r+.5)/2-.5)),d=u|0,f=Math.min(a-1,d+1),p=u-d;t.phi[l]=(n.phi[o*a+d]*(1-p)+n.phi[o*a+f]*p)*(1-c)+(n.phi[s*a+d]*(1-p)+n.phi[s*a+f]*p)*c}}}let o=Math.min(1.9,2/(1+Math.sin(Math.PI/t.n))-.05);i(t,n*a,4,1),i(t,n*a,e===2?100:e===1?30:16,o),i(t,n*a,8,1)}return r[0].phi}var ed=[1,1,0,-1,-1,-1,0,1],td=[0,1,1,1,0,-1,-1,-1],nd=[1,Math.SQRT2,1,Math.SQRT2,1,Math.SQRT2,1,Math.SQRT2];function rd(e,t,n){let r=106/t,i=t*t,a=new Uint8Array(i);for(let t=0;t<i;t++)a[t]=+(e[t]>=128);let o=new Float32Array(i),s=new Float32Array(i),c=new Int32Array(i);Zu(a,0,t,o,null),Zu(a,1,t,s,c);let l=new Float32Array(i),u=new Float32Array(i);for(let t=0;t<i;t++){let n=e[t]/255;l[t]=r*(n>0&&n<1?n-.5:a[t]?Math.sqrt(o[t])-.5:.5-Math.sqrt(s[t]))}Qu(l,t,u),Qu(l,t,u);let d=$u(e,t,r),f=0;for(let e=0;e<i;e++)d[e]>f&&(f=d[e]);let p=2*Math.sqrt(f),m=Math.min(.9*n+.12*p,1.2*p),h=f>0?m/Math.sqrt(f):0,g=new Float32Array(i);for(let e=0;e<i;e++)g[e]=d[e]>0?h*Math.sqrt(d[e]):0;Qu(g,t,u);let _={N:t,i00:new Uint16Array(i),wx:new Uint8Array(i),wy:new Uint8Array(i),ao:new Uint8Array(i)},{i00:v,wx:y,wy:b,ao:x}=_,S=t<=64?[1,2,3,5,8]:t<=96?[1,2,4,7,11]:[1,2,4,7,11,15],C=t-1;for(let e=0;e<t;e++)for(let n=0;n<t;n++){let i=e*t+n,o=a[i]?i:s[i]<=9?c[i]:-1;if(o<0)continue;let u=o%t,d=(o-u)/t,f=u>0?u-1:0,p=u<C?u+1:C,m=d>0?d-1:0,h=d<C?d+1:C,_=-(g[d*t+p]-g[d*t+f])/(2*r),w=-(g[h*t+u]-g[m*t+u])/(2*r),T=1,E=Math.sqrt(_*_+w*w+1);_/=E,w/=E,T/=E;let D=Math.max(0,l[o]);if(D<2){let e=l[d*t+p]-l[d*t+f],n=l[h*t+u]-l[m*t+u],r=Math.hypot(e,n)||1;e/=r,n/=r;let i=.7*(1-D/2);_+=i*(-e-_),w+=i*(-n-w),T+=i*(0-T),E=Math.sqrt(_*_+w*w+T*T)||1,_/=E,w/=E,T/=E}let O=g[o],k=0;for(let e=0;e<8;e++){let n=0;for(let i=0;i<S.length;i++){let a=S[i],o=u+ed[e]*a,s=d+td[e]*a;o<0?o=0:o>C&&(o=C),s<0?s=0:s>C&&(s=C);let c=(g[s*t+o]-O)/(a*r*nd[e]);c>n&&(n=c)}k+=n/Math.sqrt(1+n*n)}let A=1-Math.min(1,D/3),j=1-.2*A*A,M=(1-.9*k/8)**1.5*j;x[i]=Math.max(1,Math.round(255*M**(1/2.2)));let N=(_*.5+.5)*63,P=(w*.5+.5)*63,F=Math.min(62,Math.max(0,N|0)),I=Math.min(62,Math.max(0,P|0));v[i]=I*Hu+F,y[i]=Math.round(255*Math.min(1,Math.max(0,N-F))),b[i]=Math.round(255*Math.min(1,Math.max(0,P-I)))}return _}function id(e){if(typeof OffscreenCanvas==`function`)return new OffscreenCanvas(e,e);if(typeof document<`u`){let t=document.createElement(`canvas`);return t.width=t.height=e,t}return null}function ad(e,t){return e.getContext(`2d`,t?{willReadFrequently:!0}:void 0)}function od(e,t){let n=id(t),r=n&&ad(n,!0);if(!r)return null;let i=106/t;r.setTransform(1/i,0,0,1/i,3/i,3/i),r.fillStyle=`#fff`,r.fill(e);let a=r.getImageData(0,0,t,t).data,o=new Uint8ClampedArray(t*t);for(let e=0;e<t*t;e++)o[e]=a[e*4+3];return o}var sd=new Map,cd=new Set,ld=new WeakMap,ud=0;function dd(e){let t=ld.get(e);return t||ld.set(e,t=`p${ud++}`),t}var fd=[],pd=!1;function md(){pd=!1;let e=fd.shift();e&&e(),fd.length&&hd()}function hd(){if(pd)return;pd=!0;let e=globalThis.requestIdleCallback;e?e(md,{timeout:120}):setTimeout(md,16)}function gd(e){fd.push(e),hd()}function _d(e,t,n,r,i){let a=`${e}|${n}|${Math.round(r)}`,o=sd.get(a);if(o)return o;let s=()=>{if(cd.delete(a),sd.has(a))return;let e=od(t,n);e&&(sd.size>=48&&sd.clear(),sd.set(a,rd(e,n,r)))};return i?(s(),sd.get(a)??null):(cd.has(a)||(cd.add(a),gd(s)),null)}function vd(e,t,n=192,r=.65){_d(e,t,yd(n),15*r,!0)}function yd(e){return e<=100?64:e<=224?96:128}var bd=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,xd=new Map;function Sd(e){let t=xd.get(e);if(!t){let n=ru(e);if(!n){let t=id(1),r=t&&ad(t,!0);if(r){r.fillStyle=e,r.fillRect(0,0,1,1);let t=r.getImageData(0,0,1,1).data;n=[t[0],t[1],t[2]]}else n=[128,128,128]}t=[bd(n[0]/255),bd(n[1]/255),bd(n[2]/255)],xd.size>200&&xd.clear(),xd.set(e,t)}return t}var Cd=2048,wd=2.5,Td=Cd/wd,Ed=new Float32Array(Cd);for(let e=0;e<Cd;e++){let t=(e+.5)/Td,n=t<=.75?t:.75+.25*(1-Math.exp(-(t-.75)/.25));Ed[e]=255*(n<=.0031308?12.92*n:1.055*n**(1/2.4)-.055)}var Dd=e=>Ed[e<=0?0:e>=wd?2047:e*Td|0],Od=1024,kd=new Map;function Ad(e){let t=kd.get(e);if(!t){t=new Float32Array(1025);for(let n=0;n<=Od;n++)t[n]=(n/Od)**+e;kd.size>16&&kd.clear(),kd.set(e,t)}return t}var jd=[.92,.96,1],Md=[1,.98,.95],Nd=(e,t,n)=>{let r=n<=e?0:n>=t?1:(n-e)/(t-e);return r*r*(3-2*r)},Pd=(e,t,n)=>1-Nd(e-t,e+t,n);function Fd(e,t,n,r){let{L:i,V:a,H:o,U:s,W:c,A:l,B:u}=n,d=Math.max(t[0],t[1],t[2],.05),f=[t[0]/d,t[1]/d,t[2]/d],p=Math.max(.03,.3-.15*r.shadow),m=.15+.14*r.spread,h=.85,g=Math.min(90,Math.round(110/r.spread**1.3)),_=Math.max(2,Math.round(8/r.spread)),v=Ad(g),y=Ad(_),b=.45*r.highlight,x=.1*r.highlight,S=.11*r.highlight,C=.3*r.rim,w=[p*f[0],p*f[1],p*f[2]];for(let n=0;n<Hu;n++)for(let r=0;r<Hu;r++){let d=r/63*2-1,f=n/63*2-1,p=d*d+f*f;if(p>1.14)continue;if(p>1){let e=1/Math.sqrt(p);d*=e,f*=e,p=1}let g=Math.sqrt(1-p),_=d*i[0]+f*i[1]+g*i[2],T=Math.max(0,d*a[0]+f*a[1]+g*a[2]),E=Math.max(0,d*o[0]+f*o[1]+g*o[2]),D=Math.min(1,Math.max(0,(_+m)/(1+m))),O=1-T,k=O*O,A=k*O,j=A*k,M=E*Od|0,N=(b*v[M]+x*y[M])*(1+3*j),P=2*T*d-a[0],F=2*T*f-a[1],I=2*T*g-a[2],L=.45+.55*Nd(-.4,.6,P*s[0]+F*s[1]+I*s[2]),R=P*c[0]+F*c[1]+I*c[2],z=0;if(R>.5){let e=(P*l[0]+F*l[1]+I*l[2])/R,t=(P*u[0]+F*u[1]+I*u[2])/R;z=Pd(.34,.12,Math.abs(e))*Pd(.12,.06,Math.abs(t))}let B=C*A*L+S*z,V=(n*Hu+r)*3;e[V]=Dd(t[0]*(w[0]+h*D)+N*Md[0]+B*jd[0]),e[V+1]=Dd(t[1]*(w[1]+h*D)+N*Md[1]+B*jd[1]),e[V+2]=Dd(t[2]*(w[2]+h*D)+N*Md[2]+B*jd[2])}}function Id(e,t,n,r){let i=(t*.5+.5)*63,a=(n*.5+.5)*63,o=Math.min(62,Math.max(0,i|0)),s=Math.min(62,Math.max(0,a|0)),c=i-o,l=a-s,u=(s*Hu+o)*3,d=(1-c)*(1-l),f=c*(1-l),p=(1-c)*l,m=c*l;for(let t=0;t<3;t++)r[t]=e[u+t]*d+e[u+3+t]*f+e[u+192+t]*p+e[u+192+3+t]*m}function Ld(e,t,n,r){let{N:i,i00:a,wx:o,wy:s,ao:c}=e;for(let e=0,l=0;e<i*i;e++,l+=4){let i=c[e];if(i===0){n[l+3]=0;continue}let u=r[i],d=a[e]*3,f=o[e]*(1/255),p=s[e]*(1/255),m=(1-f)*(1-p)*u,h=f*(1-p)*u,g=(1-f)*p*u,_=f*p*u;n[l]=t[d]*m+t[d+3]*h+t[d+192]*g+t[d+192+3]*_,n[l+1]=t[d+1]*m+t[d+4]*h+t[d+192+1]*g+t[d+192+4]*_,n[l+2]=t[d+2]*m+t[d+5]*h+t[d+192+2]*g+t[d+192+5]*_,n[l+3]=255}}var Rd=e=>{let t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function zd(e){let t=Math.cos(e.roll),n=Math.sin(e.roll),r=t*e.lx+n*e.ly,i=-n*e.lx+t*e.ly,a=e.facing<0?-1:1,o=a*Math.min(1,Math.abs(e.facing)/.16),{cy:s,sy:c,cp:l,sp:u}=e,d=(e,t,n,r=o)=>Rd([s*e+c*u*t-c*l*n,l*t+u*n,r*(c*e-s*u*t+s*l*n)]),f=d(qu*r,qu*i,Ju),p=d(0,0,1,a),m=Rd([f[0]+p[0],f[1]+p[1],f[2]+p[2]]),h=d(r,i,0,a),g=Math.cos(80*Math.PI/180),_=Math.sin(80*Math.PI/180),v=g*r-_*i,y=_*r+g*i,b=Rd([.55*v,.55*y,.83]),x=Rd([b[1],-b[0],0]),S=[b[1]*x[2]-b[2]*x[1],b[2]*x[0]-b[0]*x[2],b[0]*x[1]-b[1]*x[0]];return{L:f,V:p,H:m,U:h,W:d(b[0],b[1],b[2],a),A:d(x[0],x[1],x[2],a),B:d(S[0],S[1],S[2],a)}}var Bd=new WeakMap;function Vd(e,t){let n=e.canvas??e,r=Bd.get(n);r||(r=new Map,Bd.set(n,r));let i=r.get(t);return i||(i={N:0,img:null,mc:new Float32Array(Uu*3),mcPrev:new Float32Array(Uu*3),mcMix:new Float32Array(Uu*3),mixVersion:0,blendT:1,blendFrames:1,sinceBuild:0,L:null,V:null,lx:NaN,ly:NaN,base:``,shadow:NaN,highlight:NaN,spread:NaN,rim:NaN,version:0,imgVersion:-1,imgAoK:NaN,imgForm:null,aoK:-1,aoMul:new Float32Array(256),near:null,rimG:null,far:null,scratch:[null,null],scratchIdx:0,scratchN:0,scratchStale:!0,sprites:[null,null,null],spriteVersion:-1,spritePx:0},r.size>4&&r.clear(),r.set(t,i)),i}var Hd=1/48,Ud=(e,t)=>!t||Math.abs(e[0]-t[0])>=Hd||Math.abs(e[1]-t[1])>=Hd||Math.abs(e[2]-t[2])>=Hd;function Wd(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}function Gd(e,t,n,r,i){let a=Math.sqrt(1-n*n),o=[0,0,0],s=1-r;if(typeof e.createConicGradient==`function`){let n=e.createConicGradient(0,50,50);for(let e=0;e<=Wu;e++){let r=e/Wu*Math.PI*2;Id(t,a*Math.cos(r),a*Math.sin(r),o),n.addColorStop(e/Wu,`rgb(${o[0]*s|0} ${o[1]*s|0} ${o[2]*s|0})`)}return n}let c=e.createLinearGradient(50+i[0]*50,50+i[1]*50,50-i[0]*50,50-i[1]*50),l=(e,n,r)=>{Id(t,e,n,o),c.addColorStop(r,`rgb(${o[0]*s|0} ${o[1]*s|0} ${o[2]*s|0})`)};return l(a*i[0],a*i[1],0),l(-a*i[1],a*i[0],.5),l(-a*i[0],-a*i[1],1),c}var Kd=typeof navigator<`u`&&/AppleWebKit\//.test(navigator.userAgent)&&!/Chrome\/|Chromium\/|Edg\//.test(navigator.userAgent),qd=[[.55,()=>0],[0,()=>0],[0,e=>Math.min(.6,.25*e.shadow)]];function Jd(e,t,n,r,i,a){let o=yd(n.dev),s=_d(t.typeKey??dd(t.path),t.path,o,n.halfDepth,!!n.still);if(!s)return!1;let c=Vd(e,t.typeKey??dd(t.path)),l=zd(n),u=(()=>{let e=Math.hypot(l.L[0],l.L[1]);return e<.05?[0,-1]:[l.L[0]/e,l.L[1]/e]})();if((Ud(l.L,c.L)||Ud(l.V,c.V)||n.lx!==c.lx||n.ly!==c.ly||r.base!==c.base||a.shadow!==c.shadow||a.highlight!==c.highlight||a.spread!==c.spread||a.rim!==c.rim)&&(c.version>0&&c.mcPrev.set(c.mcMix),Fd(c.mc,Sd(r.base),l,a),c.version===0?(c.mcMix.set(c.mc),c.blendT=1):(c.blendFrames=Math.min(10,Math.max(1,c.sinceBuild)),c.blendT=0),c.sinceBuild=0,c.mixVersion++,c.L=l.L,c.V=l.V,c.lx=n.lx,c.ly=n.ly,c.base=r.base,c.shadow=a.shadow,c.highlight=a.highlight,c.spread=a.spread,c.rim=a.rim,c.version++,c.near=c.rimG=c.far=null),c.sinceBuild++,c.blendT<1){c.blendT=Math.min(1,c.blendT+1/c.blendFrames);let e=c.blendT>=1?1:c.blendT*c.blendT*(3-2*c.blendT),t=c.mcPrev,n=c.mc,r=c.mcMix;for(let i=0;i<Uu*3;i++)r[i]=t[i]+(n[i]-t[i])*e;c.mixVersion++}let d=Math.min(1.3,1.2*a.shadow);if(d!==c.aoK){for(let e=0;e<256;e++)c.aoMul[e]=Math.max(0,1-d*(1-e/255));c.aoK=d}if((!c.img||c.N!==o)&&(c.img=new ImageData(o,o),c.N=o,c.imgVersion=-1),(c.imgVersion!==c.mixVersion||c.imgAoK!==d||c.imgForm!==s)&&(Ld(s,c.mcMix,c.img.data,c.aoMul),c.imgVersion=c.mixVersion,c.imgAoK=d,c.imgForm=s,c.scratchStale=!0),c.scratchN!==o&&(c.scratch=[null,null],c.scratchN=o,c.scratchStale=!0),c.scratchStale){c.scratchIdx^=1;let e=c.scratch[c.scratchIdx];if(!e){let t=id(o),n=t&&ad(t,!1);if(!t||!n)return!1;e=c.scratch[c.scratchIdx]={c:t,g:n}}e.g.putImageData(c.img,0,0),c.scratchStale=!1}let f=c.scratch[c.scratchIdx],p=t.sides===`sprite`||t.sides!==`vector`&&Kd;if(p){let e=Math.ceil(106*n.dev/100);if(c.spritePx!==e&&(c.sprites=[null,null,null],c.spritePx=e,c.spriteVersion=-1),c.spriteVersion!==c.version){let n=e/106;for(let r=0;r<3&&p;r++){let i=c.sprites[r];if(!i){let t=id(e),n=t&&ad(t,!1);if(!t||!n){p=!1;break}i=c.sprites[r]={c:t,g:n}}i.g.setTransform(1,0,0,1,0,0),i.g.clearRect(0,0,e,e),i.g.setTransform(n,0,0,n,3*n,3*n),i.g.fillStyle=Gd(i.g,c.mc,qd[r][0],qd[r][1](a),u),i.g.fill(t.path)}p&&(c.spriteVersion=c.version)}}!p&&!c.near&&(c.near=Gd(e,c.mc,.55,0,u),c.rimG=Gd(e,c.mc,0,0,u),c.far=Gd(e,c.mc,0,Math.min(.6,.25*a.shadow),u));let{cy:m,sy:h,cp:g,sp:_,halfDepth:v,cap:y}=n,b=n.facing>=0?1:-1,[x,S,C,w,T,E]=n.ctm,D=null;p&&(e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`);let O=1,k=0,A=0,j=1,M=0,N=0;for(let n=0;n<16;n++){let r=-1+2*(b>0?n:16-n)/16,i=Yu(r,y),a=r*b,o=m*i,s=h*_*i,l=g*i,u=r*h*v-50*o,d=-r*m*_*v-50*s-50*l,f=O*j-k*A,x=j/f,S=-k/f,C=-A/f,w=O/f,T=(A*N-j*M)/f,E=(k*M-O*N)/f;e.transform(x*o+C*s,S*o+w*s,C*l,w*l,x*u+C*d+T,S*u+w*d+E),O=o,k=s,A=0,j=l,M=u,N=d;let P=a>.4?0:a>=0?1:2;if(p)e.drawImage(c.sprites[P].c,-3,-3,106,106);else{let n=P===0?c.near:P===1?c.rimG:c.far;n!==D&&(e.fillStyle=D=n),e.fill(t.path)}}e.setTransform(x,S,C,w,T,E);let P=1/(m*g),F=h*v/m,I=-_*v*P,L=Math.hypot(F,I),R=L>1e-6?b*F/L:1,z=L>1e-6?b*I/L:0,B=50*y+Math.hypot(50*(1-y),L),V=(B+50)/100,ee=(B-50)/2,te=1+(V-1)*R*R,ne=(V-1)*R*z,H=1+(V-1)*z*z,U=Wd(Wd(n.ctm,[m,h*_,0,g,0,0]),[te,ne,ne,H,ee*R-50*te-50*ne,ee*z-50*ne-50*H]);if(e.save(),e.setTransform(U[0],U[1],U[2],U[3],U[4],U[5]),e.clip(t.path),e.imageSmoothingEnabled=!0,e.imageSmoothingQuality=`high`,e.drawImage(f.c,-3,-3,106,106),e.restore(),n.dev>=256&&a.rim>0&&a.highlight>0){e.save(),e.globalCompositeOperation=`source-atop`,e.setTransform(U[0],U[1],U[2],U[3],U[4],U[5]);let n=Math.min(.5,.3*a.rim*Math.min(1.4,a.highlight)),r=e.createLinearGradient(50+u[0]*50,50+u[1]*50,50-u[0]*50,50-u[1]*50);r.addColorStop(0,`rgba(235,244,255,${n.toFixed(3)})`),r.addColorStop(.45,`rgba(235,244,255,${(.35*n).toFixed(3)})`),r.addColorStop(.75,`rgba(235,244,255,0)`),e.strokeStyle=r,e.lineJoin=`round`,e.lineWidth=1.3,e.stroke(t.path),e.restore()}return!0}var Yd=1.5,Xd=.1,Zd=17,Qd=15,$d=(e,t)=>t+(1-t)*Math.sqrt(Math.max(0,1-e*e)),ef=25,tf=6.3,nf={eyes:1,mouth:-3.5},rf=new Map;function af(e,t,n){let r=`${e}|${t}|${n}`,i=rf.get(r);if(!i){let a=fu(e,-.3*t,.05*t),o=fu(e,-.12*t,.03*t),s=[],c=[];for(let t=0;t<Zd;t++){let n=t/16;s.push(n>.6?``:sf(a,o,n/.6)),c.push(n>=.5?e:sf(a,e,n/.5))}i={base:e,far:a,near:o,light:fu(e,.04*n),dark:fu(e,-.3*t,.05*t),capTop:fu(e,.035*n),capBottom:fu(e,-.035*t),crispMix:s,smoothMix:c,grad:null},rf.size>200&&rf.clear(),rf.set(r,i)}return i}var of=e=>(e.startsWith(`hsl(`)?e:fu(e,0)).match(/[\d.]+/g).map(Number);function sf(e,t,n){let r=of(e),i=of(t),a=r.map((e,t)=>e+(i[t]-e)*n);return`hsl(${a[0].toFixed(1)} ${a[1].toFixed(1)}% ${a[2].toFixed(1)}%)`}var cf=34,lf=Math.PI*1.55,uf=57,df=.4,ff=-.28,pf=new Map;function mf(e){let t=pf.get(e);return t||(t={base:fu(e,.1,.02),light:fu(e,.3,.04),dark:fu(e,-.22,.08),halo:fu(e,.2)},pf.size>200&&pf.clear(),pf.set(e,t)),t}var hf=(e,t)=>e.replace(`)`,` / ${Math.max(0,Math.min(1,t)).toFixed(3)})`);function gf(e,t,n,r,i,a,o){let s=o?.strength??0,c=Math.min(1,t.whirl*s);if(c<=.01)return;let l=o?.size??1,u=o?.width??1,d=o?.length??1,f=o?.tilt??1,p=lf*d,m=mf(n),h=-t.whirlAngle,g=uf*l,_=g*df*f*(a?1.14:.86),v=Math.atan2(i,r)-ff;e.save(),e.rotate(ff),e.translate(0,5),e.lineCap=`butt`;let y=(t,n,r,i,a)=>{e.strokeStyle=i,e.lineWidth=r,e.beginPath(),e.ellipse(0,a,g,_,0,t,n,!1),e.stroke()};if(a)for(let e=0;e<cf;e++){let t=e/cf,n=h+t*p,r=n+p/cf+.012;if(Math.sin((r+n)/2)<=0)continue;let i=(1-t)**1.3;y(n,r,(2+8*i)*1.5*u,`rgba(0,0,0,${(.2*c*i).toFixed(3)})`,3.5)}for(let e=0;e<cf;e++){let t=e/cf,n=h+t*p,r=n+p/cf+.012,i=(r+n)/2;if(Math.sin(i)>0!==a)continue;let o=.6+.4*Math.sin(i),s=(1-t)**1.3,l=1+.18*Math.sin(t*9+1.2),d=(2+8*s)*o*u*l,f=c*(.3+.7*s)*o,g=.5+.5*Math.cos(i-v);y(n,r,d*2.6,hf(m.halo,f*.2),0),y(n,r,d*.8,hf(m.dark,f*.45),d*.32),y(n,r,d,hf(m.base,f*.72),0),y(n,r,d*.62,hf(m.light,f*.78*(.4+.6*g)),-d*.16),y(n,r,d*.24,`rgba(255,255,255,${(f*.9*(.15+.85*g*g)).toFixed(3)})`,-d*.3)}e.restore()}function _f(e,t,n,r){let i=t*Yd;e.clearRect(0,0,i,i);let a=t/100,o,s;if(r.dpr!==void 0)o=r.dpr,s=[o,0,0,o,0,0];else if(e.getTransform){let t=e.getTransform();s=[t.a,t.b,t.c,t.d,t.e,t.f],o=t.a||1}else o=1,s=[1,0,0,1,0,0];let c=r.shadow??.35,l=r.highlight??1.3,u=Qd*(r.depth??.65),d=1-.09999999999999998*(r.rim??.5),f=r.spread??1.55,p=(r.light??265)*Math.PI/180,m=Math.sin(p),h=-Math.cos(p),g=af(r.color,c,l),_=Math.cos(n.yaw),v=Math.sin(n.yaw),y=Math.cos(n.pitch),b=Math.sin(n.pitch),x=_*y,S=e=>Math.abs(e)<.22?e<0?-.22:.22:e,C=S(_),w=S(y),T=Math.cos(n.roll),E=Math.sin(n.roll),D=n.sx*a,O=n.sy*a,k=50*(1-n.sy)*a,A=Wd(s,[T*D,E*D,-E*O,T*O,i/2+n.x*a-E*k,i/2+Xd*t+n.y*a+T*k]);e.save(),e.setTransform(A[0],A[1],A[2],A[3],A[4],A[5]),e.lineCap=`round`,e.lineJoin=`round`;let j=r.shading,M=(i,a,s)=>{let u=g.near,p=g.base;if(j===`crisp`){if(!g.grad||g.grad.lx!==m||g.grad.ly!==h){let t=e.createLinearGradient(m*56,h*56,-m*56,-h*56);t.addColorStop(0,g.light),t.addColorStop(.45,g.near),t.addColorStop(1,g.dark);let n=e.createLinearGradient(m*46,h*46,-m*46,-h*46);n.addColorStop(0,g.capTop),n.addColorStop(1,g.capBottom),g.grad={lx:m,ly:h,lit:t,cap:n}}u=g.grad.lit,p=g.grad.cap}let _=!1;j===`plastic`&&(_=Jd(e,{...r,path:i,typeKey:a},{cy:C,sy:v,cp:w,sp:b,facing:x,roll:n.roll,halfDepth:s,cap:d,lx:m,ly:h,dev:t*o,ctm:A,still:r.still},g,null,{shadow:c,highlight:l,spread:f,rim:r.rim??.5}));let y=j===`plastic`&&!_?`smooth`:j,S=y===`smooth`,T=S&&typeof Path2D==`function`?new Path2D:null,E=x>=0?1:-1,[D,O,k,M,N,P]=A,F=null,I=1,L=0,R=0,z=1,B=0,V=0;for(let t=0;t<Zd&&!_;t++){let n=-1+2*(E>0?t:16-t)/16,r=$d(n,d),a=t/16,o=C*r,c=v*b*r,l=w*r,f=n*v*s-50*o,m=-n*C*b*s-50*c-50*l,h=I*z-L*R,_=z/h,y=-L/h,x=-R/h,D=I/h,O=(R*V-z*B)/h,k=(L*B-I*V)/h;e.transform(_*o+x*c,y*o+D*c,x*l,D*l,_*f+x*m+O,y*f+D*m+k),I=o,L=c,R=0,z=l,B=f,V=m;let A;A=S?g.smoothMix[t]:t===16?p:a>.6?u:g.crispMix[t],A!==F&&(e.fillStyle=F=A),e.fill(i),T&&T.addPath(i,{a:o,b:c,c:0,d:l,e:f,f:m})}if(_||e.setTransform(D,O,k,M,N,P),T&&y===`smooth`){e.save(),e.clip(T);let t=Math.min(1,.34*c),n=e.createRadialGradient(-m*45,-h*45,4*f,-m*45,-h*45,84*f);n.addColorStop(0,`rgba(0,0,0,${t})`),n.addColorStop(.5,`rgba(0,0,0,${t*.35})`),n.addColorStop(1,`rgba(0,0,0,0)`),e.globalCompositeOperation=`multiply`,e.fillStyle=n,e.fillRect(-120,-120,240,240),e.globalCompositeOperation=`source-over`;let r=Math.min(1,.22*l),i=e.createRadialGradient(m*37,h*37,0,m*37,h*37,62*f);i.addColorStop(0,`rgba(255,255,255,${r})`),i.addColorStop(.6,`rgba(255,255,255,${r*.23})`),i.addColorStop(1,`rgba(255,255,255,0)`),e.fillStyle=i,e.fillRect(-120,-120,240,240),e.restore()}return _};gf(e,n,r.color,m,h,!1,r.whirl),r.parts&&M(r.parts,`${r.typeKey??`custom`}:parts`,u*(r.partsDepth??.4));let N=M(r.path,r.typeKey??`custom`,u);if(x>-.2){e.save();{let t=x>=0?1:-1,n=$d(t,d),i=C*n,a=v*b*n,o=w*n,s=t*v*u-50*i,c=-t*C*b*u-50*a-50*o,[l,f,p,m,h,g]=A;e.setTransform(l*i+p*a,f*i+m*a,p*o,m*o,l*s+p*c+h,f*s+m*c+g),e.clip(r.path),e.setTransform(l,f,p,m,h,g)}e.translate(r.faceX-50,r.faceY-50),e.scale(r.faceScale,r.faceScale),N&&(e.globalAlpha=.93),Df(e,n,r),e.restore()}gf(e,n,r.color,m,h,!0,r.whirl),e.restore()}var vf=30;function yf(e,t,n,r){let i=Math.asin(Math.max(-1,Math.min(1,e/vf)))+n,a=Math.asin(Math.max(-1,Math.min(1,-t/vf)))+r,o=Math.cos(a);return{x:vf*Math.sin(i)*o,y:-30*Math.sin(a),sx:Math.cos(i),sy:o,z:Math.cos(i)*o}}var bf=8,xf=new Map;function Sf(e,t,n){let r=Math.round(e*50),i=Math.round(t*50),a=Math.round(n*50),o=r+2e3*i+4e6*a,s=xf.get(o);if(!s){let e=r/50,t=i/50,n=a/50,c=`M${-e} ${t}`;for(let r=1;r<=bf;r++){let i=r/bf,a=1-i;c+=` L${(a*a*-e+i*i*e).toFixed(3)} ${((a*a+i*i)*t+2*a*i*n).toFixed(3)}`}s=new Path2D(c),xf.size>256&&xf.clear(),xf.set(o,s)}return s}var Cf=Math.sin(.684),wf=Math.cos(.684),Tf=new Map;function Ef(e){let t=e=>Math.round(e*50)/50,n=t(e.hw),r=t(e.t0),i=t(e.a),a=t(e.yt),o=t(e.ab),s=t(e.yb),c=`${n},${r},${i},${a},${o},${s}`,l=Tf.get(c);if(l)return l;let u=e=>e.toFixed(3),d=r*Cf,f=r*wf,p=-n+d,m=-f,h=n-d,g=-f,_=-n-d,v=f,y=n+d,b=f,x=4/3*r*wf,S=4/3*r*Cf,C=`M${u(p)} ${u(m)}C${u(-n+i*n)} ${u(a-r)} ${u(n-i*n)} ${u(a-r)} ${u(h)} ${u(g)}C${u(h+x)} ${u(g-S)} ${u(y+x)} ${u(b-S)} ${u(y)} ${u(b)}C${u(n-o*n)} ${u(s+r)} ${u(-n+o*n)} ${u(s+r)} ${u(_)} ${u(v)}C${u(_-x)} ${u(v-S)} ${u(p-x)} ${u(m-S)} ${u(p)} ${u(m)}Z`;return l=new Path2D(C),Tf.size>256&&Tf.clear(),Tf.set(c,l),l}function Df(e,t,n){let[r,i,a]=t.w,o=n.ink,s=nf[n.face],c=ef/2,l=t.lookX,u=t.lookY,{yaw:d,pitch:f}=t,p=(t,n,r,i=1)=>{let a=yf(t,n,d,f);a.z<=.02||i<=.01||(e.save(),e.globalAlpha=i*Math.min(1,a.z*5),e.translate(a.x,a.y),e.scale(Math.max(.02,a.sx),Math.max(.02,a.sy)),r(),e.restore())},m=(e,t)=>Math.abs(e)<=t?0:Math.sign(e)*(Math.abs(e)-t)/(1-t),h=e=>Math.max(-1,Math.min(1,e)),g=m(h(-t.pitch/.26-t.lookY/7),.34),_=Math.abs(m(h(t.lookX/4.5),.4)),v=Math.max(.3,1+.55*g-.1*_),y=1-.05*g+.12*_,b=r+i*(1-t.laugh),x=i*t.laugh,S=Math.max(0,-t.y)/26,C=.5+.5*t.breath;for(let n of[-1,1]){let r=n<0?t.blinkL:t.blinkR,i=Math.max(0,Math.min(1,t.eyeOpen*(1-r))),d=b*i,f=b*(1-i),m=x,h=a,g=d*.01+f*5.4+m*6.2+h*6,_=d*1.1*v+f*.6+m*(2.2-S*1.5)+h*(-1.4+C),w=d*-3.3*v+f*.6+m*(-11.4-4*S)+h*(5.4+2*C),T=d*tf*2*y+f*2.8+m*4.4+h*4,E=l*(d+.5*(f+m)),D=u*(d+.5*f);p(n*c+E,s+D,()=>{e.strokeStyle=o,e.lineWidth=T,e.stroke(Sf(g,_,w))})}if(n.face===`mouth`){let n=l*.35,s=(.6+.4*r)*(1+.06*t.breath),c=(.6+.4*i)*(1+.25*Math.max(0,-t.y)/26),u=2.7*a*(1+.25*t.breath),d=(e,t,n)=>r*e+i*t+a*n,f={hw:d(6.5*s,9.5*c,u),t0:d(1.9,0,0),a:d(2/3,2/3,0),yt:d(3.53*s,1.6*c,-4*u/3),ab:d(2/3,0,0),yb:d(3.53*s,17.3*c,4*u/3)};p(n,d(12.5,11.6,15.5),()=>{e.fillStyle=o,e.fill(Ef(f))})}}var Of={x:NaN,y:NaN},kf=new Set,Af=0,jf=0;function Mf(e){Af=0;let t=jf?Math.min(.1,(e-jf)/1e3):0;jf=e,kf.forEach(e=>e(t)),kf.size&&(Af=requestAnimationFrame(Mf))}function Nf(){Af||typeof document>`u`||document.hidden||(jf=0,Af=requestAnimationFrame(Mf))}var Pf=!1;function Ff(){Pf||typeof document>`u`||(Pf=!0,document.addEventListener(`pointermove`,e=>{Of.x=e.clientX,Of.y=e.clientY},{passive:!0}),document.addEventListener(`pointerleave`,()=>{Of.x=NaN,Of.y=NaN}),window.addEventListener(`blur`,()=>{Of.x=NaN,Of.y=NaN}),document.addEventListener(`visibilitychange`,()=>{document.hidden?(Af&&cancelAnimationFrame(Af),Af=0):kf.size&&Nf()}))}function If(e){return Ff(),kf.add(e),Nf(),()=>{kf.delete(e),!kf.size&&Af&&(cancelAnimationFrame(Af),Af=0)}}function Lf(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0)%1e3/1e3}var Rf=(e,t,n)=>Math.min(n,Math.max(t,Number.isFinite(e)?e:1)),zf=new Map;function Bf(e){let t=zf.get(e);return t||(t=new Path2D(e),zf.set(e,t)),t}var Vf=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,Hf=(0,l.forwardRef)(function({type:e=`clover`,path:t,face:n,state:r=`default`,size:i=64,color:a,ink:o,brightness:s=1,saturation:c=1.5,speed:u=1,paused:d=!1,seed:f,shading:p=`plastic`,shadow:m=.35,highlight:h=1.3,depth:g=.65,light:_=265,rim:v=.5,spread:y=1.55,interactive:b=!0,turn:x=1,theme:S=`auto`,whirl:C=0,whirlSize:w=1,whirlWidth:T=1,whirlLength:E=1,whirlTilt:D=1,jumpHeight:O=26,jumpTime:k=.68,jumpStretch:A=1,jumpSpin:j=1,jumpLean:M=6,jumpEvery:N=8,jumpLand:P=0,jumpSquash:F=1.15,jumpSquashTime:I=.37,jumpSquashEase:L=`pulse`,jumpGroundTime:R=.11,jumpGroundEase:z=`pulse`,jumpRiseTime:B=.33,jumpRiseEase:V=`pulse`,jumpClickSquashTime:ee=.24,className:te,style:ne,"aria-label":H,...U},re){let ie=(0,l.useRef)(null);(0,l.useImperativeHandle)(re,()=>ie.current);let ae=(0,l.useId)(),oe=Ql[e]??Ql.clover,se=n??oe.face,ce=a??oe.color,le=s===1&&c===1?ce:fu(ce,(Math.min(2,Math.max(0,s))-1)*.35,(Math.min(2,Math.max(0,c))-1)*.5),ue=o??su(le),de=Math.min(1,Math.max(0,f??Lf(ae))),fe=r in eu?r:`default`,pe=d||!(u>0),W=p===!0?`crisp`:p===!1?`flat`:p,me=typeof t==`string`&&t.trim()?t.trim():null,he=me?`path:${Lf(me)}:${me.length}`:e,G=(0,l.useRef)(null),ge=(0,l.useRef)(null),_e=(0,l.useRef)(0),K=(0,l.useRef)(u);K.current=u;let ve=(0,l.useRef)(b);ve.current=b,ge.current={path:typeof Path2D>`u`?null:Bf(me??tu[e]??tu.clover),face:se,faceX:oe.faceX,faceY:oe.faceY,faceScale:oe.faceScale,color:le,ink:ue,shading:W,shadow:Rf(m,0,2),highlight:Rf(h,0,2),depth:Rf(g,.2,2),light:_,rim:Rf(v,0,2),spread:Rf(y,.4,2.5),typeKey:he,still:pe||Vf(),whirl:{strength:Rf(C,0,2),size:Rf(w,.6,1.6),width:Rf(T,.4,2),length:Rf(E,.4,1.6),tilt:Rf(D,.5,1.8)},parts:typeof Path2D<`u`&&!me&&nu[e]?Bf(nu[e]):void 0};let ye=e=>{if(S!==`auto`)return S;let t=e?.closest(`[data-theme], .dark, .light`);if(t){let e=t.getAttribute(`data-theme`);if(e===`dark`||e===`light`)return e;if(t.classList.contains(`dark`))return`dark`;if(t.classList.contains(`light`))return`light`}return typeof matchMedia==`function`&&matchMedia(`(prefers-color-scheme: light)`).matches?`light`:`dark`},be=()=>{let e=ie.current,t=ge.current;if(!e||!t||!t.path)return;let n=e.clientWidth/1.5||_e.current||(typeof i==`number`?i:64);if(!n)return;let r=Math.min(2,typeof devicePixelRatio==`number`&&devicePixelRatio||1),a=Math.round(n*Yd*r);(e.width!==a||e.height!==a)&&(e.width=a,e.height=a),_e.current=n;let o=e.getContext(`2d`);o&&(o.setTransform(r,0,0,r,0,0),t.dpr=r,_f(o,n,G.current?G.current.pose:Vu(fe),t))};(0,l.useLayoutEffect)(()=>{if(G.current?G.current.setState(fe):G.current=new Bu(de,fe),G.current.setTurn(Rf(x,0,2)),G.current.setJump({height:O,time:Math.max(.2,k),stretch:A,spin:Math.max(0,Math.round(j)),lean:M,every:N,land:P,squash:F,squashTime:Math.max(.05,I),squashEase:L,groundTime:Math.max(0,R),groundEase:z,riseTime:Math.max(.05,B),riseEase:V,clickSquashTime:Math.max(.05,ee)}),Vf()){let e=ie.current;if(e&&ge.current&&ge.current.path){let t=e.clientWidth/1.5||_e.current||(typeof i==`number`?i:64);if(!t)return;_e.current=t;let n=Math.min(2,typeof devicePixelRatio==`number`&&devicePixelRatio||1);e.width=e.height=Math.round(t*Yd*n);let r=e.getContext(`2d`);r&&(ge.current.theme=ye(e),ge.current.dpr=n,r.setTransform(n,0,0,n,0,0),_f(r,t,Vu(fe),ge.current))}return}ge.current&&ie.current&&(ge.current.theme=ye(ie.current)),be()}),(0,l.useEffect)(()=>{var e;if(W!==`plastic`||!((e=ge.current)!=null&&e.path))return;let t=ge.current.path,n=(typeof i==`number`?i:64)*Math.min(2,typeof devicePixelRatio==`number`&&devicePixelRatio||1),r=(typeof requestIdleCallback==`function`?requestIdleCallback:e=>setTimeout(e,1))(()=>vd(he,t,n,g));return()=>{typeof cancelIdleCallback==`function`?cancelIdleCallback(r):clearTimeout(r)}},[W,he,i,g]),(0,l.useEffect)(()=>{if(pe||Vf())return;let e=ie.current;if(!e)return;let t=!0,n=null,r=t=>{let n=G.current;if(n){if(ve.current&&!Number.isNaN(Of.x)){let t=e.getBoundingClientRect(),r=t.width/1.5||1,i=(Of.x-(t.left+t.width/2))/r,a=(Of.y-(t.top+t.height/2+Xd*r))/r,o=Math.hypot(i,a),s=o<1?1:o>3?0:1-(o-1)/2;n.setPointer(i/Math.max(1,o),a/Math.max(1,o),s)}else n.setPointer(0,0,0);n.update(t*K.current),be()}},i=()=>{n||=If(r)},a=()=>{n&&n(),n=null},o=null;return typeof IntersectionObserver==`function`?(o=new IntersectionObserver(e=>{t=e[0]?.isIntersecting??!0,t?i():a()}),o.observe(e)):i(),()=>{a(),o&&o.disconnect()}},[pe]);let xe=typeof i==`number`?`${i*Yd}px`:`calc(${i} * ${Yd})`,Se=e=>typeof i==`number`?`${-i*e}px`:`calc(${i} * ${-e})`,Ce=.5/2,we={display:`inline-block`,verticalAlign:`middle`,width:xe,height:xe,marginLeft:Se(Ce),marginRight:Se(Ce),marginTop:Se(.35),marginBottom:Se(.15),flex:`none`,...ne},Te=e=>{var t,n;b&&!pe&&((t=G.current)==null||t.poke()),(n=U.onClick)==null||n.call(U,e)};return(0,Q.jsx)(`canvas`,{ref:ie,className:te?`ba ${te}`:`ba`,"data-bot-avatar":e,"data-face":se,"data-state":fe,role:`img`,"aria-label":H??`${oe.label} bot, ${eu[fe]}`,style:we,...U,onClick:Te})}),Uf=137.508,Wf=e=>(e*Uf%360).toFixed(3);function Gf(e){let t=e.avatarIndex;return{type:$l[t%$l.length],color:`hsl(${Wf(t)} 72% 58%)`,seed:t*.61803398875%1}}var Kf=2e3,qf=0;function Jf(e){let[t,n]=(0,l.useState)(!e);return(0,l.useEffect)(()=>{if(e){n(!1);return}let t=setTimeout(()=>n(!0),Kf);return()=>clearTimeout(t)},[e]),t}function Yf({thread:e,working:t,size:n}){let r=Jf(t),i=r?`rest`:`moving`;return(0,Q.jsx)(Hf,{...Gf(e),state:t?`working`:`default`,size:n,paused:r,turn:t?void 0:qf},i)}var Xf={nextThread:`Next thread`,previousThread:`Previous thread`,nextPane:`Next pane`,previousPane:`Previous pane`,toggleSidebar:`Toggle sidebar`,newThread:`New thread`,openTerminal:`New terminal`,closePane:`Close pane`},Zf={nextThread:`ctrl+j`,previousThread:`ctrl+k`,nextPane:`ctrl+l`,previousPane:`ctrl+h`,toggleSidebar:`meta+b`,newThread:`ctrl+x`,openTerminal:`ctrl+e`,closePane:`ctrl+q`};function Qf(){try{let e=JSON.parse(localStorage.getItem(`webr-shortcuts`)??`{}`);return{...Zf,...Object.fromEntries(Object.entries(e).filter(([e])=>Object.hasOwn(Zf,e)))}}catch{return Zf}}function $f(e){let t={ctrl:`⌃`,alt:`⌥`,meta:`⌘`,shift:`⇧`,space:`Space`,escape:`Esc`};return e.split(`+`).map(e=>t[e]??e.toUpperCase())}function ep(e){return $f(e).join(``)}function tp(e){let t=[e.ctrlKey&&`ctrl`,e.altKey&&`alt`,e.metaKey&&`meta`,e.shiftKey&&`shift`].filter(Boolean),n=e.key.toLowerCase()===` `?`space`:e.key.toLowerCase();return[`control`,`alt`,`meta`,`shift`].includes(n)?``:[...t,n].join(`+`)}function np(e){return/^(meta\+(w|t|r|l|n)|ctrl\+(w|t|r|n))$/.test(e)||!/(ctrl|alt|meta)\+/.test(e)}function rp(e){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;document.documentElement.dataset.theme=e===`system`?t?`dark`:`light`:e}function ip({expanded:e=!1}){let[t,n]=(0,l.useState)(`system`);(0,l.useEffect)(()=>{let e=localStorage.getItem(`webr-theme`),t=e===`light`||e===`dark`?e:`system`;n(t),rp(t);let r=window.matchMedia(`(prefers-color-scheme: dark)`),i=()=>{let e=localStorage.getItem(`webr-theme`)||`system`;n(e),rp(e)};return r.addEventListener(`change`,i),window.addEventListener(`webr-theme-change`,i),()=>{r.removeEventListener(`change`,i),window.removeEventListener(`webr-theme-change`,i)}},[]);let r=e=>{n(e),localStorage.setItem(`webr-theme`,e),rp(e)};return(0,Q.jsx)(`div`,{className:e?`theme-control theme-control--expanded`:`theme-control`,role:`group`,"aria-label":`Color theme`,children:[[`system`,V],[`light`,ue],[`dark`,ee]].map(([n,i])=>(0,Q.jsx)(Zl,{label:`${n[0].toUpperCase()}${n.slice(1)} theme`,children:(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`${n} theme`,"aria-pressed":t===n,className:t===n?`theme-option is-selected`:`theme-option`,onClick:()=>r(n),children:[(0,Q.jsx)(i,{size:15,strokeWidth:1.8}),e&&(0,Q.jsx)(`span`,{children:n})]})},n))})}var ap={machine_disconnected:`The machine is not connected.`,launch_in_progress:`Wait for the launch to finish, then try again.`,thread_not_found:`This thread does not exist anymore.`};async function op(e,t={}){let n=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(ap[r.error??``]??`Herdr could not complete this action.`);return r}var sp=(e,t)=>op(`/api/threads/${encodeURIComponent(e.id)}/archive`,{machineId:e.machineId,archived:t}),cp=(e,t)=>op(`/api/threads/${encodeURIComponent(e.id)}/rename`,{machineId:e.machineId,title:t}),lp=(e,t)=>op(`/api/projects/rename`,{machineId:e.machineId??`local`,logicalId:e.logicalId??e.id,name:t}),up=e=>`/api/projects/icon?machineId=${encodeURIComponent(e.machineId??`local`)}&logicalId=${encodeURIComponent(e.logicalId??e.id)}`;async function dp(e,t){if(!(await fetch(up(e),{method:`PUT`,headers:{"Content-Type":`image/png`},body:t})).ok)throw Error(`Could not save this icon.`)}async function fp(e){let t=await fetch(`/api/projects/${encodeURIComponent(e.machineId??`local`)}/${encodeURIComponent(e.id)}/icon-candidates`);return t.ok?await t.json():[]}async function pp(e){if(!(await fetch(up(e),{method:`DELETE`})).ok)throw Error(`Could not reset this icon.`)}var mp=(e,t)=>op(`/api/threads/${encodeURIComponent(e.id)}/panes/terminal`,{machineId:e.machineId,afterPaneId:t}),hp=(e,t,n)=>op(`/api/threads/${encodeURIComponent(e.id)}/panes/close`,{machineId:e.machineId,paneId:t,force:n}),gp=e=>op(`/api/threads/${encodeURIComponent(e.id)}/delete`,{machineId:e.machineId}),_p=()=>op(`/api/archive/delete`),vp=(e,t,n)=>e===1?t:n;function yp(e){let t=e.length,n=e.filter(e=>e.ownsWorktree).length,r=vp(t,`Delete this thread`,`Delete ${t} threads`),i=vp(t,`its terminal`,`their terminals`);return n?`${r} permanently? This closes ${i} and removes ${n===t?vp(t,`its worktree`,`their worktrees`):`${n} ${vp(n,`worktree`,`worktrees`)}`}, including uncommitted changes.`:`${r} permanently? This closes ${i}. Your project files stay untouched.`}var bp=(e,t)=>e.panes.length>1&&e.panes.some(e=>e.id===t&&e.kind!==`agent`),xp=(e,t)=>e[t-1]??e[t+1];function Sp(e,t,n){let r=e.findIndex(e=>e.id===n);return e.slice(t,t+2).find(e=>e.id!==n)??xp(e,r)}function Cp(e,t,n,r=2){let i=n<0?t:n<t?n:n>=t+r?n-r+1:t;return Math.max(0,Math.min(i,e-r))}function wp(e){let t=performance.now();return()=>performance.now()-t}var Tp=()=>performance.now();function Ep(){}var Dp=e=>cl(e instanceof Error?e.message:`Herdr could not complete this action.`);function Op({open:e,onClose:t,projects:n,threads:r,thread:i,focusedPane:o,mode:s,onModeChange:c,onToggleSidebar:u,onFocusPane:d,onTerminalAction:v,onOpenTerminal:y,onClosePane:b}){let[x,S]=(0,l.useState)(``),[C,w]=(0,l.useState)(0),[T,E]=(0,l.useState)(Zf),D=(0,l.useRef)(null);(0,l.useEffect)(()=>{e&&(S(``),w(0),E(Qf()),requestAnimationFrame(()=>D.current?.focus()))},[e]);let k=e=>{let t=r.findIndex(e=>e.id===i?.id),n=r[((t===-1&&e<0?0:t)+e+r.length)%r.length];n&&a(`/threads/${encodeURIComponent(n.id)}`)},A=e=>{i?.panes.length&&d(i.panes[(i.panes.findIndex(e=>e.id===o)+e+i.panes.length)%i.panes.length].id)},j=(0,l.useMemo)(()=>[{label:`New thread`,icon:(0,Q.jsx)(se,{size:16}),shortcut:`newThread`,run:()=>{a(`/new${i?`?project=${encodeURIComponent(i.projectId)}`:``}`)}},{label:`Settings`,icon:(0,Q.jsx)(oe,{size:16}),run:()=>{a(`/settings`)}},{label:`Toggle sidebar`,icon:(0,Q.jsx)(H,{size:16}),shortcut:`toggleSidebar`,run:u},...r.length?[{label:`Next thread`,icon:(0,Q.jsx)(m,{size:16}),shortcut:`nextThread`,run:()=>k(1)},{label:`Previous thread`,icon:(0,Q.jsx)(_,{size:16}),shortcut:`previousThread`,run:()=>k(-1)}]:[],{label:`Group threads by project`,icon:(0,Q.jsx)(M,{size:16}),detail:s===`projects`?`Selected`:void 0,run:()=>c(`projects`)},{label:`Show all threads`,icon:(0,Q.jsx)(L,{size:16}),detail:s===`threads`?`Selected`:void 0,run:()=>c(`threads`)},...[`system`,`light`,`dark`].map(e=>({label:`${e[0].toUpperCase()}${e.slice(1)} theme`,icon:e===`system`?(0,Q.jsx)(V,{size:16}):e===`light`?(0,Q.jsx)(ue,{size:16}):(0,Q.jsx)(ee,{size:16}),run:()=>{localStorage.setItem(`webr-theme`,e),rp(e),window.dispatchEvent(new Event(`webr-theme-change`))}})),...i?[{label:i.archivedAt?`Unarchive thread`:`Archive thread`,icon:i.archivedAt?(0,Q.jsx)(f,{size:16}):(0,Q.jsx)(p,{size:16}),run:()=>{sp(i,!i.archivedAt).catch(Dp)}},{label:`Copy thread link`,icon:(0,Q.jsx)(O,{size:16}),run:()=>{navigator.clipboard.writeText(location.href)}},...i.bindingState===`attached`?[{label:`New terminal`,icon:(0,Q.jsx)(ce,{size:16}),shortcut:`openTerminal`,run:y},...bp(i,o)?[{label:`Close pane`,icon:(0,Q.jsx)(pe,{size:16}),shortcut:`closePane`,run:b}]:[]]:[],...i.bindingState===`attached`?[{label:`Request terminal control`,icon:(0,Q.jsx)(ce,{size:16}),run:()=>v(`control`)},{label:`Release terminal control`,icon:(0,Q.jsx)(ce,{size:16}),run:()=>v(`release`)},{label:`Take over terminal control`,icon:(0,Q.jsx)(ce,{size:16}),run:()=>{sl(`Replace the active controller of this terminal?`,{confirmLabel:`Take over`}).then(e=>{e&&v(`takeover`)})}}]:[],{label:`Next pane`,icon:(0,Q.jsx)(g,{size:16}),shortcut:`nextPane`,run:()=>A(1)},{label:`Previous pane`,icon:(0,Q.jsx)(h,{size:16}),shortcut:`previousPane`,run:()=>A(-1)},...i.panes.map((e,t)=>({label:`Focus ${e.title}`,icon:(0,Q.jsx)(ce,{size:16}),detail:`Pane ${t+1}`,run:()=>d(e.id)}))]:[],...r.map(e=>({label:e.title,icon:(0,Q.jsx)(Yf,{thread:e,working:e.status===`working`,size:22}),detail:n.find(t=>t.id===e.projectId)?.name,run:()=>{a(`/threads/${encodeURIComponent(e.id)}`)}}))],[n,r,i,o,s,c,u,d,v,y,b]).filter(e=>`${e.label} ${e.detail??``}`.toLowerCase().includes(x.toLowerCase().trim()));if(!e)return null;let N=e=>{t(),e.run()};return(0,Q.jsx)(`div`,{className:`palette-overlay`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,Q.jsxs)(`div`,{className:`palette`,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),t()),e.key===`ArrowDown`&&(e.preventDefault(),w(e=>(e+1)%(j.length||1))),e.key===`ArrowUp`&&(e.preventDefault(),w(e=>(e-1+(j.length||1))%(j.length||1))),e.key===`Enter`&&j.length&&(e.preventDefault(),N(j[Math.min(C,j.length-1)])),e.key===`Tab`&&(e.preventDefault(),D.current?.focus())},children:[(0,Q.jsx)(`input`,{ref:D,"aria-label":`Search commands and threads`,placeholder:`Search threads and actions…`,value:x,onChange:e=>{S(e.target.value),w(0)}}),(0,Q.jsxs)(`div`,{className:`palette-results`,role:`listbox`,"aria-label":`Results`,children:[j.map((e,t)=>(0,Q.jsxs)(`button`,{role:`option`,"aria-selected":C===t,className:C===t?`is-selected`:``,onMouseEnter:()=>w(t),onClick:()=>N(e),children:[(0,Q.jsx)(`span`,{className:`palette-icon`,"aria-hidden":`true`,children:e.icon}),(0,Q.jsx)(`span`,{className:`palette-label`,children:e.label}),e.detail&&(0,Q.jsx)(`small`,{children:e.detail}),e.shortcut&&(0,Q.jsx)(Zl,{label:T[e.shortcut],children:(0,Q.jsx)(`kbd`,{children:ep(T[e.shortcut])})})]},`${e.label}-${t}`)),!j.length&&(0,Q.jsx)(`p`,{children:`No results`})]}),(0,Q.jsxs)(`div`,{className:`palette-help`,children:[`↑↓ Navigate `,(0,Q.jsx)(`span`,{children:`↵ Select`}),` `,(0,Q.jsx)(`span`,{children:`Esc Close`})]})]})})}var kp=2e3,Ap=e=>fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});async function jp(){let e=await Ap(`/api/pair/invites`);if(!e.ok)throw Error(`Webr could not create a code.`);return e.json()}async function Mp(){let e=await fetch(`/api/devices`);if(!e.ok)throw Error(`Webr could not list devices.`);return e.json()}async function Np(){let e=await fetch(`/api/audit`);if(!e.ok)throw Error(`Webr could not load recent activity.`);return e.json()}async function Pp(){let e=await fetch(`/api/remote/tailscale`);return e.ok?(await e.json()).status:`unavailable`}var Fp=e=>Ap(`/api/devices/${encodeURIComponent(e)}/revoke`),Ip=(e,t)=>Ap(`/api/pair/${encodeURIComponent(e)}/${t}`);async function Lp(){try{let e=await fetch(`/api/pair/pending`);return e.ok?await e.json():[]}catch{return[]}}var Rp=()=>typeof Notification<`u`&&Notification.permission===`granted`,zp=()=>document.visibilityState===`visible`||Rp();function Bp(e,t){if(document.visibilityState!==`visible`&&Rp())for(let n of e)t.has(n.id)||(t.add(n.id),new Notification(`A device wants to connect to Webr`,{body:`${n.deviceName} · ${n.source}`,tag:n.id}))}function Vp(){let[e,t]=(0,l.useState)([]),n=(0,l.useRef)(new Set),r=(0,l.useCallback)(async()=>{if(!zp())return;let e=await Lp();Bp(e,n.current),t(e)},[]);return(0,l.useEffect)(()=>{r();let e=setInterval(()=>void r(),kp);return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(e),document.removeEventListener(`visibilitychange`,r)}},[r]),{pending:e,decide:(0,l.useCallback)(async(e,n)=>{t(t=>t.filter(t=>t.id!==e)),await Ip(e,n).catch(()=>void 0),await r()},[r])}}function Hp(e,t=Date.now()){let n=Math.round((e-t)/1e3),[r,i]=[[`day`,86400],[`hour`,3600],[`minute`,60]].find(([,e])=>Math.abs(n)>=e)??[`second`,1];return Math.abs(n)<45?`just now`:new Intl.RelativeTimeFormat(`en`,{numeric:`auto`}).format(Math.round(n/i),r)}var Up=()=>typeof Notification<`u`,Wp=()=>Up()?Notification.permission:`denied`,Gp=()=>Notification.requestPermission();function Kp({kind:e,deviceName:t,source:n}){let r=t??`A device`,i=n?` from ${n}`:``;return{pair_requested:`${r} asked to connect${i}`,pair_approved:`${r} was approved${i}`,pair_denied:`${r} was declined${i}`,invite_created:`A connection code was created${i}`,invite_redeemed:`${r} connected with a code${i}`,device_revoked:`${r} was disconnected`,session_expired:`${r} was signed out after being idle`}[e]}function qp(e,t=Date.now()){return e<=t?`expired`:new Intl.RelativeTimeFormat(`en`,{numeric:`auto`}).format(...Jp(e-t))}function Jp(e){let t=Math.round(e/864e5);return t>=1?[t,`day`]:[Math.max(1,Math.round(e/36e5)),`hour`]}function Yp(){let{pending:e,decide:t}=Vp(),n=e[0];return(0,Q.jsx)(kc,{open:!!n,onOpenChange:e=>{!e&&n&&t(n.id,`deny`)},children:(0,Q.jsxs)(Xc,{children:[(0,Q.jsx)(Ac,{className:`dialog-backdrop`}),(0,Q.jsx)(qc,{className:`dialog pairing-prompt`,children:n&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Zc,{className:`pairing-title`,children:[`Allow `,n.deviceName,` to connect?`]}),(0,Q.jsxs)(Bc,{className:`dialog-message`,children:[`Requested from `,n.source,`. Only approve if this code matches the one shown on that device.`]}),(0,Q.jsx)(`div`,{className:`pairing-code`,"aria-label":`Code ${n.code}`,children:n.code}),e.length>1&&(0,Q.jsxs)(`p`,{className:`settings-note`,children:[e.length-1,` more waiting`]}),(0,Q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,onClick:()=>void t(n.id,`deny`),children:`Deny`}),(0,Q.jsx)(`button`,{type:`button`,autoFocus:!0,className:`dialog-button is-primary`,onClick:()=>void t(n.id,`approve`),children:`Approve`})]})]})})]})})}var Xp=({children:e})=>(0,Q.jsx)(Q.Fragment,{children:e}),Zp=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],Qp={image_too_large:`This image is larger than 20 MB.`,file_too_large:`This file is larger than 5 MB.`,empty_file:`This file is empty.`,unsupported_image:`Only PNG, JPEG, GIF and WebP images can be attached.`,uploads_unsupported_target:`Files cannot be attached on this machine yet.`,upload_failed:`The file could not be sent to the machine.`,machine_disconnected:`The machine is not connected.`},$p=e=>Zp.includes(e.type),em=e=>e?.files?[...e.files].filter($p):[],tm=e=>e?.files?[...e.files]:[],nm=e=>!!e?.types&&[...e.types].includes(`Files`),rm=e=>e.replace(/([\s\\'"()&;$`!*?[\]{}<>|#~])/g,`\\$1`);async function im(e,t){if(!$p(t))throw Error(Qp.unsupported_image);if(t.size>20971520)throw Error(Qp.image_too_large);let n=await fetch(`/api/uploads?machineId=${encodeURIComponent(e)}`,{method:`POST`,headers:{"Content-Type":t.type},body:t}),r=await n.json().catch(()=>({}));if(!n.ok||!r.path)throw Error(Qp[r.error??``]??`The image could not be attached.`);return r.path}async function am(e,t){if($p(t))return im(e,t);if(t.size>5242880)throw Error(Qp.file_too_large);let n=await fetch(`/api/uploads?machineId=${encodeURIComponent(e)}&name=${encodeURIComponent(t.name)}`,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:t}),r=await n.json().catch(()=>({}));if(!n.ok||!r.path)throw Error(Qp[r.error??``]??`The file could not be attached.`);return r.path}var om=160,sm=e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result)),r.onerror=()=>n(r.error),r.readAsDataURL(e)});async function cm(e){if(typeof createImageBitmap!=`function`)return sm(e);let t=await createImageBitmap(e),n=Math.min(1,om/Math.max(t.width,t.height)),r=document.createElement(`canvas`);return r.width=Math.max(1,Math.round(t.width*n)),r.height=Math.max(1,Math.round(t.height*n)),r.getContext(`2d`)?.drawImage(t,0,0,r.width,r.height),t.close(),r.toDataURL(`image/jpeg`,.8)}async function lm(e,t){let n=[];for(let r of t)n.push(await am(e,r));return n.map(rm).join(` `)+` `}var um=e=>Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);function dm(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=um(e);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var fm=`Nothing to attach.`,pm=e=>$p(e)?cm(e):Promise.resolve(``),mm=(e,t)=>[e.trim(),...t.map(e=>rm(e.path))].filter(Boolean).join(` `);function hm({machineId:e}){let[t,n]=(0,l.useState)(!1),[r,i]=(0,l.useState)([]),[a,o]=(0,l.useState)(0),[s,c]=(0,l.useState)(``),u=(0,l.useRef)(0),d=async t=>{if(!t.length){c(fm);return}c(``),o(e=>e+t.length);for(let n of t)try{let t=await am(e,n),r=await pm(n);i(e=>[...e,{id:dm(),name:n.name||`file`,preview:r,path:t}])}catch(e){c(e instanceof Error?e.message:`The file could not be attached.`)}finally{o(e=>e-1)}};return{dragging:t,attachments:r,setAttachments:i,uploading:a,error:s,remove:e=>i(t=>t.filter(t=>t.id!==e)),handlers:{onDragEnter:e=>{nm(e.dataTransfer)&&(e.preventDefault(),u.current+=1,n(!0))},onDragOver:e=>{nm(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:e=>{nm(e.dataTransfer)&&(u.current=Math.max(0,u.current-1),u.current||n(!1))},onDrop:e=>{nm(e.dataTransfer)&&(e.preventDefault(),u.current=0,n(!1),d(tm(e.dataTransfer)))},onPaste:e=>{let t=em(e.clipboardData);t.length&&(e.preventDefault(),d(t))}}}}function gm({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=l.useRef(e!==void 0),[a,o]=l.useState(t);return[i&&e!==void 0?e:a,l.useCallback(e=>{i||o(e)},[])]}function _m(e){let t=l.useRef(!0);t.current&&(t.current=!1,e())}function vm(e,t,n,r,i,a,o,s,c,l=2){let u=Fr(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return jr(n.current,u)?void 0:u}var ym=l.createContext(void 0),bm=l.createContext(void 0),xm=l.createContext(void 0),Sm=l.createContext(!1),Cm=l.createContext(``);function wm(){let e=l.useContext(ym);if(!e)throw Error(Mi(22));return e}function Tm(){let e=l.useContext(bm);if(!e)throw Error(Mi(23));return e}function Em(){let e=l.useContext(xm);if(!e)throw Error(Mi(24));return e}function Dm(){return l.useContext(Cm)}function Om(){return l.useContext(Sm)}function km(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var Am=(e,t)=>Object.is(e,t);function jm(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Mm(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!km(e,t,(e,t)=>jm(e,t,n)):e!==t}function Nm(e,t,n){return e?e.some(e=>e!==void 0&&jm(t,e,n)):!1}function Pm(e,t,n){return e?e.findIndex(e=>e!==void 0&&jm(e,t,n)):-1}function Fm(e,t){if(t!==Am)return n=>Nm(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function Im(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(Fm(t,n)):Pm(e,t,n);return i===-1?null:i}function Lm(e,t,n,r,i,a){return Nm(r,t,i)?a!=null&&e>a&&Nm(r,n[a],i)?a:e:e===a?Im(n,r,i,!0):a}function Rm(e,t,n){return e.filter(e=>!jm(t,e,n))}function zm(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function Bm(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function Vm(e){return Bm(e?.[0])}function Hm(e){return Vm(e)?e.flatMap(e=>e.items):e}function Um(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(Vm(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function Wm(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return zm(e)}function Gm(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?zm(e.value):zm(e)}var Km={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?Um(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>jm(t,e,n)):jm(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemProps:e=>e.itemProps,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight},qm=`data-valid`,Jm=`data-invalid`,Ym={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Xm={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Zm={disabled:!1,...Xm},Qm={valid(e){return e===null?null:e?{[qm]:``}:{[Jm]:``}}},$m={invalid:void 0,name:void 0,validityData:{state:Ym,errors:[],error:``,value:``,initialValue:null},setValidityData:et,disabled:void 0,setTouched:et,setDirty:et,setFilled:et,setFocused:et,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:Zm,registerFieldControl:et,validation:{getValidationProps:(e,t=nt)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:et,getInputControl:()=>null,commit:async()=>{},change:et}},eh=l.createContext($m);function th(e=!0){let t=l.useContext(eh);if(t.setValidityData===et&&!e)throw Error(Mi(28));return t}function nh(e,t,n,r,i=!0,a){let{registerFieldControl:o}=th(),s=$e(()=>Symbol());W(()=>{let c=s.current;if(!i){o(c,void 0);return}o(c,{controlRef:e,getValue:r,id:t,name:a,value:n})},[e,i,r,t,a,o,s,n]),W(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var rh=l.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:et,validationMode:`onSubmit`,submitCountRef:{current:0}});function ih(){return l.useContext(rh)}var ah=l.createContext({controlId:void 0,registerControlId:et,resetControlId:et,labelId:void 0,setLabelId:et,messageIds:[],setMessageIds:et,getDescriptionProps:e=>e});function oh(){return l.useContext(ah)}function sh(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=oh(),o=zc(),s=$e(()=>Symbol()),c=l.useRef(!1),u=l.useRef(!1),d=$(()=>{c.current&&i!==et&&(c.current=!1,i(s.current,void 0))});return W(()=>{if(!n||i===et){d();return}let e;if(t!==void 0)u.current=!0,e=t;else if(u.current)e=o;else{a();return}if(e===void 0){d();return}c.current=!0,i(s.current,e)},[t,n,i,a,o,s,d]),W(()=>d,[d]),(n?r:void 0)??t??o}function ch(e){return e==null?void 0:`${e}-popup`}function lh(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function uh(e){return Array.isArray(e)?e.map(e=>uh(e)).join(`,`):e==null?``:String(e)}var dh=new Map;function fh(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${uh(e.locale)}|${JSON.stringify(t)}`,r=dh.get(n);if(r)return r;let i=new Intl.Collator(e.locale,t),a={contains(e,t,n){if(!t)return!0;let r=Wm(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(i.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Wm(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Wm(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return dh.set(n,a),a}var ph=fh;function mh(e,t=!1){let{overflowY:n}=je(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}var hh=Symbol(`none`),gh={value:hh,index:-1};function _h(e,t,n){let r=e.get(t);if(r!==void 0||n===Am)return r;for(let[r,i]of e)if(jm(r,t,n))return i}function vh(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:a,defaultInputValue:o,inputValue:s,open:c,defaultOpen:u=!1,selectionMode:d,onItemHighlighted:f,name:p,form:m,disabled:h=!1,readOnly:g=!1,required:_=!1,inputRef:v,grid:y=!1,items:b,filteredItems:x,filter:S,filterQuery:C,openOnInputClick:w=!0,autoHighlight:T=!1,keepHighlight:E=!1,highlightItemOnHover:D=!0,loopFocus:O=!0,itemToStringLabel:k,itemToStringValue:A,isItemEqualToValue:j=Am,virtualized:M=!1,inline:N=!1,fillInputOnItemPress:P=!0,modal:F=!1,limit:I=-1,autoComplete:L=`list`,formAutoComplete:R,locale:z,submitOnItemClick:B=!1}=e,{clearErrors:V}=ih(),{setDirty:ee,validityData:te,setFilled:ne,name:H,disabled:U,setTouched:re,setFocused:ie,validationMode:ae,validation:oe}=th(),se=Al(),ce=sh({id:t}),le=ph({locale:z}),ue=Array.isArray(b)?null:b;if(ue&&typeof ue.label!=`function`)throw Error(Mi(100));let de=ue?ue.data:b,fe=ue?.value,pe=fe?void 0:de,me=l.useMemo(()=>{if(!x||!fe)return;let e=Hm(x),t=e.map(fe),n;return{values:t,findItem(r,i){if(!n){n=new Map;for(let r=0;r<t.length;r+=1)n.has(t[r])||n.set(t[r],e[r])}return _h(n,r,i)}}},[x,fe]),he=l.useMemo(()=>ue?e=>ue.label(e,j,e=>{let t=me?.findItem(e,j);return t==null?Wm(e,k):ue.itemLabel(t)}):k,[ue,k,me,j]),G=l.useMemo(()=>ue?Object.assign(e=>ue.itemLabel(e),{selected:e=>Wm(e,he)}):k,[ue,he,k]);function ge(e){return Wm(e,he)}let[_e,K]=l.useState(!1),[ye,be]=l.useState(null),xe=l.useRef(ye),Se=l.useRef([]),Ce=l.useRef([]),we=l.useRef(null),Te=l.useRef(null),Ee=l.useRef(null),De=l.useRef(null),Oe=l.useRef(null),ke=l.useRef(!0),Ae=l.useRef(!1),je=l.useRef(null),Me=l.useRef(null),Ne=l.useRef(null),Pe=l.useRef(gh),Ie=l.useRef(null),q=l.useRef([]),Le=l.useRef(null),Re=U||h,ze=H??p,Be=d===`multiple`,Ve=d===`single`,He=s!==void 0||o!==void 0,Ue=de!==void 0,We=x!==void 0,Ge;Ge=T===`always`?`always`:T?`input-change`:!1;let[Ke,qe]=gm({controlled:i,default:Be?r??tt:r,name:`Combobox`,state:`selectedValue`}),Je=l.useMemo(()=>S===null?()=>!0:S===void 0?lh(le,G):S,[S,le,G]),Ye=$e(()=>He?o??``:Ve?ge(Ke):``).current,[Xe,Ze]=gm({controlled:s,default:Ye,name:`Combobox`,state:`inputValue`}),[J,Qe]=gm({controlled:c,default:u,name:`Combobox`,state:`open`}),rt=Vm(de),it=!J&&ye!==null?ye:String(Xe).trim(),at=Ve?ge(Ke):``,ot=Ve&&!_e&&it!==``&&at.length===it.length&&le.contains(at,it),st=ot?``:C??it,ct=Ue&&We&&ot&&(!ue||ue.hasValue(Ke,j)),lt=l.useMemo(()=>de?Hm(de):tt,[de]),ut=l.useMemo(()=>{if(x&&!ct)return x;if(!de)return tt;if(rt){let e=de,t=[],n=0;for(let r of e){if(I>-1&&n>=I)break;let e=I>-1?I-n:1/0,i=st===``?r.items.slice(0,e):[];if(st!==``)for(let t of r.items){if(i.length>=e)break;Je(t,st,G)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(st===``)return I>-1?lt.slice(0,I):lt;let e=[];for(let t of lt){if(I>-1&&e.length>=I)break;Je(t,st,G)&&e.push(t)}return e},[x,ct,de,rt,st,I,Je,G,lt]),dt=l.useMemo(()=>{if(me&&ut===x)return me.values;let e=Hm(ut);return fe?e.map(e=>fe(e)):e},[ut,x,me,fe]),Y=$e(()=>{let e=null;return N&&J&&Ue&&d!==`none`&&(e=Im(dt,Ke,j,Be)),new ps({id:ce,labelId:void 0,selectedValue:Ke,open:J,items:pe,selectionMode:d,name:ze,form:m,disabled:Re,readOnly:g,required:_,grid:y,virtualized:M,openOnInputClick:w,itemToStringLabel:he,isItemEqualToValue:j,modal:F,autoHighlight:Ge,submitOnItemClick:B,hasInputValue:He,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:N,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemProps:nt,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:d===`none`},{onOpenChangeComplete:et,setOpen:et,setInputValue:et,setSelectedValue:et,setIndices:et,handleSelection:et,forceMount:et,requestSubmit:et,listRef:Se,labelsRef:Ce,popupRef:we,emptyRef:Oe,inputRef:Te,startDismissRef:Ee,endDismissRef:De,keyboardActiveRef:ke,chipsContainerRef:je,clearRef:Me,valuesRef:q,pointerDownItemRef:Le,selectionEventRef:Ne},Km)}).current,ft=d===`none`?Xe:Ke,pt=l.useMemo(()=>d===`none`?ft:Array.isArray(Ke)?Ke.map(e=>Gm(e,A)):Gm(Ke,A),[ft,A,d,Ke]),mt=$(f),ht=$(n),gt=Y.useState(`activeIndex`),_t=Y.useState(`selectedIndex`),vt=Y.useState(`positionerElement`),yt=Y.useState(`listElement`),bt=Y.useState(`triggerElement`),xt=Y.useState(`inputElement`),St=Y.useState(`inputGroupElement`),Ct=Y.useState(`inline`),wt=Y.useState(`inputInsidePopup`),Tt=Y.useState(`inputOwnsFormValue`),Et=Ve&&!wt&&Xe===at,Dt=Kn(bt),{mounted:kt,setMounted:At,transitionStatus:jt}=_s(J),{openMethod:Mt,triggerProps:Nt}=tl(J),Pt=$(()=>pt);nh(wt?Dt:Te,ce,ft,Pt,!Re,p);let Ft=$(()=>{de?Ce.current=dt.map(ge):Y.set(`forceMounted`,!0)}),It=$((e,t,n)=>{if(t===-1){if(Pe.current===gh)return;Pe.current=gh}else Pe.current={value:e,index:t};mt(e,Pn(n,void 0,{index:t}))}),Lt=$(e=>{let t={};e.activeIndex!==void 0&&(t.activeIndex=e.activeIndex),e.selectedIndex!==void 0&&(t.selectedIndex=e.selectedIndex),Y.update(t);let n=e.activeIndex;if(n===void 0)return;let r=e.type||`none`;n===null?It(void 0,-1,r):It(q.current[n],n,r)}),Rt=$((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(Ae.current=n.reason===Cn,n.reason===`input-change`){J&&ye!==null&&be(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&K(!0),Ie.current={hasQuery:e};let n=Y.state.listElement;if(!Y.state.virtualized&&n){let e=we.current;for(let t of Fe(n.firstElementChild??n)){if(!ve(t)||(e?!X(e,t):t.getAttribute(`role`)===`dialog`))break;if(mh(t)){t.scrollTop=0;break}}}e&&Ge&&Y.state.activeIndex==null&&(J||Ct)&&Y.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&Y.state.inputInsidePopup&&(Ie.current={hasQuery:!1,selection:!0});Ze(t)}}),zt=$(e=>{let t=!e&&wt&&!Ct&&Xe!==``&&(String(Xe).trim()===ye||Xe===at);!e&&(t||Xe===``||Et)&&K(!1),be(null),t&&Rt(``,Z(Cn))}),Bt=$((t,n)=>{if(J!==t&&(n.reason===`escape-key`&&Ue&&dt.length===0&&!Oe.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&ye!==null&&zt(n.reason===Sn),!t&&_e&&(Ve?(Ct||be(it),it===``&&K(!1)):Be&&(Ct||be(it),wt&&Lt({activeIndex:null}),(!wt||Ct)&&Rt(``,Z(Cn,n.event,void 0,{isItemPress:n.reason===bn})))),Qe(t),!t&&wt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(re(!0),ie(!1),ae===`onBlur`)))){let e=d===`none`?Xe:Ke;oe.commit(e)}}),Vt=$((e,t)=>{a?.(e,t),!t.isCanceled&&(qe(e),(d===`none`&&we.current&&P||Ve&&!Y.state.inputInsidePopup)&&Rt(ge(e),Z(t.reason,t.event)))}),Ht=$((e,t)=>{let n=Ot(e),r=Ne.current??e;Ne.current=null;let i=Z(bn,r),a=n?.closest(`a`)?.getAttribute(`href`);if(a){a.startsWith(`#`)&&Bt(!1,i);return}if(Be){let e=Array.isArray(Ke)?Ke:[],n=Nm(e,t,j),r=n?Rm(e,t,j):[...e,t];if(Vt(r,i),i.isCanceled||!(Te.current&&Te.current.value.trim()!==``))return;if(Y.state.inputInsidePopup){Rt(``,Z(Cn,i.event,void 0,{isItemPress:!0}));let e=Ie.current;e&&!n&&(e.toggledValue=t)}else Bt(!1,i)}else{if(Vt(t,i),i.isCanceled)return;Bt(!1,i)}}),Ut=$(()=>{let e=oe.inputRef.current?.form??Y.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),Wt=$(()=>{if(At(!1),ht?.(!1),K(!1),be(null),Lt(d===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Be&&Te.current&&Te.current.value!==``&&!Ae.current&&Rt(``,Z(Cn)),Ve){if(Y.state.inputInsidePopup)Te.current&&Te.current.value!==``&&Rt(``,Z(Cn));else{let e=ge(Ke);Te.current&&Te.current.value!==e&&Rt(e,Z(e===``?Cn:hn))}}}),Gt=l.useMemo(()=>Ct&&vt?{current:vt.closest(`[role="dialog"]`)}:we,[Ct,vt]);xs({enabled:!e.actionsRef,open:J,ref:Gt,onComplete(){J||Wt()}}),l.useImperativeHandle(e.actionsRef,()=>({unmount:Wt}),[Wt]),W(function(){let e=xe.current!==null&&ye===null;if(xe.current=ye,J&&(!e||!Ue)||(J||(Le.current=null),d===`none`))return;let t=Ue?dt:q.current;Lt({selectedIndex:Im(t,Ke,j,Be)})},[J,ye,Ke,d,Be,Ue,dt,j,Lt]),W(()=>{de&&(q.current=dt,Se.current.length=dt.length)},[de,dt]),W(()=>{let e=Ie.current;if(e){let t=J||Ct||Y.state.positionerElement?.hidden===!1;if(e.hasQuery)Ge&&t&&Y.set(`activeIndex`,0),Ie.current=null;else if(String(Xe).trim()===``&&(Ie.current=null,t)){let t=e.selection;Ge===`always`&&!t&&Y.state.selectionMode===`none`&&Y.set(`activeIndex`,0),queueMicrotask(()=>{if(!Y.state.open&&!Y.state.inline||Te.current&&Te.current.value.trim()!==``)return;let n=Y.state.selectedValue,r=Y.state.selectionMode===`multiple`;if(r&&Array.isArray(n)?n.length>0:Y.state.selectionMode!==`none`&&n!=null){let t=Ue||We?dt:q.current,i=Pm(t,e.toggledValue,Y.state.isItemEqualToValue);Y.set(`activeIndex`,i===-1?Im(t,n,Y.state.isItemEqualToValue,r):i)}else t?Y.set(`activeIndex`,null):Ge===`always`&&Y.set(`activeIndex`,0)})}}if(!J&&!Ct)return;let t=Ue||We?dt:q.current,n=Y.state.activeIndex;if(n==null){if(Ge===`always`&&t.length>0){Y.set(`activeIndex`,0);return}It(void 0,-1,hn);return}if(n>=t.length){It(void 0,-1,hn),Y.set(`activeIndex`,null);return}let r=t[n],i=Pe.current.value,a=i!==hh&&jm(r,i,Y.state.isItemEqualToValue);(Pe.current.index!==n||!a)&&It(r,n,hn)},[gt,Ge,It,We,Ue,dt,Ct,J,Y,Xe]),W(()=>{if(d===`none`){ne(String(Xe)!==``);return}ne(Be?Array.isArray(Ke)&&Ke.length>0:Ke!=null)},[ne,d,Xe,Ke,Be]),l.useEffect(()=>{Ue&&Ge&&dt.length===0&&Lt({activeIndex:null})},[Ue,Ge,dt.length,Lt]);function Kt(){J&&it!==``&&it!==String(Ye)&&!Et&&K(!0)}function qt(){J&&ye!==null&&zt(!1)}let Jt=!1;function Yt(){!Jt&&Xe!==at&&(Jt=!0,Rt(at,Z(hn)))}function Xt(){d!==`none`&&(V(ze),ee(Mm(Ke,te.initialValue,j)),oe.change(Ke),Ve&&!He&&!wt&&Yt())}function Zt(){Ve&&!He&&!wt&&!_e&&Yt()}function Qt(){d===`none`&&(V(ze),ee(Xe!==te.initialValue),oe.change(Xe))}$c(it,Kt),$c(J,qt),$c(Ke,Xt),$c(at,Zt),$c(de,Zt),$c(Xe,Qt);let $t=Gs({open:Ct?!0:J,onOpenChange:Bt,elements:{reference:wt?bt:xt,floating:vt}}),en=y?`grid`:`listbox`,tn=J||Ct,nn=tn?`true`:`false`,rn=l.useMemo(()=>{let e=xt?.tagName===`INPUT`,t=xt==null||e,n=t||tn,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=nn,r[`aria-haspopup`]=en,r[`aria-controls`]=tn?yt?.id:void 0,r[`aria-autocomplete`]=g?`none`:L),{reference:r,floating:{role:`presentation`}}},[xt,tn,nn,en,yt?.id,L,g]),an=La($t,{enabled:!Re&&w,event:`mousedown-only`,toggle:!1,touchOpenDelay:wt?0:100,reason:wn}),on=Ua($t,{enabled:!Re&&!Ct,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:Ct?!0:void 0,outsidePress(e){let t=Ot(e);return!X(bt,t)&&!X(Me.current,t)&&!X(je.current,t)&&!X(St,t)}}),sn=dc($t,{enabled:!Re,id:ce,listRef:Se,activeIndex:gt,selectedIndex:_t,virtual:!0,loopFocus:O,allowEscape:O&&!Ge,focusItemOnOpen:_e||d===`none`&&!Ge?!1:`auto`,focusItemOnHover:D,resetOnPointerLeave:!E,orientation:y?`horizontal`:void 0,rtl:se===`rtl`,disabledIndices:tt,grid:y?vm:void 0,onNavigate(e,t){(t||J)&&jt!==`ending`&&Lt(t?{activeIndex:e,type:ke.current?On:kn}:{activeIndex:e})}}),cn=l.useMemo(()=>Vi(sn.reference,{onKeyDown(e){y&&Y.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},on.reference,an.reference,rn.reference),[sn.reference,on.reference,an.reference,rn.reference,y,Y]),ln=l.useMemo(()=>Vi(Ss,on.floating),[on.floating]),un=l.useMemo(()=>Vi(sn.floating,rn.floating),[sn.floating,rn.floating]),dn=l.useMemo(()=>{let e=sn.item;return e?{...e,onFocus:void 0}:nt},[sn.item]);Y.useContextCallback(`setOpen`,Bt),Y.useContextCallback(`setInputValue`,Rt),Y.useContextCallback(`setSelectedValue`,Vt),Y.useContextCallback(`setIndices`,Lt),Y.useContextCallback(`handleSelection`,Ht),Y.useContextCallback(`forceMount`,Ft),Y.useContextCallback(`requestSubmit`,Ut),Y.useContextCallback(`onOpenChangeComplete`,n),_m(()=>{Y.update({inline:N,popupProps:ln,listProps:un,inputProps:cn,triggerProps:Nt,itemProps:dn})});let fn={id:ce,selectedValue:Ke,open:J,mounted:kt,transitionStatus:jt,items:pe,inline:N,popupProps:ln,listProps:un,inputProps:cn,triggerProps:Nt,itemProps:dn,openMethod:Mt,selectionMode:d,name:ze,form:m,disabled:Re,readOnly:g,required:_,grid:y,virtualized:M,openOnInputClick:w,itemToStringLabel:he,modal:F,autoHighlight:Ge,isItemEqualToValue:j,submitOnItemClick:B,hasInputValue:He};W(()=>{Y.update({...fn,inputOwnsFormValue:d===`none`&&(N||!Y.state.inputInsidePopup)})},[Y,...Object.values(fn)]);let pn=Bn(v,oe.inputRef),mn=l.useMemo(()=>({query:it,hasItems:Ue,filteredItems:ut,flatFilteredValues:dt}),[it,Ue,ut,dt]),gn=l.useMemo(()=>Array.isArray(ft)?``:Gm(ft,A),[ft,A]),_n=Be&&Array.isArray(Ke)&&Ke.length>0,vn=Be||d===`none`&&Tt?void 0:ze,yn=l.useMemo(()=>!Be||!Array.isArray(Ke)||!ze?null:Ke.map(e=>{let t=Gm(e,A);return(0,Q.jsx)(`input`,{type:`hidden`,form:m,name:ze,value:t,disabled:Re},t)}),[Be,Ke,m,ze,A,Re]),xn=(0,Q.jsxs)(l.Fragment,{children:[e.children,(0,Q.jsx)(`input`,{...oe.getValidationProps(Re,{onFocus(){if(wt){bt?.focus();return}(Te.current||bt)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||Re||g)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=Z(hn,e.nativeEvent),i=()=>q.current.findIndex(e=>Gm(e,A).toLowerCase()===n||ge(e).toLowerCase()===n);function a(){if(Be)return;if(d===`none`){Rt(t,r);return}let e=i();e===-1&&(e=q.current.findIndex((e,t)=>{let r=Ce.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:q.current[e];a!=null&&Vt?.(a,r)}Ve&&(Ft(),de&&i()===-1&&Y.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:ce&&vn==null?`${ce}-hidden-input`:void 0,form:m,name:vn,autoComplete:R,disabled:Re,required:_&&!_n,readOnly:g,value:gn,ref:pn,style:vn?tr:er,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),yn]});return(0,Q.jsx)(ym.Provider,{value:Y,children:(0,Q.jsx)(bm.Provider,{value:$t,children:(0,Q.jsx)(Sm.Provider,{value:Ue,children:(0,Q.jsx)(xm.Provider,{value:mn,children:(0,Q.jsx)(Cm.Provider,{value:Xe,children:xn})})})})})}function yh(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,Q.jsx)(vh,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}function bh(e,t){return e??t}var xh=`data-popup-side`,Sh=`data-list-empty`,Ch={...Zt,...Qm,popupSide:e=>e?{[xh]:e}:null,listEmpty:e=>e?{[Sh]:``}:null},wh=l.createContext(void 0);function Th(){return l.useContext(wh)}var Eh=l.createContext(void 0);function Dh(e){let t=l.useContext(Eh);if(t===void 0&&!e)throw Error(Mi(21));return t}var Oh=l.forwardRef(function(e,t){let n=wm(),{buttonRef:r,getButtonProps:i}=Fc({native:!1}),a=Bn(t,r);function o(e){n.context.setOpen(!1,Z(xn,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return(0,Q.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:tr})});function kh(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function Ah(){return Em().filteredItems.length===0}function jh(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function Mh(e,t){let n=e>=t-1?t-2:e;return n>=0?n:void 0}function Nh(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}var Ph=l.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:c,disabled:u,setTouched:d,setFocused:f,validationMode:p,validation:m}=th(),{labelId:h}=oh(),g=Th(),_=!!Dh(!0),v=wm(),y=Dm(),b=Al(),x=v.useState(`required`),S=v.useState(`disabled`),C=v.useState(`readOnly`),w=v.useState(`name`),T=v.useState(`form`),E=v.useState(`selectionMode`),D=v.useState(`autoHighlight`),O=v.useState(`inputProps`),k=v.useState(`triggerProps`),A=v.useState(`open`),j=v.useState(`mounted`),M=v.useState(`selectedValue`),N=v.useState(`id`),P=v.useState(`inline`),F=v.useState(`modal`),I=!!D,L=kh(v),R=u||S||i,z=Ah(),B=_||P,V=!B||F,ee=zc(a??(B?void 0:N)),te=_?Xm:c,[ne,H]=l.useState(null),U=l.useRef(!1),re=l.useRef(null),ie=l.useRef(!1),ae=E===`none`&&!_,oe=$(e=>{let t=_||v.state.inline;t&&!v.state.hasInputValue&&v.context.setInputValue(``,Z(hn)),v.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:ae})}),se=_?s:m.getValidationProps(R,s);function ce(){v.context.setIndices({activeIndex:null,selectedIndex:null,type:v.context.keyboardActiveRef.current?On:kn})}function le(){v.context.keyboardActiveRef.current=!1}let ue={...te,open:A,disabled:R,readOnly:C,popupSide:L,listEmpty:z};function de(e){if(!g)return;let t,{highlightedChipIndex:n}=g,r=g.chipsRef.current.length,[i,a]=jh(b);return n===void 0?(e.key===i&&(e.currentTarget.selectionStart??0)===0&&M.length>0&&(e.preventDefault(),t=r>0?r-1:void 0),t):(e.key===i?(e.preventDefault(),t=n>0?n-1:void 0):e.key===a?(e.preventDefault(),t=n<r-1?n+1:void 0):(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),t=Mh(n,M.length),ce()),t)}let fe=ta(`input`,e,{state:ue,ref:[t,v.context.inputRef,oe],props:[O,k,{value:ne??y,"aria-readonly":C||void 0,"aria-required":x||void 0,"aria-labelledby":h,disabled:R,readOnly:C,required:E===`none`?x:void 0,form:T,...ae&&w&&{name:w},id:ee,onFocus(){if(f(!0),!P||!ie.current)return;ie.current=!1;let e=re.current;e!=null&&Object.hasOwn(v.context.valuesRef.current,e)&&v.context.setIndices({activeIndex:e})},onBlur(){d(!0),f(!1);let e=v.state.activeIndex;if(P&&e!==null&&D!==`always`&&(re.current=e,ie.current=!0,v.context.setIndices({activeIndex:null})),p===`onBlur`){let e=E===`none`?y:M;m.commit(e)}},onCompositionStart(e){Ge||(U.current=!0,H(e.currentTarget.value))},onCompositionEnd(e){U.current=!1;let t=e.currentTarget.value;H(null),v.context.setInputValue(t,Z(Sn,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=U.current||!r;function a(e){!C&&!R&&e&&i&&(v.context.setOpen(!0,Z(Sn,t)),I||ce())}if(U.current){let n=e.currentTarget.value;H(n),n===``&&!v.state.openOnInputClick&&!v.state.inputInsidePopup&&v.context.setOpen(!1,Z(Cn,t));let r=n.trim(),i=I&&r!==``;a(r),A&&v.state.activeIndex!==null&&!i&&ce();return}let o=Z(Sn,t);if(v.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=Z(Cn,t);s&&!v.state.inputInsidePopup&&(E===`single`&&v.context.setSelectedValue(null,c),v.state.openOnInputClick||v.context.setOpen(!1,c)),a(e.currentTarget.value.trim()),A&&v.state.activeIndex!==null&&!I&&ce()},onKeyDown(e){if(e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;if(v.context.keyboardActiveRef.current=!0,R||C){C&&e.key===`Enter`&&A&&v.state.activeIndex!==null&&xt(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=b===`rtl`;if(e.key===`Home`){xt(e);let n=Ye&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){xt(e);let i=Ye&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!j&&e.key===`Escape`){let t=E===`multiple`&&Array.isArray(M)?M.length===0:M===null,n=Z(En,e.nativeEvent),r=E===`multiple`?[]:null;v.context.setInputValue(``,n),v.context.setSelectedValue(r,n),!t&&!v.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(g&&e.key===`Backspace`&&t.value===``&&g.highlightedChipIndex===void 0&&Array.isArray(M)&&M.length>0){let t=g.chipsRef.current.length,n=t>0?t-1:M.length-1,r=M.filter((e,t)=>t!==n);ce(),v.context.setSelectedValue(r,Z(hn,e.nativeEvent));return}let i=g?.highlightedChipIndex!==void 0,a=de(e);if(g?.setHighlightedChipIndex(a),a===void 0?i&&v.context.inputRef.current?.focus():g?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&A){let t=v.state.activeIndex,n=e.nativeEvent;if(t===null){if(P)return;v.context.setOpen(!1,Z(hn,n));return}xt(e),Nh(v,t,n)}},onPointerMove:le,onPointerDown:le},se],stateAttributesMapping:Ch}),pe=_?(0,Q.jsx)(eh.Provider,{value:$m,children:fe}):fe;return(0,Q.jsxs)(l.Fragment,{children:[A&&V&&(0,Q.jsx)(Oh,{ref:v.context.startDismissRef}),pe]})}),Fh=5;function Ih(e,t){let n=Lh(t);return e.clientX>=n.left-Fh&&e.clientX<=n.right+Fh&&e.clientY>=n.top-Fh&&e.clientY<=n.bottom+Fh}function Lh(e){let t=e.getBoundingClientRect(),n=G(e);if(Ze)return t;let r=n.getComputedStyle(e,`::before`),i=n.getComputedStyle(e,`::after`);if(r.content===`none`&&i.content===`none`)return t;let a=parseFloat(r.width)||0,o=parseFloat(r.height)||0,s=parseFloat(i.width)||0,c=parseFloat(i.height)||0,l=Math.max(t.width,a,s),u=Math.max(t.height,o,c),d=l-t.width,f=u-t.height;return{left:t.left-d/2,right:t.right+d/2,top:t.top-f/2,bottom:t.bottom+f/2}}var Rh=l.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:u,disabled:d,setTouched:f,setFocused:p,validationMode:m,validation:h}=th(),{labelId:g}=oh(),_=wm(),v=_.useState(`selectionMode`),y=_.useState(`disabled`),b=_.useState(`readOnly`),x=_.useState(`required`),S=_.useState(`positionerElement`),C=_.useState(`listElement`),w=_.useState(`popupId`),T=_.useState(`triggerProps`),E=_.useState(`inputInsidePopup`),D=_.useState(`id`),O=_.useState(`labelId`),k=_.useState(`open`),A=_.useState(`selectedValue`),j=_.useState(`activeIndex`),M=_.useState(`selectedIndex`),N=_.useState(`hasSelectedValue`),P=Tm(),F=Dm(),I=ot(),L=d||y||a,R=Ah(),z=kh(_);sh({id:E?o:void 0});let B=E?o??D:o,V=bh(g,O),ee;k&&E?ee=w??ch(D):k&&(ee=C?.id);let te=l.useRef(``);function ne(e){te.current=e.pointerType}let{reference:H}=fc(P,{enabled:!k&&!b&&!y&&v===`single`,listRef:_.context.labelsRef,activeIndex:j,selectedIndex:M,onMatch(e){let t=_.context.valuesRef.current[e];t!==void 0&&_.context.setSelectedValue(t,Z(hn))}}),{reference:U}=La(P,{enabled:!y,event:`mousedown`}),{buttonRef:re,getButtonProps:ie}=Fc({native:i,disabled:L}),ae={...u,readOnly:b,open:k,disabled:L,popupSide:z,listEmpty:R,placeholder:v!==`none`&&!N};return ta(`button`,e,{ref:[t,re,$(e=>{_.set(`triggerElement`,e)})],state:ae,props:[T,U,H,{id:B,tabIndex:E?0:-1,role:E?`combobox`:void 0,"aria-expanded":k,"aria-haspopup":E?`dialog`:`listbox`,"aria-controls":ee,"aria-required":E&&x||void 0,"aria-readonly":E&&b||void 0,"aria-labelledby":V,onPointerDown:ne,onPointerEnter:ne,onFocus(){p(!0),!L&&I.start(0,_.context.forceMount)},onBlur(e){if(!X(S,e.relatedTarget)&&(f(!0),p(!1),m===`onBlur`)){let e=v===`none`?F:A;h.commit(e)}},onMouseDown(e){if(L||(E||P.set(`domReferenceElement`,e.currentTarget),_.context.forceMount(),te.current!==`touch`&&(_.context.inputRef.current?.focus(),E||e.preventDefault()),k))return;let t=J(e.currentTarget);function n(e){let t=_.state.triggerElement;if(!t)return;let n=Ot(e),r=_.state.positionerElement,i=_.state.listElement;X(t,n)||X(r,n)||X(i,n)||Ih(e,t)||_.context.setOpen(!1,Z(An,e))}E&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(xt(e),_.context.setOpen(!0,Z(Dn,e.nativeEvent)),_.context.inputRef.current?.focus())}},h.getValidationProps(L,c),ie],stateAttributesMapping:Ch})}),zh=l.createContext(null);function Bh(){return l.useContext(zh)}function Vh(e){let{children:t}=e,{filteredItems:n}=Em(),r=Bh(),i=r?r.items:n;return(0,Q.jsx)(l.Fragment,{children:i.map(t)})}var Hh=l.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function Uh(){return l.useContext(Hh)}function Wh(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=$(i),[,o]=l.useState(!1),s=$e(Kh).current,c=$e(Gh).current,u=l.useRef(0),d=l.useRef(!0),f=l.useRef(null),p=l.useRef(null),m=$(()=>{d.current||(d.current=!0,o(e=>!e))}),h=$((e,t)=>{c.set(e,t),m()}),g=$(e=>{c.delete(e),m()}),_=$(e=>{let t=new Map;return n.current.length=0,r&&(r.current.length=0),e.forEach(e=>{t.set(e.element,{...e.registration.metadata??{},index:e.index}),n.current[e.index]=e.element,r&&(r.current[e.index]=e.registration.label===void 0?e.registration.textRef?.current?.textContent??e.element.textContent:e.registration.label)}),u.current=n.current.length,t});function v(e){if(p.current?.disconnect(),p.current=null,typeof MutationObserver!=`function`||e.length<2)return;let t=new MutationObserver(n=>{if(!Yh(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&Xh(r,n)>0){t.disconnect(),m();return}r=n}});p.current=t;let n=new Set;for(let t=1;t<e.length;t+=1){let r=Jh(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let y=$(()=>{let[e,t]=qh(c),n=_(e),r=f.current,i=!r||r.length!==e.length||e.some((e,t)=>{let n=r[t];return e.index!==n.index||e.element!==n.element||e.registration.index!==n.registration.index||e.registration.metadata!==n.registration.metadata});v(t),f.current=e,d.current=!1,i&&(s.forEach(e=>e(n)),a(n))});W(()=>(!d.current&&f.current&&_(f.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,_]),W(()=>{d.current&&y()}),W(()=>()=>{p.current?.disconnect(),d.current=!0},[]);let b=$(e=>(s.add(e),()=>{s.delete(e)})),x=l.useMemo(()=>({register:h,unregister:g,subscribeMapChange:b,nextIndexRef:u}),[h,g,b,u]);return(0,Q.jsx)(Hh.Provider,{value:x,children:t})}function Gh(){return new Map}function Kh(){return new Set}function qh(e){let t=new Set,n=[],r=[];e.forEach((e,i)=>{if(!i.isConnected)return;let a=e.index,o={index:a??-1,element:i,registration:e};a===null?r.push(o):a>=0&&(t.add(a),n.push(o))});let i=0;return r.sort((e,t)=>Xh(e.element,t.element)),r.forEach(e=>{for(;t.has(i);)i+=1;e.index=i,n.push(e),i+=1}),t.size>0&&n.sort((e,t)=>e.index-t.index),[n,r.map(e=>e.element)]}function Jh(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function Yh(e){for(let t of e)for(let e=0;e<t.removedNodes.length;e+=1)if(t.removedNodes[e].isConnected)return!0;return!1}function Xh(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var Zh=l.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=wm(),u=Tm(),d=!!Dh(!0),{filteredItems:f,hasItems:p}=Em(),m=c.useState(`selectionMode`),h=c.useState(`grid`),g=c.useState(`readOnly`),_=c.useState(`listProps`),v=c.useState(`virtualized`),y=c.useState(`forceMounted`),b=m===`multiple`,x=f.length===0,S=$(e=>{c.set(`positionerElement`,e)}),C=$(e=>{c.set(`listElement`,e)}),w=l.useMemo(()=>typeof o==`function`?n||=(0,Q.jsx)(Vh,{children:o}):o,[o]),T={empty:x},E=u.useState(`floatingId`),D=ta(`div`,e,{state:T,ref:[t,C,d?null:S],props:[_,{children:w,tabIndex:-1,id:E,role:h?`grid`:`listbox`,"aria-multiselectable":b?`true`:void 0,"aria-readonly":!h&&g?!0:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;xt(e),Nh(c,t,e.nativeEvent)}},onKeyDownCapture(){c.context.keyboardActiveRef.current=!0},onPointerMoveCapture(){c.context.keyboardActiveRef.current=!1}},s]});if(v)return D;let O=p&&!y?void 0:c.context.labelsRef;return(0,Q.jsx)(Wh,{elementsRef:c.context.listRef,labelsRef:O,children:D})}),Qh=``;function $h(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function eg(){let e=ot(),t=l.useRef(null);return l.useEffect(()=>{if(Ue)return;let n=t.current;if(n==null)return;let r=$h(n);if(r==null)return;let i=r.data,a=`${i}${Qh}`;return r.nodeValue=a,e.start(200,()=>{r.nodeValue===a&&(r.nodeValue=i)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=i)}},[t,e]),t}var tg=l.createContext(void 0);function ng(){let e=l.useContext(tg);if(e===void 0)throw Error(Mi(20));return e}var rg=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=wm(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?(0,Q.jsx)(tg.Provider,{value:n,children:(0,Q.jsx)(_a,{ref:t,...r})}):null}),ig=20;function ag(e,t,n,r){let[i,a]=l.useState(!1);W(()=>{if(!e||!t||n==null){a(!1);return}let r=J(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-ig)},[e,t,n]),bt(e&&(!t||i),r)}var og=l.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m=!1,collisionAvoidance:h=la,style:g,..._}=e,v=wm(),y=Tm(),b=ng(),x=v.useState(`modal`),S=v.useState(`open`),C=v.useState(`mounted`),w=v.useState(`openMethod`),T=v.useState(`positionerElement`),E=v.useState(`triggerElement`),D=v.useState(`inputElement`),O=v.useState(`inputGroupElement`),k=v.useState(`inputInsidePopup`),A=v.useState(`transitionStatus`),j=Ah(),M=Wl({anchor:i??(k?E:O??D),floatingRootContext:y,positionMethod:a,mounted:C,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m,keepMounted:b,collisionAvoidance:h,lazyFlip:!0});ag(S&&x,w===`touch`,T,E);let N={open:S,side:M.side,align:M.align,anchorHidden:M.anchorHidden,empty:j};W(()=>{v.set(`popupSide`,M.side)},[v,M.side]);let P=$(e=>{v.set(`positionerElement`,e)}),F=Jl(e,N,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,P],hidden:!C,inert:!S});return(0,Q.jsxs)(Eh.Provider,{value:M,children:[C&&x&&(0,Q.jsx)(Yc,{inert:Jc(!S),cutout:O??D??E}),F]})}),sg={...Qt,...zt},cg=l.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=wm(),u=Dh(),d=Tm(),f=c.useState(`mounted`),p=c.useState(`open`),m=c.useState(`openMethod`),h=c.useState(`popupProps`),g=c.useState(`transitionStatus`),_=c.useState(`inputInsidePopup`),v=c.useState(`inputElement`),y=c.useState(`modal`),b=c.useState(`id`),x=Ah(),S=s.id??(_?ch(b):void 0);W(()=>(c.set(`popupId`,c.context.popupRef.current?.id||S),()=>{c.set(`popupId`,void 0)}),[c,S]),xs({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete(!0)}});let C=ta(`div`,e,{state:{open:p,side:u.side,align:u.align,anchorHidden:u.anchorHidden,transitionStatus:g,empty:x},ref:[t,c.context.popupRef],props:[h,{id:S,role:_?`dialog`:`presentation`,onFocus(e){let t=Ot(e.nativeEvent);m!==`touch`&&(X(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},ql(g),s],stateAttributesMapping:sg}),w=a===void 0?_?e=>e===`touch`?c.context.popupRef.current:v:!1:a,T;T=o??(_?void 0:!1);let E=!_||y;return(0,Q.jsx)(Ia,{context:d,disabled:!f,modal:E,openInteractionType:m,initialFocus:w,returnFocus:T,getInsideElements:()=>[c.context.startDismissRef.current,c.context.endDismissRef.current],children:(0,Q.jsxs)(l.Fragment,{children:[C,E&&(0,Q.jsx)(Oh,{ref:c.context.endDismissRef})]})})});function lg(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:u}=Uh(),d=l.useRef(-1),[f,p]=l.useState(a==null&&t?()=>{if(d.current===-1){let e=u.current;u.current+=1,d.current=e}return d.current}:-1),m=a??f,h=l.useRef(null),g=l.useCallback(e=>{let t=h.current;t&&s(t),h.current=e,e&&o(e,{metadata:r??null,index:a??null,label:n,textRef:i})},[a,o,s,r,n,i]);return W(()=>{if(a==null)return c(e=>{let t=h.current?e.get(h.current)?.index:null;t!=null&&p(t)})},[a,c]),{ref:g,index:m}}var ug=l.createContext(void 0);function dg(){let e=l.useContext(ug);if(!e)throw Error(Mi(19));return e}var fg=l.createContext(!1);function pg(){return l.useContext(fg)}function mg(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:u,disabled:d=!1,nativeButton:f=!1,...p}=t,m=l.useRef(null),h=lg({guess:!0,index:u,textRef:m}),g=wm(),_=pg(),v=Om(),y=g.useState(`selectionMode`),b=g.useState(`disabled`),x=g.useState(`readOnly`),S=g.useState(`isItemEqualToValue`),C=b||d,w=y!==`none`,T=u??i??h.index,E=T!==-1,D=g.useState(`id`),O=g.useState(`isActive`,T),k=g.useState(`isSelected`,c),A=g.useState(`itemProps`),j=l.useRef(null),M=D!=null&&E?`${D}-${T}`:void 0,N=k&&w;W(()=>{if(!E||!r&&u==null)return;let e=g.context.listRef.current;return e[T]=j.current,()=>{delete e[T]}},[E,r,T,u,g]),W(()=>{if(!E||v)return;let e=g.context.valuesRef.current;return e[T]=c,()=>{delete e[T]}},[E,v,T,c,g]),W(()=>{if(!E||v)return;let e=g.state.selectedValue,t=g.state.selectedIndex;g.state.selectionMode===`multiple`&&Array.isArray(e)?t=Lm(T,c,g.context.valuesRef.current,e,S,t):jm(c,e,S)&&(t=T),g.set(`selectedIndex`,t)},[E,v,g,T,c,S]);let{getButtonProps:P,buttonRef:F}=Fc({disabled:C,focusableWhenDisabled:!0,native:f,composite:!0}),I={disabled:C,selected:N,highlighted:O};function L(e){function t(){g.context.handleSelection(e,c)}g.state.submitOnItemClick?(fa.flushSync(t),g.context.requestSubmit()):t()}let R={id:M,role:_?`gridcell`:`option`,"aria-selected":w?N:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(g.context.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){C||x||L(e.nativeEvent)},onMouseUp(e){let t=g.context.pointerDownItemRef.current===e.currentTarget;g.context.pointerDownItemRef.current=null,!(C||x||e.button!==0||t||!O)&&L(e.nativeEvent)}},z=ta(`div`,t,{ref:[F,n,h.ref,j],state:I,props:[A,R,p,P]}),B=l.useMemo(()=>({selected:N,textRef:m}),[N,m]);return(0,Q.jsx)(ug.Provider,{value:B,children:z})}function hg(e){let{componentProps:t,forwardedRef:n}=e,r=wm().useState(`isItemEqualToValue`),{flatFilteredValues:i}=Em(),a=Pm(i,t.value??null,r);return(0,Q.jsx)(mg,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}var gg=l.memo(l.forwardRef(function(e,t){let n=wm().useState(`virtualized`);return n&&e.index==null?(0,Q.jsx)(hg,{componentProps:e,forwardedRef:t}):(0,Q.jsx)(mg,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),_g=l.forwardRef(function(e,t){let{selected:n}=dg();return e.keepMounted||n?(0,Q.jsx)(vg,{...e,ref:t}):null}),vg=l.memo(l.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=dg(),c=l.useRef(null),{transitionStatus:u,setMounted:d}=_s(s),f=ta(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:u},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:zt});return xs({batch:!0,enabled:!s,open:s,ref:c,onComplete(){s||d(!1)}}),f})),yg=l.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=Em(),c=wm(),l=eg(),u=s.length===0?a:null;return ta(`div`,e,{ref:[t,c.context.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})});function bg({label:e,value:t,options:n,onChange:r,icon:i,allowCustom:a=!1,action:o}){let[s,c]=(0,l.useState)(``),u=n.find(e=>e.value===t)??{value:t,label:t},d=s.trim(),f=n.filter(e=>e.label.toLowerCase().includes(d.toLowerCase())),p=a&&d&&!n.some(e=>e.value===d)?{value:d,label:`Use “${d}”`}:null;return(0,Q.jsxs)(yh,{items:p?[...f,p]:f,value:u,filter:null,inputValue:s,onInputValueChange:c,onOpenChange:()=>c(``),itemToStringLabel:e=>e.label,isItemEqualToValue:(e,t)=>e.value===t.value,onValueChange:e=>{e&&!e.disabled&&r(e.value)},children:[(0,Q.jsx)(Zl,{label:`${e}: ${u.label}`,children:(0,Q.jsxs)(Rh,{className:`composer-select`,"aria-label":`${e}: ${u.label}`,children:[(0,Q.jsx)(`span`,{className:`composer-select-icon`,"aria-hidden":`true`,children:u.icon??i}),(0,Q.jsx)(`span`,{className:`composer-select-label`,children:u.shortLabel??(u.label||e)}),(0,Q.jsx)(b,{className:`composer-select-caret`,size:11,"aria-hidden":`true`})]})}),(0,Q.jsx)(rg,{children:(0,Q.jsx)(og,{className:`composer-select-positioner`,sideOffset:6,align:`start`,collisionPadding:12,children:(0,Q.jsxs)(cg,{className:`composer-select-popup`,"aria-label":`${e} options`,children:[(0,Q.jsxs)(`div`,{className:`composer-select-search`,children:[(0,Q.jsx)(ie,{size:14,"aria-hidden":`true`}),(0,Q.jsx)(Ph,{"aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}…`,maxLength:a?120:void 0})]}),(0,Q.jsx)(yg,{className:`composer-select-empty`,children:`No matches`}),(0,Q.jsx)(Zh,{className:`composer-select-list`,children:e=>(0,Q.jsxs)(gg,{value:e,disabled:e.disabled,className:`composer-select-option`,children:[e.icon&&(0,Q.jsx)(`span`,{className:`composer-select-option-icon`,"aria-hidden":`true`,children:e.icon}),(0,Q.jsx)(`span`,{className:`composer-select-option-label`,children:e.label}),(0,Q.jsx)(_g,{className:`composer-select-check`,children:(0,Q.jsx)(y,{size:14})})]},e.value)}),o&&(0,Q.jsxs)(`button`,{type:`button`,className:`composer-select-action`,onClick:o.onClick,children:[o.icon,(0,Q.jsx)(`span`,{children:o.label})]})]})})})]})}var xg=[`pi`,`claude`,`codex`,`gemini`,`cursor`,`devin`,`agy`,`cline`,`omp`,`mastracode`,`opencode`,`copilot`,`kimi`,`kiro`,`droid`,`amp`,`grok`,`hermes`,`kilo`,`qodercli`,`qwen`,`letta`,`maki`,`muse`];function Sg({harness:e,size:t=14}){let[n,r]=(0,l.useState)(!1);return(0,Q.jsx)(`span`,{className:`harness-icon`,style:{width:t,height:t},"aria-hidden":`true`,children:xg.includes(e)&&!n?(0,Q.jsx)(`img`,{src:`/harness-icons/${e}.png`,alt:``,width:t,height:t,onError:()=>r(!0)}):(0,Q.jsx)(`span`,{className:`harness-icon-letter`,children:e.charAt(0).toUpperCase()})})}var Cg={macos:`M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701`,linux:`M12.504 0c-.155 0-.315.008-.48.021-4.226.333-3.105 4.807-3.17 6.298-.076 1.092-.3 1.953-1.05 3.02-.885 1.051-2.127 2.75-2.716 4.521-.278.832-.41 1.684-.287 2.489a.424.424 0 00-.11.135c-.26.268-.45.6-.663.839-.199.199-.485.267-.797.4-.313.136-.658.269-.864.68-.09.189-.136.394-.132.602 0 .199.027.4.055.536.058.399.116.728.04.97-.249.68-.28 1.145-.106 1.484.174.334.535.47.94.601.81.2 1.91.135 2.774.6.926.466 1.866.67 2.616.47.526-.116.97-.464 1.208-.946.587-.003 1.23-.269 2.26-.334.699-.058 1.574.267 2.577.2.025.134.063.198.114.333l.003.003c.391.778 1.113 1.132 1.884 1.071.771-.06 1.592-.536 2.257-1.306.631-.765 1.683-1.084 2.378-1.503.348-.199.629-.469.649-.853.023-.4-.2-.811-.714-1.376v-.097l-.003-.003c-.17-.2-.25-.535-.338-.926-.085-.401-.182-.786-.492-1.046h-.003c-.059-.054-.123-.067-.188-.135a.357.357 0 00-.19-.064c.431-1.278.264-2.55-.173-3.694-.533-1.41-1.465-2.638-2.175-3.483-.796-1.005-1.576-1.957-1.56-3.368.026-2.152.236-6.133-3.544-6.139zm.529 3.405h.013c.213 0 .396.062.584.198.19.135.33.332.438.533.105.259.158.459.166.724 0-.02.006-.04.006-.06v.105a.086.086 0 01-.004-.021l-.004-.024a1.807 1.807 0 01-.15.706.953.953 0 01-.213.335.71.71 0 00-.088-.042c-.104-.045-.198-.064-.284-.133a1.312 1.312 0 00-.22-.066c.05-.06.146-.133.183-.198.053-.128.082-.264.088-.402v-.02a1.21 1.21 0 00-.061-.4c-.045-.134-.101-.2-.183-.333-.084-.066-.167-.132-.267-.132h-.016c-.093 0-.176.03-.262.132a.8.8 0 00-.205.334 1.18 1.18 0 00-.09.4v.019c.002.089.008.179.02.267-.193-.067-.438-.135-.607-.202a1.635 1.635 0 01-.018-.2v-.02a1.772 1.772 0 01.15-.768c.082-.22.232-.406.43-.533a.985.985 0 01.594-.2zm-2.962.059h.036c.142 0 .27.048.399.135.146.129.264.288.344.465.09.199.14.4.153.667v.004c.007.134.006.2-.002.266v.08c-.03.007-.056.018-.083.024-.152.055-.274.135-.393.2.012-.09.013-.18.003-.267v-.015c-.012-.133-.04-.2-.082-.333a.613.613 0 00-.166-.267.248.248 0 00-.183-.064h-.021c-.071.006-.13.04-.186.132a.552.552 0 00-.12.27.944.944 0 00-.023.33v.015c.012.135.037.2.08.334.046.134.098.2.166.268.01.009.02.018.034.024-.07.057-.117.07-.176.136a.304.304 0 01-.131.068 2.62 2.62 0 01-.275-.402 1.772 1.772 0 01-.155-.667 1.759 1.759 0 01.08-.668 1.43 1.43 0 01.283-.535c.128-.133.26-.2.418-.2zm1.37 1.706c.332 0 .733.065 1.216.399.293.2.523.269 1.052.468h.003c.255.136.405.266.478.399v-.131a.571.571 0 01.016.47c-.123.31-.516.643-1.063.842v.002c-.268.135-.501.333-.775.465-.276.135-.588.292-1.012.267a1.139 1.139 0 01-.448-.067 3.566 3.566 0 01-.322-.198c-.195-.135-.363-.332-.612-.465v-.005h-.005c-.4-.246-.616-.512-.686-.71-.07-.268-.005-.47.193-.6.224-.135.38-.271.483-.336.104-.074.143-.102.176-.131h.002v-.003c.169-.202.436-.47.839-.601.139-.036.294-.065.466-.065zm2.8 2.142c.358 1.417 1.196 3.475 1.735 4.473.286.534.855 1.659 1.102 3.024.156-.005.33.018.513.064.646-1.671-.546-3.467-1.089-3.966-.22-.2-.232-.335-.123-.335.59.534 1.365 1.572 1.646 2.757.13.535.16 1.104.021 1.67.067.028.135.06.205.067 1.032.534 1.413.938 1.23 1.537v-.043c-.06-.003-.12 0-.18 0h-.016c.151-.467-.182-.825-1.065-1.224-.915-.4-1.646-.336-1.77.465-.008.043-.013.066-.018.135-.068.023-.139.053-.209.064-.43.268-.662.669-.793 1.187-.13.533-.17 1.156-.205 1.869v.003c-.02.334-.17.838-.319 1.35-1.5 1.072-3.58 1.538-5.348.334a2.645 2.645 0 00-.402-.533 1.45 1.45 0 00-.275-.333c.182 0 .338-.03.465-.067a.615.615 0 00.314-.334c.108-.267 0-.697-.345-1.163-.345-.467-.931-.995-1.788-1.521-.63-.4-.986-.87-1.15-1.396-.165-.534-.143-1.085-.015-1.645.245-1.07.873-2.11 1.274-2.763.107-.065.037.135-.408.974-.396.751-1.14 2.497-.122 3.854a8.123 8.123 0 01.647-2.876c.564-1.278 1.743-3.504 1.836-5.268.048.036.217.135.289.202.218.133.38.333.59.465.21.201.477.335.876.335.039.003.075.006.11.006.412 0 .73-.134.997-.268.29-.134.52-.334.74-.4h.005c.467-.135.835-.402 1.044-.7zm2.185 8.958c.037.6.343 1.245.882 1.377.588.134 1.434-.333 1.791-.765l.211-.01c.315-.007.577.01.847.268l.003.003c.208.199.305.53.391.876.085.4.154.78.409 1.066.486.527.645.906.636 1.14l.003-.007v.018l-.003-.012c-.015.262-.185.396-.498.595-.63.401-1.746.712-2.457 1.57-.618.737-1.37 1.14-2.036 1.191-.664.053-1.237-.2-1.574-.898l-.005-.003c-.21-.4-.12-1.025.056-1.69.176-.668.428-1.344.463-1.897.037-.714.076-1.335.195-1.814.12-.465.308-.797.641-.984l.045-.022zm-10.814.049h.01c.053 0 .105.005.157.014.376.055.706.333 1.023.752l.91 1.664.003.003c.243.533.754 1.064 1.189 1.637.434.598.77 1.131.729 1.57v.006c-.057.744-.48 1.148-1.125 1.294-.645.135-1.52.002-2.395-.464-.968-.536-2.118-.469-2.857-.602-.369-.066-.61-.2-.723-.4-.11-.2-.113-.602.123-1.23v-.004l.002-.003c.117-.334.03-.752-.027-1.118-.055-.401-.083-.71.043-.94.16-.334.396-.4.69-.533.294-.135.64-.202.915-.47h.002v-.002c.256-.268.445-.601.668-.838.19-.201.38-.336.663-.336zm7.159-9.074c-.435.201-.945.535-1.488.535-.542 0-.97-.267-1.28-.466-.154-.134-.28-.268-.373-.335-.164-.134-.144-.333-.074-.333.109.016.129.134.199.2.096.066.215.2.36.333.292.2.68.467 1.167.467.485 0 1.053-.267 1.398-.466.195-.135.445-.334.648-.467.156-.136.149-.267.279-.267.128.016.034.134-.147.332a8.097 8.097 0 01-.69.468zm-1.082-1.583V5.64c-.006-.02.013-.042.029-.05.074-.043.18-.027.26.004.063 0 .16.067.15.135-.006.049-.085.066-.135.066-.055 0-.092-.043-.141-.068-.052-.018-.146-.008-.163-.065zm-.551 0c-.02.058-.113.049-.166.066-.047.025-.086.068-.14.068-.05 0-.13-.02-.136-.068-.01-.066.088-.133.15-.133.08-.031.184-.047.259-.005.019.009.036.03.03.05v.02h.003z`,windows:`M0,0H11.377V11.372H0ZM12.623,0H24V11.372H12.623ZM0,12.623H11.377V24H0Zm12.623,0H24V24H12.623`},wg={macos:`0 2 24 24`,linux:`0 0 24 24`,windows:`0 0 24 24`};function Tg({os:e,size:t=14}){return(0,Q.jsx)(`svg`,{viewBox:wg[e],width:t,height:t,fill:`currentColor`,"aria-hidden":`true`,children:(0,Q.jsx)(`path`,{d:Cg[e]})})}function Eg({project:e}){let t=(0,l.useRef)(null),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{a(!1),t.current?.complete&&(r(t.current.naturalWidth>0),a(t.current.naturalWidth===0))},[e.iconUrl]),(0,Q.jsxs)(`span`,{className:`thread-project ${n?`has-icon`:``}`,style:{"--project-color":e.color},"aria-hidden":`true`,children:[(0,Q.jsx)(`span`,{className:`thread-project-letter`,children:e.initial}),e.iconUrl&&!i&&(0,Q.jsx)(`img`,{ref:t,src:e.iconUrl,alt:``,decoding:`async`,onLoad:()=>r(!0),onError:()=>a(!0)})]})}function Dg({projects:e,projectId:t,onChange:n,onAddProject:r}){return(0,Q.jsx)(bg,{label:`Project`,value:t,onChange:n,icon:(0,Q.jsx)(N,{size:14}),action:r?{label:`Add project`,icon:(0,Q.jsx)(re,{size:14}),onClick:r}:void 0,options:e.map(e=>({value:e.id,label:e.name,icon:(0,Q.jsx)(Eg,{project:e},e.id)}))})}var Og=e=>e.os?(0,Q.jsx)(Tg,{os:e.os}):e.id===`local`?(0,Q.jsx)(V,{size:14}):(0,Q.jsx)(ae,{size:14});function kg({machine:e,machines:t,projects:n,projectId:r,harness:i,model:a,onMachineChange:o,onProjectChange:s,onHarnessChange:c,onModelChange:l,onAddProject:u}){let d=e.harnesses.find(e=>e.id===i)?.models??[];return(0,Q.jsxs)(`div`,{className:`composer-selectors`,children:[(0,Q.jsx)(bg,{label:`Machine`,value:e.id,onChange:o,icon:Og(e),options:t.map(e=>({icon:Og(e),value:e.id,label:`${e.name}${e.connected?``:` · Not connected`}`,shortLabel:e.name,disabled:!e.connected}))}),(0,Q.jsx)(Dg,{projects:n,projectId:r,onChange:s,onAddProject:u},e.id),(0,Q.jsx)(bg,{label:`Harness`,value:i,onChange:c,icon:(0,Q.jsx)(ce,{size:14}),options:e.harnesses.map(e=>({value:e.id,label:e.name,shortLabel:e.name===`Claude Code`?`Claude`:e.name,icon:(0,Q.jsx)(Sg,{harness:e.id})}))}),(0,Q.jsx)(bg,{label:`Model`,value:a,onChange:l,icon:(0,Q.jsx)(k,{size:14}),allowCustom:e.harnesses.find(e=>e.id===i)?.customModels??!1,options:d.map(e=>({value:e,label:e,shortLabel:e.split(`/`).at(-1)}))},`${e.id}:${i}`)]})}var Ag=l.createContext(void 0),jg=e=>{let t=l.useContext(Ag);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},Mg=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Q.jsx)(Ag.Provider,{value:e,children:t})),Ng={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Pg=new class{#e=Ng;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 Fg(e){setTimeout(e,0)}var Ig=typeof window>`u`||`Deno`in globalThis;function Lg(){}function Rg(e,t){return typeof e==`function`?e(t):e}function zg(e){return typeof e==`number`&&e>=0&&e!==1/0}function Bg(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Vg(e,t){return typeof e==`function`?e(t):e}function Hg(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Wg(o,t.options))return!1}else if(!Kg(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 Ug(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Gg(t.options.mutationKey)!==Gg(a))return!1}else if(!Kg(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Wg(e,t){return(t?.queryKeyHashFn||Gg)(e)}function Gg(e){return JSON.stringify(e,(e,t)=>Zg(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Kg(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(e&&t&&typeof e==`object`&&typeof t==`object`){if(Array.isArray(e)&&Array.isArray(t)){if(t.length>e.length)return!1;for(let n=0;n<t.length;n++)if(!Kg(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Kg(e[r],t[r]))return!1;return!0}return!1}var qg=Object.prototype.hasOwnProperty;function Jg(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=Xg(e)&&Xg(t);if(!r&&!(Zg(e)&&Zg(t)))return t;let i=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),o=a.length,s=r?Array(o):{},c=0;for(let l=0;l<o;l++){let o=r?l:a[l],u=e[o],d=t[o];if(u===d){s[o]=u,(r?l<i:qg.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=Jg(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Yg(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 Xg(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Zg(e){if(!Qg(e))return!1;let t=Object.getPrototypeOf(e),n=t?.constructor;if(n===void 0)return!0;if(typeof n!=`function`)return!1;let r=n.prototype;return!(!Qg(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function Qg(e){return Object.prototype.toString.call(e)===`[object Object]`}function $g(e){return new Promise(t=>{Pg.setTimeout(t,e)})}function e_(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:Jg(e,t)}function t_(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function n_(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var r_=Symbol();function i_(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===r_?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function a_(e,t){return typeof e==`function`?e(...t):!!e}function o_(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??=t(),r?i:(r=!0,i.aborted?n():i.addEventListener(`abort`,n,{once:!0}),i))}),e}var s_=()=>Ig,c_=()=>s_(),l_=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(){}},u_=new class extends l_{#e;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&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`}},d_=Fg;function f_(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=d_,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 p_=f_(),m_=new class extends l_{#e=!0;#t;#n;constructor(){super(),this.#n=e=>{if(typeof window<`u`&&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 h_(e){return Math.min(1e3*2**e,3e4)}function g_(e){return(e??`online`)!==`online`||m_.isOnline()}var __=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function v_(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(Lg);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new __(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>u_.isFocused()&&(e.networkMode===`always`||m_.isOnline())&&e.canRun(),p=()=>g_(e.networkMode)&&e.canRun(),m=e=>{c()||(r?.(),i=`resolved`,a(e))},h=e=>{c()||(r?.(),i=`rejected`,o(e))},g=()=>new Promise(t=>{r=e=>{(c()||f())&&t(e)},e.onPause?.()}).then(()=>{r=void 0,c()||e.onContinue?.()}),_=()=>{if(c())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(m).catch(r=>{if(c())return;let i=e.retry??(c_()?0:3),a=e.retryDelay??h_,o=typeof a==`function`?a(n,r):a,s=i===!0||typeof i==`number`&&n<i||typeof i==`function`&&i(n,r);if(t||!s){h(r);return}n++,e.onFail?.(n,r),$g(o).then(()=>f()?void 0:g()).then(()=>{t?h(r):_()})})};return{promise:s,status:()=>i,cancel:l,continue:()=>(r?.(),s),cancelRetry:u,continueRetry:d,canStart:p,start:()=>(p()?_():g().then(_),s)}}var y_=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),zg(this.gcTime)&&(this.#e=Pg.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(c_()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(Pg.clearTimeout(this.#e),this.#e=void 0)}};function b_(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=>{o_(e,()=>t.signal,()=>n=!0)},u=i_(t.options,t.fetchOptions),d=async(e,r,i)=>{if(n)return Promise.reject(t.signal.reason);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?n_:t_;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?S_:x_,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:x_(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 x_(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 S_(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var C_=class extends y_{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e){super(),this.#s=!1,this.#o=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#r=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#t=E_(this.options),this.state=e.state??this.#t,this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return this.#e}get promise(){return this.#a?.promise}setOptions(e){if(this.options={...this.#o,...e},e?._type&&(this.#e=e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let e=E_(this.options);e.data!==void 0&&(this.setState(T_(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=e_(this.state.data,e,this.options);return this.#c({data:n,type:`success`,dataUpdatedAt:t?.updatedAt,manual:t?.manual}),n}setState(e){this.#c({type:`setState`,state:e})}cancel(e){let t=this.#a?.promise;return this.#a?.cancel(e),t?t.then(Lg).catch(Lg):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return this.#t}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>Vg(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===r_||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Vg(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:!Bg(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(e=>e.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#a?.continue()}onOnline(){this.observers.find(e=>e.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#a?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:`observerAdded`,query:this,observer:e}))}removeObserver(e){let t=this.observers.indexOf(e);t!==-1&&(this.observers.splice(t,1),this.observers.length||(this.#a&&(this.#s||this.state.fetchStatus===`paused`&&this.state.status===`pending`?this.#a.cancel({revert:!0}):this.#a.cancelRetry()),this.scheduleGc()),this.#r.notify({type:`observerRemoved`,query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#c({type:`invalidate`})}async fetch(e,t){if(this.state.fetchStatus!==`idle`&&this.#a?.status()!==`rejected`){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#a)return this.#a.continueRetry(),this.#a.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.#s=!0,n.signal)})},i=()=>{let e=i_(this.options,t),n=(()=>{let e={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(e),e})();return this.#s=!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.#i,state:this.state,fetchFn:i};return r(e),e})();(this.#e===`infinite`?b_(this.options.pages):this.options.behavior)?.onFetch(a,this),this.#n=this.state,(this.state.fetchStatus===`idle`||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#c({type:`fetch`,meta:a.fetchOptions?.meta});let o=this.#a=v_({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof __&&e.revert&&this.setState({...this.#n,fetchStatus:`idle`}),n.abort()},onFail:(e,t)=>{this.#c({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#c({type:`pause`})},onContinue:()=>{this.#c({type:`continue`})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{let e=await o.start();if(e===void 0)throw Error(`${this.queryHash} data is undefined`);return this.setData(e),this.#r.config.onSuccess?.(e,this),this.#r.config.onSettled?.(e,this.state.error,this),e}catch(e){if(e instanceof __){if(e.silent)return this.#a.promise;if(e.revert){if(this.state.data===void 0)throw e;return this.state.data}}throw this.#c({type:`error`,error:e}),this.#r.config.onError?.(e,this),this.#r.config.onSettled?.(this.state.data,e,this),e}finally{this.#a===o&&(this.#a=void 0),this.scheduleGc()}}#c(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,...w_(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...T_(e.data,e.dataUpdatedAt),dataUpdateCount:t.dataUpdateCount+1,...!e.manual&&{fetchStatus:`idle`,fetchFailureCount:0,fetchFailureReason:null}};return this.#n=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`,isInvalidated:!0};case`invalidate`:return{...t,isInvalidated:!0};case`setState`:return{...t,...e.state}}};this.state=t(this.state),p_.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function w_(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:g_(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function T_(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function E_(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 D_=class extends l_{#e;#t=void 0;#n=void 0;#r=void 0;#i;#a;#o;#s;#c;#l;#u;#d;#f;#p=new Set;constructor(e,t){super(),this.options=t,this.#e=e,this.#o=null,this.bindMethods(),this.setOptions(t)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),k_(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return A_(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return A_(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 Vg(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&&!Yg(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&j_(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||Vg(this.options.enabled,this.#t)!==Vg(t.enabled,this.#t)||Vg(this.options.staleTime,this.#t)!==Vg(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Vg(this.options.enabled,this.#t)!==Vg(t.enabled,this.#t)||i!==this.#f)&&this.#v(i)}getOptimisticResult(e){let t=this.#e.getQueryCache().build(this.#e,e),n=this.createResult(t,e);return Yg(this.getCurrentResult(),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),Reflect.get(e,n))})}trackProp(e){this.#p.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),r=()=>{},i,a=new Promise(e=>{i=e,r=this.#e.getQueryCache().subscribe(i=>{i.type===`updated`&&i.query.queryHash===n.queryHash&&n.state.data!==void 0&&(r(),e(this.createResult(n,t)))})});return Promise.race([n.fetch().then(()=>{let e=this.createResult(n,t);return i?.(e),e}).finally(()=>{r()}),a])}fetch(e){return this.#m({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#r))}#m(e){this.#S();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Lg)),t}#h(e){return!c_()&&Vg(this.options.enabled,this.#t)!==!1&&zg(e)}#g(){this.#b();let e=Vg(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=Bg(this.#r.dataUpdatedAt,e)+1;this.#u=Pg.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return Vg(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=Pg.setInterval(()=>{(this.options.refetchIntervalInBackground||u_.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(Pg.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(Pg.clearInterval(this.#d),this.#d=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&&k_(e,t),o=i&&j_(e,n,t,r);(a||o)&&(l={...l,...w_(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.#l?.state.data,this.#l):t.placeholderData,e!==void 0&&(m=`success`,d=e_(i?.data,e,t),u=!0)}if(t.select&&d!==void 0&&!h){if(i&&d===a?.data&&t.select===this.#s)d=this.#c;else try{this.#s=t.select,d=t.select(d),d=e_(i?.data,d,t),this.#c=d,this.#o=null}catch(e){this.#o=e}}else d===void 0&&(this.#o=null);this.#o&&(f=this.#o,d=this.#c,p=Date.now(),m=`error`,u=!1);let g=l.fetchStatus===`fetching`,_=m===`pending`,v=m===`error`,y=_&&g,b=d!==void 0;return{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:e.isFetched(),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:M_(e,t),refetch:this.refetch,isEnabled:Vg(t.enabled,e)!==!1}}updateResult(){let e=this.#r,t=this.createResult(this.#t,this.options);if(this.#i=this.#t.state,this.#a=this.options,this.#i.data!==void 0&&(this.#l=this.#t),Yg(t,e))return;this.#r=t;let n=(()=>{if(!e)return!0;let{notifyOnChangeProps:t}=this.options,n=typeof t==`function`?t():t;if(n===`all`||!n&&!this.#p.size)return!0;let r=new Set(n??this.#p);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)})})();p_.batch(()=>{n&&this.listeners.forEach(e=>{e(this.#r)}),this.#e.getQueryCache().notify({query:this.#t,type:`observerResultsUpdated`})})}#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()}};function O_(e,t){return Vg(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Vg(t.retryOnMount,e)!==!1)}function k_(e,t){return O_(e,t)||e.state.data!==void 0&&A_(e,t,t.refetchOnMount)}function A_(e,t,n){if(Vg(t.enabled,e)!==!1&&Vg(t.staleTime,e)!==`static`){let r=Vg(n,e);return r===`always`||r!==!1&&M_(e,t)}return!1}function j_(e,t,n,r){return(e!==t||Vg(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&M_(e,n)}function M_(e,t){return Vg(t.enabled,e)!==!1&&e.isStaleByTime(Vg(t.staleTime,e))}var N_=class extends y_{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||P_(),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.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=v_({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(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),p_.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function P_(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var F_=class extends l_{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new N_({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=I_(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=I_(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=I_(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=I_(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){p_.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=>Ug(t,e))}findAll(e={}){return this.getAll().filter(t=>Ug(e,t))}notify(e){p_.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return p_.batch(()=>Promise.all(e.map(e=>e.continue().catch(Lg))))}};function I_(e){return e.options.scope?.id}var L_=class extends l_{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??Wg(r,t),a=this.get(i);return a||(a=new C_({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){this.#e.get(e.queryHash)===e&&(e.destroy(),this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){p_.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=>Hg(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Hg(e,t)):t}notify(e){p_.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){p_.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){p_.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},R_=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new L_,this.#t=e.mutationCache||new F_,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=u_.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=m_.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(Vg(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=Rg(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return p_.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;p_.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return p_.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=p_.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Lg).catch(Lg)}invalidateQueries(e,t={}){return p_.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=p_.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(Lg)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Lg)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(Vg(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Vg(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Lg).catch(Lg)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Lg).catch(Lg)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return m_.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(Gg(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Kg(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Gg(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Kg(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||=Wg(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===r_&&(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()}},z_=l.createContext(!1),B_=()=>l.useContext(z_);z_.Provider;function V_(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var H_=l.createContext(V_()),U_=()=>l.useContext(H_),W_=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?a_(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},G_=e=>{l.useEffect(()=>{e.clearReset()},[e])},K_=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||a_(n,[e.error,r])),q_=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))}},J_=(e,t)=>e?.suspense&&t.isPending,Y_=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function X_(e,t,n){let r=B_(),i=U_(),a=jg(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,q_(o),W_(o,i,s),G_(i);let[u]=l.useState(()=>new t(a,o)),d=u.getOptimisticResult(o),f=!r&&c;if(l.useSyncExternalStore(l.useCallback(e=>{let t=f?u.subscribe(p_.batchCalls(e)):Lg;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),l.useEffect(()=>{u.setOptions(o)},[o,u]),J_(o,d))throw Y_(o,u,i);if(K_({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return o.notifyOnChangeProps?d:u.trackResult(d)}function Z_(e,t){return X_(e,D_,t)}var Q_=1e3,$_=e=>`webr-catalog:${e}`,ev=e=>{try{return JSON.parse(localStorage.getItem($_(e))??`null`)??void 0}catch{return}},tv=(e,t)=>{try{localStorage.setItem($_(e),JSON.stringify(t))}catch{}};function nv(e,t,n=1,r=``,i=``){return Z_({queryKey:[`machine-catalog`,e,r,n,i],enabled:!!e&&t,placeholderData:()=>ev(e),refetchInterval:e=>e.state.data?.modelsPending?Q_:!1,queryFn:async({signal:t})=>{let n=await fetch(`/api/catalog/`+encodeURIComponent(e)+(i?`?projectId=`+encodeURIComponent(i):``),{signal:t});if(!n.ok)throw Error(`Machine catalog is not available.`);let r=await n.json();return tv(e,r),r}})}var rv=e=>e.startsWith(`/`)||e.startsWith(`~`),iv=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[];function av(e,t){let[n,r]=(0,l.useState)([]);return(0,l.useEffect)(()=>{if(!rv(t)){r([]);return}let n=new AbortController;return fetch(`/api/directories?machineId=${encodeURIComponent(e)}&prefix=${encodeURIComponent(t)}`,{signal:n.signal}).then(e=>e.ok?e.json():[]).then(e=>r(iv(e))).catch(()=>{}),()=>n.abort()},[e,t]),n}var ov=e=>e.startsWith(`/`)||e.startsWith(`~/`);function sv({machineId:e,onCreated:t}){let[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(!1),[c,u]=(0,l.useState)(``),[d,f]=(0,l.useState)(0),[p,m]=(0,l.useState)(!1),h=av(e,n),g=p&&h.length>0&&(h.length!==1||h[0]!==n),_=e=>{r(e),f(0),m(!0)},v=e=>{g&&(e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),f(t=>(t+(e.key===`ArrowDown`?1:h.length-1))%h.length)):e.key===`Tab`?(e.preventDefault(),_(h[d]??h[0])):e.key===`Enter`?(e.preventDefault(),_(h[d]??h[0]),m(!1)):e.key===`Escape`&&m(!1))},y=(0,l.useRef)(null);return(0,Q.jsxs)(`form`,{className:`thread-composer workspace-composer`,onSubmit:async r=>{r.preventDefault(),s(!0),u(``);let a=JSON.stringify({machineId:e,path:n,label:i});y.current?.payload!==a&&(y.current={payload:a,key:dm()});try{let e=await fetch(`/api/workspaces`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":y.current.key},body:a}),n=await e.json();if(!e.ok)throw Error(n.error??`Could not create workspace`);if(n.state===`unknown`)throw Error(`The result is not known; check Herdr before you create another workspace.`);t()}catch(e){u(e instanceof Error?e.message:`Could not create workspace`)}finally{s(!1)}},"aria-label":`Create workspace`,"aria-busy":o,children:[(0,Q.jsxs)(`label`,{className:`path-field`,children:[`Project folder`,(0,Q.jsx)(`input`,{value:n,onChange:e=>{r(e.target.value),f(0),m(!0)},onKeyDown:v,onBlur:()=>m(!1),placeholder:`/absolute/path/to/project`,autoComplete:`off`,spellCheck:!1,role:`combobox`,"aria-expanded":g,"aria-autocomplete":`list`,required:!0,pattern:`(/|~/).*`}),g&&(0,Q.jsx)(`ul`,{className:`path-suggestions`,role:`listbox`,children:h.map((e,t)=>(0,Q.jsx)(`li`,{role:`option`,"aria-selected":t===d,"data-highlighted":t===d||void 0,onMouseDown:t=>{t.preventDefault(),_(e)},children:e},e))})]}),(0,Q.jsxs)(`label`,{children:[`Workspace name`,(0,Q.jsx)(`input`,{value:i,onChange:e=>a(e.target.value),required:!0,maxLength:80})]}),(0,Q.jsx)(`button`,{type:`submit`,disabled:o||!ov(n)||!i.trim(),children:o?`Creating…`:`Create workspace`}),c&&(0,Q.jsx)(`p`,{className:`form-error`,role:`alert`,children:c})]})}var cv={main:`Main checkout`,worktree:`New worktree`,remember:`Remember by project`},lv=`webr-new-session-behavior`,uv=`webr-new-worktree`,dv=(e,t)=>`webr-last-worktree:${e}:${t}`,fv=e=>e===`main`||e===`worktree`||e===`remember`,pv=()=>{let e=localStorage.getItem(uv);return e===null?`remember`:e===`false`?`main`:`worktree`};function mv(){let e=localStorage.getItem(lv);return fv(e)?e:pv()}function hv(e){localStorage.setItem(lv,e)}function gv(e,t,n){localStorage.setItem(dv(e,t),String(n))}var _v=(e,t)=>localStorage.getItem(dv(e,t))!==`false`;function vv(e,t){let n=mv();return n===`remember`?_v(e,t):n===`worktree`}var yv=`webr-new-thread-draft`,bv=e=>!!e&&typeof e==`object`&&[`id`,`name`,`preview`,`path`].every(t=>typeof e[t]==`string`);function xv(){try{let e=JSON.parse(localStorage.getItem(yv)??`{}`);return{prompt:typeof e.prompt==`string`?e.prompt:``,images:Array.isArray(e.images)?e.images.filter(bv):[]}}catch{return{prompt:``,images:[]}}}function Sv(e){try{!e.prompt&&!e.images.length?localStorage.removeItem(yv):localStorage.setItem(yv,JSON.stringify(e))}catch{}}var Cv=()=>Sv({prompt:``,images:[]}),wv=(e,t)=>`webr-last-harness:${e}:${t}`;function Tv({projects:e,machines:t,selectedProjectId:n,onOpenSidebar:r}){let[i,o]=(0,l.useState)(e.find(e=>e.id===n)?.id??e[0]?.id??``),[s,c]=(0,l.useState)(t.find(e=>n&&Object.hasOwn(e.projectPaths,n))?.id??t[0]?.id??``),[u,d]=(0,l.useState)(``),[f,p]=(0,l.useState)(`Default`),[m,h]=(0,l.useState)(!0),[g,v]=(0,l.useState)(``),[y,b]=(0,l.useState)(!1),[x,S]=(0,l.useState)(``),[C,w]=(0,l.useState)(!1),T=(0,l.useRef)(null),E=(0,l.useRef)(null),D=hm({machineId:s}),O=t.find(e=>e.id===s)??{id:``,name:`No target`,connected:!1,session:``,projectPaths:{},harnesses:[]},k=nv(s,O.connected,O.configVersion,O.session,i),A={...O,harnesses:O.connected?k.data?.harnesses??[]:[]},M=e.filter(e=>Object.hasOwn(A.projectPaths,e.id)).map(e=>({...e,path:A.projectPaths[e.id]})),N=k.data?.isGitRepo===!0,F=A.harnesses.find(e=>e.id===u),I=!!(g.trim()&&!D.uploading&&f.trim()&&A.connected&&M.some(e=>e.id===i)&&F?.launchEnabled)&&!y,L=k.data?.harnesses.map(e=>e.id).join(`,`),R=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let e=xv();v(e.prompt),D.setAttachments(e.images),R.current=!0},[]),(0,l.useEffect)(()=>{R.current&&Sv({prompt:g,images:D.attachments})},[g,D.attachments]),(0,l.useEffect)(()=>{h(vv(s,i))},[s,i]),(0,l.useEffect)(()=>{if(!i||!k.data)return;let e=k.data.harnesses,t=localStorage.getItem(wv(s,i));d(e.find(e=>e.id===t)?.id??e.find(e=>e.launchEnabled)?.id??e[0]?.id??``),p(`Default`)},[s,i,L]),(0,l.useEffect)(()=>{let e=T.current,t=e&&M.find(t=>!e.has(t.id));t&&(T.current=null,B(t.id))},[M]),(0,l.useEffect)(()=>{!s&&t.length&&c(t.find(e=>e.id===`local`)?.id??t[0].id),!i&&M.length&&o(M[0].id)},[t,s,M,i]);let z=n=>{let r=t.find(e=>e.id===n);r?.connected&&(c(n),Object.hasOwn(r.projectPaths,i)||o(e.find(e=>Object.hasOwn(r.projectPaths,e.id))?.id??``),d(``),p(`Default`),S(``))},B=e=>{o(e),d(``),p(`Default`),S(``)},V=e=>{d(e),p(`Default`),i&&localStorage.setItem(wv(s,i),e)};return(0,Q.jsxs)(`main`,{className:`new-thread-page`,"aria-label":`New thread`,children:[(0,Q.jsx)(`button`,{className:`mobile-menu`,onClick:r,children:`Threads`}),(0,Q.jsx)(`h1`,{children:`What do you want to build today?`}),A.connected&&A.writable&&(!M.length||C)?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:M.length?`Add a project to this Herdr session.`:`This Herdr session has no projects yet.`}),(0,Q.jsx)(sv,{machineId:A.id,onCreated:()=>{T.current=new Set(M.map(e=>e.id)),w(!1)}}),!!M.length&&(0,Q.jsx)(`button`,{className:`workspace-cancel`,onClick:()=>w(!1),children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`form`,{className:`thread-composer ${D.dragging?`is-dropping`:``}`,onSubmit:async e=>{if(e.preventDefault(),!I)return;b(!0),S(``);let t=JSON.stringify({prompt:mm(g,D.attachments),projectId:i,machineId:s,agent:u,model:f.trim(),worktree:m&&N});E.current?.payload!==t&&(E.current={payload:t,key:dm()});try{let e=await fetch(`/api/threads`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":E.current.key},body:t}),n=await e.json();if(!e.ok)throw Error(n.error||`Could not create thread`);gv(s,i,m),Cv(),await a(`/threads/${encodeURIComponent(n.id)}`)}catch(e){S(e instanceof Error?e.message:`Could not create thread`),b(!1)}},"aria-busy":y,...D.handlers,children:[(D.attachments.length>0||D.uploading>0)&&(0,Q.jsxs)(`ul`,{className:`composer-images`,"aria-label":`Attached files`,children:[D.attachments.map(e=>(0,Q.jsxs)(`li`,{className:e.preview?void 0:`is-file`,children:[e.preview?(0,Q.jsx)(`img`,{src:e.preview,alt:e.name}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(j,{size:18,strokeWidth:1.8}),(0,Q.jsx)(`span`,{children:e.name})]}),(0,Q.jsx)(Zl,{label:`Remove file`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,onClick:()=>D.remove(e.id),children:(0,Q.jsx)(pe,{size:12,strokeWidth:2.4})})})]},e.id)),Array.from({length:D.uploading},(e,t)=>(0,Q.jsx)(`li`,{className:`is-uploading`,"aria-label":`Uploading file`},`uploading-`+t))]}),(0,Q.jsx)(`textarea`,{autoFocus:!0,required:!0,maxLength:8e3,value:g,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},"aria-label":`Thread prompt`,placeholder:`Write a prompt, or drop an image…`}),(0,Q.jsxs)(`div`,{className:`composer-toolbar`,children:[(0,Q.jsx)(kg,{machine:A,machines:t,projects:M,projectId:i,harness:u,model:f,onMachineChange:z,onProjectChange:B,onHarnessChange:V,onModelChange:p,onAddProject:A.connected&&A.writable?()=>w(!0):void 0}),N&&(0,Q.jsx)(Zl,{label:m?`new worktree`:`current checkout`,children:(0,Q.jsxs)(`label`,{className:`worktree-option`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:m,onChange:e=>h(e.target.checked),"aria-label":`Create a new worktree`}),(0,Q.jsx)(P,{size:15,"aria-hidden":`true`})]})}),(0,Q.jsx)(`div`,{className:`composer-actions`,children:(0,Q.jsx)(Zl,{label:`Create thread`,children:(0,Q.jsx)(`button`,{className:`composer-send`,type:`submit`,disabled:!I,"aria-label":`Create thread`,children:y?`…`:(0,Q.jsx)(_,{size:18,strokeWidth:2.2})})})})]})]}),(F?.reason||!t.length||A.error||k.isError)&&(0,Q.jsx)(`p`,{className:`composer-preview-note`,children:F?.reason??(t.length?A.error?`Machine is not connected: ${A.error.replaceAll(`_`,` `)}.`:`The machine catalog is not available.`:`No target is configured.`)}),D.error&&(0,Q.jsx)(`p`,{className:`form-error`,role:`alert`,children:D.error}),x&&(0,Q.jsx)(`p`,{className:`form-error`,role:`alert`,children:x})]})]})}var Ev=ns(function(e){return Oc(`dialog`,e)}),Dv=52,Ov=`?`;function kv(e){let t=e.slice(e.indexOf(`;`)+1);if(e.includes(`;`)&&t&&t!==Ov)try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(Uint8Array.from(atob(t),e=>e.charCodeAt(0)))}catch{return}}function Av(e){let t=t=>{t.clipboardData?.setData(`text/plain`,e),t.preventDefault()};document.addEventListener(`copy`,t,!0);try{return document.execCommand(`copy`)}catch{return!1}finally{document.removeEventListener(`copy`,t,!0)}}async function jv(e){try{return await navigator.clipboard.writeText(e),!0}catch{return Av(e)}}var Mv=e=>(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.selectionStart!==e.selectionEnd||!!document.getSelection()?.toString();function Nv(e,t,n,r){let i=e=>r(e?`copied`:`blocked`),a,o=()=>{let e=a;a=void 0,e!==void 0&&jv(e).then(i)},s=e=>void jv(e).then(t=>{if(t)return i(!0);a=e,r(`waiting-for-click`)}),c=()=>{t.hasSelection()&&jv(t.getSelection()).then(i)},l=e=>{e.defaultPrevented||!t.hasSelection()||Mv(e.target)||(e.clipboardData?.setData(`text/plain`,t.getSelection()),e.preventDefault(),i(!0))},u=t.parser.registerOscHandler(Dv,e=>{let t=kv(e);return t!==void 0&&n()&&s(t),!0});return e.addEventListener(`mouseup`,c),window.addEventListener(`copy`,l),window.addEventListener(`pointerdown`,o,!0),window.addEventListener(`keydown`,o,!0),()=>{u.dispose(),window.removeEventListener(`pointerdown`,o,!0),window.removeEventListener(`keydown`,o,!0),e.removeEventListener(`mouseup`,c),window.removeEventListener(`copy`,l)}}var Pv=(e=>(e[e.Border=-1]=`Border`,e[e.Data=0]=`Data`,e[e.Function=1]=`Function`,e[e.Position=2]=`Position`,e[e.Timing=3]=`Timing`,e[e.Alignment=4]=`Alignment`,e))(Pv||{}),Fv=[0,1],Iv=[1,0],Lv=[2,3],Rv=[3,2],zv={L:Fv,M:Iv,Q:Lv,H:Rv},Bv=/^\d*$/,Vv=/^[A-Z0-9 $%*+./:-]*$/,Hv=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,Uv=1,Wv=40,Gv=3,Kv=3,qv=40,Jv=10,Yv=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],Xv=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],Zv=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<Uv||e>Wv)throw RangeError(`Version value out of range`);if(r<-1||r>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let i=Array.from({length:this.size}).fill(!1);for(let e=0;e<this.size;e++)this.modules.push(i.slice()),this.types.push(i.map(()=>0));this.drawFunctionPatterns();let a=this.addEccAndInterleave(n);if(this.drawCodewords(a),r===-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(r=t,e=n),this.applyMask(t)}}this.mask=r,this.applyMask(r),this.drawFormatBits(r)}size;mask;modules=[];types=[];getModule(e,t){return e>=0&&e<this.size&&t>=0&&t<this.size&&this.modules[t][e]}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0,Pv.Timing),this.setFunctionModule(e,6,e%2==0,Pv.Timing);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n===0&&r===0||n===0&&r===t-1||n===t-1&&r===0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.ecc[1]<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let r=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,$v(r,e));this.setFunctionModule(8,7,$v(r,6)),this.setFunctionModule(8,8,$v(r,7)),this.setFunctionModule(7,8,$v(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,$v(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,$v(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,$v(r,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=$v(t,e),r=this.size-11+e%3,i=Math.floor(e/3);this.setFunctionModule(r,i,n),this.setFunctionModule(i,r,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a<this.size&&o>=0&&o<this.size&&this.setFunctionModule(a,o,i!==2&&i!==4,Pv.Position)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!==1,Pv.Alignment)}setFunctionModule(e,t,n,r=Pv.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==my(t,n))throw RangeError(`Invalid argument`);let r=Xv[n[0]][t],i=Yv[n[0]][t],a=Math.floor(py(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=hy(i);for(let t=0,n=0;t<r;t++){let r=e.slice(n,n+s-i+(t<o?0:1));n+=r.length;let a=gy(r,l);t<o&&r.push(0),c.push(r.concat(a))}let u=[];for(let e=0;e<c[0].length;e++)c.forEach((t,n)=>{(e!==s-i||n>=o)&&u.push(t[e])});return u}drawCodewords(e){if(e.length!==Math.floor(py(this.version)/8))throw RangeError(`Invalid argument`);let t=0;for(let n=this.size-1;n>=1;n-=2){n===6&&(n=5);for(let r=0;r<this.size;r++)for(let i=0;i<2;i++){let a=n-i,o=n+1&2?r:this.size-1-r;!this.types[o][a]&&t<e.length*8&&(this.modules[o][a]=$v(e[t>>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.types[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[t][a]===n?(r++,r===5?e+=Gv:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*qv),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*qv}for(let t=0;t<this.size;t++){let n=!1,r=0,i=[0,0,0,0,0,0,0];for(let a=0;a<this.size;a++)this.modules[a][t]===n?(r++,r===5?e+=Gv:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*qv),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*qv}for(let t=0;t<this.size-1;t++)for(let n=0;n<this.size-1;n++){let r=this.modules[t][n];r===this.modules[t][n+1]&&r===this.modules[t+1][n]&&r===this.modules[t+1][n+1]&&(e+=Kv)}let t=0;for(let e of this.modules)t=e.reduce((e,t)=>e+ +!!t,t);let n=this.size*this.size,r=Math.ceil(Math.abs(t*20-n*10)/n)-1;return e+=r*Jv,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Qv(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function $v(e,t){return!!(e>>>t&1)}var ey=class{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}getData(){return this.bitData.slice()}},ty=[1,10,12,14],ny=[2,9,11,13],ry=[4,8,16,16];function iy(e,t){return e[Math.floor((t+7)/17)+1]}function ay(e){let t=[];for(let n of e)Qv(n,8,t);return new ey(ry,e.length,t)}function oy(e){if(!ly(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let n=0;n<e.length;){let r=Math.min(e.length-n,3);Qv(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new ey(ty,e.length,t)}function sy(e){if(!uy(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=Hv.indexOf(e.charAt(n))*45;r+=Hv.indexOf(e.charAt(n+1)),Qv(r,11,t)}return n<e.length&&Qv(Hv.indexOf(e.charAt(n)),6,t),new ey(ny,e.length,t)}function cy(e){return e===``?[]:ly(e)?[oy(e)]:uy(e)?[sy(e)]:[ay(fy(e))]}function ly(e){return Bv.test(e)}function uy(e){return Vv.test(e)}function dy(e,t){let n=0;for(let r of e){let e=iy(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function fy(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)===`%`?(t.push(Number.parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}function py(e){if(e<Uv||e>Wv)throw RangeError(`Version number out of range`);let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t}function my(e,t){return Math.floor(py(e)/8)-Yv[t[0]][e]*Xv[t[0]][e]}function hy(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let t=[];for(let n=0;n<e-1;n++)t.push(0);t.push(1);let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=_y(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=_y(n,2)}return t}function gy(e,t){let n=t.map(e=>0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=_y(t,e))}return n}function _y(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}function vy(e,t,n=1,r=40,i=-1,a=!0){if(!(Uv<=n&&n<=r&&r<=Wv)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=my(o,t)*8,i=dy(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[Iv,Lv,Rv])a&&s<=my(o,e)*8&&(t=e);let c=[];for(let t of e){Qv(t.mode[0],4,c),Qv(t.numChars,iy(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=my(o,t)*8;Qv(0,Math.min(4,l-c.length),c),Qv(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)Qv(e,8,c);let u=Array.from({length:Math.ceil(c.length/8)},()=>0);return c.forEach((e,t)=>u[t>>>3]|=e<<7-(t&7)),new Zv(o,t,u,i)}function yy(e,t){let{ecc:n=`L`,boostEcc:r=!1,minVersion:i=1,maxVersion:a=40,maskPattern:o=-1,border:s=1}=t||{},c=typeof e==`string`?cy(e):Array.isArray(e)?[ay(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=vy(c,zv[n],i,a,o,r),u=by({version:l.version,maskPattern:l.mask,size:l.size,data:l.modules,types:l.types},s);return t?.invert&&(u.data=u.data.map(e=>e.map(e=>!e))),t?.onEncoded?.(u),u}function by(e,t=1){if(!t)return e;let{size:n}=e,r=n+t*2;e.size=r,e.data.forEach(e=>{for(let n=0;n<t;n++)e.unshift(!1),e.push(!1)});for(let n=0;n<t;n++)e.data.unshift(Array.from({length:r},e=>!1)),e.data.push(Array.from({length:r},e=>!1));let i=Pv.Border;e.types.forEach(e=>{for(let n=0;n<t;n++)e.unshift(i),e.push(i)});for(let n=0;n<t;n++)e.types.unshift(Array.from({length:r},e=>i)),e.types.push(Array.from({length:r},e=>i));return e}var xy=2;function Sy({value:e,label:t}){let{data:n,size:r}=yy(e),i=n.flatMap((e,t)=>e.flatMap((e,n)=>e?[`M${n+xy} ${t+xy}h1v1h-1z`]:[])),a=r+4;return(0,Q.jsxs)(`svg`,{className:`qr-code`,role:`img`,"aria-label":t,viewBox:`0 0 ${a} ${a}`,shapeRendering:`crispEdges`,children:[(0,Q.jsx)(`rect`,{width:a,height:a,fill:`#fff`}),(0,Q.jsx)(`path`,{d:i.join(``),fill:`#000`})]})}function Cy(){let[e,t]=(0,l.useState)(Wp);return!Up()||e!=="default"?null:(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsxs)(`span`,{children:[`Notify me about new requests`,(0,Q.jsx)(`small`,{className:`device-meta`,children:`Shown when Webr is open in a hidden tab.`})]}),(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,onClick:()=>void Gp().then(t),children:`Turn on`})]})}var wy=8;function Ty({refreshKey:e}){let[t,n]=(0,l.useState)([]);return(0,l.useEffect)(()=>{Np().then(n,()=>void 0)},[e]),t.length?(0,Q.jsxs)(`div`,{className:`remote-activity`,children:[(0,Q.jsx)(`h3`,{className:`settings-subtitle`,children:`Recent activity`}),t.slice(0,wy).map(e=>(0,Q.jsxs)(`p`,{className:`activity-row`,children:[(0,Q.jsx)(`span`,{children:Kp(e)}),(0,Q.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:Hp(e.at)})]},e.id))]}):null}function Ey({invite:e,onClose:t}){let[n,r]=(0,l.useState)(0),[i,a]=(0,l.useState)(!1),o=e.urls[n],s=e=>jv(e).then(e=>{e&&(a(!0),setTimeout(()=>a(!1),1500))}),c=()=>s(e.token),u=t=>{r(t),s(e.urls[t])};return(0,Q.jsx)(Ev,{open:!0,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(Xc,{children:[(0,Q.jsx)(Ac,{className:`dialog-backdrop`}),(0,Q.jsxs)(qc,{className:`dialog pairing-invite`,children:[(0,Q.jsx)(Zc,{className:`pairing-title`,children:`Connect a device`}),o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Bc,{className:`dialog-message`,children:`Scan with the device’s camera, or open Webr there and enter the code.`}),(0,Q.jsx)(Sy,{value:o,label:`QR code to connect a device`}),e.urls.length>1&&(0,Q.jsx)(`div`,{className:`theme-control theme-control--labels`,role:`group`,"aria-label":`Address`,children:e.urls.map((e,t)=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":t===n,className:t===n?`theme-option is-selected`:`theme-option`,onClick:()=>u(t),children:new URL(e).host},e))})]}):(0,Q.jsxs)(Bc,{className:`dialog-message`,children:[`No network address was found for other devices. Start Webr with `,(0,Q.jsx)(`code`,{children:`--origin <url>`}),` if you reach it through a proxy.`]}),(0,Q.jsxs)(`div`,{className:`pairing-token`,children:[(0,Q.jsx)(`code`,{children:e.token}),(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,onClick:()=>void c(),"aria-label":`Copy code`,children:i?(0,Q.jsx)(y,{size:14}):(0,Q.jsx)(O,{size:14})})]}),(0,Q.jsx)(`p`,{className:`settings-note`,children:`Works once and expires in 5 minutes.`}),(0,Q.jsx)(`div`,{className:`dialog-actions`,children:(0,Q.jsx)(Rc,{className:`dialog-button is-primary`,children:`Done`})})]})]})})}var Dy={unavailable:`Install Tailscale on this computer and your other devices to get a private, secure HTTPS address for Webr. HTTPS unlocks features browsers only allow on secure pages, such as the microphone.`,"https-disabled":`Tailscale is installed, but HTTPS certificates are off. Turn them on in the Tailscale admin console under DNS, then restart Webr to unlock features that need a secure address, such as the microphone.`};function Oy(){let[e,t]=(0,l.useState)(`ready`);return(0,l.useEffect)(()=>{Pp().then(t,()=>void 0)},[]),e===`ready`?null:(0,Q.jsx)(`p`,{className:`tailscale-callout`,role:`note`,children:Dy[e]})}function ky(){let[e,t]=(0,l.useState)([]),[n,r]=(0,l.useState)(),[i,a]=(0,l.useState)(``),o=(0,l.useCallback)(()=>Mp().then(t,()=>void 0),[]);(0,l.useEffect)(()=>{o()},[o]);let s=()=>jp().then(e=>{a(``),r(e)},e=>a(e.message)),c=async e=>{await sl(`Disconnect ${e.name}? It will need to be approved again.`,{confirmLabel:`Disconnect`,danger:!0})&&(await Fp(e.id),e.current?location.reload():await o())};return(0,Q.jsxs)(`section`,{id:`remote-access`,children:[(0,Q.jsx)(`div`,{className:`settings-section-title`,children:(0,Q.jsx)(`h2`,{children:`Remote access`})}),(0,Q.jsx)(`p`,{className:`settings-note`,children:`Other devices ask to connect and you approve them here. This computer never needs a code.`}),(0,Q.jsx)(Oy,{}),(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsx)(`span`,{children:`Connect a device`}),(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,onClick:()=>void s(),children:`Show code`})]}),(0,Q.jsx)(Cy,{}),i&&(0,Q.jsx)(`p`,{role:`alert`,className:`form-error`,children:i}),e.map(e=>(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsxs)(`span`,{children:[e.name,e.current&&(0,Q.jsx)(`em`,{className:`device-tag`,children:`This device`}),(0,Q.jsxs)(`small`,{className:`device-meta`,children:[`Active `,Hp(e.lastSeenAt),` · Signs out `,qp(e.expiresAt),` if unused`]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,onClick:()=>void c(e),children:`Disconnect`})]},e.id)),(0,Q.jsx)(Ty,{refreshKey:e}),n&&(0,Q.jsx)(Ey,{invite:n,onClose:()=>r(void 0)})]})}var Ay=9e5,jy=2e3,My=18e4,Ny=async e=>{let t=await fetch(`/api/update`,{signal:e});if(!t.ok)throw Error(`Updates are not available.`);return await t.json()},Py=async()=>{let e=await fetch(`/api/update/check`,{method:`POST`});if(!e.ok)throw Error(`Updates are not available.`);return await e.json()},Fy=500,Iy=`Restart the Webr server? This page reloads and every open terminal reconnects. Running agents keep working.`,Ly=e=>new Promise(t=>setTimeout(t,e)),Ry=async()=>(await fetch(`/api/update`,{cache:`no-store`}).catch(()=>void 0))?.ok===!0;async function zy(){let e=!1;for(let t=Date.now()+My;Date.now()<t;await Ly(Fy))if(!await Ry())e=!0;else if(e)return!0;return!1}var By=({current:e,latest:t})=>`Update Webr from ${e} to ${t}? Webr restarts and this page reloads. Running agents keep working.`;function Vy(){let[e,t]=(0,l.useState)(),n=Z_({queryKey:[`update`],queryFn:({signal:e})=>Ny(e),refetchInterval:e?jy:Ay,refetchOnWindowFocus:!e}).data,r=(0,l.useCallback)(e=>{t(void 0),cl(e)},[]);(0,l.useEffect)(()=>{e&&n&&(n.current===e?n.state===`failed`&&r(n.error??`The update failed.`):window.location.reload())},[e,n,r]),(0,l.useEffect)(()=>{if(!e)return;let t=setTimeout(()=>r(`Webr did not come back after the update. Reload this page, or restart Herdr.`),My);return()=>clearTimeout(t)},[e,r]);let i=jg(),[a,o]=(0,l.useState)(!1),s=(0,l.useCallback)(async()=>{o(!0);try{i.setQueryData([`update`],await Py())}catch{await cl(`Webr could not check for updates.`)}finally{o(!1)}},[i]),c=(0,l.useCallback)(async()=>{n&&await sl(By(n),{confirmLabel:`Update`})&&((await fetch(`/api/update`,{method:`POST`}).catch(()=>void 0))?.status===202?t(n.current):await cl(`Webr could not start the update.`))},[n]),[u,d]=(0,l.useState)(!1),f=(0,l.useCallback)(async()=>{if(await sl(Iy,{confirmLabel:`Restart`,danger:!0})){if((await fetch(`/api/restart`,{method:`POST`}).catch(()=>void 0))?.status!==202)return void await cl(`Webr could not restart.`);d(!0),await zy()?window.location.reload():(d(!1),await cl(`Webr did not come back. Reload this page, or restart Herdr.`))}},[]);return{status:n,updating:!!e,checking:a,checkNow:s,requestUpdate:c,restarting:u,requestRestart:f}}function Hy(){let{status:e,updating:t,checking:n,checkNow:r,requestUpdate:i,restarting:a,requestRestart:o}=Vy(),s=e&&!e.available;return(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h2`,{children:`Updates`}),(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsxs)(`span`,{children:[e?`Webr ${e.current}`:`Webr`,(0,Q.jsx)(`small`,{className:`device-meta`,children:e?.available?`Version ${e.latest} is available.`:s?`You are on the latest version.`:`Checking for updates…`})]}),(0,Q.jsxs)(`span`,{className:`settings-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button is-primary is-danger`,disabled:a||t,onClick:()=>void o(),children:a?`Restarting…`:`Restart server`}),e?.available?(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button is-primary`,disabled:t,onClick:()=>void i(),children:t?`Updating…`:`Update to ${e.latest}`}):(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,disabled:n||!e,onClick:()=>void r(),children:n?`Checking…`:`Check for updates`})]})]})]})}function Uy({onOpenSidebar:e}){let[t,n]=(0,l.useState)(`worktree`),[r,i]=(0,l.useState)(Zf),[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(``);(0,l.useEffect)(()=>{n(mv()),i(Qf())},[]);let u=(e,t)=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){o(null),c(``);return}let n=tp(e);if(!n)return;if(np(n)||n===`meta+k`){c(`Choose a shortcut with a modifier that does not conflict with the browser or ⌘K.`);return}if(Object.entries(r).some(([e,r])=>e!==t&&r===n)){c(`That shortcut is already in use.`);return}let a={...r,[t]:n};i(a),localStorage.setItem(`webr-shortcuts`,JSON.stringify(a)),o(null),c(``)};return(0,Q.jsxs)(`main`,{className:`form-page settings-page`,children:[(0,Q.jsx)(`button`,{className:`mobile-menu`,onClick:e,children:`Threads`}),(0,Q.jsx)(`h1`,{children:`Settings`}),(0,Q.jsx)(Hy,{}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h2`,{children:`Appearance`}),(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsx)(`span`,{children:`Theme`}),(0,Q.jsx)(ip,{expanded:!0})]})]}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h2`,{children:`New threads`}),(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsx)(`span`,{children:`New session behavior`}),(0,Q.jsx)(`div`,{className:`theme-control theme-control--labels`,role:`group`,"aria-label":`New session behavior`,children:Object.keys(cv).map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":t===e,className:t===e?`theme-option is-selected`:`theme-option`,onClick:()=>{n(e),hv(e)},children:cv[e]},e))})]})]}),(0,Q.jsx)(ky,{}),(0,Q.jsxs)(`section`,{id:`shortcuts`,children:[(0,Q.jsxs)(`div`,{className:`settings-section-title`,children:[(0,Q.jsx)(`h2`,{children:`Keyboard shortcuts`}),(0,Q.jsx)(`button`,{onClick:()=>{i(Zf),localStorage.removeItem(`webr-shortcuts`),o(null),c(``)},children:`Reset`})]}),(0,Q.jsx)(`p`,{className:`settings-note`,children:`Press ⌘K for all actions and threads.`}),Object.keys(Xf).map(e=>(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsx)(`span`,{children:Xf[e]}),(0,Q.jsx)(`button`,{className:`shortcut-key`,"data-recording":a===e,onClick:()=>{o(e),c(``)},onKeyDown:t=>a===e&&u(t,e),"aria-label":`Change ${Xf[e]} shortcut`,children:a===e?`Press keys…`:$f(r[e]).map((e,t)=>(0,Q.jsx)(`kbd`,{children:e},t))})]},e)),s&&(0,Q.jsx)(`p`,{role:`alert`,className:`form-error`,children:s})]})]})}var Wy=l.createContext(void 0);function Gy(e=!0){let t=l.useContext(Wy);if(t===void 0&&!e)throw Error(Mi(25));return t}var Ky=l.createContext(void 0);function qy(e){let t=l.useContext(Ky);if(t===void 0&&!e)throw Error(Mi(33));return t}var Jy=l.createContext(void 0);function Yy(e){let t=l.useContext(Jy);if(t===void 0&&!e)throw Error(Mi(36));return t}function Xy(e){let{closeOnClick:t,highlighted:n,id:r,nodeId:i,store:a,typingRef:o,itemRef:s,itemMetadata:c}=e,{events:u}=a.useState(`floatingTreeRoot`),d=a.useState(`open`),f=Gy(!0),p=f!==void 0;return l.useMemo(()=>({id:r,role:`menuitem`,tabIndex:d&&n?0:-1,onKeyDown(e){e.key===` `&&o?.current&&e.preventDefault()},onMouseMove(e){i&&u.emit(`itemhover`,{nodeId:i,target:e.currentTarget})},onClick(e){t&&u.emit(`close`,{domEvent:e,reason:bn})},onMouseUp(e){if(f){let t=f.initialCursorPointRef.current;if(f.initialCursorPointRef.current=null,p&&t&&Math.abs(e.clientX-t.x)<=1&&Math.abs(e.clientY-t.y)<=1||p&&!Ke&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!p||e.button===2)&&c.type===`regular-item`&&Pc(s.current,e,{detail:1})}}),[t,n,r,u,i,d,a,o,s,f,p,c])}var Zy={type:`regular-item`};function Qy(e){let{closeOnClick:t,disabled:n,highlighted:r,id:i,store:a,typingRef:o=a.context.typingRef,nativeButton:s,itemMetadata:c,nodeId:u}=e,d=l.useRef(null),{getButtonProps:f,buttonRef:p}=Fc({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),m=Xy({closeOnClick:t,highlighted:r,id:i,nodeId:u,store:a,typingRef:o,itemRef:d,itemMetadata:c}),h=l.useCallback(e=>Vi(m,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,f),[m,f,c]),g=Bn(d,p);return l.useMemo(()=>({getItemProps:h,itemRef:g}),[h,g])}var $y=l.forwardRef(function(e,t){let{render:n,className:r,id:i,label:a,nativeButton:o=!1,disabled:s=!1,closeOnClick:c=!0,style:l,...u}=e,d=lg({guess:!0,label:a}),f=qy(!0),p=zc(i),{store:m}=Yy(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=Qy({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:Zy});return ta(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),eb=l.createContext(void 0);function tb(e){let t=l.useContext(eb);if(t===void 0&&!e)throw Error(Mi(69));return t}var nb=l.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=Yy(),{side:c,align:u}=qy(),d=tb(!0)!=null,f=s.useState(`open`),p=s.useState(`transitionStatus`),m=s.useState(`popupProps`),h=s.useState(`mounted`),g=s.useState(`instantType`),_=s.useState(`activeTriggerElement`),v=s.useState(`parent`),y=s.useState(`lastOpenChangeReason`),b=s.useState(`rootId`),x=s.useState(`floatingRootContext`),S=s.useState(`floatingTreeRoot`),C=s.useState(`closeDelay`),w=s.useState(`hoverEnabled`),T=s.useState(`disabled`),E=s.useState(`openMethod`),D=v.type===`context-menu`;xs({open:f,ref:s.context.popupRef,onComplete(){f&&s.context.onOpenChangeComplete?.(!0)}}),l.useEffect(()=>{function e(e){s.setOpen(!1,Z(e.reason,e.domEvent))}return S.events.on(`close`,e),()=>{S.events.off(`close`,e)}},[S.events,s]),tc(x,{enabled:w&&!T&&!D&&v.type!==`menubar`,closeDelay:C});let O=s.useStateSetter(`popupElement`),k=ta(`div`,e,{state:{transitionStatus:p,side:c,align:u,open:f,nested:v.type===`menu`,instant:g},ref:[t,s.context.popupRef,O],stateAttributesMapping:$t,props:[m,{onKeyDown(e){d&&Uc.has(e.key)&&e.stopPropagation()}},ql(p),o,{"data-rootownerid":b}]}),A=v.type===void 0||D;return(_||v.type===`menubar`&&y!==`outside-press`)&&(A=!0),(0,Q.jsx)(Ia,{context:x,openInteractionType:E,modal:D,disabled:!h,returnFocus:a===void 0?A:a,initialFocus:v.type!==`menu`,restoreFocus:!0,externalTree:v.type===`menubar`?void 0:S,previousFocusableElement:_,nextFocusableElement:v.type===void 0?s.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:v.type===void 0?s.context.beforeContentFocusGuardRef:void 0,children:k})}),rb=l.createContext(void 0);function ib(){let e=l.useContext(rb);if(e===void 0)throw Error(Mi(32));return e}var ab=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=Yy();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Q.jsx)(rb.Provider,{value:n,children:(0,Q.jsx)(_a,{ref:t,...r,portalOwnerRole:o})})}),ob=l.forwardRef(function(e,t){let{anchor:n,positionMethod:r=`absolute`,className:i,render:a,side:o,align:s,sideOffset:c=0,alignOffset:u=0,collisionBoundary:d=`clipping-ancestors`,collisionPadding:f=5,arrowPadding:p=5,sticky:m=!1,disableAnchorTracking:h=!1,collisionAvoidance:g=la,style:_,...v}=e,{store:y}=Yy(),b=ib(),x=Gy(!0),S=y.useState(`parent`),C=y.useState(`floatingRootContext`),w=y.useState(`floatingTreeRoot`),T=y.useState(`mounted`),E=y.useState(`open`),D=y.useState(`modal`),O=y.useState(`openMethod`),k=y.useState(`activeTriggerElement`),A=y.useState(`transitionStatus`),j=y.useState(`positionerElement`),M=y.useState(`instantType`),N=y.useState(`adaptiveOrigin`),P=y.useState(`lastOpenChangeReason`),F=y.useState(`floatingNodeId`),I=y.useState(`floatingParentNodeId`),L=C.useState(`domReferenceElement`),R=l.useRef(null),z=bs(j),B=n,V=c,ee=u,te=s,ne=g;S.type===`context-menu`&&(B=n??S.context?.anchor,te??=`start`,!o&&te!==`center`&&(ee=e.alignOffset??2,V=e.sideOffset??-5));let H=o,U=te;S.type===`menu`?(H??=`inline-end`,U??=`start`,ne=e.collisionAvoidance??ua):S.type===`menubar`&&(H??=S.context.orientation===`vertical`?`inline-end`:`bottom`,U??=`start`);let re=S.type===`context-menu`,ie=Wl({anchor:B,floatingRootContext:C,positionMethod:x?`fixed`:r,mounted:T,side:H,sideOffset:V,align:U,alignOffset:ee,arrowPadding:re?0:p,collisionBoundary:d,collisionPadding:f,sticky:m,nodeId:F,keepMounted:b,disableAnchorTracking:h,collisionAvoidance:ne,shift:re?{crossAxis:!(`side`in ne&&ne.side===`flip`),rootBoundary:`layoutViewport`}:void 0,externalTree:w,adaptiveOrigin:N});l.useEffect(()=>{function e(e){e.open&&(e.parentNodeId===F&&y.set(`hoverEnabled`,!1),e.nodeId!==F&&e.parentNodeId===y.select(`floatingParentNodeId`)&&y.setOpen(!1,Z(jn)))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[y,w.events,F]),l.useEffect(()=>{if(y.select(`floatingParentNodeId`)==null)return;function e(e){if(e.open||e.nodeId!==y.select(`floatingParentNodeId`))return;let t=e.reason??`sibling-open`;y.setOpen(!1,Z(t))}return w.events.on(`menuopenchange`,e),()=>{w.events.off(`menuopenchange`,e)}},[w.events,y]);let ae=ot();l.useEffect(()=>{E||ae.clear()},[E,ae]),l.useEffect(()=>{function e(e){if(E&&e.nodeId===y.select(`floatingParentNodeId`)){if(e.target&&k&&k!==e.target){let e=y.select(`closeDelay`);e>0?ae.isStarted()||ae.start(e,()=>{y.setOpen(!1,Z(jn))}):y.setOpen(!1,Z(jn))}else ae.clear()}}return w.events.on(`itemhover`,e),()=>{w.events.off(`itemhover`,e)}},[w.events,E,k,y,ae]),l.useEffect(()=>{let e={open:E,nodeId:F,parentNodeId:I,reason:y.select(`lastOpenChangeReason`)};w.events.emit(`menuopenchange`,e)},[w.events,E,y,F,I]),W(()=>{let e=L,t=R.current;if(e&&(R.current=e),t&&e&&e!==t){y.set(`instantType`,void 0);let e=new AbortController;return z(()=>{y.set(`instantType`,`trigger-change`)},e.signal),()=>{e.abort()}}},[L,z,y]);let oe={open:E,side:ie.side,align:ie.align,anchorHidden:ie.anchorHidden,nested:S.type===`menu`,instant:M},se=S.type===`menubar`&&S.context.modal;ag(E&&(se||D&&P!==`trigger-hover`),O===`touch`,j,k);let ce=Jl(e,oe,{styles:ie.positionerStyles,transitionStatus:A,props:v,refs:[t,y.useStateSetter(`positionerElement`)],hidden:!T,inert:!E}),le=T&&S.type!==`menu`&&(S.type!==`menubar`&&D&&P!==`trigger-hover`||S.type===`menubar`&&S.context.modal),ue=null;return S.type===`menubar`?ue=S.context.contentElement:S.type===void 0&&(ue=k),(0,Q.jsxs)(Ky.Provider,{value:ie,children:[le&&(0,Q.jsx)(Yc,{ref:S.type===`context-menu`||S.type===`nested-context-menu`?S.context.internalBackdropRef:null,inert:Jc(!E),cutout:ue}),(0,Q.jsx)(Ta,{id:F,children:(0,Q.jsx)(Wh,{elementsRef:y.context.itemDomElements,labelsRef:y.context.itemLabels,children:ce})})]})}),sb=l.createContext(null);function cb(e){let t=l.useContext(sb);if(t===null&&!e)throw Error(Mi(5));return t}var lb={...Us,disabled:e=>e.parent.type===`menubar`&&e.parent.context.disabled||e.disabled,modal:e=>(e.parent.type===void 0||e.parent.type===`context-menu`)&&(e.modal??!0),openMethod:e=>e.openMethod,allowMouseEnter:e=>e.allowMouseEnter,highlightItemOnHover:e=>e.highlightItemOnHover,parent:e=>e.parent,rootId:e=>e.parent.type===`menu`?e.parent.store.select(`rootId`):e.parent.type===void 0?e.rootId:e.parent.context.rootId,activeIndex:e=>e.activeIndex,isActive:(e,t)=>e.activeIndex===t,hoverEnabled:e=>e.hoverEnabled,instantType:e=>e.instantType,lastOpenChangeReason:e=>e.openChangeReason,floatingTreeRoot:e=>e.parent.type===`menu`?e.parent.store.select(`floatingTreeRoot`):e.floatingTreeRoot,floatingNodeId:e=>e.floatingNodeId,floatingParentNodeId:e=>e.floatingParentNodeId,itemProps:e=>e.itemProps,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin,keyboardEventRelay:e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type===`menu`)return e.parent.store.select(`keyboardEventRelay`)}},ub=class extends ps{constructor(e,t,n=!1){let r=new Is,i=fb(r,t,n,e);super(i,db(r),lb),this.unsubscribeParentListener=this.observe(`parent`,e=>{if(this.unsubscribeParentListener?.(),e.type===`menu`){let t=e.store.select(`rootId`),n=e.store.select(`floatingTreeRoot`),r=e.store.select(`keyboardEventRelay`);this.unsubscribeParentListener=e.store.subscribe(()=>{let i=e.store.select(`rootId`),a=e.store.select(`floatingTreeRoot`),o=e.store.select(`keyboardEventRelay`);(t!==i||n!==a||r!==o)&&(t=i,n=a,r=o,this.notifyAll())}),this.context.allowMouseUpTriggerRef=e.store.context.allowMouseUpTriggerRef;return}e.type!==void 0&&(this.context.allowMouseUpTriggerRef=e.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(e,t){this.state.floatingRootContext.context.events.emit(`setOpen`,{open:e,eventDetails:t})}unsubscribeParentListener=null};function db(e){return{positionerRef:l.createRef(),popupRef:l.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:l.createRef(),beforeContentFocusGuardRef:l.createRef(),onOpenChangeComplete:void 0,triggerElements:e}}function fb(e,t,n=!1,r){return{...Ls(e,t,n),disabled:!1,modal:!0,openMethod:null,allowMouseEnter:!1,highlightItemOnHover:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new ya,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:nt,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var pb=l.createContext(void 0);function mb(){return l.useContext(pb)}var hb=ns(function(e){let{children:t,open:n,onOpenChange:r,onOpenChangeComplete:i,defaultOpen:a=!1,disabled:o=!1,modal:s,loopFocus:c=!0,orientation:u=`vertical`,actionsRef:d,closeParentOnEsc:f=!1,handle:p,triggerId:m,defaultTriggerId:h=null,highlightItemOnHover:g=!0}=e,_=Gy(!0),v=Yy(!0),y=cb(!0),b=mb(),x=l.useMemo(()=>b&&v?{type:`menu`,store:v.store}:y?{type:`menubar`,context:y}:_&&!v?{type:`context-menu`,context:_}:{type:void 0},[_,v,y,b]),S=Ai(),C=Ai(),w=Sa(),T=x.type===`menu`?x.store:void 0,E=(n??a)&&T?.state.transitionStatus===`starting`,D=$e(()=>E?T?.state.instantType:void 0).current,O=gb({open:a,openProp:n,activeTriggerId:h,triggerIdProp:m,parent:x,disabled:o,highlightItemOnHover:g,modal:x.type===void 0?s:void 0,rootId:S,instantType:D},C,w!=null);O.useControlledProp(`openProp`,n),O.useControlledProp(`triggerIdProp`,m),O.useContextCallback(`onOpenChangeComplete`,i);let k=O.useState(`floatingTreeRoot`),A=wa(k),j=O.useState(`open`),M=O.useState(`activeTriggerElement`),N=O.useState(`positionerElement`),P=O.useState(`hoverEnabled`),F=O.useState(`disabled`),I=O.useState(`lastOpenChangeReason`),L=O.useState(`parent`),R=O.useState(`activeIndex`),z=O.useState(`payload`),B=O.useState(`floatingParentNodeId`),V=l.useRef(null),ee=l.useRef(L.type!==`context-menu`),te=ot(),ne=l.useRef(!0),H=ot(),U=B!=null,{openMethod:re,triggerProps:ie}=tl(j);O.useSyncedValues({disabled:o,highlightItemOnHover:g,modal:L.type===void 0?s:void 0,openMethod:re,rootId:S}),Ms(O);let{forceUnmount:ae,transitionStatus:oe}=Ns(j,O,()=>{O.set(`allowMouseEnter`,!1)},E),se=bs(O.context.popupRef);l.useEffect(()=>{if(D===void 0)return;let e=()=>{O.state.instantType===D&&O.set(`instantType`,void 0)};if(!j){e();return}if(oe!==void 0)return;if(O.context.popupRef.current==null){e();return}let t=new AbortController;return se(e,t.signal),()=>{t.abort()}},[D,j,oe,se,O]),W(()=>{_&&!v?O.update({parent:{type:`context-menu`,context:_},floatingNodeId:A,floatingParentNodeId:w}):v&&O.update({floatingNodeId:A,floatingParentNodeId:w})},[_,v,A,w,O]),l.useEffect(()=>{if(j||(V.current=null),L.type===`context-menu`){if(!j){te.clear(),ee.current=!1;return}te.start(500,()=>{ee.current=!0})}},[te,j,L.type]),W(()=>{!j&&!P&&O.set(`hoverEnabled`,!0)},[j,P,O]);let ce=$((e,t)=>{let n=t.reason;if(!e&&!O.select(`open`)||j===e&&t.trigger===M&&I===n)return;let i=ks(t);if(!e&&t.trigger==null&&(t.trigger=M??void 0),r?.(e,t),t.isCanceled)return;O.state.floatingRootContext.dispatchOpenChange(e,t);let a=t.event;if(e===!1&&a?.type===`click`&&a.pointerType===`touch`&&!ne.current)return;e&&n===`trigger-focus`?(ne.current=!1,H.start(300,()=>{ne.current=!0})):(ne.current=!0,H.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null);V.current=t.event;let c=Os(O.state,e,t.trigger,i());c.openChangeReason=n,c.instantType=L.type===`menubar`&&(n===`trigger-focus`||n===`focus-out`||n===`trigger-hover`||n===`list-navigation`||n===`sibling-open`)?`group`:o||s?o?`click`:`dismiss`:void 0,O.update(c)}),le=gs({popupStore:O,floatingRootContext:O.state.floatingRootContext,floatingId:C,nested:w!=null,onOpenChange:ce}),ue=le.context.events;W(()=>{let e=({open:e,eventDetails:t})=>ce(e,t);return ue.on(`setOpen`,e),()=>{ue?.off(`setOpen`,e)}},[ue,ce]);let de=l.useCallback(()=>{O.setOpen(!1,Z(Nn))},[O]);l.useImperativeHandle(d,()=>({unmount:ae,close:de}),[ae,de]);let fe;L.type===`context-menu`&&(fe=L.context),l.useImperativeHandle(fe?.positionerRef,()=>N,[N]),l.useImperativeHandle(fe?.actionsRef,()=>({setOpen:ce}),[ce]);let pe=Ua(le,{enabled:!F,bubbles:{escapeKey:f&&L.type===`menu`},outsidePress(){return L.type!==`context-menu`||V.current?.type===`contextmenu`||ee.current},externalTree:U?k:void 0}),me=Al(),he=l.useCallback(e=>{O.select(`activeIndex`)!==e&&O.set(`activeIndex`,e)},[O]),G=dc(le,{enabled:!F,listRef:O.context.itemDomElements,activeIndex:R,nested:L.type!==void 0,loopFocus:c,orientation:u,parentOrientation:L.type===`menubar`?L.context.orientation:void 0,rtl:me===`rtl`,disabledIndices:tt,onNavigate:he,openOnArrowKeyDown:L.type!==`context-menu`,externalTree:U?k:void 0,focusItemOnHover:g}),ge=l.useCallback(e=>{O.context.typingRef.current=e},[O]),_e=fc(le,{enabled:!F,listRef:O.context.itemLabels,elementsRef:O.context.itemDomElements,activeIndex:R,resetMs:500,onMatch:e=>{j&&e!==R&&O.set(`activeIndex`,e)},onTyping:ge}),K=l.useMemo(()=>{let e=Vi(_e.reference,G.reference,pe.reference,{onMouseMove(){O.set(`allowMouseEnter`,!0)}},ie);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=j,e},[O,_e.reference,G.reference,pe.reference,ie,j]),ve=l.useMemo(()=>{let e=Vi(G.trigger,pe.trigger,ie);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[G.trigger,pe.trigger,ie]);$e(()=>(O.update({inactiveTriggerProps:ve}),null)),Ps(O,{floatingRootContext:le,activeTriggerProps:K,inactiveTriggerProps:ve,popupProps:l.useMemo(()=>Vi(Ss,{id:C,role:`menu`,"aria-orientation":u===`horizontal`?`horizontal`:void 0,"aria-labelledby":M?.id,onMouseMove(){O.set(`allowMouseEnter`,!0),L.type===`menu`&&O.set(`hoverEnabled`,!1)},onClick(){O.select(`hoverEnabled`)&&O.set(`hoverEnabled`,!1)},onKeyDown(e){let t=O.select(`keyboardEventRelay`);t&&!e.isPropagationStopped()&&t(e)}},_e.floating,G.floating,pe.floating),[M,C,u,L.type,O,_e.floating,G.floating,pe.floating]),itemProps:G.item??nt});let ye=l.useMemo(()=>({store:O,parent:x}),[O,x]),be=(0,Q.jsxs)(Jy.Provider,{value:ye,children:[p&&(0,Q.jsx)(Ts,{handle:p,store:O}),typeof t==`function`?t({payload:z}):t]});return L.type===void 0||L.type===`context-menu`?(0,Q.jsx)(Ea,{externalTree:k,children:be}):be});function gb(e,t,n){return $e(()=>new ub(e,t,n)).current}function _b(e){let t=Yy().store,n=l.useMemo(()=>({parentMenu:t}),[t]);return(0,Q.jsx)(pb.Provider,{value:n,children:(0,Q.jsx)(hb,{...e})})}function vb(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Mc(),{ref:i,index:a}=lg(e),o=n===a,s=l.useRef(null),c=Bn(i,s);return{compositeProps:{tabIndex:o?0:-1,onFocus(){r(a)},onMouseMove(){let e=s.current;if(!t||!e)return;let n=e.hasAttribute(`disabled`)||e.ariaDisabled===`true`;!o&&!n&&e.focus()}},compositeRef:c,index:a}}function yb(e){let{render:t,className:n,style:r,state:i=nt,props:a=tt,refs:o=tt,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=vb({metadata:s});return ta(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function bb(e){if(ve(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Ae(e))return bb(Ne(e))}function xb(e,t){let n=l.useRef(null);function r(t){fa.flushSync(()=>{e.setOpen(!1,Z(Tn,t.nativeEvent,t.currentTarget))}),oi(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&si(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{fa.flushSync(()=>{e.setOpen(!1,Z(Tn,n.nativeEvent,n.currentTarget))});let i=ai(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&X(r,i);){let e=i;if(i=ni(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Sb(e){let{enabled:t=!0,mouseDownAction:n,open:r}=e,i=l.useRef(!1);return l.useMemo(()=>t?{onMouseDown:e=>{(n===`open`&&!r||n===`close`&&r)&&(i.current=!0,J(e.currentTarget).addEventListener(`click`,()=>{i.current=!1},{once:!0}))},onClick:e=>{i.current&&(i.current=!1,e.preventBaseUIHandler())}}:nt,[t,n,r])}var Cb=rs(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,id:s,openOnHover:c,delay:u=100,closeDelay:d=0,handle:f,payload:p,...m}=e,h=Yy(!0),g=Ws(f)??h?.store;if(!g)throw Error(Mi(85));let _=zc(s),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),b=g.useState(`isOpenedByTrigger`,_),x=g.useState(`triggerPopupId`,_),S=l.useRef(null),C=Tb(),w=Mc(!0),T=Ca(),E=l.useMemo(()=>T??new ya,[T]),{registerTrigger:D,isMountedByThisTrigger:O}=js(_,S,g,{payload:p,closeDelay:d,parent:C,floatingTreeRoot:E,floatingNodeId:wa(E),floatingParentNodeId:Sa(),keyboardEventRelay:w?.relayKeyboardEvent}),k=C.type===`menubar`,A=g.useState(`disabled`),j=a||A||k&&C.context.disabled,{getButtonProps:M,buttonRef:N}=Fc({disabled:j,native:o});l.useEffect(()=>{!b&&C.type===void 0&&(g.context.allowMouseUpTriggerRef.current=!1)},[g,b,C.type]);let P=l.useRef(null),F=ot(),I=$(e=>{if(!P.current)return;F.clear(),g.context.allowMouseUpTriggerRef.current=!1;let t=e.target;X(P.current,t)||X(g.select(`positionerElement`),t)||t===P.current||(t==null||bb(t)!==g.select(`rootId`))&&(Ih(e,P.current)||E.events.emit(`close`,{domEvent:e,reason:An}))});l.useEffect(()=>{b&&g.select(`lastOpenChangeReason`)===`trigger-hover`&&J(P.current).addEventListener(`mouseup`,I,{once:!0})},[b,I,g]);let L=k&&C.context.hasSubmenuOpen,R=rc(y,{enabled:(c??L)&&!j&&(!k||L&&!O),handleClose:bc({blockPointerEvents:!k}),mouseOnly:!0,move:!1,restMs:C.type===void 0?u:void 0,delay:{close:d},triggerElementRef:S,externalTree:E,isActiveTrigger:v,isClosing:()=>g.select(`transitionStatus`)===`ending`}),z=wb(b,g.select(`lastOpenChangeReason`)),B=La(y,{enabled:!j,event:b&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:C.type===void 0&&z}),V=Ys(y,{enabled:!j&&L}),ee=Sb({open:b,enabled:k,mouseDownAction:`open`}),te=l.useMemo(()=>Vi(V.reference,B.reference),[V.reference,B.reference]),ne=g.useState(`triggerProps`,O),{preFocusGuardRef:H,handlePreFocusGuardFocus:U,handleFocusTargetFocus:re}=xb(g,S),ie={disabled:j,open:b},ae=[P,t,N,D,S],oe=[te,R??nt,ne,{"aria-haspopup":`menu`,"aria-controls":x,id:_,onMouseDown:e=>{g.select(`open`)||(F.start(200,()=>{g.context.allowMouseUpTriggerRef.current=!0}),J(e.currentTarget).addEventListener(`mouseup`,I,{once:!0}))}},k?{role:`menuitem`}:{},ee,m,M],se=ta(`button`,e,{enabled:!k,stateAttributesMapping:Zt,state:ie,ref:ae,props:oe});return k?(0,Q.jsx)(yb,{tag:`button`,render:n,className:r,style:i,state:ie,refs:ae,props:oe,stateAttributesMapping:Zt}):b?(0,Q.jsxs)(l.Fragment,{children:[(0,Q.jsx)(nr,{ref:H,onFocus:U},`${_}-pre-focus-guard`),(0,Q.jsx)(l.Fragment,{children:se},_),(0,Q.jsx)(nr,{ref:g.context.triggerFocusTargetRef,onFocus:re},`${_}-post-focus-guard`)]}):(0,Q.jsx)(l.Fragment,{children:se},_)});function wb(e,t){let n=ot(),[r,i]=l.useState(!1);return W(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function Tb(){let e=cb(!0);return l.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var Eb={"aria-expanded":void 0},Db=l.forwardRef(function(e,t){let{render:n,className:r,style:i,label:a,id:o,nativeButton:s=!1,openOnHover:c=!0,delay:u=100,closeDelay:d=0,disabled:f=!1,...p}=e,m=mb();if(!m?.parentMenu)throw Error(Mi(37));let h=lg({guess:!0,label:a}),g=qy(),{store:_}=Yy(),v=zc(o),y=_.useState(`open`),b=_.useState(`floatingRootContext`),x=_.useState(`floatingTreeRoot`),S=_.useState(`triggerPopupId`,v),C=Ds(v,_),w=$(e=>{C(e),e!==null&&_.select(`open`)&&_.select(`activeTriggerId`)==null&&_.update({activeTriggerId:v??null,activeTriggerElement:e,closeDelay:d})}),T=l.useRef(null),E=l.useCallback(e=>{T.current=e,_.set(`activeTriggerElement`,e)},[_]);W(()=>(w(T.current),()=>w(null)),[w,v,_]),_.useSyncedValue(`closeDelay`,d);let D=m.parentMenu,O=_.useState(`disabled`),k=D.useState(`disabled`),A=f||O||k,j=D.useState(`itemProps`),M=D.useState(`isActive`,h.index),N=l.useMemo(()=>({type:`submenu-trigger`,setActive(){D.select(`highlightItemOnHover`)&&D.set(`activeIndex`,h.index)}}),[D,h.index]),{getItemProps:P,itemRef:F}=Qy({closeOnClick:!1,disabled:A,highlighted:M,id:v,store:_,typingRef:D.context.typingRef,nativeButton:s,itemMetadata:N,nodeId:g?.context.nodeId}),I=rc(b,{enabled:_.useState(`hoverEnabled`)&&c&&!A,handleClose:bc({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:u,delay:{open:u,close:d},shouldOpen:u>0?()=>D.select(`allowMouseEnter`):void 0,triggerElementRef:T,externalTree:x,isClosing:()=>_.select(`transitionStatus`)===`ending`,guardStaleOpen:!0}),L=La(b,{enabled:!A,event:`mousedown`,toggle:!c,ignoreMouse:c,stickIfOpen:!1}).reference??nt,R=_.useState(`triggerProps`,!0);delete R.id;let z={disabled:A,highlighted:M,open:y},B=_.useState(`openMethod`),V=_.useState(`lastOpenChangeReason`)===`list-navigation`||B===`keyboard`;return ta(`div`,e,{state:z,stateAttributesMapping:Xt,props:[L,I,R,j,y&&V&&Xe?Eb:void 0,{"aria-controls":S,tabIndex:y||M?0:-1,onBlur(){M&&D.set(`activeIndex`,null)}},p,P],ref:[t,h.ref,F,w,E]})});function Ob(e){let[t,n]=l.useState({getBoundingClientRect(){return DOMRect.fromRect({width:0,height:0,x:0,y:0})}}),r=l.useRef(null),i=l.useRef(null),a=l.useRef(null),o=l.useRef(null),s=l.useRef(!0),c=l.useRef(null),u=Ai(),d=l.useMemo(()=>({anchor:t,setAnchor:n,actionsRef:a,backdropRef:r,internalBackdropRef:i,positionerRef:o,allowMouseUpTriggerRef:s,initialCursorPointRef:c,rootId:u}),[t,u]);return(0,Q.jsx)(Wy.Provider,{value:d,children:(0,Q.jsx)(Jy.Provider,{value:void 0,children:(0,Q.jsx)(hb,{...e})})})}var kb=500,Ab=l.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{setAnchor:o,actionsRef:s,internalBackdropRef:c,backdropRef:u,positionerRef:d,allowMouseUpTriggerRef:f,initialCursorPointRef:p,rootId:m}=Gy(!1),{store:h}=Yy(!1),g=h.useState(`open`),_=h.useState(`disabled`),v=l.useRef(null),y=l.useRef(null),b=ot(),x=ot(),S=l.useRef(!1),C=l.useRef(null);function w(e,t,n){let r=n.type.startsWith(`touch`);p.current={x:e,y:t},o({getBoundingClientRect(){return DOMRect.fromRect({width:r?10:0,height:r?10:0,x:e,y:t})}}),S.current=!1,s.current?.setOpen(!0,Z(gn,n)),x.start(kb,()=>{S.current=!0})}function T(e){if(_)return;f.current=!0,xt(e),w(e.clientX,e.clientY,e.nativeEvent);let t=J(v.current);C.current?.abort();let n=new AbortController;C.current=n,t.addEventListener(`mouseup`,e=>{if(f.current=!1,!S.current)return;x.clear(),S.current=!1;let t=Ot(e);X(d.current,t)||m&&t&&bb(t)===m||s.current?.setOpen(!1,Z(An,e))},{once:!0,signal:n.signal})}function E(){b.clear(),y.current=null}function D(e){if(_){E();return}if(f.current=!1,e.touches.length!==1){E();return}e.stopPropagation();let t=e.touches[0],n={x:t.clientX,y:t.clientY};y.current=n,b.start(kb,()=>{w(n.x,n.y,e.nativeEvent)})}function O(e){if(e.touches.length!==1){E();return}if(b.isStarted()&&y.current){let t=e.touches[0],n=Math.abs(t.clientX-y.current.x),r=Math.abs(t.clientY-y.current.y);(n>10||r>10)&&E()}}return l.useEffect(()=>()=>{C.current?.abort()},[]),l.useEffect(()=>{function e(e){if(_)return;let t=Ot(e);(X(v.current,t)||X(c.current,t)||X(u.current,t))&&e.preventDefault()}return q(J(v.current),`contextmenu`,e)},[u,_,c]),ta(`div`,e,{state:{open:g},ref:[v,t],props:[{onContextMenu:T,onTouchStart:D,onTouchMove:O,onTouchEnd:E,onTouchCancel:E,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:Zt})}),jb=ob,Mb={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`Pi`};function Nb(e){return Object.hasOwn(Mb,e)?Mb[e]:e}function Pb(e){let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/6e4));return t<1?`now`:t<60?`${t}m`:t<1440?`${Math.floor(t/60)}h`:`${Math.floor(t/1440)}d`}var Fb=[{id:`validate`,label:`Checking the machine`,active:`Checking the machine…`},{id:`checkout`,label:`Creating the worktree`,active:`Creating the worktree…`},{id:`start`,label:`Starting the agent`,active:`Starting the agent…`},{id:`prompt`,label:`Sending your prompt`,active:`Sending your prompt…`}],Ib=6e5,Lb=e=>e===`checkout_complete`?2:Math.max(0,Fb.findIndex(t=>t.id===e)),Rb=e=>[`pending`,`running`].includes(e.operation?.state??``)&&!e.panes.some(e=>e.kind===`agent`),zb=e=>[`failed`,`unknown`].includes(e.operation?.state??``)&&!e.panes.some(e=>e.kind===`agent`),Bb=e=>Fb[Lb(e.operation?.step??`validate`)].active,Vb=(e,t)=>t-Date.parse(e.updatedAt)<Ib,Hb=(e,t=Date.now())=>e.panes.some(e=>e.kind===`agent`)||Rb(e)||zb(e)&&Vb(e,t),Ub=e=>new URLSearchParams({machineId:e.machineId??`local`,projectId:e.id}),Wb=e=>e.branch??e.label,Gb=e=>e.path.split(`/`).at(-1)??``,Kb=(e,t)=>`${Wb(e)} ${Gb(e)}`.toLowerCase().includes(t.trim().toLowerCase()),qb=async(e,t)=>{let n=await fetch(`/api/worktrees?${Ub(e)}`,{signal:t});if(!n.ok)throw Error(`Could not list worktrees.`);return await n.json()},Jb=async(e,t)=>{let n=await fetch(`/api/worktrees/open`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({machineId:e.machineId??`local`,projectId:e.id,path:t.path})});if(!n.ok)throw Error(`Could not open this worktree.`);return(await n.json()).id},Yb=async(e,t)=>{try{await a(`/threads/${encodeURIComponent(await Jb(e,t))}`)}catch(e){cl(e instanceof Error?e.message:`Could not open this worktree.`)}},Xb=e=>{(e.key.length===1||e.key===`Backspace`)&&e.stopPropagation()};function Zb({project:e}){let[t,n]=(0,l.useState)(``),r=Z_({queryKey:[`worktrees`,e.machineId,e.id],queryFn:({signal:t})=>qb(e,t),staleTime:0,gcTime:0}),i=(r.data??[]).filter(e=>Kb(e,t));return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`composer-select-search`,children:[(0,Q.jsx)(ie,{size:14,"aria-hidden":`true`}),(0,Q.jsx)(`input`,{autoFocus:!0,"aria-label":`Search worktrees`,placeholder:`Search worktrees…`,value:t,onChange:e=>n(e.target.value),onKeyDown:Xb})]}),(0,Q.jsxs)(`div`,{className:`worktree-menu-list`,children:[i.map(t=>(0,Q.jsx)(Zl,{label:t.path,side:`right`,children:(0,Q.jsxs)($y,{className:`thread-menu-item`,onClick:()=>void Yb(e,t),children:[(0,Q.jsx)(P,{size:14,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{className:`worktree-menu-name`,children:[Wb(t),(0,Q.jsx)(`small`,{children:Gb(t)})]})]})},t.path)),r.isError&&(0,Q.jsx)(`p`,{className:`worktree-menu-note`,role:`alert`,children:`Could not list worktrees.`}),r.data&&!i.length&&(0,Q.jsx)(`p`,{className:`worktree-menu-note`,children:r.data.length?`No matches`:`Every worktree already has a thread`})]})]})}function Qb({projects:e}){return(0,Q.jsxs)(hb,{children:[(0,Q.jsx)(Zl,{label:`Open existing worktree`,children:(0,Q.jsx)(Cb,{className:`sidebar-open-worktree`,"aria-label":`Open existing worktree`,disabled:!e.length,children:(0,Q.jsx)(ie,{size:16,"aria-hidden":`true`})})}),(0,Q.jsx)(ab,{children:(0,Q.jsx)(ob,{className:`thread-menu-positioner`,sideOffset:6,align:`start`,children:(0,Q.jsx)(nb,{className:`thread-menu`,children:e.map(e=>(0,Q.jsxs)(_b,{children:[(0,Q.jsxs)(Db,{className:`thread-menu-item`,children:[(0,Q.jsx)(Eg,{project:e}),(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(x,{size:14,"aria-hidden":`true`,className:`worktree-menu-chevron`})]}),(0,Q.jsx)(ab,{children:(0,Q.jsx)(ob,{className:`thread-menu-positioner`,sideOffset:4,alignOffset:-4,children:(0,Q.jsx)(nb,{className:`thread-menu worktree-menu`,children:(0,Q.jsx)(Zb,{project:e})})})})]},`${e.machineId}:${e.id}`))})})})]})}function $b({thread:e,onDone:t,onError:n}){let[r,i]=(0,l.useState)(e.title),a=(0,l.useRef)(null),o=(0,l.useRef)(!1);(0,l.useEffect)(()=>{a.current?.focus(),a.current?.select()},[]);let s=i=>{if(o.current)return;o.current=!0,t();let a=r.trim();i&&a&&a!==e.title&&cp(e,a).catch(n)};return(0,Q.jsx)(`input`,{ref:a,className:`thread-name-input`,"aria-label":`Rename ${e.title}`,value:r,maxLength:90,onChange:e=>i(e.target.value),onBlur:()=>s(!0),onClick:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&s(!0),e.key===`Escape`&&s(!1)}})}function ex({project:e,onDone:t,onError:n}){let[r,i]=(0,l.useState)(e.name),a=(0,l.useRef)(null),o=(0,l.useRef)(!1);(0,l.useEffect)(()=>{a.current?.focus(),a.current?.select()},[]);let s=i=>{if(o.current)return;o.current=!0,t();let a=r.trim();i&&a&&a!==e.name&&lp(e,a).catch(n)};return(0,Q.jsx)(`input`,{ref:a,className:`thread-name-input group-name-input`,"aria-label":`Rename ${e.name}`,value:r,maxLength:90,onChange:e=>i(e.target.value),onBlur:()=>s(!0),onClick:e=>e.stopPropagation(),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`&&s(!0),e.key===`Escape`&&s(!1)}})}var tx=128;async function nx(e){let t=await createImageBitmap(e),n=document.createElement(`canvas`);n.width=n.height=tx;let r=Math.min(tx/t.width,tx/t.height),i=t.width*r,a=t.height*r;return n.getContext(`2d`).drawImage(t,(tx-i)/2,(tx-a)/2,i,a),new Promise((e,t)=>n.toBlob(n=>n?e(n):t(Error(`Could not read this image.`)),`image/png`))}function rx({project:e,open:t,onClose:n,onError:r}){let i=(0,l.useRef)(null),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(!1),[u,d]=(0,l.useState)([]);(0,l.useEffect)(()=>{if(!t)return;let n=!0;return fp(e).then(e=>{n&&d(e)}).catch(()=>{}),()=>{n=!1,d([])}},[t,e.id,e.machineId]);let f=async e=>{c(!0);try{await e(),n()}catch(e){r(e)}finally{c(!1)}},p=t=>{t&&f(async()=>dp(e,await nx(t)))},m=t=>void f(async()=>dp(e,await nx(await(await fetch(t.url)).blob())));return(0,Q.jsx)(Ev,{open:t,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(Xc,{children:[(0,Q.jsx)(Ac,{className:`dialog-backdrop`}),(0,Q.jsxs)(qc,{className:`dialog`,children:[(0,Q.jsxs)(Zc,{className:`dialog-message`,children:[`Change icon for `,e.name]}),(0,Q.jsxs)(`div`,{className:`icon-current`,children:[(0,Q.jsx)(Eg,{project:e}),(0,Q.jsx)(`span`,{children:`Current icon`})]}),(0,Q.jsxs)(`button`,{type:`button`,className:`icon-dropzone ${a?`is-dragging`:``}`,disabled:s,onClick:()=>i.current?.click(),onDragOver:e=>{e.preventDefault(),o(!0)},onDragLeave:()=>o(!1),onDrop:e=>{e.preventDefault(),o(!1),p(e.dataTransfer.files[0])},children:[(0,Q.jsx)(I,{size:22,"aria-hidden":`true`}),`Drop an image here, or click to choose`]}),(0,Q.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,hidden:!0,onChange:e=>{p(e.target.files?.[0]),e.target.value=``}}),u.length>0&&(0,Q.jsx)(`div`,{className:`icon-candidates`,role:`group`,"aria-label":`Images found in this project`,children:u.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:`icon-candidate`,disabled:s,title:e.name,"aria-label":`Use ${e.name}`,onClick:()=>m(e),children:(0,Q.jsx)(`img`,{src:e.url,alt:``,loading:`lazy`})},e.url))}),(0,Q.jsxs)(`div`,{className:`dialog-actions`,children:[(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,disabled:s,onClick:()=>void f(()=>pp(e)),children:`Reset to default`}),(0,Q.jsx)(Rc,{className:`dialog-button`,children:`Cancel`})]})]})]})})}var ix=220,ax=`[data-flip-id]`,ox=e=>{let t=e.getBoundingClientRect().top-e.scrollTop;return new Map([...e.querySelectorAll(ax)].map(e=>[e.dataset.flipId,{element:e,top:e.getBoundingClientRect().top-t}]))};function sx(e){let t=(0,l.useRef)(new Map);(0,l.useLayoutEffect)(()=>{if(!e.current)return;let n=ox(e.current);for(let[e,{element:r,top:i}]of n){let n=t.current.get(e);n===void 0||Math.abs(n-i)<1||r.animate([{transform:`translateY(${n-i}px)`},{transform:`none`}],{duration:ix,easing:`cubic-bezier(.2, .8, .2, 1)`})}t.current=new Map([...n].map(([e,{top:t}])=>[e,t]))})}function cx(e,t){let n=new Map;for(let r of e){let e=r.logicalId??r.id,i=n.get(e);i?(i.locations.push(r.id),r.id===t&&(i.project=r)):n.set(e,{id:e,project:r,locations:[r.id]})}return[...n.values()]}var lx=/^\/(?:Users|home)\/[^/]+/,ux=e=>e.replace(lx,`~`),dx={working:`Working`,blocked:`Needs input`,done:`Done`,idle:`Idle`,unknown:`Unknown`},fx={blocked:z,done:w,unknown:T},px=e=>cl(e instanceof Error?e.message:`Herdr could not complete this action.`),mx=async e=>{await sl(yp([e]),{confirmLabel:`Delete`,danger:!0})&&await gp(e).catch(px)},hx=(0,l.memo)(function({thread:e,project:t,machineName:n,current:r,showProject:i}){let a=!!e.archivedAt,o=a?f:p,s=a?`Unarchive ${e.title}`:`Archive ${e.title}`,[c,u]=(0,l.useState)(!1),d=c?(0,Q.jsx)($b,{thread:e,onDone:()=>u(!1),onError:px}):void 0;return(0,Q.jsxs)(Ob,{children:[(0,Q.jsxs)(Ab,{className:`thread-item`,"data-flip-id":e.id,onDoubleClick:e=>{e.preventDefault(),u(!0)},children:[(0,Q.jsx)(gx,{thread:e,project:t,machineName:n,current:r,showProject:i,editor:d}),(0,Q.jsx)(Zl,{label:a?`Unarchive`:`Archive`,children:(0,Q.jsx)(`button`,{type:`button`,className:`thread-archive`,"aria-label":s,onClick:()=>void sp(e,!a).catch(px),children:(0,Q.jsx)(o,{size:15,strokeWidth:1.8,"aria-hidden":`true`})})})]}),(0,Q.jsx)(ab,{children:(0,Q.jsx)(jb,{className:`thread-menu-positioner`,children:(0,Q.jsx)(nb,{className:`thread-menu`,children:(0,Q.jsxs)($y,{className:`thread-menu-item is-danger`,onClick:()=>void mx(e),children:[(0,Q.jsx)(de,{size:14,"aria-hidden":`true`}),`Delete permanently`]})})})})]})});function gx({thread:e,project:t,machineName:n,current:r,showProject:i,editor:a}){let o=Rb(e),s=zb(e),c=s?fe:o?void 0:fx[e.status],l=s||e.status===`blocked`||e.status===`done`,u=o?Bb(e):s?`Launch stopped`:dx[e.status],d=o||s?u:i?t?.name:Nb(e.agent),f=a?`div`:`a`;return(0,Q.jsx)(Zl,{label:`${e.title} · ${t?.name??``} · ${n} · ${Nb(e.agent)} · ${e.model} · ${u}`,side:`right`,children:(0,Q.jsxs)(f,{className:`thread-row ${r?`is-current`:``} ${l?`needs-attention status-${s?`blocked`:e.status}`:``}`,href:a?void 0:`/threads/${encodeURIComponent(e.id)}`,"aria-current":r?`page`:void 0,"aria-label":`${e.title} · ${t?.name??``} · ${n} · ${u}`,children:[(0,Q.jsxs)(`span`,{className:`thread-avatar`,"aria-hidden":`true`,children:[(0,Q.jsx)(Yf,{thread:e,working:e.status===`working`||o,size:24}),c&&(0,Q.jsx)(c,{className:`thread-status status-${s?`blocked`:e.status}`,size:14,strokeWidth:2.2}),(0,Q.jsx)(`span`,{className:`thread-avatar-harness`,children:(0,Q.jsx)(Sg,{harness:e.agent,size:14})})]}),(0,Q.jsxs)(`span`,{className:`thread-copy`,children:[(0,Q.jsxs)(`span`,{className:`thread-context`,children:[i&&t&&!o&&!s&&(0,Q.jsx)(Eg,{project:t}),e.worktree&&!o&&!s&&(0,Q.jsx)(P,{className:`thread-worktree`,size:11,"aria-label":`Worktree`}),d]}),a??(0,Q.jsx)(`span`,{className:`thread-name`,children:e.title})]}),(0,Q.jsx)(`span`,{className:`thread-time`,children:Pb(e.updatedAt)})]})})}function _x({project:e,closed:t,onToggle:n}){let[r,i]=(0,l.useState)(!1),[o,s]=(0,l.useState)(!1),c=r?`div`:`button`,u=r?(0,Q.jsx)(ex,{project:e,onDone:()=>i(!1),onError:px}):(0,Q.jsx)(`span`,{className:`group-name`,children:e.name});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Ob,{children:[(0,Q.jsx)(Ab,{className:`group-header`,children:(0,Q.jsxs)(c,{className:`group-title`,onClick:r?void 0:n,"aria-expanded":r?void 0:!t,children:[(0,Q.jsx)(`span`,{className:`group-chevron`,"aria-hidden":`true`,children:t?(0,Q.jsx)(x,{size:14}):(0,Q.jsx)(b,{size:14})}),(0,Q.jsx)(Eg,{project:e}),u]})}),(0,Q.jsx)(ab,{children:(0,Q.jsx)(jb,{className:`thread-menu-positioner`,children:(0,Q.jsxs)(nb,{className:`thread-menu`,children:[(0,Q.jsxs)($y,{className:`thread-menu-item`,onClick:()=>void a(`/new?project=${encodeURIComponent(e.id)}`),children:[(0,Q.jsx)(re,{size:14,"aria-hidden":`true`}),`New thread`]}),(0,Q.jsxs)($y,{className:`thread-menu-item`,onClick:()=>i(!0),children:[(0,Q.jsx)(U,{size:14,"aria-hidden":`true`}),`Rename project`]}),(0,Q.jsxs)($y,{className:`thread-menu-item`,onClick:()=>s(!0),children:[(0,Q.jsx)(I,{size:14,"aria-hidden":`true`}),`Change icon`]}),(0,Q.jsx)(`div`,{className:`thread-menu-path`,title:e.path,children:ux(e.path)})]})})})]}),(0,Q.jsx)(rx,{project:e,open:o,onClose:()=>s(!1),onError:px})]})}function vx({threads:e,renderThread:t}){let[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1),o=async()=>{if(await sl(yp(e),{confirmLabel:`Delete all`,danger:!0})){a(!0);try{let e=await _p();e.failed.length&&await cl(`${e.failed.length} archived ${e.failed.length===1?`thread`:`threads`} could not be deleted.`)}catch(e){px(e)}finally{a(!1)}}};return(0,Q.jsxs)(`section`,{className:`thread-group archived-threads`,"aria-label":`Archived threads`,children:[(0,Q.jsxs)(`div`,{className:`group-header`,children:[(0,Q.jsxs)(`button`,{className:`group-title`,onClick:()=>r(e=>!e),"aria-expanded":n,children:[(0,Q.jsx)(`span`,{className:`group-chevron`,"aria-hidden":`true`,children:n?(0,Q.jsx)(b,{size:14}):(0,Q.jsx)(x,{size:14})}),(0,Q.jsx)(p,{size:14,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`group-name`,children:`Archived`}),(0,Q.jsx)(`span`,{className:`group-count`,children:e.length})]}),(0,Q.jsx)(`button`,{type:`button`,className:`archived-delete-all`,onClick:()=>void o(),disabled:i,children:i?`Deleting…`:`Delete all`})]}),n&&e.map(t)]})}function yx({projects:e,threads:t,archived:n=[],machines:r,currentId:i,mode:a,onModeChange:o,collapsed:s,mobileOpen:c,onCollapse:u,onCloseMobile:d,onOpenPalette:f,updateAction:p}){let[m,h]=(0,l.useState)([]),g=t.find(e=>e.id===i)?.projectId,_=cx(e,g),v=(0,l.useRef)(null);sx(v);let y=(t,n)=>{let a=e.find(e=>e.id===t.projectId);return(0,Q.jsx)(hx,{thread:t,project:a,machineName:r.find(e=>e.id===t.machineId)?.name??t.machineId,current:i===t.id,showProject:n},t.id)};return(0,Q.jsxs)(Q.Fragment,{children:[c&&(0,Q.jsx)(`button`,{className:`sidebar-scrim`,"aria-label":`Close sidebar`,onClick:d}),(0,Q.jsxs)(`aside`,{className:`sidebar ${s?`is-collapsed`:``} ${c?`is-mobile-open`:``}`,"aria-label":`Threads`,onClick:e=>{c&&e.target.closest(`a[href]`)&&d()},children:[(0,Q.jsxs)(`div`,{className:`sidebar-header`,children:[!s&&(0,Q.jsxs)(`span`,{className:`brand`,children:[(0,Q.jsx)(`img`,{src:`/brand-mark.png`,alt:``,width:20,height:20}),`webr`]}),(0,Q.jsx)(`button`,{className:`icon-button sidebar-collapse`,"aria-label":s?`Expand sidebar`:`Collapse sidebar`,onClick:u,children:s?(0,Q.jsx)(ne,{size:16}):(0,Q.jsx)(te,{size:16})}),(0,Q.jsx)(`button`,{className:`icon-button mobile-close`,"aria-label":`Close sidebar`,onClick:d,children:(0,Q.jsx)(pe,{size:16})})]}),(0,Q.jsxs)(`div`,{className:`sidebar-actions`,children:[(0,Q.jsx)(Zl,{label:`New thread`,children:(0,Q.jsxs)(`a`,{className:`sidebar-new-thread`,href:`/new${g?`?project=${encodeURIComponent(g)}`:``}`,"aria-label":`New thread`,children:[(0,Q.jsx)(se,{size:16,"aria-hidden":`true`}),!s&&(0,Q.jsx)(`span`,{children:`New thread`})]})}),(0,Q.jsx)(Qb,{projects:e}),!s&&(0,Q.jsxs)(`div`,{className:`sidebar-view-switch`,role:`group`,"aria-label":`Sidebar layout`,children:[(0,Q.jsx)(Zl,{label:`Show threads`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Show threads`,"aria-pressed":a===`threads`,onClick:()=>o(`threads`),children:(0,Q.jsx)(L,{size:16,"aria-hidden":`true`})})}),(0,Q.jsx)(Zl,{label:`Group by project`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Group by project`,"aria-pressed":a===`projects`,onClick:()=>o(`projects`),children:(0,Q.jsx)(M,{size:16,"aria-hidden":`true`})})})]})]}),!s&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`nav`,{ref:v,className:`thread-navigation`,"aria-label":`Agent threads`,children:[a===`projects`?_.filter(e=>t.some(t=>e.locations.includes(t.projectId))).sort((e,n)=>(t.find(e=>n.locations.includes(e.projectId))?.updatedAt??``).localeCompare(t.find(t=>e.locations.includes(t.projectId))?.updatedAt??``)).map(({id:e,project:n,locations:r})=>(0,Q.jsxs)(`section`,{className:`thread-group`,children:[(0,Q.jsx)(_x,{project:n,closed:m.includes(e),onToggle:()=>h(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])}),!m.includes(e)&&t.filter(e=>r.includes(e.projectId)).map(e=>y(e,!1))]},e)):t.map(e=>y(e,!0)),!t.length&&!n.length&&(0,Q.jsx)(`p`,{className:`sidebar-empty`,children:`No agents yet. Press ⌘K to start one.`})]}),!!n.length&&(0,Q.jsx)(vx,{threads:n,renderThread:e=>y(e,!0)}),(0,Q.jsxs)(`div`,{className:`sidebar-footer`,children:[(0,Q.jsxs)(`a`,{className:`sidebar-settings`,href:`/settings`,children:[(0,Q.jsx)(oe,{size:15}),` Settings`]}),p,(0,Q.jsx)(Zl,{label:`Open command palette`,children:(0,Q.jsx)(`button`,{type:`button`,className:`sidebar-palette`,"aria-label":`Open command palette`,onClick:f,children:(0,Q.jsx)(`kbd`,{children:`⌘K`})})})]})]})]})]})}function bx(){let{status:e,updating:t,requestUpdate:n}=Vy();return!e||!(e.available||t)?null:(0,Q.jsx)(Zl,{label:`Webr ${e.latest} is available`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`sidebar-update`,disabled:t,onClick:()=>void n(),children:[(0,Q.jsx)(C,{size:14,"aria-hidden":`true`}),t?`Updating…`:`Update`]})})}var xx=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},Sx=(e=>e?xx(e):xx),Cx=e=>e;function wx(e,t=Cx){let n=l.useSyncExternalStore(e.subscribe,l.useCallback(()=>t(e.getState()),[e,t]),l.useCallback(()=>t(e.getInitialState()),[e,t]));return l.useDebugValue(n),n}var Tx=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Ex=(e,t)=>e&&Tx(e,t)?e:t;function Dx(e){let t=new Map,n=new Set,r=Sx((e,r)=>({projections:{},threads:{},projects:{},threadIds:[],projectIds:[],connected:!1,connection:t=>e(e=>{if(t)return{connected:t};for(let t of Object.keys(e.projections))n.add(t);return{connected:t,projections:Object.fromEntries(Object.entries(e.projections).map(([e,t])=>[e,{...t,connected:!1,freshAt:null}])),threads:Object.fromEntries(Object.entries(e.threads).map(([e,t])=>[e,{...t,status:`unknown`,bindingState:`detached`}]))}}),install:i=>{let a=r(),o=a.projections[i.machineId],s=t.get(i.machineId)??new Set;if(s.has(i.generation)||!n.has(i.machineId)&&o?.generation===i.generation&&o.revision>=i.revision)return;n.delete(i.machineId),o&&o.generation!==i.generation&&s.add(o.generation),s.size>8&&s.delete(s.values().next().value),t.set(i.machineId,s);let c=Object.fromEntries(Object.entries(a.threads).filter(([,e])=>e.machineId!==i.machineId));for(let e of i.threads)c[e.id]=Ex(a.threads[e.id],{...e,panes:e.panes.map(t=>Ex(a.threads[e.id]?.panes.find(e=>e.id===t.id&&e.terminalId===t.terminalId),t))});let l={...a.projections,[i.machineId]:i},u={};for(let e of Object.values(l))for(let t of e.projects)u[t.id]=Ex(a.projects[t.id],t);let d=Object.values(c).sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)).map(e=>e.id),f=Object.keys(u);e({projections:l,threads:c,projects:u,threadIds:Ex(a.threadIds,d),projectIds:Ex(a.projectIds,f)})}}));for(let t of e.projections)r.getState().install(t);return r}var Ox=()=>Sx(e=>({focusedPanes:{},paneWindows:{},focus:(t,n)=>e(e=>({focusedPanes:{...e.focusedPanes,[t]:n}})),showWindow:(t,n)=>e(e=>({paneWindows:{...e.paneWindows,[t]:n}}))}));function kx(e){if(e.length<32)throw Error(`short_frame`);let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=Number(t.getBigUint64(12));if(t.getUint32(0)!==1212437041||t.getUint32(24)!==e.length-32||e.length-32>262144||!Number.isSafeInteger(n)||t.getUint8(28)>1||t.getUint8(29)||t.getUint16(30))throw Error(`invalid_frame`);let r={streamId:t.getUint32(4),generation:t.getUint32(8),seq:n,width:t.getUint16(20),height:t.getUint16(22),full:!!t.getUint8(28),bytes:e.subarray(32)};if(!r.streamId||!r.generation||!r.width||r.width>500||!r.height||r.height>300)throw Error(`invalid_dimensions`);return r}var Ax=class{seq;accept(e){if(this.seq===void 0&&!e.full)throw Error(`baseline_required`);if(this.seq!==void 0&&e.seq!==this.seq+1)throw Error(`sequence_gap`);this.seq=e.seq}},jx=class{terminal;acknowledge;budget;frames=[];bytes=0;writing=!1;closed=!1;constructor(e,t,n=524288){this.terminal=e,this.acknowledge=t,this.budget=n}push(e){if(!this.closed){if(this.bytes+e.bytes.length>this.budget)throw Error(`renderer_overload`);this.bytes+=e.bytes.length,this.frames.push(e),this.frames.length,this.bytes/1024,this.flush()}}close(){this.closed=!0,this.frames=[],this.bytes=0}flush(){if(this.closed||this.writing||!this.frames.length)return;this.writing=!0;let e=this.frames.shift();this.terminal.resize(e.width,e.height);let t=e.full?new Uint8Array(e.bytes.length+2):e.bytes;e.full&&(t.set([27,99]),t.set(e.bytes,2));let n=Tp();this.terminal.write(t,()=>{this.closed||(Tp()-n,this.bytes-=e.bytes.length,this.writing=!1,this.acknowledge(e),this.flush())})}},Mx=(e,t=Math.random)=>Math.min(3e4,Math.round(Math.min(25e3,1e3*2**Math.min(e,5))*(.8+t()*.4))),Nx=`Another controller owns this terminal.`,Px=class{install;onConnection;metadata;binary;stopped=!0;epoch=0;nextId=1;panes=new Map;reconnect;instance=``;failures=0;connectedAt=0;scrollSentAt=new Map;inputSentAt=new Map;openedAt=new Map;constructor(e,t){this.install=e,this.onConnection=t}start(){this.stopped=!1,this.connect()}stop(){this.stopped=!0,clearTimeout(this.reconnect),this.disconnect()}mount(e){let t=this.nextId++;return this.panes.set(t,{...e,generation:1,sequence:new Ax,writable:!1,accepted:!1,baseline:!1,pending:0,resizing:!1,attempts:0}),this.open(t),{close:()=>{let e=this.panes.get(t);e&&(this.send({type:`release`,streamId:t,generation:e.generation}),e.renderer?.close()),this.panes.delete(t)},input:(e,n=!1)=>{let r=this.panes.get(t);r?.writable&&(this.inputSentAt.set(t,Tp()),this.send({type:`input`,streamId:t,generation:r.generation,text:e,paste:n}))},control:(e=!1)=>{let n=this.panes.get(t);n&&(n.mode!==`control`||e)&&(this.send({type:`release`,streamId:t,generation:n.generation}),n.reason=void 0,n.mode=`control`,++n.generation,n.sequence=new Ax,this.open(t,e))},observe:()=>{let e=this.panes.get(t);e&&e.mode!==`observe`&&(this.send({type:`release`,streamId:t,generation:e.generation}),e.mode=`observe`,++e.generation,e.sequence=new Ax,this.open(t))},resize:(e,n,r=!1)=>{let i=this.panes.get(t);i&&(e!==i.cols||n!==i.rows||r&&i.mode===`control`&&i.accepted)&&(i.cols=e,i.rows=n,i.mode===`control`&&i.accepted?(i.writable=!1,i.baseline=!1,i.resizing=!0,i.onState(`Waiting for the resized full baseline.`,!1),this.send({type:`resize`,streamId:t,generation:i.generation,cols:e,rows:n})):(this.send({type:`release`,streamId:t,generation:i.generation}),++i.generation,i.sequence=new Ax,this.open(t)))},scroll:(e,n,r,i)=>{let a=this.panes.get(t);a?.writable&&(this.scrollSentAt.set(t,Tp()),this.send({type:`scroll`,streamId:t,generation:a.generation,direction:e,lines:n,column:r,row:i}))},mouse:(e,n,r,i,a)=>{let o=this.panes.get(t);o?.writable&&this.send({type:`mouse`,streamId:t,generation:o.generation,action:e,button:n,column:r,row:i,modifiers:a})}}}command(e,t,n,r){let i=[...this.panes.entries()].find(([,r])=>r.machineId===e&&r.threadId===t&&r.terminalId===n);if(!i)return;let[a,o]=i;o.writable=!1,o.reason=void 0,this.send({type:`release`,streamId:a,generation:o.generation}),o.mode=r===`release`?`observe`:`control`,++o.generation,o.sequence=new Ax,this.open(a,r===`takeover`)}send(e){return this.binary?.readyState!==WebSocket.OPEN||this.metadata?.readyState!==WebSocket.OPEN?!1:this.binary.bufferedAmount>32768?(this.disconnect(),!1):(this.binary.send(JSON.stringify(e)),!0)}open(e,t=!1){let n=this.panes.get(e);n&&(n.writable=!1,n.accepted=!1,n.baseline=!1,n.pending=0,n.resizing=!1,n.renderer?.close(),n.renderer=new jx(n.terminal,t=>{if(this.panes.get(e)!==n||n.generation!==t.generation||!this.send({type:`ack`,streamId:e,generation:t.generation,seq:t.seq}))return;if(--n.pending,t.full&&(!n.resizing||t.width===n.cols&&t.height===n.rows)){n.baseline=!0,n.resizing=!1;let t=this.openedAt.get(e);t!==void 0&&(Tp()-t,this.openedAt.delete(e))}let r=n.mode===`control`&&n.accepted&&n.baseline;n.writable=r,t.full&&n.onState(r?`Input control is active.`:n.reason??`Read-only`,r)}),n.onState(n.mode===`control`?`Waiting for terminal control.`:n.reason??`Read-only`,!1),this.openedAt.set(e,Tp()),this.send({type:`open`,streamId:e,generation:n.generation,machineId:n.machineId,threadId:n.threadId,terminalId:n.terminalId,mode:n.mode,cols:n.cols,rows:n.rows,takeover:t}))}connect(){if(this.stopped)return;this.instance=dm();let e=++this.epoch,t=(location.protocol===`https:`?`wss://`:`ws://`)+location.host,n=new WebSocket(t+`/api/ws/metadata?instance=`+this.instance),r=new WebSocket(t+`/api/ws/terminal?instance=`+this.instance);this.metadata=n,this.binary=r,r.binaryType=`arraybuffer`;let i=()=>{if(e===this.epoch&&n.readyState===1&&r.readyState===1){this.connectedAt=Date.now(),this.onConnection(!0);for(let[e,t]of this.panes)++t.generation,t.sequence=new Ax,t.attempts=0,this.open(e)}};n.onopen=i,r.onopen=i,n.onmessage=t=>{if(e===this.epoch)try{let e=JSON.parse(t.data);e.type===`projection`&&this.install(e.projection)}catch{this.disconnect()}},r.onmessage=t=>{if(e===this.epoch)try{if(typeof t.data==`string`){let e=JSON.parse(t.data),n=this.panes.get(e.streamId);if(!n||n.generation!==e.generation)return;if(e.type===`stream.opened`&&(n.accepted=!!e.writable&&n.mode===`control`,n.accepted&&(n.baseline=!1,n.resizing=!0,this.send({type:`resize`,streamId:e.streamId,generation:e.generation,cols:n.cols,rows:n.rows})),n.writable=n.accepted&&n.baseline,n.onState(n.writable?`Input control is active.`:n.reason??(n.accepted?`Waiting for the full baseline; input is disabled.`:`Read-only`),n.writable)),e.type===`stream.closed`||e.type===`stream.error`){if(n.writable=!1,n.accepted=!1,n.baseline=!1,n.renderer?.close(),n.onState(e.reason===`controller_conflict`?Nx:String(e.reason).replaceAll(`_`,` `),!1),e.type===`stream.error`&&n.mode===`control`){n.reason=e.reason===`controller_conflict`?Nx:String(e.reason).replaceAll(`_`,` `),n.mode=`observe`,++n.generation,n.sequence=new Ax,this.open(e.streamId);return}e.reason===`stream_resync_required`&&n.attempts++<2&&(++n.generation,n.sequence=new Ax,n.mode=`observe`,this.open(e.streamId))}return}let e=Tp(),n=kx(new Uint8Array(t.data));t.data.byteLength,Tp()-e;let r=this.inputSentAt.get(n.streamId);r!==void 0&&(Tp()-r,this.inputSentAt.delete(n.streamId));let i=this.scrollSentAt.get(n.streamId);i!==void 0&&(Tp()-i,this.scrollSentAt.delete(n.streamId));let a=this.panes.get(n.streamId);if(!a||a.generation!==n.generation)return;a.sequence.accept(n),++a.pending,a.pending,a.renderer?.push(n)}catch{this.disconnect()}};let a=()=>{e===this.epoch&&this.disconnect()};n.onclose=a,n.onerror=a,r.onclose=a,r.onerror=a}disconnect(){this.connectedAt&&Date.now()-this.connectedAt>=3e4&&(this.failures=0),this.connectedAt=0,++this.epoch,this.metadata?.close(),this.binary?.close(),this.metadata=void 0,this.binary=void 0,this.onConnection(!1);for(let e of this.panes.values())e.renderer?.close(),e.writable=!1,e.mode=`observe`,e.onState(`Disconnected; input was not saved.`,!1);clearTimeout(this.reconnect),this.stopped||(this.reconnect=setTimeout(()=>this.connect(),Mx(this.failures++)))}},Fx=(0,l.createContext)(null);function Ix({bootstrap:e,children:t}){let[n]=(0,l.useState)(()=>{let t=Dx(e);return{runtime:t,ui:Ox(),terminals:new Px(e=>{let n=wp(`projectionInstallMs`);t.getState().install(e),n()},e=>t.getState().connection(e))}}),[r]=(0,l.useState)(()=>new R_({defaultOptions:{queries:{staleTime:15e3,retry:!1}}}));return(0,l.useEffect)(()=>(n.terminals.start(),()=>n.terminals.stop()),[n]),(0,Q.jsx)(Fx.Provider,{value:n,children:(0,Q.jsx)(Mg,{client:r,children:t})})}function Lx(){let e=(0,l.useContext)(Fx);if(!e)throw Error(`Runtime provider is missing`);return e}function Rx(e){return wx(Lx().runtime,e)}var zx={Enter:`\r`,Backspace:``,Tab:` `,Escape:`\x1B`,ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`};function Bx(e){let t=e.ctrlKey&&/^[a-z]$/i.test(e.key)?String.fromCharCode(e.key.toUpperCase().charCodeAt(0)-64):zx[e.key],n=e.key===`Enter`&&e.shiftKey;return t&&(e.altKey||n?`\x1B`+t:t)}var Vx=e=>/^[a-z@\[\\\]^_]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)&31):void 0;function Hx({onInput:e,onFocusChange:t}){let[n,r]=(0,l.useState)(``),i=(0,l.useRef)(!1),a=(0,l.useRef)(null);return(0,Q.jsx)(`textarea`,{className:`terminal-input-capture`,value:n,"aria-label":`Terminal input`,rows:1,onFocus:()=>t?.(!0),onBlur:()=>t?.(!1),onCompositionStart:()=>{i.current=!0,a.current=null},onCompositionEnd:t=>{i.current=!1;let n=t.data;a.current=n,n&&e(n),r(``),t.currentTarget.value=``},onChange:t=>{if(i.current){r(t.target.value);return}let n=t.target.value;n&&n!==a.current&&e(n),a.current=null,r(``),t.currentTarget.value=``},onPaste:t=>{t.preventDefault(),a.current=null;let n=t.clipboardData.getData(`text/plain`);n&&e(n,!0)},onKeyDown:t=>{if(t.defaultPrevented||t.nativeEvent.isComposing||i.current||t.metaKey)return;a.current=null;let n=Bx(t);n&&(t.preventDefault(),e(n))}})}var Ux=[{label:`Tab`,key:`Tab`},{label:(0,Q.jsx)(h,{size:16}),key:`ArrowLeft`,name:`Left`},{label:(0,Q.jsx)(m,{size:16}),key:`ArrowDown`,name:`Down`},{label:(0,Q.jsx)(_,{size:16}),key:`ArrowUp`,name:`Up`},{label:(0,Q.jsx)(g,{size:16}),key:`ArrowRight`,name:`Right`}],Wx=e=>e.preventDefault(),Gx=e=>({onPointerDown:t=>{Wx(t),e()},onMouseDown:Wx,onTouchStart:Wx,onClick:t=>{t.detail===0&&e()}}),Kx={idle:`Dictate`,preparing:`Preparing voice input`,recording:`Stop dictation`,transcribing:`Transcribing`},qx=e=>e===`recording`?(0,Q.jsx)(le,{size:14,fill:`currentColor`}):e===`idle`?(0,Q.jsx)(B,{size:16}):(0,Q.jsx)(R,{size:16,className:`is-spinning`});function Jx({voice:e}){return(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":Kx[e.phase],"aria-pressed":e.phase===`recording`,className:`terminal-voice is-${e.phase}`,...Gx(e.toggle),children:qx(e.phase)})}function Yx({ctrl:e,onToggleCtrl:t,onBytes:n,voice:r}){return(0,Q.jsxs)(`div`,{className:`terminal-key-bar`,role:`toolbar`,"aria-label":`Terminal keys`,children:[(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-pressed":e,className:e?`is-armed`:``,...Gx(t),children:`Ctrl`}),Ux.map(({label:e,key:t,name:r})=>(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":r??t,...Gx(()=>{let e=Bx({key:t,ctrlKey:!1,altKey:!1});e&&n(e)}),children:e},t)),r?.available&&(0,Q.jsx)(Jx,{voice:r})]})}var Xx=`(pointer: coarse)`,Zx=120,Qx=350;function $x(){let e=window.visualViewport;if(!e||!matchMedia(Xx).matches)return()=>{};let t=document.documentElement,n=e.height,r=()=>{t.style.setProperty(`--app-height`,`${e.height}px`),t.style.setProperty(`--app-top`,`${e.offsetTop}px`)},i=()=>{t.style.removeProperty(`--app-height`),t.style.removeProperty(`--app-top`)},a=()=>{n=Math.max(n,e.height,window.innerHeight);let a=n-e.height>Zx;a?r():i(),t.toggleAttribute(`data-keyboard-open`,a)};a();let o,s=()=>{clearTimeout(o),o=setTimeout(a,Qx)},c=()=>{n=0,a()};return e.addEventListener(`resize`,a),e.addEventListener(`scroll`,a),window.addEventListener(`orientationchange`,c),window.addEventListener(`focusout`,s),window.addEventListener(`focusin`,s),()=>{clearTimeout(o),window.removeEventListener(`focusout`,s),window.removeEventListener(`focusin`,s),window.removeEventListener(`orientationchange`,c),e.removeEventListener(`resize`,a),e.removeEventListener(`scroll`,a),i(),t.removeAttribute(`data-keyboard-open`)}}function eS(){return typeof matchMedia==`function`&&matchMedia(Xx).matches}var tS=100,nS=20,rS=10,iS=e=>rS*(1+Math.min(2,Math.abs(e)/60));function aS(e,t,n,r){let i=e=>{if(!r()||!e.altKey||e.shiftKey)return;let{element:i,cols:a,rows:o}=t(),s=i?.getBoundingClientRect();if(!s?.width||!s.height)return;let c=Math.floor((e.clientX-s.left)/s.width*a),l=Math.floor((e.clientY-s.top)/s.height*o);if(c<0||l<0||c>=a||l>=o)return;e.preventDefault();let u=e.button===2||e.buttons&2?`right`:e.button===1||e.buttons&4?`middle`:`left`;n()?.mouse(e.type===`pointerdown`?`down`:e.type===`pointerup`?`up`:e.buttons?`drag`:`move`,u,c,l,e.ctrlKey?2:0)},a=0,o=0,s,c=e=>{let{element:n,cols:r,rows:i}=t(),a=n?.getBoundingClientRect();if(a?.width&&a.height)return{column:Math.min(r,Math.max(1,Math.floor((e.clientX-a.left)/a.width*r)+1)),row:Math.min(i,Math.max(1,Math.floor((e.clientY-a.top)/a.height*i)+1))}},l=()=>{let{element:e,rows:n}=t(),r=e?.getBoundingClientRect().height;return r&&n?r/n:nS},u=()=>{o=0;let e=l(),t=Math.trunc(a/e);t&&(a-=t*e,n()?.scroll(t<0?`up`:`down`,Math.min(tS,Math.abs(t)),s?.column,s?.row))},d=e=>{if(!r()||!e.deltaY)return;s=c(e),e.preventDefault();let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*l():e.deltaY;t*a<0&&(a=0),a+=t*iS(t),o||=requestAnimationFrame(u)};for(let t of[`pointerdown`,`pointerup`,`pointermove`])e.addEventListener(t,i);return e.addEventListener(`wheel`,d,{passive:!1}),()=>{for(let t of[`pointerdown`,`pointerup`,`pointermove`])e.removeEventListener(t,i);e.removeEventListener(`wheel`,d),cancelAnimationFrame(o)}}var oS=e=>e.target instanceof Element&&!!e.target.closest(`[role="dialog"]`),sS=`Nothing to attach.`,cS=e=>e===1?`Attaching file…`:`Attaching ${e} files…`,lS=e=>e===1?`File attached`:`${e} files attached`;function uS({machineId:e,active:t,writable:n,send:r,show:i}){let[a,o]=(0,l.useState)(!1),s=(0,l.useRef)(r);s.current=r;let c=(0,l.useCallback)(async t=>{if(!t.length){i(sS,`error`,4e3);return}if(!n.current){i(`Wait until the terminal accepts input, then attach the file again.`,`error`,4e3);return}i(cS(t.length),`info`);try{s.current(await lm(e,t)),i(lS(t.length),`info`,1500)}catch(e){i(e instanceof Error?e.message:`The file could not be attached.`,`error`,5e3)}},[e,i,n]);return(0,l.useEffect)(()=>{if(!t)return;let e=0,n=t=>{nm(t.dataTransfer)&&!oS(t)&&(t.preventDefault(),e+=1,o(!0))},r=e=>{nm(e.dataTransfer)&&!oS(e)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`))},i=t=>{nm(t.dataTransfer)&&!oS(t)&&(e=Math.max(0,e-1),e||o(!1))},a=t=>{nm(t.dataTransfer)&&!oS(t)&&(t.preventDefault(),e=0,o(!1),c(tm(t.dataTransfer)))};return window.addEventListener(`dragenter`,n),window.addEventListener(`dragover`,r),window.addEventListener(`dragleave`,i),window.addEventListener(`drop`,a),()=>{window.removeEventListener(`dragenter`,n),window.removeEventListener(`dragover`,r),window.removeEventListener(`dragleave`,i),window.removeEventListener(`drop`,a),o(!1)}},[t,c]),{dragging:a,attach:c}}var dS=/https?:\/\/[^\s"'<>`]+/g,fS=/[.,;:!?)\]}]+$/,pS=e=>e.metaKey||e.ctrlKey;function mS(e,t){let n=e.buffer.active,r=t;for(;r>0&&n.getLine(r)?.isWrapped;)r--;let i=``,a=r;for(let t=r;n.getLine(t)&&(t===r||n.getLine(t).isWrapped);t++)i+=n.getLine(t).translateToString(!1,0,e.cols),a=t;return{text:i,offset:(t-r)*e.cols,last:a}}function hS(e,t,n){let{text:r,offset:i}=mS(e,n),a=i+t;for(let e of r.matchAll(dS)){let t=e[0].replace(fS,``);if(a>=e.index&&a<e.index+t.length)return t}}var gS=/^https?:\/\/[^\s"'<>`]+$/,_S=/https?:\/\//,vS=e=>e.trim().split(/\s+/)[0]??``;function yS(e){let t=e.getSelectionPosition();if(!t)return;let n=e.buffer.active,r=t=>n.getLine(t)?.translateToString(!1,0,e.cols)??``,i=r(t.start.y).slice(t.start.x,t.start.y===t.end.y?t.end.x:void 0).search(_S);if(i<0)return;let a=t.start.x+i,o=[];for(let e=t.start.y;e<=t.end.y;e++){let i=e>t.start.y&&n.getLine(e)?.isWrapped?0:a,s=vS(r(e).slice(i,e===t.end.y?t.end.x:void 0));if(!s)break;o.push(s)}let s=o.join(``).replace(fS,``);return gS.test(s)?s:void 0}var bS=e=>{window.open(e,`_blank`,`noopener,noreferrer`)};function xS(e,t){let n=(e.element?.querySelector(`.xterm-screen`))?.getBoundingClientRect();if(!pS(t)||!n?.width||!n.height)return;let r=hS(e,Math.floor((t.clientX-n.left)/n.width*e.cols),Math.floor((t.clientY-n.top)/n.height*e.rows)+e.buffer.active.viewportY);r&&bS(r)}var SS=e=>{e.preventDefault(),e.stopPropagation()};function CS({selected:e,onDone:t,onCopied:n}){return(0,Q.jsxs)(`div`,{className:`terminal-url-actions`,role:`toolbar`,"aria-label":`Selected link`,style:{left:e.x,top:e.y},onMouseDown:SS,onPointerDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{bS(e.url),t()},children:[(0,Q.jsx)(A,{size:14,strokeWidth:1.8}),`Open link`]}),(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>{jv(e.url).then(n),t()},children:[(0,Q.jsx)(O,{size:14,strokeWidth:1.8}),`Copy link`]})]})}function wS(){let[e,t]=(0,l.useState)(null),n=(0,l.useRef)(void 0),r=(0,l.useCallback)((e,r,i)=>{clearTimeout(n.current),t({text:e,tone:r}),i&&(n.current=setTimeout(()=>t(null),i))},[]);return(0,l.useEffect)(()=>()=>clearTimeout(n.current),[]),{notice:e,show:r}}var TS=16e3,ES=`registerProcessor('webr-capture', class extends AudioWorkletProcessor {
|
|
3
3
|
process([input]) { if (input?.[0]) this.port.postMessage(input[0].slice()); return true; }
|
|
4
4
|
});`,DS=()=>typeof window<`u`&&window.isSecureContext&&!!navigator.mediaDevices?.getUserMedia&&typeof AudioWorkletNode<`u`,OS=()=>{try{return new AudioContext({sampleRate:TS})}catch{return new AudioContext}};function kS(e){let t=new Int16Array(e.reduce((e,t)=>e+t.length,0)),n=0;for(let r of e)for(let e of r)t[n++]=Math.max(-1,Math.min(1,e))*32767;return t.buffer}async function AS(e){let t=URL.createObjectURL(new Blob([ES],{type:`text/javascript`}));try{await e.audioWorklet.addModule(t)}finally{URL.revokeObjectURL(t)}}async function jS(){let e=OS();e.resume();let t=t=>{t?.getTracks().forEach(e=>e.stop()),e.close()},n;try{n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),await AS(e),await e.resume()}catch(e){throw t(n),e}let r=[],i=e.createMediaStreamSource(n),a=new AudioWorkletNode(e,`webr-capture`);a.port.onmessage=e=>r.push(e.data),i.connect(a);let o=()=>{i.disconnect(),a.disconnect(),t(n)};return{stop:async()=>{let t=e.sampleRate;return o(),{pcm:kS(r),sampleRate:t}},cancel:o}}var MS={voice_unavailable:`Voice input is not available on this Webr server.`,image_too_large:`The recording is too long.`};async function NS(){let e=await fetch(`/api/voice`).catch(()=>void 0);return e?.ok?(await e.json()).state:`unavailable`}async function PS(){let e=await fetch(`/api/voice/warm`,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`}).catch(()=>void 0);return e?.ok?(await e.json()).state:`unavailable`}async function FS(e,t){let n=await fetch(`/api/voice/transcribe?sampleRate=${t}`,{method:`POST`,headers:{"Content-Type":`audio/l16`},body:e}),r=await n.json().catch(()=>({}));if(!n.ok||r.text===void 0)throw Error(MS[r.error??``]??`The recording could not be transcribed.`);return r.text}var IS=2e3,LS=`Downloading the voice model (670 MB, one time). The mic works when it finishes.`,RS=e=>e===`needs-download`||e===`downloading`,zS=e=>e instanceof DOMException&&e.name===`NotAllowedError`?`Allow microphone access for Webr in your browser settings.`:`The microphone could not start.`;function BS({send:e,show:t}){let[n,r]=(0,l.useState)(`unavailable`),[i,a]=(0,l.useState)(`idle`),o=(0,l.useRef)(void 0),s=(0,l.useRef)(e);s.current=e,(0,l.useEffect)(()=>{if(!DS())return;let e=!1;return NS().then(t=>{e||r(t)}),()=>{e=!0,o.current?.cancel()}},[]),(0,l.useEffect)(()=>{if(i!==`preparing`)return;let e=setInterval(()=>void NS().then(e=>{RS(e)||(r(e),a(`idle`),t(e===`ready`?`Voice input is ready. Tap the mic to talk.`:`The voice model could not be downloaded.`,e===`ready`?`info`:`error`,4e3))}),IS);return()=>clearInterval(e)},[i,t]);let c=(0,l.useCallback)(()=>{PS(),a(`preparing`),t(LS,`info`)},[t]),u=(0,l.useCallback)(async()=>{a(`recording`);let e=jS();PS();try{o.current=await e}catch(e){a(`idle`),t(zS(e),`error`,5e3)}},[t]),d=(0,l.useCallback)(async()=>{let e=o.current;if(o.current=void 0,e){a(`transcribing`);try{let{pcm:n,sampleRate:r}=await e.stop(),i=await FS(n,r);i?s.current(i):t(`No speech was heard.`,`info`,2500)}catch(e){t(e instanceof Error?e.message:`The recording could not be transcribed.`,`error`,5e3)}finally{a(`idle`)}}},[t]),f=(0,l.useCallback)(()=>{i===`idle`?RS(n)?c():u():i===`recording`&&d()},[i,n,c,u,d]);return{available:n!==`unavailable`,phase:i,toggle:f}}var VS=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),HS=function(e){return`/`+e},US={},WS=function(e){return e.pathname.endsWith(`.css`)},GS=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=HS(t,n);let r=s(t);if(r.href in US)return;US[r.href]=!0;let i=WS(r);if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let o=document.createElement(`link`);if(o.rel=i?`stylesheet`:VS,i||(o.as=`script`),o.crossOrigin=``,o.href=r.href,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),i)return new Promise((e,t)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>t(Error(`Unable to preload CSS for ${r}`)))})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function KS(){let e=getComputedStyle(document.documentElement);return{background:e.getPropertyValue(`--terminal-bg`).trim(),foreground:e.getPropertyValue(`--terminal-ink`).trim(),cursor:e.getPropertyValue(`--terminal-cursor`).trim(),selectionBackground:e.getPropertyValue(`--terminal-selection`).trim(),black:`#222222`,red:`#df7774`,green:`#8ebea1`,yellow:`#d4b581`,blue:`#81aee0`,magenta:`#ac9dd5`,cyan:`#8dc6cf`,white:`#d5d5d5`,brightBlack:`#777777`,brightRed:`#f18f89`,brightGreen:`#a1d8b6`,brightYellow:`#eed1a2`,brightBlue:`#a7c7ef`,brightMagenta:`#c6b6e8`,brightCyan:`#abdee4`,brightWhite:`#ffffff`}}var qS=`"JetBrains Mono", "Webr Symbols", ui-monospace, Menlo, monospace`,JS=15,YS=()=>typeof document>`u`||!document.fonts?Promise.resolve():Promise.all([document.fonts.load(`400 ${JS}px "JetBrains Mono"`),document.fonts.load(`700 ${JS}px "JetBrains Mono"`),document.fonts.load(`${JS}px "Webr Symbols"`,``)]).then(()=>void 0,()=>void 0),XS=`\x1B[I`,ZS=`\x1B[O`,QS=e=>e&&Number.isFinite(e.cols)&&Number.isFinite(e.rows)?e:void 0;function $S(e,t){try{let n=t();n.onContextLoss(()=>n.dispose()),e.loadAddon(n)}catch{}}function eC({pane:t,machineId:n,threadId:r,active:i,canControl:a,onFocus:o}){let s=(0,l.useRef)(null),c=(0,l.useRef)(null),u=(0,l.useRef)(null),d=(0,l.useRef)(null),{terminals:f}=Lx(),[p,m]=(0,l.useState)(`Connecting…`),[h,g]=(0,l.useState)(!1),_=(0,l.useRef)(!1),[v,y]=(0,l.useState)(!1),[b,x]=(0,l.useState)(!1),[S,C]=(0,l.useState)(!1),[w,T]=(0,l.useState)(null);(0,l.useEffect)(()=>C(eS()),[]);let{notice:E,show:D}=wS(),O=uS({machineId:n,active:i,writable:_,show:D,send:e=>{d.current?.input(e,!0)}}),k=BS({show:D,send:e=>{d.current?.input(e,!0)}}),A=(0,l.useRef)(e=>{});A.current=e=>e===`copied`?D(`Copied to clipboard`,`info`,1200):e===`waiting-for-click`?D(`Click or press a key to finish copying.`,`info`,6e3):D(`The browser blocked clipboard access.`,`error`,4e3),(0,l.useEffect)(()=>{if(!s.current)return;let i=!1,o=()=>{};return Promise.all([GS(()=>import(`./xterm.B-l5AIf6.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1])),GS(()=>import(`./addon-fit.jgKqzwky.js`).then(t=>e(t.default,1)),__vite__mapDeps([2,1])),GS(()=>import(`./addon-web-links.C9lyQRxI.js`).then(t=>e(t.default,1)),__vite__mapDeps([3,1])),GS(()=>import(`./addon-webgl.Bd5ox92E.js`).then(t=>e(t.default,1)),__vite__mapDeps([4,1])),YS()]).then(([e,{FitAddon:l},{WebLinksAddon:p},{WebglAddon:h}])=>{if(i||!s.current)return;let v=new e.Terminal({fontFamily:qS,fontSize:JS,lineHeight:1.2,letterSpacing:0,cursorBlink:!0,cursorInactiveStyle:`block`,allowTransparency:!1,scrollback:0,theme:KS(),disableStdin:!0,linkHandler:{activate:()=>{}}});v.open(s.current),$S(v,()=>new h),v.attachCustomWheelEventHandler(()=>!1),u.current=v;let y=()=>{_.current&&s.current?.parentElement?.querySelector(`.terminal-input-capture`)?.focus()};v.textarea?.addEventListener(`focus`,y);let b=Nv(s.current,v,()=>_.current,e=>A.current(e)),x=v.parser.registerOscHandler(8,()=>!0);if(!t.terminalId){b(),v.dispose();return}let S=new l;v.loadAddon(S),v.loadAddon(new p(()=>{}));let C=e=>xS(v,e),w=s.current;w.addEventListener(`mouseup`,C);let E=e=>{let t=v.hasSelection()?yS(v):void 0,n=c.current?.getBoundingClientRect();T(t&&n?{url:t,x:e.clientX-n.left,y:e.clientY-n.top}:null)},D=()=>{v.hasSelection()||T(null)};w.addEventListener(`mouseup`,E);let O=v.onSelectionChange(D),k=()=>({cols:Math.floor((s.current?.clientWidth??640)/8),rows:Math.floor((s.current?.clientHeight??400)/20)}),j=()=>{try{return QS(S.proposeDimensions())}catch{return}},M=()=>!!s.current?.isConnected&&s.current.clientWidth>0&&s.current.clientHeight>0,N=()=>{let{cols:e,rows:t}=j()??k();return{cols:Math.max(2,Math.min(500,e)),rows:Math.max(1,Math.min(300,t))}};d.current=f.mount({machineId:n,threadId:r,terminalId:t.terminalId,terminal:v,mode:a?`control`:`observe`,...N(),onState:(e,t)=>{m(e),g(t),_.current=t}});let P=aS(s.current,()=>({element:v.element?.querySelector(`.xterm-screen`)??void 0,cols:v.cols,rows:v.rows}),()=>d.current,()=>_.current),F,I=new ResizeObserver(()=>{clearTimeout(F),F=setTimeout(()=>{if(!M())return;let{cols:e,rows:t}=N();d.current?.resize(e,t)},150)});I.observe(s.current);let L=()=>{if(document.visibilityState!==`visible`||!document.hasFocus()||!M())return;let{cols:e,rows:t}=N();d.current?.resize(e,t,!0)};window.addEventListener(`focus`,L),document.addEventListener(`visibilitychange`,L);let R=new MutationObserver(()=>{v.options.theme=KS()});R.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),o=()=>{clearTimeout(F),d.current?.close(),d.current=null,_.current=!1,P(),window.removeEventListener(`focus`,L),document.removeEventListener(`visibilitychange`,L),v.textarea?.removeEventListener(`focus`,y),b(),w.removeEventListener(`mouseup`,C),w.removeEventListener(`mouseup`,E),O.dispose(),T(null),x.dispose(),I.disconnect(),R.disconnect(),v.dispose(),u.current=null}}).catch(()=>m(`The terminal could not load.`)),()=>{i=!0,o()}},[t.id,t.terminalId,n,r,f,a]);let j=(e,t)=>{if(_.current){if(!b||t){d.current?.input(e,t);return}x(!1),d.current?.input(Vx(e)??e)}},M=()=>u.current?.focus(),N=()=>{h&&!u.current?.hasSelection()&&(M(),s.current?.parentElement?.querySelector(`.terminal-input-capture`)?.focus())};return(0,l.useEffect)(()=>{i&&N()},[i,h]),(0,l.useEffect)(()=>{u.current&&(u.current.options.cursorInactiveStyle=i?`block`:`outline`)},[i,h]),(0,l.useEffect)(()=>{if(!i||!h)return;let e=e=>e.target===document.body||e.target===document.documentElement||c.current?.contains(e.target),t=t=>{if(t.defaultPrevented||t.metaKey||t.isComposing||!e(t)||t.target.classList?.contains(`terminal-input-capture`))return;let n=Bx(t);n?(t.preventDefault(),t.stopPropagation(),d.current?.input(n)):t.key.length===1&&!t.ctrlKey&&N()},n=t=>{let n=t.target.classList?.contains(`terminal-input-capture`);if(!e(t)&&!n)return;let r=em(t.clipboardData);if(r.length){t.preventDefault(),t.stopPropagation(),O.attach(r);return}let i=t.clipboardData?.getData(`text/plain`);i&&!n&&(t.preventDefault(),t.stopPropagation(),d.current?.input(i,!0))};return window.addEventListener(`keydown`,t,!0),window.addEventListener(`paste`,n,!0),()=>{window.removeEventListener(`keydown`,t,!0),window.removeEventListener(`paste`,n,!0)}},[i,h,O.attach]),(0,l.useEffect)(()=>{let e=()=>{i&&N()};return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[i,h]),(0,Q.jsxs)(`section`,{ref:c,className:`terminal-pane ${i?`is-active`:``}`,"aria-label":`${t.title} terminal`,onPointerDownCapture:()=>{i||o()},onFocusCapture:()=>{i||o()},onClick:()=>{a&&!_.current&&d.current?.control(),N()},children:[(0,Q.jsx)(`span`,{className:`terminal-status`,role:`status`,children:p}),p===`Another controller owns this terminal.`&&(0,Q.jsxs)(`div`,{className:`terminal-control-conflict`,children:[`Another Herdr client controls this terminal.`,(0,Q.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),sl(`Replace the other Herdr client that controls this terminal? Its input stops working.`,{confirmLabel:`Take over`}).then(e=>{e&&d.current?.control(!0)})},children:`Take over`})]}),(0,Q.jsx)(`div`,{ref:s,className:`terminal-host`}),O.dragging&&(0,Q.jsxs)(`div`,{className:`terminal-drop-overlay`,"aria-hidden":`true`,children:[(0,Q.jsx)(F,{size:22,strokeWidth:1.6}),(0,Q.jsx)(`span`,{children:`Drop image to attach`})]}),w&&(0,Q.jsx)(CS,{selected:w,onDone:()=>{T(null),u.current?.clearSelection()},onCopied:e=>A.current(e?`copied`:`blocked`)}),E&&(0,Q.jsx)(`div`,{className:`terminal-attach-notice is-${E.tone}`,role:E.tone===`error`?`alert`:`status`,children:E.text}),(a||h)&&(0,Q.jsx)(Hx,{onInput:j,onFocusChange:e=>{y(e),u.current?.modes.sendFocusMode&&d.current?.input(e?XS:ZS)}}),a&&i&&S&&v&&(0,Q.jsx)(Yx,{ctrl:b,onToggleCtrl:()=>x(e=>!e),onBytes:e=>d.current?.input(e),voice:k})]})}function tC({thread:e}){let t=zb(e),n=Lb(e.operation?.step??`validate`);return(0,Q.jsxs)(`main`,{className:`launch-progress`,"aria-label":`Launch progress`,role:`status`,children:[(0,Q.jsx)(`h1`,{children:t?`The launch stopped`:`Starting your agent`}),(0,Q.jsx)(`blockquote`,{className:`launch-prompt`,children:e.prompt||e.title}),(0,Q.jsx)(`ol`,{className:`launch-steps`,children:Fb.map((e,r)=>{let i=r<n?`done`:r===n?t?`failed`:`active`:`waiting`,a=i===`done`?w:i===`failed`?S:i===`active`?R:E;return(0,Q.jsxs)(`li`,{className:`launch-step is-${i}`,"aria-current":i===`active`?`step`:void 0,children:[(0,Q.jsx)(a,{size:16,strokeWidth:1.8,"aria-hidden":`true`}),e.label]},e.id)})}),t&&(0,Q.jsxs)(`div`,{className:`launch-failure`,role:`alert`,children:[(0,Q.jsxs)(`p`,{children:[`Herdr stopped while `,Fb[n].label.toLowerCase(),`. The worktree may already exist, so check it in Herdr before you try again.`]}),(0,Q.jsx)(`a`,{className:`launch-retry`,href:`/new?project=${encodeURIComponent(e.projectId)}`,children:`Start a new thread`})]})]})}var nC=({pane:e})=>e.kind===`agent`?(0,Q.jsx)(v,{size:14,strokeWidth:1.8,"aria-hidden":`true`}):(0,Q.jsx)(ce,{size:14,strokeWidth:1.8,"aria-hidden":`true`});function rC({pane:e,side:t,onOpen:n}){return(0,Q.jsx)(Zl,{label:`Show ${e.title}`,side:t===`left`?`right`:`left`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`pane-collapsed`,"aria-label":`Show ${e.title}`,onClick:n,children:[(0,Q.jsx)(nC,{pane:e}),(0,Q.jsx)(`span`,{children:e.title})]})})}var iC=(e,t)=>JSON.stringify([t,e.map(e=>e.id)]),aC=(e,t)=>{let[n,r]=JSON.parse(e);return{start:n,panes:r.flatMap(e=>t.filter(t=>t.id===e))}},oC=(e,t)=>aC((0,l.useDeferredValue)(iC(e,t)),e);function sC({panes:e,windowStart:t,onFocusPane:n,renderPane:r}){let{panes:i,start:a}=oC(e,t),o=e=>e>=a&&e<a+2;return(0,Q.jsx)(`div`,{className:`pane-strip ${i.length>1?`is-split`:``}`,children:i.map((e,t)=>(0,Q.jsx)(l.ViewTransition,{default:`pane-move`,enter:`pane-enter`,exit:`pane-exit`,children:o(t)?(0,Q.jsx)(`div`,{className:`pane-slot`,children:r(e)}):(0,Q.jsx)(rC,{pane:e,side:t<a?`left`:`right`,onOpen:()=>n(e.id)})},e.id))})}function cC({panes:e,focusedPane:t,onFocusPane:n,renderPane:r}){let i=(0,l.useDeferredValue)(t),a=e.find(e=>e.id===i)??e[0];return(0,Q.jsxs)(`div`,{className:`pane-tabbed`,children:[e.length>1&&(0,Q.jsx)(`div`,{className:`pane-tabs`,role:`tablist`,"aria-label":`Panes`,children:e.map(e=>(0,Q.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":e.id===a?.id,className:`pane-tab`,onClick:()=>n(e.id),children:[(0,Q.jsx)(nC,{pane:e}),(0,Q.jsx)(`span`,{children:e.title})]},e.id))}),a&&(0,Q.jsx)(l.ViewTransition,{enter:`pane-enter`,exit:`pane-exit`,children:(0,Q.jsx)(`div`,{className:`pane-slot`,role:`tabpanel`,children:r(a)})},a.id)]})}function lC({thread:e,connected:t,canControl:n,onFocusPane:r,focusedPane:i,windowStart:o,narrow:s}){let c=t&&(Rb(e)||zb(e)),u=t&&e.bindingState===`detached`&&!c;(0,l.useEffect)(()=>{u&&a(`/new?project=${encodeURIComponent(e.projectId)}`)},[u,e.projectId]);let d=t=>t.terminalId?(0,Q.jsx)(eC,{pane:t,machineId:e.machineId,threadId:e.id,active:i===t.id,canControl:n,onFocus:()=>r(t.id)},t.terminalId):null;if(c)return(0,Q.jsx)(tC,{thread:e});let f={panes:e.panes,focusedPane:i,onFocusPane:r,renderPane:d};return(0,Q.jsxs)(`main`,{className:`native-thread-layout`,"aria-label":`${e.title} tab`,children:[(!t||e.bindingState!==`attached`)&&(0,Q.jsx)(`p`,{className:`runtime-notice`,role:`status`,children:t?`Waiting for the terminal to attach…`:`Disconnected; input is disabled.`}),t&&e.bindingState===`attached`&&!n&&(0,Q.jsx)(`p`,{className:`runtime-notice`,role:`status`,children:`Terminal input is unavailable because this Herdr version is not supported.`}),t&&e.bindingState===`attached`&&(s?(0,Q.jsx)(cC,{...f}):(0,Q.jsx)(sC,{...f,windowStart:o}))]})}var uC=e=>Symbol.iterator in e,dC=e=>`entries`in e,fC=(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},pC=(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 mC(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:uC(e)&&uC(t)?dC(e)&&dC(t)?fC(e,t):pC(e,t):fC({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function hC(e){let t=l.useRef(void 0);return n=>{let r=e(n);return mC(t.current,r)?t.current:t.current=r}}function gC(e,t){if(e.repeat||e.defaultPrevented||e.isComposing)return;let n=e.target;if(!n?.closest(`[data-recording="true"]`)&&(!n?.closest(`input, textarea, select, [contenteditable="true"]`)||n.closest(`.xterm, .terminal-input-capture`)))return Object.entries(t).find(([,t])=>t===tp(e))?.[0]}var _C=`(max-width: 760px)`;function vC(e,t,n,r){let i=wx(e,e=>e.paneWindows[t]??0),a=Cp(n.length,i,n.indexOf(r));return(0,l.useEffect)(()=>{a!==i&&e.getState().showWindow(t,a)},[e,t,a,i]),a}var yC=e=>{if(typeof matchMedia!=`function`)return()=>{};let t=matchMedia(_C);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},bC=()=>typeof matchMedia==`function`&&matchMedia(_C).matches,xC=()=>(0,l.useSyncExternalStore)(yC,bC,()=>!1);function SC(e,t,n){let r=e?.status===`done`;(0,l.useEffect)(()=>{e&&t&&r&&n&&fetch(`/api/threads/${encodeURIComponent(e.id)}/focus`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({machineId:e.machineId,paneId:t})}).catch(()=>void 0)},[e?.id,e?.machineId,t,r,n])}var CC=e=>e.preventDefault();function wC(e){return(0,Q.jsx)(Xp,{children:(0,Q.jsx)(Ix,{bootstrap:e.bootstrap,children:(0,Q.jsx)(TC,{...e})})})}function TC({page:e,bootstrap:t,threadId:n,projectId:r}){let{ui:i,terminals:o}=Lx(),s=Rx(hC(e=>e.projectIds.map(t=>e.projects[t]))),c=Rx(hC(e=>e.threadIds.map(t=>e.threads[t]).filter(e=>!e.archivedAt&&Hb(e)))),u=Rx(hC(e=>e.threadIds.map(t=>e.threads[t]).filter(e=>!!e.archivedAt))),d=Rx(e=>e.threads[n??``]),f=Rx(e=>e.projections),p=Rx(e=>e.connected),m=Object.values(f).flatMap(e=>{let n=e.machine??t.machines.find(t=>t.id===e.machineId);return n?[{...n,connected:p&&e.connected,error:e.error}]:[]}),[h,g]=(0,l.useState)(!1),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(!1);(0,l.useEffect)(Ep,[]),(0,l.useEffect)($x,[]);let[x,S]=(0,l.useState)(`threads`),C=`${d?.machineId??``}:${d?.id??``}`,w=wx(i,e=>e.focusedPanes[C]),T=d?.panes.some(e=>e.id===w)?w:d?.panes[0]?.id??``,E=(0,l.useCallback)(e=>i.getState().focus(C,e),[i,C]);SC(e===`thread`?d:void 0,T,p&&!!m.find(e=>e.id===d?.machineId)?.writable);let O=(0,l.useRef)(void 0);(0,l.useEffect)(()=>{d?O.current=d.id:e===`thread`&&O.current===n&&a(`/`)},[d,e,n]),(0,l.useEffect)(()=>{let e=e=>{nm(e.dataTransfer)&&e.preventDefault()};return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[]),(0,l.useEffect)(()=>{let e=()=>g(new URLSearchParams(window.location.search).get(`sidebar`)===`collapsed`);e(),window.addEventListener(`popstate`,e),S(localStorage.getItem(`webr-sidebar-mode`)===`projects`?`projects`:`threads`);let t=matchMedia(`(prefers-color-scheme: dark)`),n=()=>{(localStorage.getItem(`webr-theme`)??`system`)===`system`&&rp(`system`)};return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n),window.removeEventListener(`popstate`,e)}},[]);let k=e=>void cl(e instanceof Error?e.message:`Herdr could not change the pane.`),A=vC(i,C,d?.panes.map(e=>e.id)??[],T),j=xC(),M=(0,l.useCallback)(()=>{d&&T&&mp(d,T).then(({paneId:e})=>E(e),k)},[d,T,E]),N=(0,l.useCallback)(async(e=T)=>{if(!d||!bp(d,e))return;let t=d.panes.find(t=>t.id===e),n=Sp(d.panes,A,e);try{let r=await hp(d,e,!1);r.busy&&await sl(`${t.title} is running a process. Close it anyway?`,{confirmLabel:`Close`,danger:!0})&&(r=await hp(d,e,!0)),r.closed&&n&&E(n.id)}catch(e){k(e)}},[d,T,A,E]),P=(0,l.useCallback)(()=>{if(window.matchMedia(`(max-width: 760px)`).matches){v(e=>!e);return}g(e=>{let t=!e,n=new URL(window.location.href);return t?n.searchParams.set(`sidebar`,`collapsed`):n.searchParams.delete(`sidebar`),window.history.replaceState(window.history.state,``,n),t})},[]),F=(0,l.useCallback)(e=>{S(e),localStorage.setItem(`webr-sidebar-mode`,e)},[]);return(0,l.useEffect)(()=>{let e=e=>{if(e.repeat||e.isComposing||e.target?.closest(`[data-recording="true"]`))return;if(e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`k`){e.preventDefault(),b(e=>!e);return}if(y||e.defaultPrevented)return;let t=gC(e,Qf());if(t){if(e.preventDefault(),t===`toggleSidebar`&&P(),t===`openTerminal`&&M(),t===`closePane`&&N(),t===`newThread`&&a(`/new${d?`?project=${encodeURIComponent(d.projectId)}`:``}`),(t===`nextPane`||t===`previousPane`)&&d?.panes.length){let e=d.panes.findIndex(e=>e.id===T);E(d.panes[(e+(t===`nextPane`?1:-1)+d.panes.length)%d.panes.length].id)}if((t===`nextThread`||t===`previousThread`)&&c.length){let e=c.findIndex(e=>e.id===d?.id),n=t===`nextThread`?(e+1)%c.length:(e-1+c.length)%c.length;a(`/threads/${encodeURIComponent(c[n].id)}`)}}};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[d,c,y,P,M,N,T,E]),(0,Q.jsxs)(`div`,{className:`app-shell ${e===`thread`?`is-thread`:``}`,children:[(0,Q.jsx)(yx,{projects:s,threads:c,archived:u,machines:m,currentId:d?.id,mode:x,onModeChange:F,collapsed:h,mobileOpen:_,onCollapse:P,onCloseMobile:()=>v(!1),onOpenPalette:()=>b(!0),updateAction:(0,Q.jsx)(bx,{})}),(0,Q.jsxs)(`div`,{className:`main-panel`,children:[e===`thread`&&d&&(0,Q.jsx)(lC,{thread:d,connected:p&&!!f[d.machineId]?.connected,canControl:!!m.find(e=>e.id===d.machineId)?.writable,focusedPane:T,onFocusPane:E,windowStart:A,narrow:j}),e===`new`&&(0,Q.jsx)(Tv,{projects:s,machines:m,selectedProjectId:r,onOpenSidebar:P},r),e===`settings`&&(0,Q.jsx)(Uy,{onOpenSidebar:P}),e===`missing`&&(0,Q.jsxs)(`main`,{className:`not-found`,children:[(0,Q.jsx)(`h1`,{children:`Thread not found`}),(0,Q.jsx)(`a`,{href:`/`,children:`Open a thread`})]})]}),e===`thread`&&(0,Q.jsxs)(`div`,{className:`mobile-controls`,children:[(0,Q.jsx)(`button`,{"aria-label":`Open sidebar`,onPointerDown:CC,onClick:P,children:(0,Q.jsx)(H,{size:22})}),(0,Q.jsx)(`button`,{"aria-label":`Open command palette`,onPointerDown:CC,onClick:()=>b(!0),children:(0,Q.jsx)(D,{size:22})})]}),!1,(0,Q.jsx)(Yp,{}),(0,Q.jsx)(Op,{open:y,onClose:()=>b(!1),projects:s,threads:c,thread:d,focusedPane:T,mode:x,onModeChange:F,onToggleSidebar:P,onFocusPane:E,onTerminalAction:e=>{let t=d?.panes.find(e=>e.id===T);d&&t?.terminalId&&o.command(d.machineId,d.id,t.terminalId,e)},onOpenTerminal:M,onClosePane:()=>void N()})]})}export{wC as default};
|