@pablopunk/webr 0.1.5 → 0.1.7
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 +2 -1
- package/dist/client/_astro/App.DijFEuO0.css +1 -0
- package/dist/client/_astro/App.Z2LzeAW7.js +2 -0
- package/dist/server/chunks/{App_CmESMUHE.mjs → App_C1XnVbA2.mjs} +105 -32
- package/dist/server/chunks/{_id__CQzMt2xL.mjs → _id__CAx6DC51.mjs} +1 -1
- package/dist/server/chunks/{_tab__D-smYrCo.mjs → _tab__BJ-ULrm_.mjs} +1 -1
- package/dist/server/chunks/{new_NXgn74q9.mjs → new_BfRTqcQ4.mjs} +1 -1
- package/dist/server/chunks/{settings_D1jcCWzt.mjs → settings_BD_xdLnR.mjs} +1 -1
- package/dist/server/entry.mjs +5 -5
- package/package.json +1 -1
- package/server/cli.ts +12 -2
- package/server/plugin/index.ts +1 -1
- package/src/server/host.ts +4 -0
- package/src/server/runtime/manager.ts +7 -1
- package/src/server/runtime/reconcile.ts +5 -2
- package/src/server/transport/icons.ts +1 -1
- package/dist/client/_astro/App.1PYvyCIo.css +0 -1
- package/dist/client/_astro/App.B3aX6cef.js +0 -2
|
@@ -1,2 +0,0 @@
|
|
|
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"])))=>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(`Check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),y=d(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),b=d(`ChevronRight`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),x=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`}]]),S=d(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),C=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`}]]),w=d(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),T=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`}]]),E=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`}]]),D=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`}]]),O=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 k=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`}]]),A=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`}]]),j=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`}]]),M=d(`LoaderCircle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),N=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`}]]),P=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`}]]),F=d(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),I=d(`PanelBottom`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 15h18`,key:`5xshup`}]]),L=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`}]]),R=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`}]]),z=d(`PanelLeft`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}]]),ee=d(`PanelRight`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),B=d(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),te=d(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),ne=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`}]]),re=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`}]]),V=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`}]]),H=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`}]]),ie=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`}]]),ae=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`}]]),oe=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`}]]),se=d(`X`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),U=typeof document<`u`?l.useLayoutEffect:()=>{};function ce(){return typeof window<`u`}function W(e){return de(e)?(e.nodeName||``).toLowerCase():`#document`}function le(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function ue(e){return((de(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function de(e){return ce()?e instanceof Node||e instanceof le(e).Node:!1}function G(e){return ce()?e instanceof Element||e instanceof le(e).Element:!1}function K(e){return ce()?e instanceof HTMLElement||e instanceof le(e).HTMLElement:!1}function fe(e){return!ce()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof le(e).ShadowRoot}function pe(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=we(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function me(e){return/^(table|td|th)$/.test(W(e))}function he(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ge=/transform|translate|scale|rotate|perspective|filter/,_e=/paint|layout|strict|content/,ve=e=>!!e&&e!==`none`,ye;function be(e){let t=G(e)?we(e):e;return ve(t.transform)||ve(t.translate)||ve(t.scale)||ve(t.rotate)||ve(t.perspective)||!Se()&&(ve(t.backdropFilter)||ve(t.filter))||ge.test(t.willChange||``)||_e.test(t.contain||``)}function xe(e){let t=Ee(e);for(;K(t)&&!Ce(t);){if(be(t))return t;if(he(t))return null;t=Ee(t)}return null}function Se(){return ye??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),ye}function Ce(e){return/^(html|body|#document)$/.test(W(e))}function we(e){return le(e).getComputedStyle(e)}function Te(e){return G(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Ee(e){if(W(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||fe(e)&&e.host||ue(e);return fe(t)?t.host:t}function De(e){let t=Ee(e);return Ce(t)?(e.ownerDocument||e).body:K(t)&&pe(t)?t:De(t)}function Oe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=De(e),i=r===e.ownerDocument?.body,a=le(r);if(i){let e=ke(a);return t.concat(a,a.visualViewport||[],pe(r)?r:[],e&&n?Oe(e):[])}return t.concat(r,Oe(r,[],n))}function ke(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 Ae(){return typeof navigator>`u`?{userAgent:``,platform:``,maxTouchPoints:0}:{userAgent:navigator.userAgent,platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??0}}var{userAgent:je,platform:Me,maxTouchPoints:Ne}=Ae(),Pe=je.toLowerCase(),Fe=Me.toLowerCase(),Ie=/^i(os$|p)/.test(Fe)||Fe===`macintel`&&Ne>1,Le=`android`,Re=Fe===Le||Pe.includes(Le),ze=!Ie&&Fe.startsWith(`mac`);Fe.startsWith(`win`),!Re&&/^(linux|chrome os)/.test(Fe);var Be=ze||Ie,Ve=typeof CSS<`u`&&!!CSS.supports?.(`-webkit-backdrop-filter:none`),He=!Ve&&Pe.includes(`firefox`);!Ve&&Pe.includes(`chrom`);var Ue=Be,We=/jsdom|happydom/.test(Pe);function J(e){return e?.ownerDocument||document}var Ge={};function Ke(e,t){let n=l.useRef(Ge);return n.current===Ge&&(n.current=e(t)),n}function qe(){}var Je=Object.freeze([]),Ye=Object.freeze({});function Xe(e){l.useEffect(e,Je)}var Ze=0,Qe=class e{static create(){return new e}currentId=Ze;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ze,t()},e)}isStarted(){return this.currentId!==Ze}clear=()=>{this.currentId!==Ze&&(clearTimeout(this.currentId),this.currentId=Ze)};disposeEffect=()=>this.clear};function $e(){let e=Ke(Qe.create).current;return Xe(e.disposeEffect),e}var et=null;globalThis.requestAnimationFrame;var tt=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)}},nt=class e{static create(){return new e}static request(e){return tt.request(e)}static cancel(e){return tt.cancel(e)}currentId=et;request(e){this.cancel(),this.currentId=tt.request(()=>{this.currentId=et,e()})}cancel=()=>{this.currentId!==et&&(tt.cancel(this.currentId),this.currentId=et)};disposeEffect=()=>this.cancel};function rt(){let e=Ke(nt.create).current;return Xe(e.disposeEffect),e}var it={},at={},ot=``;function st(e,t){return pe(e)?e:t}function ct(e,t,n){return/hidden|clip/.test(e.getComputedStyle(st(t,n)).overflowY)}function lt(e){if(typeof document>`u`)return!1;let t=J(e);return le(t).innerWidth-t.documentElement.clientWidth>0}function ut(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=st(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 dt(e){let t=J(e),n=t.documentElement,r=t.body,i=st(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 Y(e){let t=J(e),n=t.documentElement,r=t.body,i=le(n),a=0,o=0,s=!1,c=nt.create();if(Ve&&(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,it={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},ot=n.style.scrollBehavior,at={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=st(n,r);if(s=ut(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,it),Object.assign(r.style,at),s||(n.scrollTop=a,n.scrollLeft=o,n.removeAttribute(`data-base-ui-scroll-locked`),n.style.scrollBehavior=ot)}function d(){u(),c.request(l)}l();let f=q(i,`resize`,d);return()=>{c.cancel(),u(),typeof i.removeEventListener==`function`&&f()}}var ft=new class{lockCount=0;restore=null;timeoutLock=Qe.create();timeoutUnlock=Qe.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=le(n);if(ct(i,n,r)){let t=new i.MutationObserver(()=>{ct(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=Ie||!lt(e);this.restore=a?dt(e):Y(e)}};function pt(e=!0,t=null){U(()=>{if(e)return ft.acquire(t)},[e,t])}function mt(e){e.preventDefault(),e.stopPropagation()}function ht(e){return`nativeEvent`in e}function gt(e){return e.pointerType===``&&e.isTrusted?!0:Re&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function _t(e){return We?!1:!Re&&e.width===0&&e.height===0||Re&&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 vt(e,t){let n=[`mouse`,`pen`];return t||n.push(``,void 0),n.includes(e)}function yt(e){let t=e.type;return t===`click`||t===`mousedown`||t===`keydown`||t===`keyup`}function bt(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&&fe(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function xt(e){return`composedPath`in e?e.composedPath()[0]??e.target:e.target}var St=`data-base-ui-focusable`,Ct=`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`,wt=`ArrowLeft`,Tt=`ArrowRight`,Et=`ArrowUp`,Dt=`ArrowDown`,Ot=`data-starting-style`,kt=`data-ending-style`,At={[Ot]:``},jt={[kt]:``},Mt={transitionStatus(e){return e===`starting`?At:e===`ending`?jt:null}},Nt=`data-open`,Pt=`data-closed`,Ft=`data-anchor-hidden`,It=`data-popup-open`,Lt=`data-pressed`,Rt={[It]:``},zt={[It]:``,[Lt]:``},Bt={[Nt]:``},Vt={[Pt]:``},Ht={[Ft]:``},Ut={open(e){return e?Rt:null}},Wt={open(e){return e?zt:null}},Gt={open(e){return e?Bt:Vt},anchorHidden(e){return e?Ht:null}},Kt={...Gt,...Mt},qt=`data-trigger-disabled`;function Jt(e,t){if(!G(e))return!1;let n=e;if(t.hasElement(n))return!n.hasAttribute(qt);for(let[,e]of t.entries())if(X(e,n))return!e.hasAttribute(qt);return!1}function Yt(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 Xt(e){return e.matches(`html,body`)}function Zt(e){return K(e)&&e.matches(`input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])`)}function Qt(e){return e?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${Ct}`)!=null}function $t(e){return e?e.getAttribute(`role`)===`combobox`&&Zt(e):!1}function en(e){if(!e||We)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}function tn(e){return e?e.hasAttribute(`data-base-ui-focusable`)?e:e.querySelector(`[data-base-ui-focusable]`)||e:null}function nn(e,t){return t!=null&&!vt(t)?0:typeof e==`function`?e():e}function rn(e,t,n){let r=nn(e,n);return typeof r==`number`?r:r?.[t]}function an(e){return typeof e==`function`?e():e}function on(e,t){return t||e===`click`||e===`mousedown`}function sn(e){return e?.includes(`mouse`)&&e!==`mousedown`}var cn=`none`,ln=`trigger-press`,un=`trigger-hover`,dn=`trigger-focus`,fn=`outside-press`,pn=`item-press`,mn=`close-press`,hn=`input-change`,gn=`input-clear`,_n=`input-press`,vn=`focus-out`,yn=`escape-key`,bn=`list-navigation`,xn=`keyboard`,Sn=`pointer`,Cn=`cancel-open`,wn=`sibling-open`,Tn=`disabled`,En=`imperative-action`;function Z(e,t,n,r){let i=!1,a=!1,o=r??Ye;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 Dn(e,t,n){let r=n??Ye;return{reason:e,event:t??new Event(`base-ui`),...r}}var On=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=On()}))(),kn=l.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new Qe,currentIdRef:{current:null},currentContextRef:{current:null}});function An(e,t){e.current=t.current}function jn(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(kn),[p,m]=l.useState(!1),h=l.useRef(n);return U(()=>{h.current=n},[n]),U(()=>{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]),U(()=>{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:rn(c.current,`close`)},t!==null&&t!==i?(m(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,Z(cn))):(m(!1),e?.setIsInstantPhase(!1))},[n,i,r,a,o,c,u,f]),U(()=>()=>{if(a.current===i){if(u.current=null,!h.current)return;a.current=null,An(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 Mn(...e){return()=>{for(let t=0;t<e.length;t+=1){let n=e[t];n&&n()}}}function Nn(e,t,n,r){let i=Ke(Fn).current;return In(i,e,t,n,r)&&Rn(i,[e,t,n,r]),i.callback}function Pn(e){let t=Ke(Fn).current;return Ln(t,e)&&Rn(t,e),t.callback}function Fn(){return{callback:null,cleanup:null,refs:[]}}function In(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Ln(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Rn(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 zn(e){let t=Ke(Bn,e).current;return t.next=e,U(t.effect),t}function Bn(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var Vn={...l},Hn=Vn.useInsertionEffect,Un=Hn&&Hn!==Vn.useLayoutEffect?Hn:e=>e();function $(e){let t=Ke(Wn).current;return t.next=e,Un(t.effect),t.trampoline}function Wn(){let e={next:void 0,callback:Gn,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Gn(){}var Kn={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},qn={...Kn,position:`fixed`,top:0,left:0},Jn={...Kn,position:`absolute`},Yn=l.forwardRef(function(e,t){let[n,r]=l.useState();U(()=>{Ue&&Ve&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,Q.jsx)(`span`,{...e,ref:t,style:qn,"aria-hidden":!n||void 0,...i,"data-base-ui-focus-guard":``})}),Xn=Math.min,Zn=Math.max,Qn=Math.round,$n=Math.floor,er=e=>({x:e,y:e}),tr={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function nr(e,t,n){return Zn(e,Xn(t,n))}function rr(e,t){return typeof e==`function`?e(t):e}function ir(e){return e.split(`-`)[0]}function ar(e){return e.split(`-`)[1]}function or(e){return e===`x`?`y`:`x`}function sr(e){return e===`y`?`height`:`width`}function cr(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function lr(e){return or(cr(e))}function ur(e,t,n){n===void 0&&(n=!1);let r=ar(e),i=lr(e),a=sr(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=yr(o)),[o,yr(o)]}function dr(e){let t=yr(e);return[fr(e),t,fr(t)]}function fr(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var pr=[`left`,`right`],mr=[`right`,`left`],hr=[`top`,`bottom`],gr=[`bottom`,`top`];function _r(e,t,n){switch(e){case`top`:case`bottom`:return n?t?mr:pr:t?pr:mr;case`left`:case`right`:return t?hr:gr;default:return[]}}function vr(e,t,n,r){let i=ar(e),a=_r(ir(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(fr)))),a}function yr(e){let t=ir(e);return tr[t]+e.slice(t.length)}function br(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function xr(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:br(e)}function Sr(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 Cr(e,t,n){return Math.floor(e/t)!==n}function wr(e,t){return t<0||t>=e.length}function Tr(e,t){return Dr(e.current,{disabledIndices:t})}function Er(e,t){return Dr(e.current,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function Dr(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&&kr(e,a,r));return a}function Or(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(!kr(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=$n(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(!kr(e,r,s))return r}};d&&mt(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=Dr(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=Dr(e,{startingIndex:u%y-y,amount:y,disabledIndices:s}),i&&(f=i(t,u,f)))}wr(e,f)&&(f=u)}if(n===`both`){let n=$n(u/o);t.key===(a?`ArrowLeft`:`ArrowRight`)&&(d&&mt(t),u%o===o-1?r&&(f=Dr(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):(f=Dr(e,{startingIndex:u,disabledIndices:s}),r&&Cr(f,o,n)&&(f=Dr(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f)))),Cr(f,o,n)&&(f=u)),t.key===(a?`ArrowRight`:`ArrowLeft`)&&(d&&mt(t),u%o===0?r&&(f=Dr(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f))):(f=Dr(e,{startingIndex:u,decrement:!0,disabledIndices:s}),r&&Cr(f,o,n)&&(f=Dr(e,{startingIndex:u+(o-u%o),decrement:!0,disabledIndices:s}),i&&(f=i(t,u,f)))),Cr(f,o,n)&&(f=u));let c=$n(l/o)===n;wr(e,f)&&(r&&c?(f=t.key===(a?`ArrowRight`:`ArrowLeft`)?l:Dr(e,{startingIndex:u-u%o-1,disabledIndices:s}),i&&(f=i(t,u,f))):f=u)}return f}function kr(e,t,n){if(typeof n==`function`?n(t):n?.includes(t)??!1)return!0;let r=e[t];return r?!jr(r)||r.matches(`:disabled`)?!0:!n&&(r.hasAttribute(`disabled`)||r.getAttribute(`aria-disabled`)===`true`):!1}function Ar(e){return e.visibility===`hidden`||e.visibility===`collapse`}function jr(e,t=e?we(e):null){return!e||!e.isConnected||!t||Ar(t)?!1:typeof e.checkVisibility==`function`?e.checkVisibility():t.display!==`none`&&t.display!==`contents`}var Mr=`a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]`;function Nr(e){let t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;let n=e.getRootNode();return fe(n)?n.host:null}function Pr(e){for(let t of Array.from(e.children))if(W(t)===`summary`)return t;return null}function Fr(e,t){let n=Pr(t);return!!n&&(e===n||X(n,e))}function Ir(e){let t=e?W(e):``;return e!=null&&e.matches(Mr)&&(t!==`summary`||e.parentElement!=null&&W(e.parentElement)===`details`&&Pr(e.parentElement)===e)&&(t!==`details`||Pr(e)==null)&&(t!==`input`||e.type!==`hidden`)}function Lr(e){if(!Ir(e)||!e.isConnected||e.matches(`:disabled`))return!1;for(let t=e;t;t=Nr(t)){let n=t!==e,r=W(t)===`slot`;if(t.hasAttribute(`inert`)||n&&W(t)===`details`&&!t.open&&!Fr(e,t)||t.hasAttribute(`hidden`)||!r&&!Rr(t,n))return!1}return!0}function Rr(e,t){let n=we(e);return t?n.display!==`none`:jr(e,n)}function zr(e){let t=e.tabIndex;if(t<0){let t=W(e);if(t===`details`||t===`audio`||t===`video`||K(e)&&e.isContentEditable)return 0}return t}function Br(e){if(W(e)!==`input`)return null;let t=e;return t.type===`radio`&&t.name!==``?t:null}function Vr(e,t){let n=Br(e);if(!n)return!0;let r=t.find(e=>{let t=Br(e);return t?.name===n.name&&t.form===n.form&&t.checked});return r?r===n:t.find(e=>{let t=Br(e);return t?.name===n.name&&t.form===n.form})===n}function Hr(e){if(K(e)&&W(e)===`slot`){let t=e.assignedElements({flatten:!0});if(t.length>0)return t}return K(e)&&e.shadowRoot?Array.from(e.shadowRoot.children):Array.from(e.children)}function Ur(e,t){Hr(e).forEach(e=>{Ir(e)&&t.push(e),Ur(e,t)})}function Wr(e,t,n){Hr(e).forEach(e=>{K(e)&&e.matches(t)&&n.push(e),Wr(e,t,n)})}function Gr(e){return Lr(e)&&zr(e)>=0}function Kr(e){let t=[];return Ur(e,t),t.filter(Lr)}function qr(e){let t=Kr(e);return t.filter(e=>zr(e)>=0&&Vr(e,t))}function Jr(e,t){let n=qr(e),r=n.length;if(r===0)return;let i=bt(J(e)),a=n.indexOf(i);return n[a===-1?t===1?0:r-1:a+t]}function Yr(e){return Jr(J(e).body,1)||e}function Xr(e){return Jr(J(e).body,-1)||e}function Zr(e,t){if(!e)return null;let n=qr(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 Qr(e){return Zr(e,1)}function $r(e){return Zr(e,-1)}function ei(e,t){let n=t||e.currentTarget,r=e.relatedTarget;return!r||!X(n,r)}function ti(e){qr(e).forEach(e=>{e.dataset.tabindex=e.getAttribute(`tabindex`)||``,e.setAttribute(`tabindex`,`-1`)})}function ni(e){let t=[];Wr(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 ri(e,t,n=!0){return e.filter(e=>e.parentId===t).flatMap(t=>[...!n||t.context?.open?[t]:[],...ri(e,t.id,n)])}function ii(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 ai(e){return`data-base-ui-${e}`}var oi=0;function si(e,t={}){let{preventScroll:n=!1,sync:r=!1,shouldFocus:i}=t;cancelAnimationFrame(oi);function a(){(!i||i())&&e?.focus({preventScroll:n})}if(r)return a(),qe;let o=requestAnimationFrame(a);return oi=o,()=>{oi===o&&(cancelAnimationFrame(o),oi=0)}}var ci={inert:new WeakMap,"aria-hidden":new WeakMap},li=`data-base-ui-inert`,ui={inert:new WeakSet,"aria-hidden":new WeakSet},di=new WeakMap,fi=0;function pi(e){return ui[e]}function mi(e){return e?fe(e)?e.host:mi(e.parentNode):null}var hi=(e,t)=>t.map(t=>{if(e.contains(t))return t;let n=mi(t);return e.contains(n)?n:null}).filter(e=>e!=null),gi=e=>{let t=new Set;return e.forEach(e=>{let n=e;for(;n&&!t.has(n);)t.add(n),n=n.parentNode}),t},_i=(e,t,n)=>{let r=[],i=e=>{e&&!n.has(e)&&Array.from(e.children).forEach(e=>{W(e)!==`script`&&(t.has(e)?i(e):r.push(e))})};return i(e),r};function vi(e,t,n,r,{mark:i=!0}){let a=null;r?a=`inert`:n&&(a=`aria-hidden`);let o=null,s=null,c=hi(t,e),l=i?_i(t,gi(c),new Set(c)):[],u=[],d=[];if(a){let e=ci[a],n=pi(a);s=n,o=e;let r=hi(t,Array.from(t.querySelectorAll(`[aria-live]`))),i=c.concat(r);_i(t,gi(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=(di.get(e)||0)+1;di.set(e,t),d.push(e),t===1&&e.setAttribute(li,``)}),fi+=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=(di.get(e)||0)-1;di.set(e,t),t||e.removeAttribute(li)}),--fi,fi||(ci.inert=new WeakMap,ci[`aria-hidden`]=new WeakMap,ui.inert=new WeakSet,ui[`aria-hidden`]=new WeakSet,di=new WeakMap)}}function yi(e,t={}){let{ariaHidden:n=!1,inert:r=!1,mark:i=!0}=t,a=J(e[0]).body;return vi(e,a,n,r,{mark:i})}var bi=0;function xi(e,t=`mui`){let[n,r]=l.useState(e),i=e||n;return l.useEffect(()=>{n??(bi+=1,r(`${t}-${bi}`))},[n,t]),i}var Si=Vn.useId;function Ci(e,t){if(Si!==void 0){let n=Si();return e??(t?`${t}-${n}`:n)}return xi(e,t)}function wi(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 Ti=wi(`https://base-ui.com/production-error`,`Base UI`),Ei=19;function Di(e){return Ei>=e}function Oi(e){if(!l.isValidElement(e))return null;let t=e,n=t.props;return(Di(19)?n?.ref:t.ref)??null}function ki(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function Ai(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 ji(e,t){return typeof e==`function`?e(t):e}function Mi(e,t){return typeof e==`function`?e(t):e}var Ni={};function Pi(e,t,n,r,i){if(!n&&!r&&!i&&!e)return Ii(t);let a=Ii(e);return t&&(a=Li(a,t)),n&&(a=Li(a,n)),r&&(a=Li(a,r)),i&&(a=Li(a,i)),a}function Fi(e){if(e.length===0)return Ni;if(e.length===1)return Ii(e[0]);let t=Ii(e[0]);for(let n=1;n<e.length;n+=1)t=Li(t,e[n]);return t}function Ii(e){return Vi(e)?{...Hi(e,Ni)}:Ri(e)}function Li(e,t){return Vi(t)?Hi(t,e):zi(e,t)}function Ri(e){let t={...e};for(let e in t){let n=t[e];Bi(e,n)&&(t[e]=Wi(n))}return t}function zi(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=ki(e.style,r);break;case`className`:e[n]=Ki(e.className,r);break;default:e[n]=Bi(n,r)?Ui(e[n],r):r}}return e}function Bi(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 Vi(e){return typeof e==`function`}function Hi(e,t){return Vi(e)?e(t):e??Ni}function Ui(e,t){return t?e?(...n)=>{let r=n[0];if(qi(r)){let i=r;Gi(i);let a=t(...n);return i.baseUIHandlerPrevented||e?.(...n),a}let i=t(...n);return e?.(...n),i}:Wi(t):e}function Wi(e){return e&&((...t)=>{let n=t[0];return qi(n)&&Gi(n),e(...t)})}function Gi(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Ki(e,t){return t?e?t+` `+e:t:e}function qi(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function Ji(e,t,n={}){let r=t.render;n.enabled!==!1&&(r=Qi(r));let i=Yi(t,n,r);if(n.enabled===!1)return null;let a=n.state??Ye;return $i(e,r,i,a)}function Yi(e,t,n){let{className:r,style:i}=e,{state:a=Ye,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?ji(r,a):void 0,d=l?Mi(i,a):void 0,f=l?Ai(a,c):Ye,p=l&&s?Xi(s):void 0,m=l?ki(f,p)??{}:Ye;return typeof document<`u`&&(l?m.ref=Array.isArray(o)?Pn([m.ref,Oi(n),...o]):Nn(m.ref,Oi(n),o):Nn(null,null)),l?(u!==void 0&&(m.className=Ki(m.className,u)),d!==void 0&&(m.style=ki(m.style,d)),m):Ye}function Xi(e){return Array.isArray(e)?Fi(e):Pi(void 0,e)}var Zi=Symbol.for(`react.lazy`);function Qi(e){if(e?.$$typeof!==Zi)return e;let t=l.Children.toArray(e)[0];return l.isValidElement(t)?t:e}function $i(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Pi(n,t.props);return e.ref=n.ref,l.cloneElement(t,e)}if(e&&typeof e==`string`)return ea(e,n);throw Error(Ti(8))}function ea(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 ta={style:{transition:`none`}},na={fallbackAxisSide:`none`},ra={fallbackAxisSide:`end`},ia={clipPath:`inset(50%)`,position:`fixed`,top:0,left:0},aa=e(n(),1),oa=l.createContext(null),sa=()=>l.useContext(oa),ca=ai(`portal`);function la(e={}){let{ref:t,container:n,componentProps:r=Ye,elementProps:i}=e,a=Ci(),o=sa()?.portalNode,[s,c]=l.useState(null),[u,d]=l.useState(null),f=$(e=>{e!==null&&d(e)}),p=l.useRef(null);U(()=>{if(n===null){p.current&&(p.current=null,d(null),c(null));return}let e=(n&&(de(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=Ji(`div`,r,{ref:[t,f],props:[{id:a,[ca]:``},i]}),h=s&&m?aa.createPortal(m,s):null;return{node:u,nodeId:l.isValidElement(m)?m.props.id:void 0,subtree:h}}var ua=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}=la({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&&ei(e)&&(e.type===`focusin`?y.current&&=(ni(u),!1):(ti(u),y.current=!0))}return Mn(q(u,`focusin`,e,!0),q(u,`focusout`,e,!0))},[u,b]),U(()=>{u&&x===!0&&y.current&&(ni(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)(oa.Provider,{value:C,children:[S&&u&&(0,Q.jsx)(Yn,{"data-type":`outside`,ref:p,onFocus:e=>{ei(e,u)?h.current?.focus():Xr(_?_.domReference:null)?.focus()}}),S&&u&&(0,Q.jsx)(`span`,{role:s,"aria-owns":d,style:ia}),u&&aa.createPortal(a,u),S&&u&&(0,Q.jsx)(Yn,{"data-type":`outside`,ref:m,onFocus:e=>{ei(e,u)?g.current?.focus():(Yr(_?_.domReference:null)?.focus(),_?.closeOnFocusOut&&_?.onOpenChange(!1,Z(`focus-out`,e.nativeEvent)))}})]})]})});function da(){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 fa=class{nodesRef={current:[]};events=da();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)}},pa=l.createContext(null),ma=l.createContext(null),ha=()=>l.useContext(pa)?.id||null,ga=e=>{let t=l.useContext(ma);return e??t};function _a(e){let t=Ci(),n=ga(e),r=ha();return U(()=>{if(!t)return;let e={id:t,parentId:r};return n?.addNode(e),()=>{n?.removeNode(e)}},[n,t,r]),t}function va(e){let{children:t,id:n}=e,r=ha();return(0,Q.jsx)(pa.Provider,{value:l.useMemo(()=>({id:n,parentId:r}),[n,r]),children:t})}function ya(e){let{children:t,externalTree:n}=e,r=Ke(()=>n??new fa).current;return(0,Q.jsx)(ma.Provider,{value:r,children:t})}function ba(e){return e==null?e:`current`in e?e.current:e}function xa(e,t){let n=le(xt(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 Sa=20,Ca=[];function wa(){Ca=Ca.filter(e=>e.deref()?.isConnected)}function Ta(e){wa(),e&&W(e)!==`body`&&(Ca.push(new WeakRef(e)),Ca.length>Sa&&(Ca=Ca.slice(-20)))}function Ea(){return wa(),Ca[Ca.length-1]?.deref()}function Da(e){return e?Gr(e)?e:qr(e)[0]||e:null}function Oa(e){if(e.hasAttribute(`tabindex`)&&!e.hasAttribute(`data-tabindex`)||!e.getAttribute(`role`)?.includes(`dialog`))return;let t=Kr(e).filter(e=>{let t=e.getAttribute(`data-tabindex`)||``;return Gr(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 ka(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=$t(v)&&C,T=zn(i),E=zn(a),D=zn(u),O=zn(_),k=ga(m),A=sa(),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=Nn(L,p,A?.beforeInsideRef),ee=Nn(R,A?.afterInsideRef),B=$e(),te=$e(),ne=rt(),re=A!=null,V=tn(y),H=$((e=V)=>e?qr(e):[]),ie=$(()=>h?.().filter(e=>e!=null)??[]);l.useEffect(()=>{if(r||!s)return;function e(e){e.key===`Tab`&&X(V,bt(J(V)))&&H().length===0&&!w&&mt(e)}return q(J(V),`keydown`,e)},[r,V,s,w,H]),l.useEffect(()=>{if(r||!_)return;let e=J(V);function t(){N.current=!1}function n(e){let t=xt(e),n=ie(),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,te.start(0,()=>{M.current=!1}))}function i(){I.current=`keyboard`}return Mn(q(e,`pointerdown`,n,!0),q(e,`pointerup`,t,!0),q(e,`pointercancel`,t,!0),q(e,`keydown`,i,!0),t)},[r,y,v,V,_,A,te,ie]),l.useEffect(()=>{if(r||!c)return;let e=J(V);function t(){M.current=!0,te.start(0,()=>{M.current=!1})}function n(e){let t=xt(e);Gr(t)&&(P.current=t)}function i(t){let n=t.relatedTarget,r=t.currentTarget,i=xt(t);s&&n==null&&i!=null&&X(y,i)&&Ta(i),queueMicrotask(()=>{let a=S(),c=g.context.triggerElements,l=ie(),u=n?.hasAttribute(ai(`focus-guard`))&&[L.current,R.current,A?.beforeInsideRef.current,A?.afterInsideRef.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,ba(f),ba(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&&(ri(k.nodesRef.current,a).find(e=>X(e.context?.elements.floating,n)||X(e.context?.elements.domReference,n))||ii(k.nodesRef.current,a).find(e=>[e.context?.elements.floating,tn(e.context?.elements.floating)].includes(n)||e.context?.elements.domReference===n)));if(r===v&&V&&Oa(V),o&&r!==v&&!jr(i)&&bt(e)===e.body){if(K(V)&&(V.focus(),o===`popup`)){ne.request(()=>{V.focus()});return}let e=H(),t=P.current,n=(t&&e.includes(t)?t:null)||e[e.length-1]||V;K(n)&&n.focus()}if(x.current.insideReactTree){x.current.insideReactTree=!1;return}(w||!s)&&n&&p&&!M.current&&(w||n!==Ea())&&(j.current=!0,g.setOpen(!1,Z(vn,t)))})}function a(){N.current||(x.current.insideReactTree=!0,B.start(0,()=>{x.current.insideReactTree=!1}))}let l=K(v)?v:null;if(y||l)return Mn(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,V,s,k,A,g,c,o,H,w,S,x,B,te,ne,d,f,ie]),l.useEffect(()=>{if(r||!y||!_)return;let e=Array.from(A?.portalNode?.querySelectorAll(`[${ai(`portal`)}]`)||[]),t=(k?ii(k.nodesRef.current,S()):[]).find(e=>$t(e.context?.elements.domReference||null))?.context?.elements.domReference,n=yi([y,...e,L.current,R.current,A?.beforeOutsideRef.current,A?.afterOutsideRef.current,...ie(),t,ba(f),ba(d),w?v:null].filter(e=>e!=null),{ariaHidden:s||w,mark:!1}),i=yi([y,...e].filter(e=>e!=null));return()=>{i(),n()}},[_,r,v,y,s,A,w,k,S,d,f,ie]),U(()=>{if(!_||r||!K(V))return;F.current=``,I.current=``;let e=J(V),t=bt(e);queueMicrotask(()=>{let n=T.current,r=typeof n==`function`?n(D.current||``):n;if(r===void 0||r===!1||X(V,t))return;let i=null,a=()=>(i??=H(V),i[0]||V),o;o=r===!0||r===null?a():ba(r),o||=a();let s=X(V,bt(e));si(o,{preventScroll:o===V,shouldFocus(){if(!O.current)return!1;if(s)return!0;let t=bt(e);return!(t!==o&&X(V,t))}})})},[r,_,V,H,T,D,O]),U(()=>{if(r||!V)return;let e=J(V),t=bt(e),n=D.current==null;Ta(t);function i(e){if(e.open||(F.current=xa(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(gt(e.nativeEvent)||_t(e.nativeEvent))j.current=!1;else{let e=!1;J(V).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&&W(t)!==`body`?t:null,s=n?o||a:a||o;return s||=Ea()||null,typeof i==`boolean`?s:ba(i)||s||null}return()=>{b.off(`openchange`,i);let t=bt(e),n=ie(),r=X(y,t)||n.some(e=>e===t||X(e,t))||k&&ri(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=Da(c),i=typeof o!=`boolean`;if(o&&!j.current&&K(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,V,E,D,b,k,v,S,ie]),U(()=>{if(!Ve||_||!y)return;let e=bt(J(y));K(e)&&Zt(e)&&X(y,e)&&e.blur()},[_,y]),U(()=>{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]),U(()=>{if(!r&&V)return Oa(V),()=>{queueMicrotask(wa)}},[r,V]);let ae=!r&&(!s||!w)&&(re||s);return(0,Q.jsxs)(l.Fragment,{children:[ae&&(0,Q.jsx)(Yn,{"data-type":`inside`,ref:z,onFocus:e=>{if(s){let e=H();si(e[e.length-1])}else A?.portalNode&&(j.current=!1,ei(e,A.portalNode)?Yr(v)?.focus():ba(f??A.beforeOutsideRef)?.focus())}}),n,ae&&(0,Q.jsx)(Yn,{"data-type":`inside`,ref:ee,onFocus:e=>{s?si(H()[0]):A?.portalNode&&(c&&(j.current=!0),ei(e,A.portalNode)?Xr(v)?.focus():ba(d??A.afterOutsideRef)?.focus())}})]})}function Aa(e,t={}){let{enabled:n=!0,event:r=`click`,toggle:i=!0,ignoreMouse:a=!1,stickIfOpen:o=!0,touchOpenDelay:s=0,reason:c=ln}=t,u=`rootStore`in e?e.rootStore:e,d=u.context.dataRef,f=l.useRef(void 0),p=rt(),m=$e(),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=vt(e.pointerType,!0)&&_t(e.nativeEvent)?`virtual`:e.pointerType},onMouseDown(n){let i=f.current,o=n.nativeEvent,s=u.select(`open`);if(n.button!==0||r===`click`||vt(i,!0)&&a)return;let c=t(s,n.currentTarget,e=>e===`click`||e===`mousedown`),l=xt(o);if(Zt(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}vt(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}:Ye,[n,h])}function ja(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 Ma(e){return e!=null&&e.clientX!=null}function Na(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||Ma(c.current.openEvent))&&i.set(`positionReference`,ja(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=vt(f)?o:a;l.useEffect(()=>{if(!n){g(s);return}if(!y)return;function e(){d.current?.(),d.current=null}let t=le(o);function r(t){let n=xt(t);X(o,n)?e():_(t.clientX,t.clientY)}return!c.current.openEvent||Ma(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 Pa(){return!1}function Fa(e){return{escapeKey:typeof e==`boolean`?e:e?.escapeKey??!1,outsidePress:typeof e==`boolean`?e:e?.outsidePress??!0}}function Ia(e,t={}){let{enabled:n=!0,escapeKey:r=!0,outsidePress:i=!0,outsidePressEvent:a=`sloppy`,referencePress:o=Pa,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=ga(c),g=$(typeof i==`function`?i:()=>!1),_=typeof i==`function`?g:i,v=_!==!1,y=$(()=>a),{escapeKey:b,outsidePress:x}=Fa(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=$e(),A=$e(),j=$(()=>{A.clear(),p.current.insideReactTree=!1}),M=$(e=>{let t=p.current.floatingContext?.nodeId;return(h?ri(h.nodesRef.current,t):[]).some(t=>t.context?.open&&!t.context.dataRef.current[e])}),N=$(e=>Yt(e,u.select(`floatingElement`))||Yt(e,u.select(`domReferenceElement`))),P=$(e=>{o()&&u.setOpen(!1,Z(ln,e.nativeEvent))}),F=$(e=>{if(!d||!n||!r||e.key!==`Escape`||E.current||!b&&M(`__escapeKeyBubbles`))return;let t=Z(yn,ht(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=xt(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 Qe,t=new Qe,i=J(f);function a(){e.clear(),E.current=!0}function o(){e.start(Ve?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&&ri(h.nodesRef.current,t).some(t=>Yt(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=xt(e),r=`[${ai(`inert`)}]`,i=G(n)?n.getRootNode():null,a=Array.from((fe(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=G(n)?n:null;for(;s&&!Ce(s);){let e=Ee(s);if(Ce(e)||!G(e))break;s=e}if(!(a.length&&G(n)&&!Xt(n)&&!X(n,u.select(`floatingElement`))&&a.every(e=>!X(s,e)))){if(K(n)&&!(`touches`in e)){let t=Ce(n),r=we(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&&!gt(e)&&!T.current)return;if(w.current){t.clear(),w.current=!1;return}}(typeof _!=`function`||_(e))&&(M(`__outsidePressBubbles`)||(u.setOpen(!1,Z(fn,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=xt(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 ee(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 B(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 te(e){L(e,B)}function ne(e){l()===`sloppy`&&O.current&&!N(e)&&(O.current.dismissOnTouchEnd&&A(e),k.clear(),O.current=null)}function re(e){L(e,ne)}let V=Mn(r&&Mn(q(i,`keydown`,F),q(i,`compositionstart`,a),q(i,`compositionend`,o)),v&&Mn(q(i,`click`,z,!0),q(i,`pointerdown`,z,!0),q(i,`pointerup`,ee,!0),q(i,`pointercancel`,ee,!0),q(i,`mousedown`,z,!0),q(i,`mouseup`,ee,!0),q(i,`touchstart`,R,{capture:!0,passive:!0}),q(i,`touchmove`,te,{capture:!0,passive:!0}),q(i,`touchend`,re,{capture:!0,passive:!0})));return()=>{V(),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]),ee=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:ee,trigger:z}:{},[n,z,ee])}function La(e,t,n){let{reference:r,floating:i}=e,a=cr(t),o=lr(t),s=sr(o),c=ir(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=ar(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function Ra(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}=rr(t,e),p=xr(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=Sr(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=Sr(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 za=50,Ba=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:Ra},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=La(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<za&&(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}=La(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},Va=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}=rr(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=ir(r),_=cr(o),v=ir(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[yr(o)]:dr(o)),x=p!==`none`;!d&&x&&b.push(...vr(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=ur(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`||_===cr(t)||T.every(e=>cr(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=cr(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{}}}},Ha=new Set([`left`,`top`]);async function Ua(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ir(n),s=ar(n),c=cr(n)===`y`,l=Ha.has(o)?-1:1,u=a&&c?-1:1,d=rr(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var Wa=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await Ua(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},Ga=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=rr(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=cr(i),p=or(f),m=u[p],h=u[f],g=(e,t)=>nr(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},Ka=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=rr(e,t),u={x:n,y:r},d=cr(i),f=or(d),p=u[f],m=u[d],h=rr(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=Ha.has(ir(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},qa=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=rr(e,t),c=await i.detectOverflow(t,s),l=ir(n),u=ar(n),d=cr(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=Xn(p-c[m],g),y=Xn(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*Zn(c.left,c.right):S=p-2*Zn(c.top,c.bottom)),await o({...t,availableWidth:C,availableHeight:S});let w=await i.getDimensions(a.floating);return f!==w.width||p!==w.height?{reset:{rects:!0}}:{}}}};function Ja(e){let t=we(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=K(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Qn(n)!==a||Qn(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Ya(e){return G(e)?e:e.contextElement}function Xa(e){let t=Ya(e);if(!K(t))return er(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ja(t),o=(a?Qn(n.width):n.width)/r,s=(a?Qn(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Za=er(0);function Qa(e){let t=le(e);return!Se()||!t.visualViewport?Za:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function $a(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===le(e)}function eo(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Ya(e),o=er(1);t&&(r?G(r)&&(o=Xa(r)):o=Xa(e));let s=$a(a,n,r)?Qa(a):er(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=le(a),t=G(r)?le(r):r,n=e,i=ke(n);for(;i&&t!==n;){let e=Xa(i),t=i.getBoundingClientRect(),r=we(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=le(i),i=ke(n)}}return Sr({width:u,height:d,x:c,y:l})}function to(e,t){let n=Te(e).scrollLeft;return t?t.left+n:eo(ue(e)).left+n}function no(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-to(e,n),y:n.top+t.scrollTop}}function ro(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=ue(r),s=t?he(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=er(1),u=er(0),d=K(r);if((d||!a)&&((W(r)!==`body`||pe(o))&&(c=Te(r)),d)){let e=eo(r);l=Xa(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?no(o,c):er(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 io(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function ao(e){let t=Te(e),n=e.ownerDocument.body,r=Zn(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Zn(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+to(e),o=-t.scrollTop;return we(n).direction===`rtl`&&(a+=Zn(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var oo=25;function so(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=le(e),a=ue(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Se()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(to(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<=oo&&(s-=o)}return{width:s,height:c,x:l,y:u}}function co(e,t){let n=eo(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Xa(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function lo(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=so(e,n,t);else if(t===`document`)r=ao(ue(e));else if(G(t))r=co(t,n);else{let n=Qa(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Sr(r)}function uo(e,t){let n=t.get(e);if(n)return n;let r=Oe(e,[],!1).filter(e=>G(e)&&W(e)!==`body`),i=null,a=we(e).position===`fixed`,o=a?Ee(e):e;for(;G(o)&&!Ce(o);){let e=we(o),t=be(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Ee(o)}return t.set(e,r),r}function fo(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?he(t)?[]:uo(t,this._c):[].concat(n),r],o=lo(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=lo(t,a[e],i);s=Zn(n.top,s),c=Xn(n.right,c),l=Xn(n.bottom,l),u=Zn(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function po(e){let{width:t,height:n}=Ja(e);return{width:t,height:n}}function mo(e,t,n){let r=K(t),i=ue(t),a=n===`fixed`,o=eo(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=er(0);if((r||!a)&&((W(t)!==`body`||pe(i))&&(s=Te(t)),r)){let e=eo(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=to(i));let l=i&&!r&&!a?no(i,s):er(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 ho(e){return we(e).position===`static`}function go(e,t){if(!K(e)||we(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return ue(e)===n&&(n=n.ownerDocument.body),n}function _o(e,t){let n=le(e);if(he(e))return n;if(!K(e)){let t=Ee(e);for(;t&&!Ce(t);){if(G(t)&&!ho(t))return t;t=Ee(t)}return n}let r=go(e,t);for(;r&&me(r)&&ho(r);)r=go(r,t);return r&&Ce(r)&&ho(r)&&!be(r)?n:r||xe(e)||n}var vo=async function(e){let t=this.getOffsetParent||_o,n=this.getDimensions,r=await n(e.floating);return{reference:mo(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yo(e){return we(e).direction===`rtl`}var bo={convertOffsetParentRelativeRectToViewportRelativeRect:ro,getDocumentElement:ue,getClippingRect:fo,getOffsetParent:_o,getElementRects:vo,getClientRects:io,getDimensions:po,getScale:Xa,isElement:G,isRTL:yo};function xo(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function So(e,t,n){let r=null,i,a=ue(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=$n(d),h=$n(a.clientWidth-(u+f)),g=$n(a.clientHeight-(d+p)),_=$n(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Zn(0,Xn(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!xo(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=le(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Co(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=Ya(e),u=i||a?[...l?Oe(l):[],...t?Oe(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?So(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?eo(e):null;c&&g();function g(){let t=eo(e);h&&!xo(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 wo=Wa,To=Ga,Eo=Va,Do=qa,Oo=Ka,ko=(e,t,n)=>{let r=new Map,i=n??{},a={...bo,...i.platform,_c:r};return Ba(e,t,{...i,platform:a})},Ao=typeof document<`u`?l.useLayoutEffect:function(){};function jo(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(!jo(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)&&!jo(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Mo(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function No(e,t){let n=Mo(e);return Math.round(t*n)/n}function Po(e){let t=l.useRef(e);return Ao(()=>{t.current=e}),t}function Fo(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);jo(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=Po(c),O=Po(i),k=Po(u),A=l.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),ko(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!jo(T.current,t)&&(T.current=t,aa.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);Ao(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[u]);let j=l.useRef(!1);Ao(()=>(j.current=!0,()=>{j.current=!1}),[]),Ao(()=>{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=No(N.floating,d.x),r=No(N.floating,d.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Mo(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 Io=(e,t)=>{let n=wo(e);return{name:n.name,fn:n.fn,options:[e,t]}},Lo=(e,t)=>{let n=To(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ro=(e,t)=>({fn:Oo(e).fn,options:[e,t]}),zo=(e,t)=>{let n=Eo(e);return{name:n.name,fn:n.fn,options:[e,t]}},Bo=(e,t)=>{let n=Do(e);return{name:n.name,fn:n.fn,options:[e,t]}},Vo=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})),Ho=t(((e,t)=>{t.exports=Vo()})),Uo=t((e=>{var t=r(),n=Ho();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}})),Wo=t(((e,t)=>{t.exports=Uo()})),Go=[],Ko=void 0;function qo(){return Ko}function Jo(e){Go.push(e)}function Yo(e){let t=(t,n)=>{let r=Ke(Zo).current,i;try{Ko=r;for(let e of Go)e.before(r);i=e(t,n);for(let e of Go)e.after(r);r.didInitialize=!0}finally{Ko=void 0}return i};return t.displayName=e.displayName||e.name,t}function Xo(e){return l.forwardRef(Yo(e))}function Zo(){return{didInitialize:!1}}var Qo=Ho(),$o=Wo(),es=Di(19)?rs:is;function ts(e,t,n,r,i){return es(e,t,n,r,i)}function ns(e,t,n,r,i){let a=l.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,Qo.useSyncExternalStore)(e.subscribe,a,a)}Jo({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,Qo.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function rs(e,t,n,r,i){let a=qo();if(!a)return ns(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 is(e,t,n,r,i){return(0,$o.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var as=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 ts(this,e,t,n,r)}},os=class extends as{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){l.useDebugValue(e);let n=this;U(()=>{n.state[e]!==t&&n.set(e,t)},[n,e,t])}useSyncedValueWithCleanup(e,t){let n=this;U(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;U(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){l.useDebugValue(e);let n=this,r=t!==void 0;U(()=>{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),ts(this,this.selectors[e],t,n,r)}useContextCallback(e,t){l.useDebugValue(e);let n=$(t??qe);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)}})}},ss={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},cs=class extends os{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:da(),nested:n,triggerElements:i},ss),this.syncOnly=t}syncOpenEvent=(e,t)=>{(!e||!this.state.open||t!=null&&yt(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 ls(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 cs({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),U(()=>{let e={open:s,floatingId:i,referenceElement:c,floatingElement:u};G(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 us(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),U(()=>{if(!e&&o&&i!==`ending`&&n){let e=nt.request(()=>{a(`ending`)});return()=>{nt.cancel(e)}}},[e,o,i,n]),U(()=>{if(!e||t)return;let n=nt.request(()=>{a(void 0)});return()=>{nt.cancel(n)}},[t,e]),U(()=>{if(!e||!t)return;e&&o&&i!==`idle`&&a(`starting`);let n=nt.request(()=>{a(`idle`)});return()=>{nt.cancel(n)}},[t,e,o,i]),{mounted:o,setMounted:s,transitionStatus:i}}var ds=null;function fs(e){if(!ds){let e=[];ds=e,queueMicrotask(()=>{ds=null,aa.flushSync(()=>{for(let t of e)t()})})}ds.push(e)}function ps(e,t=!1,n=!1){let r=rt();return $((i,a=null)=>{r.cancel();let o=ba(e);if(o==null)return;let s=o,c=()=>{if(!n){aa.flushSync(i);return}fs(()=>{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=Ot;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 ms(e){let{enabled:t=!0,open:n,ref:r,batch:i=!1,onComplete:a}=e,o=$(a),s=ps(r,n,i);l.useEffect(()=>{if(!t)return;let e=new AbortController;return s(o,e.signal),()=>{e.abort()}},[t,n,o,s])}var hs={tabIndex:-1,[St]:``};function gs(e){return t=>t!==`touch`||e.current}function _s(e,t=!1){let n=Ci(),r=ha()!=null,i=Ke(()=>e(n,r)).current;return ls({popupStore:i,treatPopupAsFloatingElement:t,floatingRootContext:i.state.floatingRootContext,floatingId:n,nested:r,onOpenChange:i.setOpen}),i}function vs({handle:e,store:t}){return U(()=>e.attachStore(t),[e,t]),null}function ys(e){let t=e.context.triggerElements.size;e.select(`open`)&&e.state.triggerCount!==t&&e.set(`triggerCount`,t)}function bs(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),ys(a))}r!==null&&e!==void 0&&(n.current={store:t,id:e,element:r},t.context.triggerElements.add(e,r),ys(t))})}function xs(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 Ss(e){let t=!1;return e.preventUnmountOnClose=()=>{t=!0},()=>t}function Cs(e,t,n,r={}){let i=n.reason,a=i===un,o=t&&i===`trigger-focus`,s=!t&&(i===`trigger-press`||i===`escape-key`),c=Ss(n);if(e.context.onOpenChange?.(t,n),n.isCanceled)return;r.onBeforeDispatch?.(),e.state.floatingRootContext.dispatchOpenChange(t,n);let l=()=>{let i=xs(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?aa.flushSync(l):l()}function ws(e,t,n,r){let i=n.useState(`isMountedByTrigger`,e),a=bs(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 U(()=>(s(t.current),()=>s(null)),[s,t,n,e]),U(()=>{if(i){let e={activeTriggerElement:t.current,...r};n.update(e)}},[i,n,t,...Object.values(r)]),{registerTrigger:s,isMountedByThisTrigger:i}}function Ts(e,t={}){let{closeOnActiveTriggerUnmount:n=!1}=t,r=l.useRef(null),i=e.useState(`open`);U(()=>{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(cn);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 Es(e,t,n,r){let{mounted:i,setMounted:a,transitionStatus:o}=us(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 ms({enabled:i&&!e&&!c,open:e,ref:t.context.popupRef,onComplete(){e||l()}}),{forceUnmount:l,transitionStatus:o}}function Ds(e,t){e.useSyncedValues(t),U(()=>()=>{e.update({activeTriggerProps:Ye,inactiveTriggerProps:Ye,popupProps:Ye})},[e])}function Os(e,t){U(()=>{!t&&e.state.openMethod!==null&&e.set(`openMethod`,null)},[t,e]),U(()=>()=>{e.state.openMethod!==null&&e.set(`openMethod`,null)},[e])}var ks=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 As(e,t,n=!1){return{open:!1,openProp:void 0,mounted:!1,transitionStatus:void 0,floatingRootContext:new cs({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:Ye,inactiveTriggerProps:Ye,popupProps:Ye}}var js=e=>e.triggerIdProp??e.activeTriggerId,Ms=e=>e.openProp??e.open,Ns=e=>(e.popupElement?.id??e.floatingId)||void 0;function Ps(e,t){return t!==void 0&&Ms(e)&&js(e)===t}function Fs(e,t){return Ps(e,t)?!0:t!==void 0&&Ms(e)&&js(e)==null&&e.triggerCount===1}var Is={open:Ms,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:js,activeTriggerElement:e=>e.mounted?e.activeTriggerElement:null,popupId:Ns,isTriggerActive:(e,t)=>t!==void 0&&js(e)===t,isOpenedByTrigger:(e,t)=>Ps(e,t),isMountedByTrigger:(e,t)=>t!==void 0&&js(e)===t&&e.mounted,triggerProps:(e,t)=>t?e.activeTriggerProps:e.inactiveTriggerProps,triggerPopupId:(e,t)=>Fs(e,t)?Ns(e):void 0,popupProps:e=>e.popupProps,popupElement:e=>e.popupElement,positionerElement:e=>e.positionerElement};function Ls(e){let t=l.useCallback(t=>e===void 0?qe:e.subscribeStore(t),[e]),n=l.useCallback(()=>e===void 0?void 0:e.store,[e]);return(0,Qo.useSyncExternalStore)(t,n,()=>e?.serverStore)}function Rs(e){let{open:t=!1,onOpenChange:n,elements:r={}}=e,i=Ci(),a=ha()!=null,o=Ke(()=>new cs({open:t,transitionStatus:void 0,onOpenChange:n,referenceElement:r.reference??null,floatingElement:r.floating??null,triggerElements:new ks,floatingId:i,syncOnly:!1,nested:a})).current;return U(()=>{let e={open:t,floatingId:i};r.reference!==void 0&&(e.referenceElement=r.reference,e.domReferenceElement=G(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 zs(e){return Bs(e,e.rootContext)}function Bs(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),_=ga(r),v=l.useMemo(()=>({reference:i,floating:a,domReference:o}),[i,a,o]),y=Fo({...e,elements:{...v,...u&&{reference:u}}}),b=G(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=G(e)?{getBoundingClientRect:()=>e.getBoundingClientRect(),getClientRects:()=>e.getClientRects(),contextElement:e}:e;d(t),y.refs.setReference(t)},[y.refs]),C=l.useCallback(e=>{(G(e)||e===null)&&(g.current=e,p(e)),(G(y.refs.reference.current)||y.refs.reference.current===null||e!==null&&!G(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 U(()=>{o&&(g.current=o)},[o]),U(()=>{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 Vs=ze&&Ve;function Hs(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=$e();l.useEffect(()=>{let e=i.select(`domReferenceElement`);if(!n)return;let t=le(e);function r(){let e=i.select(`domReferenceElement`);!i.select(`open`)&&K(e)&&e===bt(J(e))&&(s.current=!0,c.current=e)}function a(){u.current=!0}function o(){u.current=!1}return Mn(q(t,`blur`,r),Vs&&q(t,`keydown`,a,!0),Vs&&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`);G(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=xt(t.nativeEvent);if(G(a)){if(Vs&&!t.relatedTarget){if(!u.current&&!Zt(a))return}else if(!en(a))return}let o=Jt(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(dn,l,f));return}d.start(p,()=>{s.current||i.setOpen(!0,Z(dn,l,f))})},onBlur(t){e();let n=t.relatedTarget,r=t.nativeEvent,a=G(n)&&n.hasAttribute(ai(`focus-guard`))&&n.getAttribute(`data-type`)===`outside`;d.start(0,()=>{let e=i.select(`domReferenceElement`),t=bt(J(e));(n||t!==e)&&(X(o.current.floatingContext?.refs.floating.current,t)||X(e,t)||a||Jt(n??t,i.context.triggerElements)||i.setOpen(!1,Z(dn,r)))})}}},[o,r,i,d]);return l.useMemo(()=>n?{reference:f,trigger:f}:{},[n,f])}var Us=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 Qe,this.restTimeout=new Qe,this.handleCloseOptions=void 0}static create(){return new e}dispose=()=>{this.openChangeTimeout.clear(),this.restTimeout.clear()};disposeEffect=()=>this.dispose},Ws=new WeakMap;function Gs(e){if(!e.performedPointerEventsMutation)return;let t=e.pointerEventsScopeElement;t&&Ws.get(t)===e&&(e.pointerEventsScopeElement?.style.removeProperty(`pointer-events`),e.pointerEventsReferenceElement?.style.removeProperty(`pointer-events`),e.pointerEventsFloatingElement?.style.removeProperty(`pointer-events`),Ws.delete(t)),e.performedPointerEventsMutation=!1,e.pointerEventsScopeElement=null,e.pointerEventsReferenceElement=null,e.pointerEventsFloatingElement=null}function Ks(e,t){let{scopeElement:n,referenceElement:r,floatingElement:i}=t,a=Ws.get(n);a&&a!==e&&Gs(a),Gs(e),e.performedPointerEventsMutation=!0,e.pointerEventsScopeElement=n,e.pointerEventsReferenceElement=r,e.pointerEventsFloatingElement=i,Ws.set(n,e),n.style.pointerEvents=`none`,r.style.pointerEvents=`auto`,i.style.pointerEvents=`auto`}function qs(e){let t=e.context.dataRef.current,n=Ke(()=>t.hoverInteractionState??Us.create()).current;return t.hoverInteractionState||=n,Xe(t.hoverInteractionState.disposeEffect),t.hoverInteractionState}function Js(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=ga(),f=ha(),p=qs(a),m=$e(),h=$(()=>on(u.current.openEvent?.type,p.interactedInside)),g=$(()=>sn(u.current.openEvent?.type)),_=$(()=>{Gs(p)});U(()=>{o||(p.pointerType=void 0,p.restTimeoutPending=!1,p.interactedInside=!1,_())},[o,p,_]),l.useEffect(()=>_,[_]),U(()=>{if(n&&o&&p.handleCloseOptions?.blockPointerEvents&&g()&&G(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 Ks(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&&ri(d.nodesRef.current,f).length>0)}function t(e){let t=rn(r,`close`,p.pointerType),n=()=>{a.setOpen(!1,Z(un,e)),d?.events.emit(`floating.closed`,e)};t?p.openChangeTimeout.start(t,n):(p.openChangeTimeout.clear(),n())}function o(e){let t=xt(e);if(!Qt(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(Jt(n.relatedTarget,a.context.triggerElements))return;let r=u.current.floatingContext?.nodeId??i,o=n.relatedTarget;if(!(d&&r&&G(o)&&ri(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(un,t)),d.events.emit(`floating.closed`,t)})}let y=s;return Mn(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 Ys={current:null};function Xs(e,t={}){let{enabled:n=!0,delay:r=0,handleClose:i=null,mouseOnly:a=!1,restMs:o=0,move:s=!0,triggerElementRef:c=Ys,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=ga(u),b=qs(g),x=l.useRef(!1),S=zn(i),C=zn(r),w=zn(o),T=zn(n),E=zn(m),D=zn(p),O=$(()=>on(_.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(!G(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=$(()=>{Gs(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===un,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=rn(C.current,`close`,b.pointerType);n?b.openChangeTimeout.start(n,()=>{g.setOpen(!1,Z(un,e)),y?.events.emit(`floating.closed`,e)}):t&&(b.openChangeTimeout.clear(),g.setOpen(!1,Z(un,e)),y?.events.emit(`floating.closed`,e))}let t=c.current??(d?g.select(`domReferenceElement`):null);if(!G(t))return;function r(e){if(b.openChangeTimeout.clear(),b.blockMouseMove=!1,a&&!vt(b.pointerType))return;let t=an(w.current),n=rn(C.current,`open`,b.pointerType),r=xt(e),i=e.currentTarget??null,o=g.select(`domReferenceElement`),s=i;if(G(r)&&!g.context.triggerElements.hasElement(r)){for(let e of g.context.triggerElements.elements())if(X(e,r)){s=e;break}}G(i)&&G(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&&G(s)&&G(o)&&X(o,s)&&d,p=t>0&&!n,m=c&&(l||d)||f,h=!l||c;if(m){k()&&g.setOpen(!0,Z(un,e,s));return}p||(n?b.openChangeTimeout.start(n,()=>{h&&k()&&g.setOpen(!0,Z(un,e,s))}):h&&k()&&g.setOpen(!0,Z(un,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(!Jt(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?Mn(q(t,`mousemove`,r,{once:!0}),q(t,`mouseenter`,r),q(t,`mouseleave`,i),l):Mn(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&&!vt(b.pointerType))return;if(i&&o&&b.handleCloseOptions?.blockPointerEvents){let e=g.select(`floatingElement`);if(e){let t=b.handleCloseOptions?.getScope?.()??n.ownerDocument.body;Ks(b,{scopeElement:t,referenceElement:n,floatingElement:e})}}let s=an(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(un,t,n))}b.pointerType===`touch`?aa.flushSync(()=>{c()}):o&&i?c():(b.restTimeoutPending=!0,b.restTimeout.start(s,c))}}},[n,b,O,A,a,g,w,k])}var Zs=`Escape`;function Qs(e){return Ve&&e.movementX===0&&e.movementY===0}function $s(e,t,n){switch(e){case`vertical`:return t;case`horizontal`:return n;default:return t||n}}function ec(e,t){return $s(t,e===`ArrowUp`||e===`ArrowDown`,e===`ArrowLeft`||e===`ArrowRight`)}function tc(e,t,n){return $s(t,e===`ArrowDown`,n?e===`ArrowLeft`:e===`ArrowRight`)||e===`Enter`||e===` `||e===``}function nc(e,t,n){return $s(t,n?e===wt:e===Tt,e===Dt)}function rc(e,t,n,r){return t===`both`||t===`horizontal`&&r?e===Zs:$s(t,n?e===Tt:e===wt,e===Et)}function ic(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=tn(E),A=$t(D),j=zn(k),M=ha(),N=ga(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),ee=l.useRef(T),B=l.useRef(!1),te=l.useRef(!1),ne=l.useRef(null),re=zn(g),V=zn(T),H=zn(o),ie=zn(b),ae=rt(),oe=rt(),se=$(()=>{function e(e){f?N?.events.emit(`virtualfocus`,e):ne.current=si(e,{sync:B.current,preventScroll:!0})}let t=n.current[F.current],r=te.current;t&&e(t),(B.current?e=>e():e=>ae.request(e))(()=>{let i=n.current[F.current]||t;i&&(t||e(i),G&&(r||!L.current)&&i.scrollIntoView?.({block:`nearest`,inline:`nearest`}))})});U(()=>{O.current.orientation=_},[O,_]),U(()=>{a&&(T&&E?(F.current=o??-1,P.current&&o!=null&&(te.current=!0,R())):z.current&&(F.current=-1,R()))},[a,T,E,o,R]),U(()=>{if(a){if(!T){B.current=!1;return}if(E){if(r==null){if(B.current=!1,H.current!=null)return;if(z.current&&(F.current=-1,se()),(!ee.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=>oe.request(e):queueMicrotask)(t),e+=1):(F.current=I.current==null||tc(I.current,_,d)||u?Tr(n):Er(n),I.current=null,R())};t()}}else wr(n.current,r)||(F.current=r,se(),te.current=!1)}}},[a,T,E,r,H,u,n,_,d,R,se,oe]),U(()=>{if(!a||E||!N||f||!z.current)return;let e=N.nodesRef.current,t=e.find(e=>e.id===M)?.context?.elements.floating,n=bt(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]),U(()=>{ee.current=T,z.current=!!E}),U(()=>{T||(I.current=null,P.current=p)},[T,p]);let ce=r!=null,W=$(e=>{if(!V.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=$(()=>Tr(n,re.current)),de=$(e=>{if(L.current=!1,B.current=!0,e.which===229||!V.current&&e.currentTarget===j.current)return;if(u&&rc(e.key,_,d,C)){ec(e.key,le())||mt(e),w.setOpen(!1,Z(bn,e.nativeEvent)),K(D)&&(f?N?.events.emit(`virtualfocus`,D):D.focus());return}let t=F.current,r=Tr(n,g),i=Er(n,g);if(A||(e.key===`Home`&&(mt(e),F.current=r,R(e)),e.key===`End`&&(mt(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(ec(e.key,_)){if(mt(e),T&&!f&&bt(e.currentTarget.ownerDocument)===e.currentTarget){F.current=tc(e.key,_,d)?r:i,R(e);return}tc(e.key,_,d)?c?t>=i?s&&t!==n.current.length?F.current=-1:(B.current=!1,F.current=r):F.current=Dr(n.current,{startingIndex:t,disabledIndices:g}):F.current=Math.min(i,Dr(n.current,{startingIndex:t,disabledIndices:g})):c?t<=r?s&&t!==-1?F.current=n.current.length:(B.current=!1,F.current=i):F.current=Dr(n.current,{startingIndex:t,decrement:!0,disabledIndices:g}):F.current=Math.max(r,Dr(n.current,{startingIndex:t,decrement:!0,disabledIndices:g})),wr(n.current,F.current)&&(F.current=-1),R(e)}}),G=l.useMemo(()=>({onFocus(e){B.current=!0,W(e)},onClick:({currentTarget:e})=>e.focus({preventScroll:!0}),onMouseMove(e){Qs(e)||(B.current=!0,te.current=!1,m&&W(e))},onPointerLeave(e){if(!V.current||!L.current||e.pointerType===`touch`)return;B.current=!0;let t=e.relatedTarget;if(m&&!n.current.includes(t)&&ie.current&&(ne.current?.(),ne.current=null,F.current=-1,R(e),!f)){let e=j.current,t=bt(J(e));e&&X(e,t)&&e.focus({preventScroll:!0})}}}),[W,V,j,m,n,R,ie,f]),fe=l.useMemo(()=>f&&T&&ce&&{"aria-activedescendant":`${y}-${r}`},[f,T,ce,y,r]),pe=l.useMemo(()=>({...A?{}:fe,onKeyDown(e){if(e.key===`Tab`&&e.shiftKey&&T&&!f){let t=xt(e.nativeEvent);if(t&&!X(j.current,t))return;mt(e),w.setOpen(!1,Z(vn,e.nativeEvent)),K(D)&&D.focus();return}de(e)},onPointerMove(e){Qs(e)||(L.current=!0)}}),[fe,de,j,A,w,T,f,D]),me=l.useMemo(()=>{function e(e){w.setOpen(!0,Z(bn,e.nativeEvent,e.currentTarget))}function t(e){p===`auto`&>(e.nativeEvent)&&(P.current=!f)}function n(e){P.current=p,p===`auto`&&_t(e.nativeEvent)&&(P.current=!0)}return{onKeyDown(t){let n=w.select(`open`);L.current=!1;let r=t.key.startsWith(`Arrow`),i=nc(t.key,le(),d),a=ec(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=ec(t.key,le());I.current=u&&e?null:t.key}if(u){i&&(mt(t),n?(F.current=ue(),R(t)):e(t));return}a&&(H.current!=null&&(F.current=H.current),mt(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,H,f]),he=l.useMemo(()=>({...fe,...me}),[fe,me]);return l.useMemo(()=>a?{reference:he,floating:pe,item:G,trigger:me}:{},[a,he,pe,me,G])}function ac(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=$e(),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&&!jr(n)||n?.matches(`:disabled`)?!1:o==null||!kr(Je,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===` `&&(mt(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!==` `&&(mt(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))});U(()=>{(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 oc=.1,sc=oc*oc,cc=.5;function lc(e,t,n,r,i,a){return r>=t!=a>=t&&e<=(i-n)*(t-r)/(a-r)+n}function uc(e,t,n,r,i,a,o,s,c,l){let u=!1;return lc(e,t,n,r,i,a)&&(u=!u),lc(e,t,i,a,o,s)&&(u=!u),lc(e,t,o,s,c,l)&&(u=!u),lc(e,t,c,l,n,r)&&(u=!u),u}function dc(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function fc(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 pc(e={}){let{blockPointerEvents:t=!1}=e,n=new Qe,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*sc;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=xt(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&&G(r.relatedTarget)&&X(u,r.relatedTarget))return;function y(){return!!(s&&ri(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=fc(d,f,D,x.top+1,O,S.bottom-1);break;case`bottom`:j=fc(d,f,D,S.top+1,O,x.bottom-1);break;case`left`:j=fc(d,f,S.right-1,A,x.left+1,k);break;case`right`:j=fc(d,f,x.right-1,A,S.left+1,k)}if(j)return;if(l&&!dc(d,f,x)){b();return}if(!g&&p(d,f)){b();return}let M=!1;switch(c){case`top`:{let n=T?cc/2:cc*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t+cc+1,o=C||T?S.bottom-cc:S.top,s=C?T?S.bottom-cc:S.top:S.bottom-cc;M=uc(d,f,r,a,i,a,S.left,o,S.right,s);break}case`bottom`:{let n=T?cc/2:cc*4,r=T||C?e+n:e-n,i=T?e-n:C?e+n:e-n,a=t-cc,o=C||T?S.top+cc:S.bottom,s=C?T?S.top+cc:S.bottom:S.top+cc;M=uc(d,f,r,a,i,a,S.left,o,S.right,s);break}case`left`:{let n=E?cc/2:cc*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e+cc+1,o=w||E?S.right-cc:S.left,s=w?E?S.right-cc:S.left:S.right-cc;M=uc(d,f,o,S.top,s,S.bottom,a,r,a,i);break}case`right`:{let n=E?cc/2:cc*4,r=E||w?t+n:t-n,i=E?t-n:w?t+n:t-n,a=e-cc,o=w||E?S.left+cc:S.right,s=w?E?S.left+cc:S.right:S.left+cc;M=uc(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 mc({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=Ia(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=xt(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 pt(r&&a===!0,o),e.useContextCallback(`onNestedDialogOpen`,(e,t)=>{u(e),f(t)}),U(()=>(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]),Ds(e,{activeTriggerProps:m.reference,inactiveTriggerProps:m.trigger,popupProps:m.floating,nestedOpenDialogCount:c,nestedOpenDrawerCount:d}),null}var hc=l.createContext(void 0);function gc(e){let t=l.useContext(hc);if(!e&&t===void 0)throw Error(Ti(27));return t}var _c={...Is,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},vc=class extends os{constructor(e,t,n){let r=new ks,i=yc(e,r,t,n);super(i,bc(r),_c)}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(xs(this.state,e,t.trigger)))}};function yc(e,t,n,r=!1){return{...As(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 bc(e){return{popupRef:l.createRef(),backdropRef:l.createRef(),internalBackdropRef:l.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:e,onOpenChange:void 0,onOpenChangeComplete:void 0}}function xc(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=gc(!0),b={modal:g,disablePointerDismissal:_,nested:y!=null,role:v},x=_s((e,t)=>new vc({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`);Os(x,S),Ts(x);let{forceUnmount:T}=Es(S,x);l.useImperativeHandle(u,()=>({unmount:T,close:()=>x.setOpen(!1,Z(En))}),[T,x]);let E=S||C;return(0,Q.jsxs)(hc.Provider,{value:x,children:[d&&(0,Q.jsx)(vs,{handle:d,store:x}),E&&(0,Q.jsx)(mc,{store:x,parentContext:y?.context,isDrawer:m}),typeof n==`function`?n({payload:w}):n]})}function Sc(e){return xc(`alert-dialog`,e)}var Cc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,forceRender:a=!1,...o}=e,s=gc(),c=s.useState(`open`),l=s.useState(`nested`),u=s.useState(`mounted`);return Ji(`div`,e,{state:{open:c,transitionStatus:s.useState(`transitionStatus`)},ref:[s.context.backdropRef,t],stateAttributesMapping:Kt,props:[{role:`presentation`,hidden:!u,style:{userSelect:`none`,WebkitUserSelect:`none`}},o],enabled:a||!l})}),wc=l.createContext(void 0);function Tc(e=!1){let t=l.useContext(wc);if(t===void 0&&!e)throw Error(Ti(16));return t}function Ec(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 Dc(e,t,{detail:n=0}={}){e.dispatchEvent(new(le(e)).PointerEvent(`click`,{bubbles:!0,cancelable:!0,composed:!0,detail:n,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,altKey:t.altKey,metaKey:t.metaKey}))}function Oc(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0,composite:a}=e,o=l.useRef(null),s=Tc(!0),c=a??s!==void 0,{props:u}=Ec({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:i}),d=l.useCallback(()=>{let e=o.current;kc(e)&&c&&t&&u.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,u.disabled,c]);return U(d,[d]),{getButtonProps:l.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:s,...l}=e;return Pi({onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Gi(e),o?.(e),e.baseUIHandlerPrevented))return;let n=e.target===e.currentTarget,r=e.currentTarget,a=kc(r),s=!i&&Ac(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(),Dc(r,e));return}if(!l||i||!d&&!u){n&&s&&d&&e.preventDefault();return}e.defaultPrevented||(e.preventDefault(),u&&(e.preventBaseUIHandler(),Dc(r,e)))},onKeyUp(e){if(!t){if(Gi(e),a?.(e),e.target===e.currentTarget&&i&&c&&kc(e.currentTarget)&&e.key===` `){e.preventDefault();return}e.baseUIHandlerPrevented||e.target===e.currentTarget&&!i&&!c&&!e.defaultPrevented&&e.key===` `&&(e.preventBaseUIHandler(),Dc(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 kc(e){return K(e)&&e.tagName===`BUTTON`}function Ac(e){return K(e)&&e.tagName===`A`&&!!e.href}var jc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,disabled:a=!1,nativeButton:o=!0,...s}=e,c=gc(),l=c.useState(`open`),{getButtonProps:u,buttonRef:d}=Oc({disabled:a,native:o}),f={disabled:a};function p(e){l&&c.setOpen(!1,Z(mn,e.nativeEvent))}return Ji(`button`,e,{state:f,ref:[t,d],props:[{onClick:p},s,u]})});function Mc(e){return Ci(e,`base-ui`)}var Nc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=gc(),c=Mc(a);return s.useSyncedValueWithCleanup(`descriptionElementId`,c),Ji(`p`,e,{ref:t,props:[{id:c},o]})}),Pc=l.createContext(void 0);function Fc(){let e=l.useContext(Pc);if(e===void 0)throw Error(Ti(26));return e}var Ic=new Set([`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Home`,`End`]),Lc=`--nested-dialogs`,Rc=`data-nested-dialog-open`,zc={...Gt,...Mt,nestedDialogOpen(e){return e?{[Rc]:``}:null}},Bc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,initialFocus:o,...s}=e,c=gc(),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`);Fc(),ms({open:_,ref:c.context.popupRef,onComplete(){_&&c.context.onOpenChangeComplete?.(!0)}});let C=o===void 0?gs(c.context.popupRef):o,w=g>0,T=c.useStateSetter(`popupElement`),E=Ji(`div`,e,{state:{open:_,nested:h,transitionStatus:b,nestedDialogOpen:w},props:[f,{id:S,"aria-labelledby":y,"aria-describedby":l,role:x,...hs,hidden:!m,onKeyDown(e){Ic.has(e.key)&&e.stopPropagation()},style:{[Lc]:g}},s],ref:[t,c.context.popupRef,T],stateAttributesMapping:zc});return(0,Q.jsx)(ka,{context:d,openInteractionType:v,disabled:!m,closeOnFocusOut:!u,initialFocus:C,returnFocus:a,modal:p!==!1,restoreFocus:`popup`,children:E})});function Vc(e){return Di(19)?e:e?`true`:void 0}var Hc=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}})}),Uc=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=gc(),a=i.useState(`mounted`),o=i.useState(`modal`),s=i.useState(`open`);return a||n?(0,Q.jsx)(Pc.Provider,{value:n,children:(0,Q.jsxs)(ua,{ref:t,...r,children:[a&&o===!0&&(0,Q.jsx)(Hc,{ref:i.context.internalBackdropRef,inert:Vc(!s)}),e.children]})}):null}),Wc=l.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,...o}=e,s=gc(),c=Mc(a);return s.useSyncedValueWithCleanup(`titleElementId`,c),Ji(`h2`,e,{ref:t,props:[{id:c},o]})});function Gc(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 Kc(e,t){let n=l.useRef(e),r=$(t);U(()=>{n.current!==e&&r(n.current),n.current=e},[e,r])}function qc(e,t){let{onClick:n,onPointerDown:r}=Gc($((n,r)=>{(typeof e==`function`?e():e)||t(r||(Ie?`touch`:``))}));return l.useMemo(()=>({onClick:n,onPointerDown:r}),[n,r])}function Jc(e){let[t,n]=l.useState(null),r=qc(e,n);return Kc(e,t=>{t&&!e&&n(null)}),l.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}var Yc=i(),Xc,Zc,Qc=e=>{Xc??=(0,Yc.createRoot)(document.body.appendChild(document.createElement(`div`))),Zc?.resolve(!1),Zc=e,Xc.render((0,Q.jsx)($c,{request:e,settle:t=>{Zc===e&&(Zc=void 0,Xc?.render(null),e.resolve(t))}}))};function $c({request:e,settle:t}){return(0,Q.jsx)(Sc,{open:!0,onOpenChange:e=>{e||t(!1)},children:(0,Q.jsxs)(Uc,{children:[(0,Q.jsx)(Cc,{className:`dialog-backdrop`}),(0,Q.jsxs)(Bc,{className:`dialog`,children:[(0,Q.jsx)(Nc,{className:`dialog-message`,children:e.message}),(0,Q.jsxs)(`div`,{className:`dialog-actions`,children:[e.cancelLabel&&(0,Q.jsx)(jc,{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 el=(e,{confirmLabel:t=`Confirm`,danger:n=!1}={})=>new Promise(r=>Qc({message:e,confirmLabel:t,cancelLabel:`Cancel`,danger:n,resolve:r})),tl=e=>new Promise(t=>Qc({message:e,confirmLabel:`OK`,resolve:()=>t()})),nl=l.createContext(void 0);function rl(e){let t=l.useContext(nl);if(t===void 0&&!e)throw Error(Ti(72));return t}var il={...Is,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},al=class extends os{constructor(e,t,n){let r=new ks;super(ol(e,r,t,n),sl(r),il)}setOpen=(e,t)=>{Cs(this,e,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(e){this.state.floatingRootContext.dispatchOpenChange(!1,Z(ln,e))}};function ol(e,t,n,r=!1){return{...As(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 sl(e){return{popupRef:l.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}var cl=Yo(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=_s((e,t)=>new al({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}),Ts(m,{closeOnActiveTriggerUnmount:!0});let{forceUnmount:b,transitionStatus:x}=Es(g,m),S=m.useState(`isInstantPhase`),C=m.useState(`instantType`),w=m.useState(`lastOpenChangeReason`),T=l.useRef(null);U(()=>{h&&t&&m.setOpen(!1,Z(Tn))},[h,t,m]),U(()=>{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]),U(()=>{g&&(_??m.set(`payload`,void 0))},[m,_,g]),l.useImperativeHandle(o,()=>({unmount:b,close:()=>m.setOpen(!1,Z(En))}),[b,m]);let E=g||v||!t&&a!==`none`;return(0,Q.jsxs)(nl.Provider,{value:m,children:[u&&(0,Q.jsx)(vs,{handle:u,store:m}),E&&(0,Q.jsx)(ll,{store:m,disabled:t,trackCursorAxis:a}),typeof p==`function`?p({payload:y}):p]})});function ll({store:e,disabled:t,trackCursorAxis:n}){let r=e.useState(`floatingRootContext`),i=Ia(r,{enabled:!t,referencePress:()=>e.select(`closeOnClick`)}),a=Na(r,{enabled:!t&&n!==`none`,axis:n===`none`?void 0:n}),o=l.useMemo(()=>Pi(a.reference,i.reference),[a.reference,i.reference]);return Ds(e,{activeTriggerProps:o,inactiveTriggerProps:o,popupProps:i.floating??Ye}),null}var ul=l.createContext(void 0);function dl(){return l.useContext(ul)}var fl=`data-base-ui-tooltip-trigger`;function pl(e){if(`composedPath`in e){let t=e.composedPath();for(let e=0;e<t.length;e+=1){let n=t[e];if(G(n))return n}}let t=e.target;return G(t)?t:null}function ml(e){let t=e;for(;t;){let e=t.closest(`[${fl}]`);if(e)return e;let n=t.getRootNode();t=`host`in n&&G(n.host)?n.host:null}return null}var hl=Xo(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=rl(!0),h=Ls(a)??m;if(!h)throw Error(Ti(82));let g=Mc(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}=ws(g,b,h,{payload:o,closeOnClick:u,closeDelay:x}),w=dl(),{activeIdRef:T,delayRef:E,isInstantPhase:D,hasProvider:O}=jn(y,{open:v}),k=qs(y);h.useSyncedValue(`isInstantPhase`,D);let A=h.useState(`disabled`),j=s??A,M=zn(j),N=h.useState(`trackCursorAxis`),P=h.useState(`disableHoverablePopup`),F=l.useRef(!1),I=$e(),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=ml(e);return n!==null&&n!==t&&X(t,n)}function ee(e){let t=z(e);return F.current=t,t&&(k.openChangeTimeout.clear(),k.restTimeout.clear(),k.restTimeoutPending=!1,I.clear()),t}let B=Xs(y,{enabled:!j,mouseOnly:!0,move:!1,handleClose:!P&&N!==`both`?pc():null,restMs:R,delay(){return d==null&&O?{close:rn(E.current,`close`)}:{close:x}},triggerElementRef:b,isActiveTrigger:_,isClosing:()=>h.select(`transitionStatus`)===`ending`,shouldOpen(){return!F.current}}),te=Hs(y,{enabled:!j}).reference,ne=e=>{let t=F.current,n=pl(e),r=ee(n),i=b.current,a=i&&n&&X(i,n);if(r&&h.select(`open`)&&h.select(`lastOpenChangeReason`)===`trigger-hover`){h.setOpen(!1,Z(un,e));return}if(t&&!r&&a&&!M.current&&!h.select(`open`)&&i&&vt(L.current)){let t=()=>{!F.current&&!M.current&&!h.select(`open`)&&h.setOpen(!0,Z(un,e,i))},n=R();n===0?(I.clear(),t()):I.start(n,t)}},re=h.useState(`triggerProps`,C);return Ji(`button`,e,{state:{open:v},ref:[t,S,b],props:[B,te,C||N!==`none`?re:void 0,{onMouseOver(e){ne(e.nativeEvent)},onFocus(e){z(pl(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,[qt]:j?``:void 0,[fl]:j?void 0:``},p],stateAttributesMapping:Ut})}),gl=l.createContext(void 0);function _l(){let e=l.useContext(gl);if(e===void 0)throw Error(Ti(70));return e}var vl=l.forwardRef(function(e,t){let{children:n,container:r,className:i,render:a,style:o,...s}=e,{node:c,subtree:u}=la({container:r,ref:t,componentProps:e,elementProps:s});return!u&&!c?null:(0,Q.jsxs)(l.Fragment,{children:[u,c&&aa.createPortal(n,c)]})}),yl=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e;return rl().useState(`mounted`)||n?(0,Q.jsx)(gl.Provider,{value:n,children:(0,Q.jsx)(vl,{ref:t,...r})}):null}),bl=l.createContext(void 0);function xl(){let e=l.useContext(bl);if(e===void 0)throw Error(Ti(71));return e}var Sl=l.createContext(void 0);function Cl(){return l.useContext(Sl)?.direction??`ltr`}var wl=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`}=rr(e,t)||{};if(l==null)return{};let f=xr(u),p={x:n,y:r},m=lr(i),h=sr(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=nr(k,j,A),N=!c.arrow&&ar(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}}}),Tl=(e,t)=>{let{name:n,fn:r}=wl(e);return{name:n,fn:r,options:[e,t]}},El={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}}}},Dl={sideX:`left`,sideY:`top`},Ol=`--available-width`,kl=`--available-height`,Al=`--anchor-width`,jl=`--anchor-height`,Ml=`--transform-origin`,Nl=Ol,Pl=kl;function Fl(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 Il(e,t,n){let{rects:r,placement:i}=e;return{side:Fl(t,ir(i),n),align:ar(i)||`center`,anchor:{width:r.reference.width,height:r.reference.height},positioner:{width:r.floating.width,height:r.floating.height}}}function Ll(e){return Rl(e,zs)}function Rl(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=zn(n),F=zn(_),I=Cl()===`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 ee=+(i===`bottom`),B=+(i===`top`),te=+(i===`right`),ne=+(i===`left`),re={boundary:c===`clipping-ancestors`?`clippingAncestors`:c,padding:z},V=l.useRef(null),H=zn(a),ie=zn(s),ae=typeof a==`function`?0:a,oe=typeof s==`function`?0:s,se=[];m&&se.push(m),se.push(Io(e=>{let t=Il(e,i,I),n=typeof H.current==`function`?H.current(t):H.current,r=typeof ie.current==`function`?ie.current(t):ie.current;return{mainAxis:n,crossAxis:r,alignmentAxis:r}},[ae,oe,I,i]));let ce=D===`none`&&E!==`shift`,W=!ce&&(d||k||E===`shift`),ue=E===`none`?null:zo({...re,padding:{top:z.top+1+ee,right:z.right+1+ne,bottom:z.bottom+1+B,left:z.left+1+te},mainAxis:!k&&E===`flip`,crossAxis:D===`flip`&&`alignment`,fallbackAxisSideDirection:O}),de=ce?null:Lo({...re,rootBoundary:A,mainAxis:D!==`none`,crossAxis:W,limiter:d||k?void 0:Ro(e=>{if(!V.current)return{};let{width:t,height:n}=V.current.getBoundingClientRect(),r=cr(ir(e.placement)),i=r===`y`?t:n,a=r===`y`?z.left+z.right:z.top+z.bottom;return{offset:i/2+a/2}})},[re,d,k,A,z,D]);E===`shift`||D===`shift`||o===`center`?se.push(de,ue):se.push(ue,de),se.push(Bo({...re,apply({elements:{floating:e},availableWidth:t,availableHeight:n,rects:r}){if(!F.current)return;let i=e.style;i.setProperty(Nl,`${t}px`),i.setProperty(Pl,`${n}px`);let a=le(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(Al,`${u}px`),i.setProperty(jl,`${d}px`)}}),Tl(e=>({element:V.current||J(e.elements.floating).createElement(`div`),padding:V.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=ir(r),u=ar(r),d=cr(l)===`y`,f=V.current,p=typeof a==`function`?a(Il(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 W&&d&&Math.abs(n.shift?.y||0)>p&&(h=`${s.reference.y+s.reference.height/2-c}px`),t.style.setProperty(Ml,d?`${m} ${h}`:`${h} ${m}`),{}}},El,x),U(()=>{!_&&g&&g.update({referenceElement:null,floatingElement:null,domReferenceElement:null,positionReference:null})},[_,g]);let G=l.useMemo(()=>({ancestorScroll:!p,elementResize:!p&&typeof ResizeObserver<`u`,layoutShift:!p&&typeof IntersectionObserver<`u`}),[p]),{refs:K,elements:fe,x:pe,y:me,middlewareData:he,update:ge,placement:_e,context:ve,isPositioned:ye,floatingStyles:be}=t({rootContext:g,open:h?_:void 0,placement:R,middleware:se,strategy:r,whileElementsMounted:h?void 0:(...e)=>Co(...e,G),nodeId:b,externalTree:C}),{sideX:xe,sideY:Se}=he.adaptiveOrigin||Dl,Ce=ye?r:`fixed`,we=l.useMemo(()=>{let e;return e=ye?x?{position:Ce,[xe]:pe,[Se]:me}:{...be,position:Ce}:{position:Ce,top:0,left:0},e[Nl]=`100vw`,e[Pl]=`100vh`,ye||(e.opacity=0),e},[x,Ce,xe,pe,Se,me,be,ye]),Te=l.useRef(null);U(()=>{if(!_)return;let e=P.current,t=typeof e==`function`?e():e,n=(zl(t)?t.current:t)||null;n!==Te.current&&(K.setPositionReference(n),Te.current=n)},[_,K,N,P]),l.useEffect(()=>{if(!_)return;let e=P.current;typeof e!=`function`&&zl(e)&&e.current!==Te.current&&(K.setPositionReference(e.current),Te.current=e.current)},[_,K,N,P]),l.useEffect(()=>{if(h&&_&&fe.reference&&fe.floating)return Co(fe.reference,fe.floating,ge,G)},[h,_,fe,ge,G]);let Ee=ir(_e),De=Fl(i,Ee,I),Oe=ar(_e)||`center`,ke=!!he.hide?.referenceHidden;U(()=>{S&&_&&ye&&Ee!==L&&T(Ee)},[S,_,ye,Ee,L]);let q=l.useMemo(()=>({position:`absolute`,top:he.arrow?.y,left:he.arrow?.x}),[he.arrow]),Ae=he.arrow?.centerOffset!==0;return l.useMemo(()=>({positionerStyles:we,arrowStyles:q,arrowRef:V,arrowUncentered:Ae,side:De,align:Oe,physicalSide:Ee,anchorHidden:ke,refs:K,context:ve,isPositioned:ye,update:ge}),[we,q,V,Ae,De,Oe,Ee,ke,K,ve,ye,ge])}function zl(e){return e!=null&&`current`in e}function Bl(e){return e===`starting`?ta:Ye}function Vl(e,t,{styles:n,transitionStatus:r,props:i,refs:a,hidden:o,inert:s=!1}){let c={...n};return s&&(c.pointerEvents=`none`),Ji(`div`,e,{state:t,ref:a,props:[{role:`presentation`,hidden:o,style:c},Bl(r),i],stateAttributesMapping:Gt})}var Hl=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=ra,style:_,...v}=e,y=rl(),b=_l(),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=Ll({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=Vl(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)(bl.Provider,{value:O,children:k})}),Ul=l.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=rl(),{side:s,align:c}=xl(),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`);ms({open:l,ref:o.context.popupRef,onComplete(){l&&o.context.onOpenChangeComplete?.(!0)}}),Js(p,{enabled:!m,closeDelay:h});let g=o.useStateSetter(`popupElement`);return Ji(`div`,e,{state:{open:l,side:s,align:c,instant:u,transitionStatus:d},ref:[t,o.context.popupRef,g],props:[hs,f,Bl(d),a],stateAttributesMapping:Kt})});function Wl({label:e,side:t=`top`,children:n}){return(0,Q.jsxs)(cl,{children:[(0,Q.jsx)(hl,{render:n}),(0,Q.jsx)(yl,{children:(0,Q.jsx)(Hl,{className:`tooltip-positioner`,side:t,sideOffset:8,collisionPadding:8,children:(0,Q.jsx)(Ul,{className:`tooltip-popup`,children:e})})})]})}var Gl={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}},Kl=Object.keys(Gl);Object.fromEntries(Kl.map(e=>[e,Gl[e].color]));var ql={default:`idle`,working:`working`,sleeping:`sleeping`},Jl={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`},Yl={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 Xl(e){let t=e.trim(),n=t.match(/^hsla?\(\s*([\d.]+)(?:deg)?[,\s]+([\d.]+)%[,\s]+([\d.]+)%/i);if(n)return nu([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 Zl(e){let t=Xl(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 Ql=`#1E1A33`,$l=`#F7F5F2`;function eu(e){return Zl(e)<.13?$l:Ql}function tu([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 nu([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 ru([e,t,n]){return`hsl(${(e*360).toFixed(1)} ${(t*100).toFixed(1)}% ${(n*100).toFixed(1)}%)`}var iu=e=>Math.min(1,Math.max(0,e));function au(e,t,n=0){let r=Xl(e);if(!r)return e;let[i,a,o]=tu(r);return ru([i,iu(a+n+(t<0?-t*.25:0)),iu(o+t)])}var ou=[`default`,`working`,`sleeping`],su=.68,cu=26,lu=.2,uu={height:cu,time:su,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},du=(e,t)=>t?e.clickSquashTime:lu*e.time,fu=(e,t)=>du(e,t)+e.time+pu[e.squashEase]*(t?e.clickSquashTime:e.squashTime)+Math.max(0,e.groundTime)+e.riseTime+Math.max(0,e.land)+.05,pu={sharp:0,pulse:2/7,soft:.5,bouncy:.144},mu=(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}}},hu=(e,t)=>1+.25*gu(e,t),gu=(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)},_u=e=>Math.exp(-((Math.min(Math.abs(e),Math.abs(e-1))/.11)**2)),vu=Math.PI/180,yu=Math.PI*2,bu={default:1.2,working:.7,sleeping:1.4},xu=1;function Su(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 Cu(e,t,n,r){return e+(t-e)*(1-Math.exp(-n*r))}var wu=e=>e<.5?4*e*e*e:1-(-2*e+2)**3/2,Tu=e=>.5-.5*Math.cos(Math.PI*e),Eu=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=Cu(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}},Du=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))}},Ou=35*vu,ku=14*vu,Au=3.2*vu,ju=2.6,Mu={default:{pitch:0,roll:0,y:0,lookX:0,lookY:0},working:{pitch:5*vu,roll:0,y:0,lookX:0,lookY:0},sleeping:{pitch:-16*vu,roll:6*vu,y:3,lookX:0,lookY:1}},Nu=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 Du(.17),this.blinkAgain=!1,this.dart=new Du(.12),this.dartX=0,this.dartY=0,this.flip=new Du(fu(uu,!1)),this.flipPoked=!1,this.jump={...uu},this.flipSide=1,this.nod=new Du(1.7),this.hopPhase=0,this.hopCount=0,this.hopGain=0,this.laughEv=new Du(.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=Su(Math.floor(e*1e6)+1);let n=this.rand;this.yawW=new Eu(n,36*vu,1.1,2.6,3,!0),this.pitchW=new Eu(n,10*vu,1.1,2.6,2.6,!0),this.rollW=new Eu(n,5*vu,1.6,3.2,2,!0),this.lookXW=new Eu(n,3.6,.5,2,14),this.lookYW=new Eu(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]=+(ou[t]===e);this.tr=1}else this.wFrom=[r[0],r[1],r[2]],this.tr=0,this.trDuration=n===`sleeping`?xu:bu[e];switch(e){case`default`:this.yawW.set(Ou,2.6,5.4,2),this.pitchW.set(ku,2.8,5.8,1.8),this.rollW.set(Au,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*vu,.9,1.8,4),this.pitchW.set(3*vu,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*vu,3,6,.7),this.pitchW.set(3*vu,3,6,.7),this.rollW.set(2*vu,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=fu(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=Tu(this.tr);for(let e=0;e<3;e++){let n=+(ou[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=Mu[ou[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*Ou*r*this.turnK),this.pitchW.aim(n*ku*r),this.rollW.aim(e*Au*r*this.turnK),this.gazeAt=t+ju+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=Cu(this.ptrS,this.ptrTargetS,8,e),this.ptrX=Cu(this.ptrX,this.ptrTargetX,14,e),this.ptrY=Cu(this.ptrY,this.ptrTargetY,14,e);let c=this.ptrS,l=1-.75*c;this.baseYaw=Cu(this.baseYaw,this.yawW.value*l+22*vu*this.ptrX*c,5,e);let u=s.pitch+this.pitchW.value*l-12*vu*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=>yu*(1.5*e+.9*wu(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=fu(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=du(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+=yu*e.spin*wu(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):_u(e-1),c=Math.max(0,e.groundTime),l=pu[e.squashEase]*o,u=a-l-c,d=a<=l?gu(a/o,e.squashEase):u<=0?hu((a-l)/c,e.groundEase):mu(u/e.riseTime,e.riseEase),f=(n<0?s(Math.max(0,1+n*e.time/t)):a>0?d:n<.2?_u(n):0)*e.squash;_+=.16*f-.06*i*e.stretch,v+=-.18*f+.09*i*e.stretch,b+=this.flipSide*e.lean*vu*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/su,this.hopPhase>=1&&(this.state===`working`?(--this.hopPhase,this.hopCount+=1):(this.hopPhase-1)*su>=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?cu:18)*r*t;let a=this.state!==`working`&&this.hopPhase>1?(this.hopPhase-1)*su:-1,o=a<0?_u(this.hopPhase):a<j?hu(a/j,A.groundEase):mu((a-j)/A.riseTime,A.riseEase);_+=(.16*o-.06*r)*t,v+=(-.18*o+.09*r)*t,i&&(h+=yu*wu(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*vu*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?wu(e/.72):1-wu((e-.72)/.28);y-=13*vu*t*o}this.breathPhase+=e/(3.6+1.2*o);let N=Math.sin(this.breathPhase*yu);n.breath=N,_+=N*(.008+.014*o),v+=N*(.012+.02*o);let P=Math.sin(t*yu/3.4)*2*(1-o);n.yaw=this.baseYaw+h;let F=this.baseYaw-this.prevYaw;F=((F+Math.PI)%yu+yu)%yu-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=Cu(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=Cu(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 Pu(e){let t=Mu[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:ou.map(t=>+(t===e))}}var Fu=64,Iu=4096,Lu=24,Ru=0xe8d4a51000,zu=48*Math.PI/180,Bu=Math.cos(zu),Vu=Math.sin(zu),Hu=(e,t)=>t+(1-t)*Math.sqrt(Math.max(0,1-e*e));function Uu(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 Wu(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:Ru;Uu(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];Uu(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 Gu(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 Ku(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 qu=[1,1,0,-1,-1,-1,0,1],Ju=[0,1,1,1,0,-1,-1,-1],Yu=[1,Math.SQRT2,1,Math.SQRT2,1,Math.SQRT2,1,Math.SQRT2];function Xu(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);Wu(a,0,t,o,null),Wu(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]))}Gu(l,t,u),Gu(l,t,u);let d=Ku(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;Gu(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+qu[e]*a,s=d+Ju[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*Yu[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*Fu+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 Zu(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 Qu(e,t){return e.getContext(`2d`,t?{willReadFrequently:!0}:void 0)}function $u(e,t){let n=Zu(t),r=n&&Qu(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 ed=new Map,td=new Set,nd=new WeakMap,rd=0;function id(e){let t=nd.get(e);return t||nd.set(e,t=`p${rd++}`),t}var ad=[],od=!1;function sd(){od=!1;let e=ad.shift();e&&e(),ad.length&&cd()}function cd(){if(od)return;od=!0;let e=globalThis.requestIdleCallback;e?e(sd,{timeout:120}):setTimeout(sd,16)}function ld(e){ad.push(e),cd()}function ud(e,t,n,r,i){let a=`${e}|${n}|${Math.round(r)}`,o=ed.get(a);if(o)return o;let s=()=>{if(td.delete(a),ed.has(a))return;let e=$u(t,n);e&&(ed.size>=48&&ed.clear(),ed.set(a,Xu(e,n,r)))};return i?(s(),ed.get(a)??null):(td.has(a)||(td.add(a),ld(s)),null)}function dd(e,t,n=192,r=.65){ud(e,t,fd(n),15*r,!0)}function fd(e){return e<=100?64:e<=224?96:128}var pd=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,md=new Map;function hd(e){let t=md.get(e);if(!t){let n=Xl(e);if(!n){let t=Zu(1),r=t&&Qu(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=[pd(n[0]/255),pd(n[1]/255),pd(n[2]/255)],md.size>200&&md.clear(),md.set(e,t)}return t}var gd=2048,_d=2.5,vd=gd/_d,yd=new Float32Array(gd);for(let e=0;e<gd;e++){let t=(e+.5)/vd,n=t<=.75?t:.75+.25*(1-Math.exp(-(t-.75)/.25));yd[e]=255*(n<=.0031308?12.92*n:1.055*n**(1/2.4)-.055)}var bd=e=>yd[e<=0?0:e>=_d?2047:e*vd|0],xd=1024,Sd=new Map;function Cd(e){let t=Sd.get(e);if(!t){t=new Float32Array(1025);for(let n=0;n<=xd;n++)t[n]=(n/xd)**+e;Sd.size>16&&Sd.clear(),Sd.set(e,t)}return t}var wd=[.92,.96,1],Td=[1,.98,.95],Ed=(e,t,n)=>{let r=n<=e?0:n>=t?1:(n-e)/(t-e);return r*r*(3-2*r)},Dd=(e,t,n)=>1-Ed(e-t,e+t,n);function Od(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=Cd(g),y=Cd(_),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<Fu;n++)for(let r=0;r<Fu;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*xd|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*Ed(-.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=Dd(.34,.12,Math.abs(e))*Dd(.12,.06,Math.abs(t))}let ee=C*A*L+S*z,B=(n*Fu+r)*3;e[B]=bd(t[0]*(w[0]+h*D)+N*Td[0]+ee*wd[0]),e[B+1]=bd(t[1]*(w[1]+h*D)+N*Td[1]+ee*wd[1]),e[B+2]=bd(t[2]*(w[2]+h*D)+N*Td[2]+ee*wd[2])}}function kd(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*Fu+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 Ad(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 jd=e=>{let t=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/t,e[1]/t,e[2]/t]};function Md(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)=>jd([s*e+c*u*t-c*l*n,l*t+u*n,r*(c*e-s*u*t+s*l*n)]),f=d(Bu*r,Bu*i,Vu),p=d(0,0,1,a),m=jd([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=jd([.55*v,.55*y,.83]),x=jd([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 Nd=new WeakMap;function Pd(e,t){let n=e.canvas??e,r=Nd.get(n);r||(r=new Map,Nd.set(n,r));let i=r.get(t);return i||(i={N:0,img:null,mc:new Float32Array(Iu*3),mcPrev:new Float32Array(Iu*3),mcMix:new Float32Array(Iu*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 Fd=1/48,Id=(e,t)=>!t||Math.abs(e[0]-t[0])>=Fd||Math.abs(e[1]-t[1])>=Fd||Math.abs(e[2]-t[2])>=Fd;function Ld(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 Rd(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<=Lu;e++){let r=e/Lu*Math.PI*2;kd(t,a*Math.cos(r),a*Math.sin(r),o),n.addColorStop(e/Lu,`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)=>{kd(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 zd=typeof navigator<`u`&&/AppleWebKit\//.test(navigator.userAgent)&&!/Chrome\/|Chromium\/|Edg\//.test(navigator.userAgent),Bd=[[.55,()=>0],[0,()=>0],[0,e=>Math.min(.6,.25*e.shadow)]];function Vd(e,t,n,r,i,a){let o=fd(n.dev),s=ud(t.typeKey??id(t.path),t.path,o,n.halfDepth,!!n.still);if(!s)return!1;let c=Pd(e,t.typeKey??id(t.path)),l=Md(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((Id(l.L,c.L)||Id(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),Od(c.mc,hd(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<Iu*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)&&(Ad(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=Zu(o),n=t&&Qu(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`&&zd;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=Zu(e),n=t&&Qu(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=Rd(i.g,c.mc,Bd[r][0],Bd[r][1](a),u),i.g.fill(t.path)}p&&(c.spriteVersion=c.version)}}!p&&!c.near&&(c.near=Rd(e,c.mc,.55,0,u),c.rimG=Rd(e,c.mc,0,0,u),c.far=Rd(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=Hu(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,ee=50*y+Math.hypot(50*(1-y),L),B=(ee+50)/100,te=(ee-50)/2,ne=1+(B-1)*R*R,re=(B-1)*R*z,V=1+(B-1)*z*z,H=Ld(Ld(n.ctm,[m,h*_,0,g,0,0]),[ne,re,re,V,te*R-50*ne-50*re,te*z-50*re-50*V]);if(e.save(),e.setTransform(H[0],H[1],H[2],H[3],H[4],H[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(H[0],H[1],H[2],H[3],H[4],H[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 Hd=1.5,Ud=.1,Wd=17,Gd=15,Kd=(e,t)=>t+(1-t)*Math.sqrt(Math.max(0,1-e*e)),qd=25,Jd=6.3,Yd={eyes:1,mouth:-3.5},Xd=new Map;function Zd(e,t,n){let r=`${e}|${t}|${n}`,i=Xd.get(r);if(!i){let a=au(e,-.3*t,.05*t),o=au(e,-.12*t,.03*t),s=[],c=[];for(let t=0;t<Wd;t++){let n=t/16;s.push(n>.6?``:$d(a,o,n/.6)),c.push(n>=.5?e:$d(a,e,n/.5))}i={base:e,far:a,near:o,light:au(e,.04*n),dark:au(e,-.3*t,.05*t),capTop:au(e,.035*n),capBottom:au(e,-.035*t),crispMix:s,smoothMix:c,grad:null},Xd.size>200&&Xd.clear(),Xd.set(r,i)}return i}var Qd=e=>(e.startsWith(`hsl(`)?e:au(e,0)).match(/[\d.]+/g).map(Number);function $d(e,t,n){let r=Qd(e),i=Qd(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 ef=34,tf=Math.PI*1.55,nf=57,rf=.4,af=-.28,of=new Map;function sf(e){let t=of.get(e);return t||(t={base:au(e,.1,.02),light:au(e,.3,.04),dark:au(e,-.22,.08),halo:au(e,.2)},of.size>200&&of.clear(),of.set(e,t)),t}var cf=(e,t)=>e.replace(`)`,` / ${Math.max(0,Math.min(1,t)).toFixed(3)})`);function lf(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=tf*d,m=sf(n),h=-t.whirlAngle,g=nf*l,_=g*rf*f*(a?1.14:.86),v=Math.atan2(i,r)-af;e.save(),e.rotate(af),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<ef;e++){let t=e/ef,n=h+t*p,r=n+p/ef+.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<ef;e++){let t=e/ef,n=h+t*p,r=n+p/ef+.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,cf(m.halo,f*.2),0),y(n,r,d*.8,cf(m.dark,f*.45),d*.32),y(n,r,d,cf(m.base,f*.72),0),y(n,r,d*.62,cf(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 uf(e,t,n,r){let i=t*Hd;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=Gd*(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=Zd(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=Ld(s,[T*D,E*D,-E*O,T*O,i/2+n.x*a-E*k,i/2+Ud*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`&&(_=Vd(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,ee=0,B=0;for(let t=0;t<Wd&&!_;t++){let n=-1+2*(E>0?t:16-t)/16,r=Kd(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*B-z*ee)/h,k=(L*ee-I*B)/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,ee=f,B=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 _};lf(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=Kd(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),bf(e,n,r),e.restore()}lf(e,n,r.color,m,h,!0,r.whirl),e.restore()}var df=30;function ff(e,t,n,r){let i=Math.asin(Math.max(-1,Math.min(1,e/df)))+n,a=Math.asin(Math.max(-1,Math.min(1,-t/df)))+r,o=Math.cos(a);return{x:df*Math.sin(i)*o,y:-30*Math.sin(a),sx:Math.cos(i),sy:o,z:Math.cos(i)*o}}var pf=8,mf=new Map;function hf(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=mf.get(o);if(!s){let e=r/50,t=i/50,n=a/50,c=`M${-e} ${t}`;for(let r=1;r<=pf;r++){let i=r/pf,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),mf.size>256&&mf.clear(),mf.set(o,s)}return s}var gf=Math.sin(.684),_f=Math.cos(.684),vf=new Map;function yf(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=vf.get(c);if(l)return l;let u=e=>e.toFixed(3),d=r*gf,f=r*_f,p=-n+d,m=-f,h=n-d,g=-f,_=-n-d,v=f,y=n+d,b=f,x=4/3*r*_f,S=4/3*r*gf,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),vf.size>256&&vf.clear(),vf.set(c,l),l}function bf(e,t,n){let[r,i,a]=t.w,o=n.ink,s=Yd[n.face],c=qd/2,l=t.lookX,u=t.lookY,{yaw:d,pitch:f}=t,p=(t,n,r,i=1)=>{let a=ff(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*Jd*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(hf(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(yf(f))})}}var xf={x:NaN,y:NaN},Sf=new Set,Cf=0,wf=0;function Tf(e){Cf=0;let t=wf?Math.min(.1,(e-wf)/1e3):0;wf=e,Sf.forEach(e=>e(t)),Sf.size&&(Cf=requestAnimationFrame(Tf))}function Ef(){Cf||typeof document>`u`||document.hidden||(wf=0,Cf=requestAnimationFrame(Tf))}var Df=!1;function Of(){Df||typeof document>`u`||(Df=!0,document.addEventListener(`pointermove`,e=>{xf.x=e.clientX,xf.y=e.clientY},{passive:!0}),document.addEventListener(`pointerleave`,()=>{xf.x=NaN,xf.y=NaN}),window.addEventListener(`blur`,()=>{xf.x=NaN,xf.y=NaN}),document.addEventListener(`visibilitychange`,()=>{document.hidden?(Cf&&cancelAnimationFrame(Cf),Cf=0):Sf.size&&Ef()}))}function kf(e){return Of(),Sf.add(e),Ef(),()=>{Sf.delete(e),!Sf.size&&Cf&&(cancelAnimationFrame(Cf),Cf=0)}}function Af(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 jf=(e,t,n)=>Math.min(n,Math.max(t,Number.isFinite(e)?e:1)),Mf=new Map;function Nf(e){let t=Mf.get(e);return t||(t=new Path2D(e),Mf.set(e,t)),t}var Pf=()=>typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches,Ff=(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:ee=.33,jumpRiseEase:B=`pulse`,jumpClickSquashTime:te=.24,className:ne,style:re,"aria-label":V,...H},ie){let ae=(0,l.useRef)(null);(0,l.useImperativeHandle)(ie,()=>ae.current);let oe=(0,l.useId)(),se=Gl[e]??Gl.clover,U=n??se.face,ce=a??se.color,W=s===1&&c===1?ce:au(ce,(Math.min(2,Math.max(0,s))-1)*.35,(Math.min(2,Math.max(0,c))-1)*.5),le=o??eu(W),ue=Math.min(1,Math.max(0,f??Af(oe))),de=r in ql?r:`default`,G=d||!(u>0),K=p===!0?`crisp`:p===!1?`flat`:p,fe=typeof t==`string`&&t.trim()?t.trim():null,pe=fe?`path:${Af(fe)}:${fe.length}`:e,me=(0,l.useRef)(null),he=(0,l.useRef)(null),ge=(0,l.useRef)(0),_e=(0,l.useRef)(u);_e.current=u;let ve=(0,l.useRef)(b);ve.current=b,he.current={path:typeof Path2D>`u`?null:Nf(fe??Jl[e]??Jl.clover),face:U,faceX:se.faceX,faceY:se.faceY,faceScale:se.faceScale,color:W,ink:le,shading:K,shadow:jf(m,0,2),highlight:jf(h,0,2),depth:jf(g,.2,2),light:_,rim:jf(v,0,2),spread:jf(y,.4,2.5),typeKey:pe,still:G||Pf(),whirl:{strength:jf(C,0,2),size:jf(w,.6,1.6),width:jf(T,.4,2),length:jf(E,.4,1.6),tilt:jf(D,.5,1.8)},parts:typeof Path2D<`u`&&!fe&&Yl[e]?Nf(Yl[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=ae.current,t=he.current;if(!e||!t||!t.path)return;let n=e.clientWidth/1.5||ge.current||(typeof i==`number`?i:64);if(!n)return;let r=Math.min(2,typeof devicePixelRatio==`number`&&devicePixelRatio||1),a=Math.round(n*Hd*r);(e.width!==a||e.height!==a)&&(e.width=a,e.height=a),ge.current=n;let o=e.getContext(`2d`);o&&(o.setTransform(r,0,0,r,0,0),t.dpr=r,uf(o,n,me.current?me.current.pose:Pu(de),t))};(0,l.useLayoutEffect)(()=>{if(me.current?me.current.setState(de):me.current=new Nu(ue,de),me.current.setTurn(jf(x,0,2)),me.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,ee),riseEase:B,clickSquashTime:Math.max(.05,te)}),Pf()){let e=ae.current;if(e&&he.current&&he.current.path){let t=e.clientWidth/1.5||ge.current||(typeof i==`number`?i:64);if(!t)return;ge.current=t;let n=Math.min(2,typeof devicePixelRatio==`number`&&devicePixelRatio||1);e.width=e.height=Math.round(t*Hd*n);let r=e.getContext(`2d`);r&&(he.current.theme=ye(e),he.current.dpr=n,r.setTransform(n,0,0,n,0,0),uf(r,t,Pu(de),he.current))}return}he.current&&ae.current&&(he.current.theme=ye(ae.current)),be()}),(0,l.useEffect)(()=>{var e;if(K!==`plastic`||!((e=he.current)!=null&&e.path))return;let t=he.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))(()=>dd(pe,t,n,g));return()=>{typeof cancelIdleCallback==`function`?cancelIdleCallback(r):clearTimeout(r)}},[K,pe,i,g]),(0,l.useEffect)(()=>{if(G||Pf())return;let e=ae.current;if(!e)return;let t=!0,n=null,r=t=>{let n=me.current;if(n){if(ve.current&&!Number.isNaN(xf.x)){let t=e.getBoundingClientRect(),r=t.width/1.5||1,i=(xf.x-(t.left+t.width/2))/r,a=(xf.y-(t.top+t.height/2+Ud*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*_e.current),be()}},i=()=>{n||=kf(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()}},[G]);let xe=typeof i==`number`?`${i*Hd}px`:`calc(${i} * ${Hd})`,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`,...re},Te=e=>{var t,n;b&&!G&&((t=me.current)==null||t.poke()),(n=H.onClick)==null||n.call(H,e)};return(0,Q.jsx)(`canvas`,{ref:ae,className:ne?`ba ${ne}`:`ba`,"data-bot-avatar":e,"data-face":U,"data-state":de,role:`img`,"aria-label":V??`${se.label} bot, ${ql[de]}`,style:we,...H,onClick:Te})}),If=137.508,Lf=e=>(e*If%360).toFixed(3);function Rf(e){let t=e.avatarIndex;return{type:Kl[t%Kl.length],color:`hsl(${Lf(t)} 72% 58%)`,seed:t*.61803398875%1}}var zf=2e3,Bf=0;function Vf(e){let[t,n]=(0,l.useState)(!e);return(0,l.useEffect)(()=>{if(e){n(!1);return}let t=setTimeout(()=>n(!0),zf);return()=>clearTimeout(t)},[e]),t}function Hf({thread:e,working:t,size:n}){let r=Vf(t),i=r?`rest`:`moving`;return(0,Q.jsx)(Ff,{...Rf(e),state:t?`working`:`default`,size:n,paused:r,turn:t?void 0:Bf},i)}var Uf={nextThread:`Next thread`,previousThread:`Previous thread`,nextPane:`Next pane`,previousPane:`Previous pane`,toggleSidebar:`Toggle sidebar`,newThread:`New thread`,toggleTerminal:`Toggle terminal`},Wf={nextThread:`ctrl+j`,previousThread:`ctrl+k`,nextPane:`ctrl+l`,previousPane:`ctrl+h`,toggleSidebar:`ctrl+b`,newThread:`ctrl+x`,toggleTerminal:`ctrl+q`};function Gf(){try{let e=JSON.parse(localStorage.getItem(`webr-shortcuts`)??`{}`);return{...Wf,...e}}catch{return Wf}}function Kf(e){let t={ctrl:`⌃`,alt:`⌥`,meta:`⌘`,shift:`⇧`,space:`Space`,escape:`Esc`};return e.split(`+`).map(e=>t[e]??e.toUpperCase())}function qf(e){return Kf(e).join(``)}function Jf(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 Yf(e){return/^(meta\+(w|t|r|l|n)|ctrl\+(w|t|r|n))$/.test(e)||!/(ctrl|alt|meta)\+/.test(e)}function Xf(e){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;document.documentElement.dataset.theme=e===`system`?t?`dark`:`light`:e}function Zf({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),Xf(t);let r=window.matchMedia(`(prefers-color-scheme: dark)`),i=()=>{let e=localStorage.getItem(`webr-theme`)||`system`;n(e),Xf(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),Xf(e)};return(0,Q.jsx)(`div`,{className:e?`theme-control theme-control--expanded`:`theme-control`,role:`group`,"aria-label":`Color theme`,children:[[`system`,P],[`light`,ie],[`dark`,F]].map(([n,i])=>(0,Q.jsx)(Wl,{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 Qf={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 $f(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(Qf[r.error??``]??`Herdr could not complete this action.`);return r}var ep=(e,t)=>$f(`/api/threads/${encodeURIComponent(e.id)}/archive`,{machineId:e.machineId,archived:t}),tp=(e,t)=>$f(`/api/threads/${encodeURIComponent(e.id)}/rename`,{machineId:e.machineId,title:t}),np=(e,t)=>$f(`/api/threads/${encodeURIComponent(e.id)}/terminal`,{machineId:e.machineId,direction:t}),rp=e=>$f(`/api/threads/${encodeURIComponent(e.id)}/terminal/close`,{machineId:e.machineId}),ip=e=>$f(`/api/threads/${encodeURIComponent(e.id)}/delete`,{machineId:e.machineId}),ap=()=>$f(`/api/archive/delete`),op=(e,t,n)=>e===1?t:n;function sp(e){let t=e.length,n=e.filter(e=>e.ownsWorktree).length,r=op(t,`Delete this thread`,`Delete ${t} threads`),i=op(t,`its terminal`,`their terminals`);return n?`${r} permanently? This closes ${i} and removes ${n===t?op(t,`its worktree`,`their worktrees`):`${n} ${op(n,`worktree`,`worktrees`)}`}, including uncommitted changes.`:`${r} permanently? This closes ${i}. Your project files stay untouched.`}var cp=e=>e.panes.find(e=>e.kind===`agent`)??e.panes[0],lp=e=>{let t=cp(e);return e.panes.find(e=>e.kind===`shell`&&e.id!==t?.id)},up=(e,t)=>e.x>t.x&&e.y===t.y?`right`:`bottom`,dp=e=>e===`right`?`right`:`down`;function fp(e,t){let n=lp(e),r=cp(e),i=n&&t.panes.find(e=>e.paneId===n.id)?.rect,a=e.panes.filter(e=>e.id!==n?.id&&e.id!==r?.id);if(e.terminalHidden&&n&&r&&i&&!a.length)return{shell:n,agent:r,side:up(i,t.area)}}function pp(e,t,n){let r=lp(e),i=t.find(e=>e.panes.some(e=>e.paneId===r?.id)),a=i?.panes.find(e=>e.paneId===r?.id)?.rect;return a&&i?dp(up(a,i.area)):n?`down`:`right`}function mp(e){let t=performance.now();return()=>performance.now()-t}var hp=()=>performance.now();function gp(){}var _p=e=>tl(e instanceof Error?e.message:`Herdr could not complete this action.`);function vp({open:e,onClose:t,projects:n,threads:r,thread:i,focusedPane:o,mode:s,onModeChange:c,onToggleSidebar:u,onFocusPane:d,onTerminalAction:v,onToggleTerminal:y,onCloseTerminal:b}){let[x,S]=(0,l.useState)(``),[C,w]=(0,l.useState)(0),[E,O]=(0,l.useState)(Wf),k=(0,l.useRef)(null);(0,l.useEffect)(()=>{e&&(S(``),w(0),O(Gf()),requestAnimationFrame(()=>k.current?.focus()))},[e]);let A=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)}`)},M=e=>{i?.panes.length&&d(i.panes[(i.panes.findIndex(e=>e.id===o)+e+i.panes.length)%i.panes.length].id)},N=(0,l.useMemo)(()=>[{label:`New thread`,icon:(0,Q.jsx)(V,{size:16}),shortcut:`newThread`,run:()=>{a(`/new${i?`?project=${encodeURIComponent(i.projectId)}`:``}`)}},{label:`Settings`,icon:(0,Q.jsx)(re,{size:16}),run:()=>{a(`/settings`)}},{label:`Toggle sidebar`,icon:(0,Q.jsx)(z,{size:16}),shortcut:`toggleSidebar`,run:u},...r.length?[{label:`Next thread`,icon:(0,Q.jsx)(m,{size:16}),shortcut:`nextThread`,run:()=>A(1)},{label:`Previous thread`,icon:(0,Q.jsx)(_,{size:16}),shortcut:`previousThread`,run:()=>A(-1)}]:[],{label:`Group threads by project`,icon:(0,Q.jsx)(D,{size:16}),detail:s===`projects`?`Selected`:void 0,run:()=>c(`projects`)},{label:`Show all threads`,icon:(0,Q.jsx)(j,{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)(P,{size:16}):e===`light`?(0,Q.jsx)(ie,{size:16}):(0,Q.jsx)(F,{size:16}),run:()=>{localStorage.setItem(`webr-theme`,e),Xf(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:()=>{ep(i,!i.archivedAt).catch(_p)}},{label:`Copy thread link`,icon:(0,Q.jsx)(T,{size:16}),run:()=>{navigator.clipboard.writeText(location.href)}},...i.bindingState===`attached`?lp(i)?[{label:`Toggle terminal`,icon:(0,Q.jsx)(H,{size:16}),shortcut:`toggleTerminal`,run:()=>y()},{label:`Close terminal`,icon:(0,Q.jsx)(se,{size:16}),detail:`Stops its shell`,run:b}]:[{label:`Toggle terminal (side)`,icon:(0,Q.jsx)(ee,{size:16}),shortcut:`toggleTerminal`,run:()=>y(`right`)},{label:`Toggle terminal (below)`,icon:(0,Q.jsx)(I,{size:16}),run:()=>y(`down`)}]:[],...i.bindingState===`attached`?[{label:`Request terminal control`,icon:(0,Q.jsx)(H,{size:16}),run:()=>v(`control`)},{label:`Release terminal control`,icon:(0,Q.jsx)(H,{size:16}),run:()=>v(`release`)},{label:`Take over terminal control`,icon:(0,Q.jsx)(H,{size:16}),run:()=>{el(`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:()=>M(1)},{label:`Previous pane`,icon:(0,Q.jsx)(h,{size:16}),shortcut:`previousPane`,run:()=>M(-1)},...i.panes.map((e,t)=>({label:`Focus ${e.title}`,icon:(0,Q.jsx)(H,{size:16}),detail:`Pane ${t+1}`,run:()=>d(e.id)}))]:[],...r.map(e=>({label:e.title,icon:(0,Q.jsx)(Hf,{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 L=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)%(N.length||1))),e.key===`ArrowUp`&&(e.preventDefault(),w(e=>(e-1+(N.length||1))%(N.length||1))),e.key===`Enter`&&N.length&&(e.preventDefault(),L(N[Math.min(C,N.length-1)])),e.key===`Tab`&&(e.preventDefault(),k.current?.focus())},children:[(0,Q.jsx)(`input`,{ref:k,"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:[N.map((e,t)=>(0,Q.jsxs)(`button`,{role:`option`,"aria-selected":C===t,className:C===t?`is-selected`:``,onMouseEnter:()=>w(t),onClick:()=>L(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)(Wl,{label:E[e.shortcut],children:(0,Q.jsx)(`kbd`,{children:qf(E[e.shortcut])})})]},`${e.label}-${t}`)),!N.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 yp=2e3,bp=e=>fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});async function xp(){let e=await bp(`/api/pair/invites`);if(!e.ok)throw Error(`Webr could not create a code.`);return e.json()}async function Sp(){let e=await fetch(`/api/devices`);if(!e.ok)throw Error(`Webr could not list devices.`);return e.json()}async function Cp(){let e=await fetch(`/api/audit`);if(!e.ok)throw Error(`Webr could not load recent activity.`);return e.json()}var wp=e=>bp(`/api/devices/${encodeURIComponent(e)}/revoke`),Tp=(e,t)=>bp(`/api/pair/${encodeURIComponent(e)}/${t}`);async function Ep(){try{let e=await fetch(`/api/pair/pending`);return e.ok?await e.json():[]}catch{return[]}}var Dp=()=>typeof Notification<`u`&&Notification.permission===`granted`,Op=()=>document.visibilityState===`visible`||Dp();function kp(e,t){if(document.visibilityState!==`visible`&&Dp())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 Ap(){let[e,t]=(0,l.useState)([]),n=(0,l.useRef)(new Set),r=(0,l.useCallback)(async()=>{if(!Op())return;let e=await Ep();kp(e,n.current),t(e)},[]);return(0,l.useEffect)(()=>{r();let e=setInterval(()=>void r(),yp);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 Tp(e,n).catch(()=>void 0),await r()},[r])}}function jp(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 Mp=()=>typeof Notification<`u`,Np=()=>Mp()?Notification.permission:`denied`,Pp=()=>Notification.requestPermission();function Fp({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 Ip(e,t=Date.now()){return e<=t?`expired`:new Intl.RelativeTimeFormat(`en`,{numeric:`auto`}).format(...Lp(e-t))}function Lp(e){let t=Math.round(e/864e5);return t>=1?[t,`day`]:[Math.max(1,Math.round(e/36e5)),`hour`]}function Rp(){let{pending:e,decide:t}=Ap(),n=e[0];return(0,Q.jsx)(Sc,{open:!!n,onOpenChange:e=>{!e&&n&&t(n.id,`deny`)},children:(0,Q.jsxs)(Uc,{children:[(0,Q.jsx)(Cc,{className:`dialog-backdrop`}),(0,Q.jsx)(Bc,{className:`dialog pairing-prompt`,children:n&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Wc,{className:`pairing-title`,children:[`Allow `,n.deviceName,` to connect?`]}),(0,Q.jsxs)(Nc,{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 zp=({children:e})=>(0,Q.jsx)(Q.Fragment,{children:e}),Bp=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`],Vp={image_too_large:`This image is larger than 20 MB.`,unsupported_image:`Only PNG, JPEG, GIF and WebP images can be attached.`,uploads_unsupported_target:`Images can be attached only on the Local machine for now.`,machine_disconnected:`The machine is not connected.`},Hp=e=>Bp.includes(e.type),Up=e=>e?.files?[...e.files].filter(Hp):[],Wp=e=>!!e?.types&&[...e.types].includes(`Files`),Gp=e=>e.replace(/([\s\\'"()&;$`!*?[\]{}<>|#~])/g,`\\$1`);async function Kp(e,t){if(!Hp(t))throw Error(Vp.unsupported_image);if(t.size>20971520)throw Error(Vp.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(Vp[r.error??``]??`The image could not be attached.`);return r.path}var qp=160,Jp=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 Yp(e){if(typeof createImageBitmap!=`function`)return Jp(e);let t=await createImageBitmap(e),n=Math.min(1,qp/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 Xp(e,t){let n=[];for(let r of t)n.push(await Kp(e,r));return n.map(Gp).join(` `)+` `}var Zp=e=>Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);function Qp(){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=Zp(e);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var $p=`Only PNG, JPEG, GIF and WebP images can be attached.`,em=(e,t)=>[e.trim(),...t.map(e=>Gp(e.path))].filter(Boolean).join(` `);function tm({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($p);return}c(``),o(e=>e+t.length);for(let n of t)try{let t=await Kp(e,n),r=await Yp(n);i(e=>[...e,{id:Qp(),name:n.name||`image`,preview:r,path:t}])}catch(e){c(e instanceof Error?e.message:`The image 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=>{Wp(e.dataTransfer)&&(e.preventDefault(),u.current+=1,n(!0))},onDragOver:e=>{Wp(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:e=>{Wp(e.dataTransfer)&&(u.current=Math.max(0,u.current-1),u.current||n(!1))},onDrop:e=>{Wp(e.dataTransfer)&&(e.preventDefault(),u.current=0,n(!1),d(Up(e.dataTransfer)))},onPaste:e=>{let t=Up(e.clipboardData);t.length&&(e.preventDefault(),d(t))}}}}function nm({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 rm(e){let t=l.useRef(!0);t.current&&(t.current=!1,e())}function im(e,t,n,r,i,a,o,s,c,l=2){let u=Or(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 wr(n.current,u)?void 0:u}var am=l.createContext(void 0),om=l.createContext(void 0),sm=l.createContext(void 0),cm=l.createContext(!1),lm=l.createContext(``);function um(){let e=l.useContext(am);if(!e)throw Error(Ti(22));return e}function dm(){let e=l.useContext(om);if(!e)throw Error(Ti(23));return e}function fm(){let e=l.useContext(sm);if(!e)throw Error(Ti(24));return e}function pm(){return l.useContext(lm)}function mm(){return l.useContext(cm)}function hm(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 gm=(e,t)=>Object.is(e,t);function _m(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function vm(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!hm(e,t,(e,t)=>_m(e,t,n)):e!==t}function ym(e,t,n){return e?e.some(e=>e!==void 0&&_m(t,e,n)):!1}function bm(e,t,n){return e?e.findIndex(e=>e!==void 0&&_m(e,t,n)):-1}function xm(e,t){if(t!==gm)return n=>ym(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 Sm(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(xm(t,n)):bm(e,t,n);return i===-1?null:i}function Cm(e,t,n,r,i,a){return ym(r,t,i)?a!=null&&e>a&&ym(r,n[a],i)?a:e:e===a?Sm(n,r,i,!0):a}function wm(e,t,n){return e.filter(e=>!_m(t,e,n))}function Tm(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function Em(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function Dm(e){return Em(e?.[0])}function Om(e){return Dm(e)?e.flatMap(e=>e.items):e}function km(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(Dm(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 Am(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 Tm(e)}function jm(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?Tm(e.value):Tm(e)}var Mm={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?km(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=>_m(t,e,n)):_m(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},Nm=`data-valid`,Pm=`data-invalid`,Fm={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Im={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},Lm={disabled:!1,...Im},Rm={valid(e){return e===null?null:e?{[Nm]:``}:{[Pm]:``}}},zm={invalid:void 0,name:void 0,validityData:{state:Fm,errors:[],error:``,value:``,initialValue:null},setValidityData:qe,disabled:void 0,setTouched:qe,setDirty:qe,setFilled:qe,setFocused:qe,validationMode:`onSubmit`,shouldValidateOnChange:()=>!1,state:Lm,registerFieldControl:qe,validation:{getValidationProps:(e,t=Ye)=>t,inputRef:{current:null},registeredInputs:new Map,registerInput:qe,getInputControl:()=>null,commit:async()=>{},change:qe}},Bm=l.createContext(zm);function Vm(e=!0){let t=l.useContext(Bm);if(t.setValidityData===qe&&!e)throw Error(Ti(28));return t}function Hm(e,t,n,r,i=!0,a){let{registerFieldControl:o}=Vm(),s=Ke(()=>Symbol());U(()=>{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]),U(()=>{let e=s.current;return()=>{o(e,void 0)}},[o,s])}var Um=l.createContext({elementRef:{current:null},formRef:{current:{fields:new Map}},errors:{},clearErrors:qe,validationMode:`onSubmit`,submitCountRef:{current:0}});function Wm(){return l.useContext(Um)}var Gm=l.createContext({controlId:void 0,registerControlId:qe,resetControlId:qe,labelId:void 0,setLabelId:qe,messageIds:[],setMessageIds:qe,getDescriptionProps:e=>e});function Km(){return l.useContext(Gm)}function qm(e={}){let{id:t,enabled:n=!0}=e,{controlId:r,registerControlId:i,resetControlId:a}=Km(),o=Mc(),s=Ke(()=>Symbol()),c=l.useRef(!1),u=l.useRef(!1),d=$(()=>{c.current&&i!==qe&&(c.current=!1,i(s.current,void 0))});return U(()=>{if(!n||i===qe){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]),U(()=>d,[d]),(n?r:void 0)??t??o}function Jm(e){return e==null?void 0:`${e}-popup`}function Ym(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function Xm(e){return Array.isArray(e)?e.map(e=>Xm(e)).join(`,`):e==null?``:String(e)}var Zm=new Map;function Qm(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${Xm(e.locale)}|${JSON.stringify(t)}`,r=Zm.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=Am(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=Am(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Am(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return Zm.set(n,a),a}var $m=Qm;function eh(e,t=!1){let{overflowY:n}=we(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}var th=Symbol(`none`),nh={value:th,index:-1};function rh(e,t,n){let r=e.get(t);if(r!==void 0||n===gm)return r;for(let[r,i]of e)if(_m(r,t,n))return i}function ih(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=gm,virtualized:M=!1,inline:N=!1,fillInputOnItemPress:P=!0,modal:F=!1,limit:I=-1,autoComplete:L=`list`,formAutoComplete:R,locale:z,submitOnItemClick:ee=!1}=e,{clearErrors:B}=Wm(),{setDirty:te,validityData:ne,setFilled:re,name:V,disabled:H,setTouched:ie,setFocused:ae,validationMode:oe,validation:se}=Vm(),ce=Cl(),W=qm({id:t}),le=$m({locale:z}),ue=Array.isArray(b)?null:b;if(ue&&typeof ue.label!=`function`)throw Error(Ti(100));let de=ue?ue.data:b,G=ue?.value,fe=G?void 0:de,pe=l.useMemo(()=>{if(!x||!G)return;let e=Om(x),t=e.map(G),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 rh(n,r,i)}}},[x,G]),me=l.useMemo(()=>ue?e=>ue.label(e,j,e=>{let t=pe?.findItem(e,j);return t==null?Am(e,k):ue.itemLabel(t)}):k,[ue,k,pe,j]),he=l.useMemo(()=>ue?Object.assign(e=>ue.itemLabel(e),{selected:e=>Am(e,me)}):k,[ue,me,k]);function ge(e){return Am(e,me)}let[_e,ve]=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),ke=l.useRef(null),q=l.useRef(!0),Ae=l.useRef(!1),je=l.useRef(null),Me=l.useRef(null),Ne=l.useRef(null),Pe=l.useRef(nh),Fe=l.useRef(null),Ie=l.useRef([]),Le=l.useRef(null),Re=H||h,ze=V??p,Be=d===`multiple`,Ve=d===`single`,He=s!==void 0||o!==void 0,Ue=de!==void 0,We=x!==void 0,J;J=T===`always`?`always`:T?`input-change`:!1;let[Ge,Xe]=nm({controlled:i,default:Be?r??Je:r,name:`Combobox`,state:`selectedValue`}),Ze=l.useMemo(()=>S===null?()=>!0:S===void 0?Ym(le,he):S,[S,le,he]),Qe=Ke(()=>He?o??``:Ve?ge(Ge):``).current,[$e,et]=nm({controlled:s,default:Qe,name:`Combobox`,state:`inputValue`}),[tt,nt]=nm({controlled:c,default:u,name:`Combobox`,state:`open`}),rt=Dm(de),it=!tt&&ye!==null?ye:String($e).trim(),at=Ve?ge(Ge):``,ot=Ve&&!_e&&it!==``&&at.length===it.length&&le.contains(at,it),st=ot?``:C??it,ct=Ue&&We&&ot&&(!ue||ue.hasValue(Ge,j)),lt=l.useMemo(()=>de?Om(de):Je,[de]),ut=l.useMemo(()=>{if(x&&!ct)return x;if(!de)return Je;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;Ze(t,st,he)&&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;Ze(t,st,he)&&e.push(t)}return e},[x,ct,de,rt,st,I,Ze,he,lt]),dt=l.useMemo(()=>{if(pe&&ut===x)return pe.values;let e=Om(ut);return G?e.map(e=>G(e)):e},[ut,x,pe,G]),Y=Ke(()=>{let e=null;return N&&tt&&Ue&&d!==`none`&&(e=Sm(dt,Ge,j,Be)),new os({id:W,labelId:void 0,selectedValue:Ge,open:tt,items:fe,selectionMode:d,name:ze,form:m,disabled:Re,readOnly:g,required:_,grid:y,virtualized:M,openOnInputClick:w,itemToStringLabel:me,isItemEqualToValue:j,modal:F,autoHighlight:J,submitOnItemClick:ee,hasInputValue:He,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:N,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemProps:Ye,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:d===`none`},{onOpenChangeComplete:qe,setOpen:qe,setInputValue:qe,setSelectedValue:qe,setIndices:qe,handleSelection:qe,forceMount:qe,requestSubmit:qe,listRef:Se,labelsRef:Ce,popupRef:we,emptyRef:ke,inputRef:Te,startDismissRef:Ee,endDismissRef:De,keyboardActiveRef:q,chipsContainerRef:je,clearRef:Me,valuesRef:Ie,pointerDownItemRef:Le,selectionEventRef:Ne},Mm)}).current,ft=d===`none`?$e:Ge,pt=l.useMemo(()=>d===`none`?ft:Array.isArray(Ge)?Ge.map(e=>jm(e,A)):jm(Ge,A),[ft,A,d,Ge]),mt=$(f),ht=$(n),gt=Y.useState(`activeIndex`),_t=Y.useState(`selectedIndex`),vt=Y.useState(`positionerElement`),yt=Y.useState(`listElement`),bt=Y.useState(`triggerElement`),St=Y.useState(`inputElement`),Ct=Y.useState(`inputGroupElement`),wt=Y.useState(`inline`),Tt=Y.useState(`inputInsidePopup`),Et=Y.useState(`inputOwnsFormValue`),Dt=Ve&&!Tt&&$e===at,Ot=zn(bt),{mounted:kt,setMounted:At,transitionStatus:jt}=us(tt),{openMethod:Mt,triggerProps:Nt}=Jc(tt),Pt=$(()=>pt);Hm(Tt?Ot:Te,W,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===nh)return;Pe.current=nh}else Pe.current={value:e,index:t};mt(e,Dn(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(Ie.current[n],n,r)}),Rt=$((t,n)=>{if(e.onInputValueChange?.(t,n),!n.isCanceled){if(Ae.current=n.reason===gn,n.reason===`input-change`){tt&&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&&ve(!0),Fe.current={hasQuery:e};let n=Y.state.listElement;if(!Y.state.virtualized&&n){let e=we.current;for(let t of Oe(n.firstElementChild??n)){if(!K(t)||(e?!X(e,t):t.getAttribute(`role`)===`dialog`))break;if(eh(t)){t.scrollTop=0;break}}}e&&J&&Y.state.activeIndex==null&&(tt||wt)&&Y.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&Y.state.inputInsidePopup&&(Fe.current={hasQuery:!1,selection:!0});et(t)}}),zt=$(e=>{let t=!e&&Tt&&!wt&&$e!==``&&(String($e).trim()===ye||$e===at);!e&&(t||$e===``||Dt)&&ve(!1),be(null),t&&Rt(``,Z(gn))}),Bt=$((t,n)=>{if(tt!==t&&(n.reason===`escape-key`&&Ue&&dt.length===0&&!ke.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&ye!==null&&zt(n.reason===hn),!t&&_e&&(Ve?(wt||be(it),it===``&&ve(!1)):Be&&(wt||be(it),Tt&&Lt({activeIndex:null}),(!Tt||wt)&&Rt(``,Z(gn,n.event,void 0,{isItemPress:n.reason===pn})))),nt(t),!t&&Tt&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(ie(!0),ae(!1),oe===`onBlur`)))){let e=d===`none`?$e:Ge;se.commit(e)}}),Vt=$((e,t)=>{a?.(e,t),!t.isCanceled&&(Xe(e),(d===`none`&&we.current&&P||Ve&&!Y.state.inputInsidePopup)&&Rt(ge(e),Z(t.reason,t.event)))}),Ht=$((e,t)=>{let n=xt(e),r=Ne.current??e;Ne.current=null;let i=Z(pn,r),a=n?.closest(`a`)?.getAttribute(`href`);if(a){a.startsWith(`#`)&&Bt(!1,i);return}if(Be){let e=Array.isArray(Ge)?Ge:[],n=ym(e,t,j),r=n?wm(e,t,j):[...e,t];if(Vt(r,i),i.isCanceled||!(Te.current&&Te.current.value.trim()!==``))return;if(Y.state.inputInsidePopup){Rt(``,Z(gn,i.event,void 0,{isItemPress:!0}));let e=Fe.current;e&&!n&&(e.toggledValue=t)}else Bt(!1,i)}else{if(Vt(t,i),i.isCanceled)return;Bt(!1,i)}}),Ut=$(()=>{let e=se.inputRef.current?.form??Y.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),Wt=$(()=>{if(At(!1),ht?.(!1),ve(!1),be(null),Lt(d===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Be&&Te.current&&Te.current.value!==``&&!Ae.current&&Rt(``,Z(gn)),Ve){if(Y.state.inputInsidePopup)Te.current&&Te.current.value!==``&&Rt(``,Z(gn));else{let e=ge(Ge);Te.current&&Te.current.value!==e&&Rt(e,Z(e===``?gn:cn))}}}),Gt=l.useMemo(()=>wt&&vt?{current:vt.closest(`[role="dialog"]`)}:we,[wt,vt]);ms({enabled:!e.actionsRef,open:tt,ref:Gt,onComplete(){tt||Wt()}}),l.useImperativeHandle(e.actionsRef,()=>({unmount:Wt}),[Wt]),U(function(){let e=xe.current!==null&&ye===null;if(xe.current=ye,tt&&(!e||!Ue)||(tt||(Le.current=null),d===`none`))return;let t=Ue?dt:Ie.current;Lt({selectedIndex:Sm(t,Ge,j,Be)})},[tt,ye,Ge,d,Be,Ue,dt,j,Lt]),U(()=>{de&&(Ie.current=dt,Se.current.length=dt.length)},[de,dt]),U(()=>{let e=Fe.current;if(e){let t=tt||wt||Y.state.positionerElement?.hidden===!1;if(e.hasQuery)J&&t&&Y.set(`activeIndex`,0),Fe.current=null;else if(String($e).trim()===``&&(Fe.current=null,t)){let t=e.selection;J===`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:Ie.current,i=bm(t,e.toggledValue,Y.state.isItemEqualToValue);Y.set(`activeIndex`,i===-1?Sm(t,n,Y.state.isItemEqualToValue,r):i)}else t?Y.set(`activeIndex`,null):J===`always`&&Y.set(`activeIndex`,0)})}}if(!tt&&!wt)return;let t=Ue||We?dt:Ie.current,n=Y.state.activeIndex;if(n==null){if(J===`always`&&t.length>0){Y.set(`activeIndex`,0);return}It(void 0,-1,cn);return}if(n>=t.length){It(void 0,-1,cn),Y.set(`activeIndex`,null);return}let r=t[n],i=Pe.current.value,a=i!==th&&_m(r,i,Y.state.isItemEqualToValue);(Pe.current.index!==n||!a)&&It(r,n,cn)},[gt,J,It,We,Ue,dt,wt,tt,Y,$e]),U(()=>{if(d===`none`){re(String($e)!==``);return}re(Be?Array.isArray(Ge)&&Ge.length>0:Ge!=null)},[re,d,$e,Ge,Be]),l.useEffect(()=>{Ue&&J&&dt.length===0&&Lt({activeIndex:null})},[Ue,J,dt.length,Lt]);function Kt(){tt&&it!==``&&it!==String(Qe)&&!Dt&&ve(!0)}function qt(){tt&&ye!==null&&zt(!1)}let Jt=!1;function Yt(){!Jt&&$e!==at&&(Jt=!0,Rt(at,Z(cn)))}function Xt(){d!==`none`&&(B(ze),te(vm(Ge,ne.initialValue,j)),se.change(Ge),Ve&&!He&&!Tt&&Yt())}function Zt(){Ve&&!He&&!Tt&&!_e&&Yt()}function Qt(){d===`none`&&(B(ze),te($e!==ne.initialValue),se.change($e))}Kc(it,Kt),Kc(tt,qt),Kc(Ge,Xt),Kc(at,Zt),Kc(de,Zt),Kc($e,Qt);let $t=Rs({open:wt?!0:tt,onOpenChange:Bt,elements:{reference:Tt?bt:St,floating:vt}}),en=y?`grid`:`listbox`,tn=tt||wt,nn=tn?`true`:`false`,rn=l.useMemo(()=>{let e=St?.tagName===`INPUT`,t=St==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`}}},[St,tn,nn,en,yt?.id,L,g]),an=Aa($t,{enabled:!Re&&w,event:`mousedown-only`,toggle:!1,touchOpenDelay:Tt?0:100,reason:_n}),on=Ia($t,{enabled:!Re&&!wt,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:wt?!0:void 0,outsidePress(e){let t=xt(e);return!X(bt,t)&&!X(Me.current,t)&&!X(je.current,t)&&!X(Ct,t)}}),sn=ic($t,{enabled:!Re,id:W,listRef:Se,activeIndex:gt,selectedIndex:_t,virtual:!0,loopFocus:O,allowEscape:O&&!J,focusItemOnOpen:_e||d===`none`&&!J?!1:`auto`,focusItemOnHover:D,resetOnPointerLeave:!E,orientation:y?`horizontal`:void 0,rtl:ce===`rtl`,disabledIndices:Je,grid:y?im:void 0,onNavigate(e,t){(t||tt)&&jt!==`ending`&&Lt(t?{activeIndex:e,type:q.current?xn:Sn}:{activeIndex:e})}}),ln=l.useMemo(()=>Pi(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]),un=l.useMemo(()=>Pi(hs,on.floating),[on.floating]),dn=l.useMemo(()=>Pi(sn.floating,rn.floating),[sn.floating,rn.floating]),fn=l.useMemo(()=>{let e=sn.item;return e?{...e,onFocus:void 0}:Ye},[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),rm(()=>{Y.update({inline:N,popupProps:un,listProps:dn,inputProps:ln,triggerProps:Nt,itemProps:fn})});let mn={id:W,selectedValue:Ge,open:tt,mounted:kt,transitionStatus:jt,items:fe,inline:N,popupProps:un,listProps:dn,inputProps:ln,triggerProps:Nt,itemProps:fn,openMethod:Mt,selectionMode:d,name:ze,form:m,disabled:Re,readOnly:g,required:_,grid:y,virtualized:M,openOnInputClick:w,itemToStringLabel:me,modal:F,autoHighlight:J,isItemEqualToValue:j,submitOnItemClick:ee,hasInputValue:He};U(()=>{Y.update({...mn,inputOwnsFormValue:d===`none`&&(N||!Y.state.inputInsidePopup)})},[Y,...Object.values(mn)]);let vn=Nn(v,se.inputRef),yn=l.useMemo(()=>({query:it,hasItems:Ue,filteredItems:ut,flatFilteredValues:dt}),[it,Ue,ut,dt]),bn=l.useMemo(()=>Array.isArray(ft)?``:jm(ft,A),[ft,A]),Cn=Be&&Array.isArray(Ge)&&Ge.length>0,wn=Be||d===`none`&&Et?void 0:ze,Tn=l.useMemo(()=>!Be||!Array.isArray(Ge)||!ze?null:Ge.map(e=>{let t=jm(e,A);return(0,Q.jsx)(`input`,{type:`hidden`,form:m,name:ze,value:t,disabled:Re},t)}),[Be,Ge,m,ze,A,Re]),En=(0,Q.jsxs)(l.Fragment,{children:[e.children,(0,Q.jsx)(`input`,{...se.getValidationProps(Re,{onFocus(){if(Tt){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(cn,e.nativeEvent),i=()=>Ie.current.findIndex(e=>jm(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=Ie.current.findIndex((e,t)=>{let r=Ce.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:Ie.current[e];a!=null&&Vt?.(a,r)}Ve&&(Ft(),de&&i()===-1&&Y.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:W&&wn==null?`${W}-hidden-input`:void 0,form:m,name:wn,autoComplete:R,disabled:Re,required:_&&!Cn,readOnly:g,value:bn,ref:vn,style:wn?Jn:qn,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Tn]});return(0,Q.jsx)(am.Provider,{value:Y,children:(0,Q.jsx)(om.Provider,{value:$t,children:(0,Q.jsx)(cm.Provider,{value:Ue,children:(0,Q.jsx)(sm.Provider,{value:yn,children:(0,Q.jsx)(lm.Provider,{value:$e,children:En})})})})})}function ah(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,Q.jsx)(ih,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}function oh(e,t){return e??t}var sh=`data-popup-side`,ch=`data-list-empty`,lh={...Wt,...Rm,popupSide:e=>e?{[sh]:e}:null,listEmpty:e=>e?{[ch]:``}:null},uh=l.createContext(void 0);function dh(){return l.useContext(uh)}var fh=l.createContext(void 0);function ph(e){let t=l.useContext(fh);if(t===void 0&&!e)throw Error(Ti(21));return t}var mh=l.forwardRef(function(e,t){let n=um(),{buttonRef:r,getButtonProps:i}=Oc({native:!1}),a=Nn(t,r);function o(e){n.context.setOpen(!1,Z(mn,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return(0,Q.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:Jn})});function hh(e){let t=e.useState(`mounted`),n=e.useState(`popupSide`),r=e.useState(`positionerElement`);return t&&r?n:null}function gh(){return fm().filteredItems.length===0}function _h(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function vh(e,t){let n=e>=t-1?t-2:e;return n>=0?n:void 0}function yh(e,t,n){let r=e.context.listRef.current[t];r&&(e.context.selectionEventRef.current=n,r.click(),e.context.selectionEventRef.current=null)}var bh=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}=Vm(),{labelId:h}=Km(),g=dh(),_=!!ph(!0),v=um(),y=pm(),b=Cl(),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=hh(v),R=u||S||i,z=gh(),ee=_||P,B=!ee||F,te=Mc(a??(ee?void 0:N)),ne=_?Im:c,[re,V]=l.useState(null),H=l.useRef(!1),ie=l.useRef(null),ae=l.useRef(!1),oe=E===`none`&&!_,se=$(e=>{let t=_||v.state.inline;t&&!v.state.hasInputValue&&v.context.setInputValue(``,Z(cn)),v.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:oe})}),U=_?s:m.getValidationProps(R,s);function ce(){v.context.setIndices({activeIndex:null,selectedIndex:null,type:v.context.keyboardActiveRef.current?xn:Sn})}function W(){v.context.keyboardActiveRef.current=!1}let le={...ne,open:A,disabled:R,readOnly:C,popupSide:L,listEmpty:z};function ue(e){if(!g)return;let t,{highlightedChipIndex:n}=g,r=g.chipsRef.current.length,[i,a]=_h(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=vh(n,M.length),ce()),t)}let de=Ji(`input`,e,{state:le,ref:[t,v.context.inputRef,se],props:[O,k,{value:re??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,...oe&&w&&{name:w},id:te,onFocus(){if(f(!0),!P||!ae.current)return;ae.current=!1;let e=ie.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`&&(ie.current=e,ae.current=!0,v.context.setIndices({activeIndex:null})),p===`onBlur`){let e=E===`none`?y:M;m.commit(e)}},onCompositionStart(e){Re||(H.current=!0,V(e.currentTarget.value))},onCompositionEnd(e){H.current=!1;let t=e.currentTarget.value;V(null),v.context.setInputValue(t,Z(hn,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=H.current||!r;function a(e){!C&&!R&&e&&i&&(v.context.setOpen(!0,Z(hn,t)),I||ce())}if(H.current){let n=e.currentTarget.value;V(n),n===``&&!v.state.openOnInputClick&&!v.state.inputInsidePopup&&v.context.setOpen(!1,Z(gn,t));let r=n.trim(),i=I&&r!==``;a(r),A&&v.state.activeIndex!==null&&!i&&ce();return}let o=Z(hn,t);if(v.context.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=Z(gn,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&&mt(e);return}let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=b===`rtl`;if(e.key===`Home`){mt(e);let n=He&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){mt(e);let i=He&&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(yn,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(cn,e.nativeEvent));return}let i=g?.highlightedChipIndex!==void 0,a=ue(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(cn,n));return}mt(e),yh(v,t,n)}},onPointerMove:W,onPointerDown:W},U],stateAttributesMapping:lh}),G=_?(0,Q.jsx)(Bm.Provider,{value:zm,children:de}):de;return(0,Q.jsxs)(l.Fragment,{children:[A&&B&&(0,Q.jsx)(mh,{ref:v.context.startDismissRef}),G]})}),xh=5;function Sh(e,t){let n=Ch(t);return e.clientX>=n.left-xh&&e.clientX<=n.right+xh&&e.clientY>=n.top-xh&&e.clientY<=n.bottom+xh}function Ch(e){let t=e.getBoundingClientRect(),n=le(e);if(We)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 wh=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}=Vm(),{labelId:g}=Km(),_=um(),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=dm(),F=pm(),I=$e(),L=d||y||a,R=gh(),z=hh(_);qm({id:E?o:void 0});let ee=E?o??D:o,B=oh(g,O),te;k&&E?te=w??Jm(D):k&&(te=C?.id);let ne=l.useRef(``);function re(e){ne.current=e.pointerType}let{reference:V}=ac(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(cn))}}),{reference:H}=Aa(P,{enabled:!y,event:`mousedown`}),{buttonRef:ie,getButtonProps:ae}=Oc({native:i,disabled:L}),oe={...u,readOnly:b,open:k,disabled:L,popupSide:z,listEmpty:R,placeholder:v!==`none`&&!N};return Ji(`button`,e,{ref:[t,ie,$(e=>{_.set(`triggerElement`,e)})],state:oe,props:[T,H,V,{id:ee,tabIndex:E?0:-1,role:E?`combobox`:void 0,"aria-expanded":k,"aria-haspopup":E?`dialog`:`listbox`,"aria-controls":te,"aria-required":E&&x||void 0,"aria-readonly":E&&b||void 0,"aria-labelledby":B,onPointerDown:re,onPointerEnter:re,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(),ne.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=xt(e),r=_.state.positionerElement,i=_.state.listElement;X(t,n)||X(r,n)||X(i,n)||Sh(e,t)||_.context.setOpen(!1,Z(Cn,e))}E&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(mt(e),_.context.setOpen(!0,Z(bn,e.nativeEvent)),_.context.inputRef.current?.focus())}},h.getValidationProps(L,c),ae],stateAttributesMapping:lh})}),Th=l.createContext(null);function Eh(){return l.useContext(Th)}function Dh(e){let{children:t}=e,{filteredItems:n}=fm(),r=Eh(),i=r?r.items:n;return(0,Q.jsx)(l.Fragment,{children:i.map(t)})}var Oh=l.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},nextIndexRef:{current:0}});function kh(){return l.useContext(Oh)}function Ah(e){let{children:t,elementsRef:n,labelsRef:r,onMapChange:i}=e,a=$(i),[,o]=l.useState(!1),s=Ke(Mh).current,c=Ke(jh).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(!Fh(n))return;let r=null;for(let n of e)if(n.isConnected){if(r&&Ih(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=Ph(e[t-1],e[t]);r&&n.add(r)}n.forEach(e=>t.observe(e,{childList:!0}))}let y=$(()=>{let[e,t]=Nh(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))});U(()=>(!d.current&&f.current&&_(f.current),()=>{n.current=[],r&&(r.current=[])}),[n,r,_]),U(()=>{d.current&&y()}),U(()=>()=>{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)(Oh.Provider,{value:x,children:t})}function jh(){return new Map}function Mh(){return new Set}function Nh(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)=>Ih(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 Ph(e,t){let n=e.parentElement;for(;n&&!n.contains(t);)n=n.parentElement;return n}function Fh(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 Ih(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}var Lh=l.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=um(),u=dm(),d=!!ph(!0),{filteredItems:f,hasItems:p}=fm(),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)(Dh,{children:o}):o,[o]),T={empty:x},E=u.useState(`floatingId`),D=Ji(`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;mt(e),yh(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)(Ah,{elementsRef:c.context.listRef,labelsRef:O,children:D})}),Rh=``;function zh(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 Bh(){let e=$e(),t=l.useRef(null);return l.useEffect(()=>{if(Ie)return;let n=t.current;if(n==null)return;let r=zh(n);if(r==null)return;let i=r.data,a=`${i}${Rh}`;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 Vh=l.createContext(void 0);function Hh(){let e=l.useContext(Vh);if(e===void 0)throw Error(Ti(20));return e}var Uh=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=um(),a=i.useState(`mounted`),o=i.useState(`forceMounted`);return a||n||o?(0,Q.jsx)(Vh.Provider,{value:n,children:(0,Q.jsx)(ua,{ref:t,...r})}):null}),Wh=20;function Gh(e,t,n,r){let[i,a]=l.useState(!1);U(()=>{if(!e||!t||n==null){a(!1);return}let r=J(n).documentElement.clientWidth,i=n.offsetWidth;a(r>0&&i>0&&i>=r-Wh)},[e,t,n]),pt(e&&(!t||i),r)}var Kh=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=na,style:g,..._}=e,v=um(),y=dm(),b=Hh(),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=gh(),M=Ll({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});Gh(S&&x,w===`touch`,T,E);let N={open:S,side:M.side,align:M.align,anchorHidden:M.anchorHidden,empty:j};U(()=>{v.set(`popupSide`,M.side)},[v,M.side]);let P=$(e=>{v.set(`positionerElement`,e)}),F=Vl(e,N,{styles:M.positionerStyles,transitionStatus:A,props:_,refs:[t,P],hidden:!C,inert:!S});return(0,Q.jsxs)(fh.Provider,{value:M,children:[C&&x&&(0,Q.jsx)(Hc,{inert:Vc(!S),cutout:O??D??E}),F]})}),qh={...Gt,...Mt},Jh=l.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=um(),u=ph(),d=dm(),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=gh(),S=s.id??(_?Jm(b):void 0);U(()=>(c.set(`popupId`,c.context.popupRef.current?.id||S),()=>{c.set(`popupId`,void 0)}),[c,S]),ms({open:p,ref:c.context.popupRef,onComplete(){p&&c.context.onOpenChangeComplete(!0)}});let C=Ji(`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=xt(e.nativeEvent);m!==`touch`&&(X(c.state.listElement,t)||t===e.currentTarget)&&c.context.inputRef.current?.focus()}},Bl(g),s],stateAttributesMapping:qh}),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)(ka,{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)(mh,{ref:c.context.endDismissRef})]})})});function Yh(e={}){let{guess:t,label:n,metadata:r,textRef:i,index:a}=e,{register:o,unregister:s,subscribeMapChange:c,nextIndexRef:u}=kh(),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 U(()=>{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 Xh=l.createContext(void 0);function Zh(){let e=l.useContext(Xh);if(!e)throw Error(Ti(19));return e}var Qh=l.createContext(!1);function $h(){return l.useContext(Qh)}function eg(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=Yh({guess:!0,index:u,textRef:m}),g=um(),_=$h(),v=mm(),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;U(()=>{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]),U(()=>{if(!E||v)return;let e=g.context.valuesRef.current;return e[T]=c,()=>{delete e[T]}},[E,v,T,c,g]),U(()=>{if(!E||v)return;let e=g.state.selectedValue,t=g.state.selectedIndex;g.state.selectionMode===`multiple`&&Array.isArray(e)?t=Cm(T,c,g.context.valuesRef.current,e,S,t):_m(c,e,S)&&(t=T),g.set(`selectedIndex`,t)},[E,v,g,T,c,S]);let{getButtonProps:P,buttonRef:F}=Oc({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?(aa.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=Ji(`div`,t,{ref:[F,n,h.ref,j],state:I,props:[A,R,p,P]}),ee=l.useMemo(()=>({selected:N,textRef:m}),[N,m]);return(0,Q.jsx)(Xh.Provider,{value:ee,children:z})}function tg(e){let{componentProps:t,forwardedRef:n}=e,r=um().useState(`isItemEqualToValue`),{flatFilteredValues:i}=fm(),a=bm(i,t.value??null,r);return(0,Q.jsx)(eg,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:a})}var ng=l.memo(l.forwardRef(function(e,t){let n=um().useState(`virtualized`);return n&&e.index==null?(0,Q.jsx)(tg,{componentProps:e,forwardedRef:t}):(0,Q.jsx)(eg,{componentProps:e,forwardedRef:t,virtualized:n,indexFromFilter:void 0})})),rg=l.forwardRef(function(e,t){let{selected:n}=Zh();return e.keepMounted||n?(0,Q.jsx)(ig,{...e,ref:t}):null}),ig=l.memo(l.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=Zh(),c=l.useRef(null),{transitionStatus:u,setMounted:d}=us(s),f=Ji(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:u},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:Mt});return ms({batch:!0,enabled:!s,open:s,ref:c,onComplete(){s||d(!1)}}),f})),ag=l.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=fm(),c=um(),l=Bh(),u=s.length===0?a:null;return Ji(`div`,e,{ref:[t,c.context.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})});function og({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)(ah,{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)(Wl,{label:`${e}: ${u.label}`,children:(0,Q.jsxs)(wh,{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)(y,{className:`composer-select-caret`,size:11,"aria-hidden":`true`})]})}),(0,Q.jsx)(Uh,{children:(0,Q.jsx)(Kh,{className:`composer-select-positioner`,sideOffset:6,align:`start`,collisionPadding:12,children:(0,Q.jsxs)(Jh,{className:`composer-select-popup`,"aria-label":`${e} options`,children:[(0,Q.jsxs)(`div`,{className:`composer-select-search`,children:[(0,Q.jsx)(te,{size:14,"aria-hidden":`true`}),(0,Q.jsx)(bh,{"aria-label":`Search ${e.toLowerCase()}`,placeholder:`Search ${e.toLowerCase()}…`,maxLength:a?120:void 0})]}),(0,Q.jsx)(ag,{className:`composer-select-empty`,children:`No matches`}),(0,Q.jsx)(Lh,{className:`composer-select-list`,children:e=>(0,Q.jsxs)(ng,{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)(rg,{className:`composer-select-check`,children:(0,Q.jsx)(v,{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})]})]})})})]})}function sg({project:e}){let t=(0,l.useRef)(null),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{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 cg({projects:e,projectId:t,onChange:n,onAddProject:r}){return(0,Q.jsx)(og,{label:`Project`,value:t,onChange:n,icon:(0,Q.jsx)(O,{size:14}),action:r?{label:`Add project`,icon:(0,Q.jsx)(B,{size:14}),onClick:r}:void 0,options:e.map(e=>({value:e.id,label:e.name,icon:(0,Q.jsx)(sg,{project:e},e.id)}))})}var lg=e=>e.id===`local`?(0,Q.jsx)(P,{size:14}):(0,Q.jsx)(ne,{size:14});function ug({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)(og,{label:`Machine`,value:e.id,onChange:o,icon:lg(e),options:t.map(e=>({icon:lg(e),value:e.id,label:`${e.name}${e.connected?``:` · Not connected`}`,shortLabel:e.name,disabled:!e.connected}))}),(0,Q.jsx)(cg,{projects:n,projectId:r,onChange:s,onAddProject:u},e.id),(0,Q.jsx)(og,{label:`Harness`,value:i,onChange:c,icon:(0,Q.jsx)(H,{size:14}),options:e.harnesses.map(e=>({value:e.id,label:e.name,shortLabel:e.name===`Claude Code`?`Claude`:e.name}))}),(0,Q.jsx)(og,{label:`Model`,value:a,onChange:l,icon:(0,Q.jsx)(E,{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 dg=l.createContext(void 0),fg=e=>{let t=l.useContext(dg);if(e)return e;if(!t)throw Error(`No QueryClient set, use QueryClientProvider to set one`);return t},pg=({client:e,children:t})=>(l.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),(0,Q.jsx)(dg.Provider,{value:e,children:t})),mg={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},hg=new class{#e=mg;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 gg(e){setTimeout(e,0)}var _g=typeof window>`u`||`Deno`in globalThis;function vg(){}function yg(e,t){return typeof e==`function`?e(t):e}function bg(e){return typeof e==`number`&&e>=0&&e!==1/0}function xg(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Sg(e,t){return typeof e==`function`?e(t):e}function Cg(e,t){let{type:n=`all`,exact:r,fetchStatus:i,predicate:a,queryKey:o,stale:s}=e;if(o){if(r){if(t.queryHash!==Tg(o,t.options))return!1}else if(!Dg(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 wg(e,t){let{exact:n,status:r,predicate:i,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(Eg(t.options.mutationKey)!==Eg(a))return!1}else if(!Dg(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Tg(e,t){return(t?.queryKeyHashFn||Eg)(e)}function Eg(e){return JSON.stringify(e,(e,t)=>Mg(t)?Object.keys(t).sort().reduce((e,n)=>(e[n]=t[n],e),{}):t)}function Dg(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(!Dg(e[n],t[n]))return!1;return!0}let n=Object.keys(t);for(let r of n)if(!Dg(e[r],t[r]))return!1;return!0}return!1}var Og=Object.prototype.hasOwnProperty;function kg(e,t,n=0){if(e===t)return e;if(n>500)return t;let r=jg(e)&&jg(t);if(!r&&!(Mg(e)&&Mg(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:Og.call(e,o))&&c++;continue}if(u===null||d===null||typeof u!=`object`||typeof d!=`object`){s[o]=d;continue}let f=kg(u,d,n+1);s[o]=f,f===u&&c++}return i===o&&c===i?e:s}function Ag(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 jg(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Mg(e){if(!Ng(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!(!Ng(r)||!r.hasOwnProperty(`isPrototypeOf`)||t!==Object.prototype)}function Ng(e){return Object.prototype.toString.call(e)===`[object Object]`}function Pg(e){return new Promise(t=>{hg.setTimeout(t,e)})}function Fg(e,t,n){return typeof n.structuralSharing==`function`?n.structuralSharing(e,t):n.structuralSharing===!1?t:kg(e,t)}function Ig(e,t,n=0){let r=[...e,t];return n&&r.length>n?r.slice(1):r}function Lg(e,t,n=0){let r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Rg=Symbol();function zg(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Rg?()=>Promise.reject(Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Bg(e,t){return typeof e==`function`?e(...t):!!e}function Vg(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 Hg=()=>_g,Ug=()=>Hg(),Wg=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(){}},Gg=new class extends Wg{#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`}},Kg=gg;function qg(){let e=[],t=0,n=e=>{e()},r=e=>{e()},i=Kg,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 Jg=qg(),Yg=new class extends Wg{#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 Xg(e){return Math.min(1e3*2**e,3e4)}function Zg(e){return(e??`online`)!==`online`||Yg.isOnline()}var Qg=class extends Error{constructor(e){super(`CancelledError`),this.revert=e?.revert,this.silent=e?.silent}};function $g(e){let t=!1,n=0,r,i=`pending`,a,o,s=new Promise((e,t)=>{a=e,o=t});s.catch(vg);let c=()=>i!==`pending`,l=t=>{if(!c()){let n=new Qg(t);h(n),e.onCancel?.(n)}},u=()=>{t=!0},d=()=>{t=!1},f=()=>Gg.isFocused()&&(e.networkMode===`always`||Yg.isOnline())&&e.canRun(),p=()=>Zg(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??(Ug()?0:3),a=e.retryDelay??Xg,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),Pg(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 e_=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),bg(this.gcTime)&&(this.#e=hg.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Ug()?1/0:3e5))}clearGcTimeout(){this.#e!==void 0&&(hg.clearTimeout(this.#e),this.#e=void 0)}};function t_(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=>{Vg(e,()=>t.signal,()=>n=!0)},u=zg(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?Lg:Ig;return{pages:c(e.pages,o,s),pageParams:c(e.pageParams,r,s)}};if(i&&a.length){let e=i===`backward`,t=e?r_:n_,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:n_(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 n_(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 r_(e,{pages:t,pageParams:n}){return t.length>0?e.getPreviousPageParam?.(t[0],t,n[0],n):void 0}var i_=class extends e_{#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=s_(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=s_(this.options);e.data!==void 0&&(this.setState(o_(e.data,e.dataUpdatedAt)),this.#t=e)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus===`idle`&&this.#r.remove(this)}setData(e,t){let n=Fg(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(vg).catch(vg):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=>Sg(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Rg||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0&&this.observers.some(e=>Sg(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:!xg(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=zg(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`?t_(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=$g({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:e=>{e instanceof Qg&&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 Qg){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,...a_(t.data,this.options),fetchMeta:e.meta??null};case`success`:let n={...t,...o_(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),Jg.batch(()=>{this.observers.slice().forEach(e=>{e.onQueryUpdate()}),this.#r.notify({query:this,type:`updated`,action:e})})}};function a_(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Zg(t.networkMode)?`fetching`:`paused`,...e===void 0&&{error:null,status:`pending`}}}function o_(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:`success`}}function s_(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 c_=class extends Wg{#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),u_(this.#t,this.options)?this.#m():this.updateResult(),this.#y())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return d_(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return d_(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 Sg(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&&!Ag(this.options,t)&&this.#e.getQueryCache().notify({type:`observerOptionsUpdated`,query:this.#t,observer:this});let r=this.hasListeners();r&&f_(this.#t,n,this.options,t)&&this.#m(),this.updateResult(),r&&(this.#t!==n||Sg(this.options.enabled,this.#t)!==Sg(t.enabled,this.#t)||Sg(this.options.staleTime,this.#t)!==Sg(t.staleTime,this.#t))&&this.#g();let i=this.#_();r&&(this.#t!==n||Sg(this.options.enabled,this.#t)!==Sg(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 Ag(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(vg)),t}#h(e){return!Ug()&&Sg(this.options.enabled,this.#t)!==!1&&bg(e)}#g(){this.#b();let e=Sg(this.options.staleTime,this.#t);if(this.#r.isStale||!this.#h(e))return;let t=xg(this.#r.dataUpdatedAt,e)+1;this.#u=hg.setTimeout(()=>{this.#r.isStale||this.updateResult()},t)}#_(){return Sg(this.options.refetchInterval,this.#t)??!1}#v(e){this.#x(),this.#f=e,this.#f!==0&&this.#h(this.#f)&&(this.#d=hg.setInterval(()=>{(this.options.refetchIntervalInBackground||Gg.isFocused())&&this.#m()},this.#f))}#y(){this.#g(),this.#v(this.#_())}#b(){this.#u!==void 0&&(hg.clearTimeout(this.#u),this.#u=void 0)}#x(){this.#d!==void 0&&(hg.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&&u_(e,t),o=i&&f_(e,n,t,r);(a||o)&&(l={...l,...a_(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=Fg(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=Fg(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:p_(e,t),refetch:this.refetch,isEnabled:Sg(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),Ag(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)})})();Jg.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 l_(e,t){return Sg(t.enabled,e)!==!1&&e.state.data===void 0&&(e.state.status!==`error`||Sg(t.retryOnMount,e)!==!1)}function u_(e,t){return l_(e,t)||e.state.data!==void 0&&d_(e,t,t.refetchOnMount)}function d_(e,t,n){if(Sg(t.enabled,e)!==!1&&Sg(t.staleTime,e)!==`static`){let r=Sg(n,e);return r===`always`||r!==!1&&p_(e,t)}return!1}function f_(e,t,n,r){return(e!==t||Sg(r.enabled,e)===!1)&&(!n.suspense||e.state.status!==`error`)&&p_(e,n)}function p_(e,t){return Sg(t.enabled,e)!==!1&&e.isStaleByTime(Sg(t.staleTime,e))}var m_=class extends e_{#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||h_(),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=$g({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),Jg.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function h_(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var g_=class extends Wg{#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 m_({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=__(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=__(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=__(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=__(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Jg.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=>wg(t,e))}findAll(e={}){return this.getAll().filter(t=>wg(e,t))}notify(e){Jg.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Jg.batch(()=>Promise.all(e.map(e=>e.continue().catch(vg))))}};function __(e){return e.options.scope?.id}var v_=class extends Wg{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??Tg(r,t),a=this.get(i);return a||(a=new i_({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(){Jg.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=>Cg(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Cg(e,t)):t}notify(e){Jg.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Jg.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Jg.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},y_=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new v_,this.#t=e.mutationCache||new g_,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Gg.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Yg.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(Sg(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=yg(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Jg.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;Jg.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Jg.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=Jg.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(vg).catch(vg)}invalidateQueries(e,t={}){return Jg.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=Jg.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(vg)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(vg)}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(Sg(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(Sg(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(vg).catch(vg)}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(vg).catch(vg)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Yg.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(Eg(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Dg(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Eg(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Dg(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||=Tg(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===Rg&&(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()}},b_=l.createContext(!1),x_=()=>l.useContext(b_);b_.Provider;function S_(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var C_=l.createContext(S_()),w_=()=>l.useContext(C_),T_=(e,t,n)=>{let r=n?.state.error&&typeof e.throwOnError==`function`?Bg(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||r)&&(t.isReset()||(e.retryOnMount=!1))},E_=e=>{l.useEffect(()=>{e.clearReset()},[e])},D_=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Bg(n,[e.error,r])),O_=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))}},k_=(e,t)=>e?.suspense&&t.isPending,A_=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function j_(e,t,n){let r=x_(),i=w_(),a=fg(n),o=a.defaultQueryOptions(e),s=a.getQueryCache().get(o.queryHash),c=e.subscribed!==!1;o._optimisticResults=r?`isRestoring`:c?`optimistic`:void 0,O_(o),T_(o,i,s),E_(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(Jg.batchCalls(e)):vg;return u.updateResult(),t},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),l.useEffect(()=>{u.setOptions(o)},[o,u]),k_(o,d))throw A_(o,u,i);if(D_({result:d,errorResetBoundary:i,throwOnError:o.throwOnError,query:s,suspense:o.suspense}))throw d.error;return o.notifyOnChangeProps?d:u.trackResult(d)}function M_(e,t){return j_(e,c_,t)}function N_(e,t,n=1,r=``,i=``){return M_({queryKey:[`machine-catalog`,e,r,n,i],enabled:!!e&&t,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.`);return await n.json()}})}var P_=e=>e.startsWith(`/`)||e.startsWith(`~`),F_=e=>Array.isArray(e)?e.filter(e=>typeof e==`string`):[];function I_(e,t){let[n,r]=(0,l.useState)([]);return(0,l.useEffect)(()=>{if(!P_(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(F_(e))).catch(()=>{}),()=>n.abort()},[e,t]),n}var L_=e=>e.startsWith(`/`)||e.startsWith(`~/`);function R_({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=I_(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:Qp()});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||!L_(n)||!i.trim(),children:o?`Creating…`:`Create workspace`}),c&&(0,Q.jsx)(`p`,{className:`form-error`,role:`alert`,children:c})]})}var z_={main:`Main checkout`,worktree:`New worktree`,remember:`Remember by project`},B_=`webr-new-session-behavior`,V_=`webr-new-worktree`,H_=(e,t)=>`webr-last-worktree:${e}:${t}`,U_=e=>e===`main`||e===`worktree`||e===`remember`,W_=()=>localStorage.getItem(V_)===`false`?`main`:`worktree`;function G_(){let e=localStorage.getItem(B_);return U_(e)?e:W_()}function K_(e){localStorage.setItem(B_,e)}function q_(e,t,n){localStorage.setItem(H_(e,t),String(n))}var J_=(e,t)=>localStorage.getItem(H_(e,t))!==`false`;function Y_(e,t){let n=G_();return n===`remember`?J_(e,t):n===`worktree`}var X_=`webr-new-thread-draft`,Z_=e=>!!e&&typeof e==`object`&&[`id`,`name`,`preview`,`path`].every(t=>typeof e[t]==`string`);function Q_(){try{let e=JSON.parse(localStorage.getItem(X_)??`{}`);return{prompt:typeof e.prompt==`string`?e.prompt:``,images:Array.isArray(e.images)?e.images.filter(Z_):[]}}catch{return{prompt:``,images:[]}}}function $_(e){try{!e.prompt&&!e.images.length?localStorage.removeItem(X_):localStorage.setItem(X_,JSON.stringify(e))}catch{}}var ev=()=>$_({prompt:``,images:[]}),tv=(e,t)=>`webr-last-harness:${e}:${t}`;function nv({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=tm({machineId:s}),D=t.find(e=>e.id===s)??{id:``,name:`No target`,connected:!1,session:``,projectPaths:{},harnesses:[]},O=N_(s,D.connected,D.configVersion,D.session,i),A={...D,harnesses:D.connected?O.data?.harnesses??[]:[]},j=e.filter(e=>Object.hasOwn(A.projectPaths,e.id)).map(e=>({...e,path:A.projectPaths[e.id],iconUrl:s===`local`?e.iconUrl:void 0})),M=A.harnesses.find(e=>e.id===u),N=!!(g.trim()&&!E.uploading&&f.trim()&&A.connected&&j.some(e=>e.id===i)&&M?.launchEnabled)&&!y,P=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let e=Q_();v(e.prompt),E.setAttachments(e.images),P.current=!0},[]),(0,l.useEffect)(()=>{P.current&&$_({prompt:g,images:E.attachments})},[g,E.attachments]),(0,l.useEffect)(()=>{h(Y_(s,i))},[s,i]),(0,l.useEffect)(()=>{if(!i||!O.data)return;let e=O.data.harnesses,t=localStorage.getItem(tv(s,i));d(e.find(e=>e.id===t)?.id??e.find(e=>e.launchEnabled)?.id??e[0]?.id??``),p(`Default`)},[s,i,O.data]),(0,l.useEffect)(()=>{!s&&t.length&&c(t.find(e=>e.id===`local`)?.id??t[0].id),!i&&j.length&&o(j[0].id)},[t,s,j,i]);let F=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(``))},I=e=>{o(e),d(``),p(`Default`),S(``)},L=e=>{d(e),p(`Default`),i&&localStorage.setItem(tv(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&&(!j.length||C)?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:j.length?`Add a project to this Herdr session.`:`This Herdr session has no projects yet.`}),(0,Q.jsx)(R_,{machineId:A.id,onCreated:()=>w(!1)}),!!j.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 ${E.dragging?`is-dropping`:``}`,onSubmit:async e=>{if(e.preventDefault(),!N)return;b(!0),S(``);let t=JSON.stringify({prompt:em(g,E.attachments),projectId:i,machineId:s,agent:u,model:f.trim(),worktree:m});T.current?.payload!==t&&(T.current={payload:t,key:Qp()});try{let e=await fetch(`/api/threads`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":T.current.key},body:t}),n=await e.json();if(!e.ok)throw Error(n.error||`Could not create thread`);q_(s,i,m),ev(),await a(`/threads/${encodeURIComponent(n.id)}`)}catch(e){S(e instanceof Error?e.message:`Could not create thread`),b(!1)}},"aria-busy":y,...E.handlers,children:[(E.attachments.length>0||E.uploading>0)&&(0,Q.jsxs)(`ul`,{className:`composer-images`,"aria-label":`Attached images`,children:[E.attachments.map(e=>(0,Q.jsxs)(`li`,{children:[(0,Q.jsx)(`img`,{src:e.preview,alt:e.name}),(0,Q.jsx)(Wl,{label:`Remove image`,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,onClick:()=>E.remove(e.id),children:(0,Q.jsx)(se,{size:12,strokeWidth:2.4})})})]},e.id)),Array.from({length:E.uploading},(e,t)=>(0,Q.jsx)(`li`,{className:`is-uploading`,"aria-label":`Uploading image`},`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)(ug,{machine:A,machines:t,projects:j,projectId:i,harness:u,model:f,onMachineChange:F,onProjectChange:I,onHarnessChange:L,onModelChange:p,onAddProject:A.connected&&A.writable?()=>w(!0):void 0}),(0,Q.jsx)(Wl,{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)(k,{size:15,"aria-hidden":`true`})]})}),(0,Q.jsx)(`div`,{className:`composer-actions`,children:(0,Q.jsx)(Wl,{label:`Create thread`,children:(0,Q.jsx)(`button`,{className:`composer-send`,type:`submit`,disabled:!N,"aria-label":`Create thread`,children:y?`…`:(0,Q.jsx)(_,{size:18,strokeWidth:2.2})})})})]})]}),(M?.reason||!t.length||A.error||O.isError)&&(0,Q.jsx)(`p`,{className:`composer-preview-note`,children:M?.reason??(t.length?A.error?`Machine is not connected: ${A.error.replaceAll(`_`,` `)}.`:`The machine catalog is not available.`:`No target is configured.`)}),E.error&&(0,Q.jsx)(`p`,{className:`form-error`,role:`alert`,children:E.error}),x&&(0,Q.jsx)(`p`,{className:`form-error`,role:`alert`,children:x})]})]})}var rv=Yo(function(e){return xc(`dialog`,e)}),iv=52,av=`?`;function ov(e){let t=e.slice(e.indexOf(`;`)+1);if(e.includes(`;`)&&t&&t!==av)try{return new TextDecoder(`utf-8`,{fatal:!0}).decode(Uint8Array.from(atob(t),e=>e.charCodeAt(0)))}catch{return}}function sv(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 cv(e){try{return await navigator.clipboard.writeText(e),!0}catch{return sv(e)}}var lv=e=>(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.selectionStart!==e.selectionEnd||!!document.getSelection()?.toString();function uv(e,t,n,r){let i=()=>{t.hasSelection()&&cv(t.getSelection()).then(r)},a=e=>{e.defaultPrevented||!t.hasSelection()||lv(e.target)||(e.clipboardData?.setData(`text/plain`,t.getSelection()),e.preventDefault(),r(!0))},o=t.parser.registerOscHandler(iv,e=>{let t=ov(e);return t!==void 0&&n()&&cv(t).then(r),!0});return e.addEventListener(`mouseup`,i),window.addEventListener(`copy`,a),()=>{o.dispose(),e.removeEventListener(`mouseup`,i),window.removeEventListener(`copy`,a)}}var dv=(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))(dv||{}),fv=[0,1],pv=[1,0],mv=[2,3],hv=[3,2],gv={L:fv,M:pv,Q:mv,H:hv},_v=/^\d*$/,vv=/^[A-Z0-9 $%*+./:-]*$/,yv=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`,bv=1,xv=40,Sv=3,Cv=3,wv=40,Tv=10,Ev=[[-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]],Dv=[[-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]],Ov=class{constructor(e,t,n,r){if(this.version=e,this.ecc=t,e<bv||e>xv)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,dv.Timing),this.setFunctionModule(e,6,e%2==0,dv.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,Av(r,e));this.setFunctionModule(8,7,Av(r,6)),this.setFunctionModule(8,8,Av(r,7)),this.setFunctionModule(7,8,Av(r,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,Av(r,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,Av(r,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,Av(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=Av(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,dv.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,dv.Alignment)}setFunctionModule(e,t,n,r=dv.Function){this.modules[t][e]=n,this.types[t][e]=r}addEccAndInterleave(e){let t=this.version,n=this.ecc;if(e.length!==Gv(t,n))throw RangeError(`Invalid argument`);let r=Dv[n[0]][t],i=Ev[n[0]][t],a=Math.floor(Wv(t)/8),o=r-a%r,s=Math.floor(a/r),c=[],l=Kv(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=qv(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(Wv(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]=Av(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+=Sv:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*wv),n=this.modules[t][a],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*wv}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+=Sv:r>5&&e++):(this.finderPenaltyAddHistory(r,i),n||(e+=this.finderPenaltyCountPatterns(i)*wv),n=this.modules[a][t],r=1);e+=this.finderPenaltyTerminateAndCount(n,r,i)*wv}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+=Cv)}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*Tv,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 kv(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 Av(e,t){return!!(e>>>t&1)}var jv=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()}},Mv=[1,10,12,14],Nv=[2,9,11,13],Pv=[4,8,16,16];function Fv(e,t){return e[Math.floor((t+7)/17)+1]}function Iv(e){let t=[];for(let n of e)kv(n,8,t);return new jv(Pv,e.length,t)}function Lv(e){if(!Bv(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);kv(Number.parseInt(e.substring(n,n+r),10),r*3+1,t),n+=r}return new jv(Mv,e.length,t)}function Rv(e){if(!Vv(e))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let t=[],n=0;for(;n+2<=e.length;n+=2){let r=yv.indexOf(e.charAt(n))*45;r+=yv.indexOf(e.charAt(n+1)),kv(r,11,t)}return n<e.length&&kv(yv.indexOf(e.charAt(n)),6,t),new jv(Nv,e.length,t)}function zv(e){return e===``?[]:Bv(e)?[Lv(e)]:Vv(e)?[Rv(e)]:[Iv(Uv(e))]}function Bv(e){return _v.test(e)}function Vv(e){return vv.test(e)}function Hv(e,t){let n=0;for(let r of e){let e=Fv(r.mode,t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}function Uv(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 Wv(e){if(e<bv||e>xv)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 Gv(e,t){return Math.floor(Wv(e)/8)-Ev[t[0]][e]*Dv[t[0]][e]}function Kv(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]=Jv(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=Jv(n,2)}return t}function qv(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]^=Jv(t,e))}return n}function Jv(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 Yv(e,t,n=1,r=40,i=-1,a=!0){if(!(bv<=n&&n<=r&&r<=xv)||i<-1||i>7)throw RangeError(`Invalid value`);let o,s;for(o=n;;o++){let n=Gv(o,t)*8,i=Hv(e,o);if(i<=n){s=i;break}if(o>=r)throw RangeError(`Data too long`)}for(let e of[pv,mv,hv])a&&s<=Gv(o,e)*8&&(t=e);let c=[];for(let t of e){kv(t.mode[0],4,c),kv(t.numChars,Fv(t.mode,o),c);for(let e of t.getData())c.push(e)}let l=Gv(o,t)*8;kv(0,Math.min(4,l-c.length),c),kv(0,(8-c.length%8)%8,c);for(let e=236;c.length<l;e^=253)kv(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 Ov(o,t,u,i)}function Xv(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`?zv(e):Array.isArray(e)?[Iv(e)]:void 0;if(!c)throw Error(`uqr only supports encoding string and binary data, but got: ${typeof e}`);let l=Yv(c,gv[n],i,a,o,r),u=Zv({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 Zv(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=dv.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 Qv=2;function $v({value:e,label:t}){let{data:n,size:r}=Xv(e),i=n.flatMap((e,t)=>e.flatMap((e,n)=>e?[`M${n+Qv} ${t+Qv}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 ey(){let[e,t]=(0,l.useState)(Np);return!Mp()||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 Pp().then(t),children:`Turn on`})]})}var ty=8;function ny({refreshKey:e}){let[t,n]=(0,l.useState)([]);return(0,l.useEffect)(()=>{Cp().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,ty).map(e=>(0,Q.jsxs)(`p`,{className:`activity-row`,children:[(0,Q.jsx)(`span`,{children:Fp(e)}),(0,Q.jsx)(`time`,{dateTime:new Date(e.at).toISOString(),children:jp(e.at)})]},e.id))]}):null}function ry({invite:e,onClose:t}){let[n,r]=(0,l.useState)(0),[i,a]=(0,l.useState)(!1),o=e.urls[n],s=()=>cv(e.token).then(e=>{e&&(a(!0),setTimeout(()=>a(!1),1500))});return(0,Q.jsx)(rv,{open:!0,onOpenChange:e=>{e||t()},children:(0,Q.jsxs)(Uc,{children:[(0,Q.jsx)(Cc,{className:`dialog-backdrop`}),(0,Q.jsxs)(Bc,{className:`dialog pairing-invite`,children:[(0,Q.jsx)(Wc,{className:`pairing-title`,children:`Connect a device`}),o?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Nc,{className:`dialog-message`,children:`Scan with the device’s camera, or open Webr there and enter the code.`}),(0,Q.jsx)($v,{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:()=>r(t),children:new URL(e).host},e))})]}):(0,Q.jsxs)(Nc,{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 s(),"aria-label":`Copy code`,children:i?(0,Q.jsx)(v,{size:14}):(0,Q.jsx)(T,{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)(jc,{className:`dialog-button is-primary`,children:`Done`})})]})]})})}function iy(){let[e,t]=(0,l.useState)([]),[n,r]=(0,l.useState)(),[i,a]=(0,l.useState)(``),o=(0,l.useCallback)(()=>Sp().then(t,()=>void 0),[]);(0,l.useEffect)(()=>{o()},[o]);let s=()=>xp().then(e=>{a(``),r(e)},e=>a(e.message)),c=async e=>{await el(`Disconnect ${e.name}? It will need to be approved again.`,{confirmLabel:`Disconnect`,danger:!0})&&(await wp(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.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)(ey,{}),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 `,jp(e.lastSeenAt),` · Signs out `,Ip(e.expiresAt),` if unused`]})]}),(0,Q.jsx)(`button`,{type:`button`,className:`dialog-button`,onClick:()=>void c(e),children:`Disconnect`})]},e.id)),(0,Q.jsx)(ny,{refreshKey:e}),n&&(0,Q.jsx)(ry,{invite:n,onClose:()=>r(void 0)})]})}function ay({onOpenSidebar:e}){let[t,n]=(0,l.useState)(`worktree`),[r,i]=(0,l.useState)(Wf),[a,o]=(0,l.useState)(null),[s,c]=(0,l.useState)(``);(0,l.useEffect)(()=>{n(G_()),i(Gf())},[]);let u=(e,t)=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){o(null),c(``);return}let n=Jf(e);if(!n)return;if(Yf(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.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)(Zf,{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(z_).map(e=>(0,Q.jsx)(`button`,{type:`button`,"aria-pressed":t===e,className:t===e?`theme-option is-selected`:`theme-option`,onClick:()=>{n(e),K_(e)},children:z_[e]},e))})]})]}),(0,Q.jsx)(iy,{}),(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(Wf),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(Uf).map(e=>(0,Q.jsxs)(`div`,{className:`settings-row`,children:[(0,Q.jsx)(`span`,{children:Uf[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 ${Uf[e]} shortcut`,children:a===e?`Press keys…`:Kf(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 oy=l.createContext(void 0);function sy(e=!0){let t=l.useContext(oy);if(t===void 0&&!e)throw Error(Ti(25));return t}var cy=l.createContext(void 0);function ly(e){let t=l.useContext(cy);if(t===void 0&&!e)throw Error(Ti(33));return t}var uy=l.createContext(void 0);function dy(e){let t=l.useContext(uy);if(t===void 0&&!e)throw Error(Ti(36));return t}function fy(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=sy(!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:pn})},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&&!ze&&e.button===2)return}s.current&&a.context.allowMouseUpTriggerRef.current&&(!p||e.button===2)&&c.type===`regular-item`&&Dc(s.current,e,{detail:1})}}),[t,n,r,u,i,d,a,o,s,f,p,c])}var py={type:`regular-item`};function my(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}=Oc({disabled:n,focusableWhenDisabled:!0,native:s,composite:!0}),m=fy({closeOnClick:t,highlighted:r,id:i,nodeId:u,store:a,typingRef:o,itemRef:d,itemMetadata:c}),h=l.useCallback(e=>Pi(m,{onMouseEnter(){c.type===`submenu-trigger`&&c.setActive()}},e,f),[m,f,c]),g=Nn(d,p);return l.useMemo(()=>({getItemProps:h,itemRef:g}),[h,g])}var hy=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=Yh({guess:!0,label:a}),f=ly(!0),p=Mc(i),{store:m}=dy(),h=m.useState(`disabled`),g=s||h,_=m.useState(`isActive`,d.index),v=m.useState(`itemProps`),{getItemProps:y,itemRef:b}=my({closeOnClick:c,disabled:g,highlighted:_,id:p,store:m,nativeButton:o,nodeId:f?.context.nodeId,itemMetadata:py});return Ji(`div`,e,{state:{disabled:g,highlighted:_},props:[v,u,y],ref:[b,t,d.ref]})}),gy=l.createContext(void 0);function _y(e){let t=l.useContext(gy);if(t===void 0&&!e)throw Error(Ti(69));return t}var vy=l.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,{store:s}=dy(),{side:c,align:u}=ly(),d=_y(!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`;ms({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]),Js(x,{enabled:w&&!T&&!D&&v.type!==`menubar`,closeDelay:C});let O=s.useStateSetter(`popupElement`),k=Ji(`div`,e,{state:{transitionStatus:p,side:c,align:u,open:f,nested:v.type===`menu`,instant:g},ref:[t,s.context.popupRef,O],stateAttributesMapping:Kt,props:[m,{onKeyDown(e){d&&Ic.has(e.key)&&e.stopPropagation()}},Bl(p),o,{"data-rootownerid":b}]}),A=v.type===void 0||D;return(_||v.type===`menubar`&&y!==`outside-press`)&&(A=!0),(0,Q.jsx)(ka,{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})}),yy=l.createContext(void 0);function by(){let e=l.useContext(yy);if(e===void 0)throw Error(Ti(32));return e}var xy=l.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,{store:i,parent:a}=dy();if(!(i.useState(`mounted`)||n))return null;let o=a.type===`menu`||a.type===`menubar`?`group`:void 0;return(0,Q.jsx)(yy.Provider,{value:n,children:(0,Q.jsx)(ua,{ref:t,...r,portalOwnerRole:o})})}),Sy=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=na,style:_,...v}=e,{store:y}=dy(),b=by(),x=sy(!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=ps(j),ee=n,B=c,te=u,ne=s,re=g;S.type===`context-menu`&&(ee=n??S.context?.anchor,ne??=`start`,!o&&ne!==`center`&&(te=e.alignOffset??2,B=e.sideOffset??-5));let V=o,H=ne;S.type===`menu`?(V??=`inline-end`,H??=`start`,re=e.collisionAvoidance??ra):S.type===`menubar`&&(V??=S.context.orientation===`vertical`?`inline-end`:`bottom`,H??=`start`);let ie=S.type===`context-menu`,ae=Ll({anchor:ee,floatingRootContext:C,positionMethod:x?`fixed`:r,mounted:T,side:V,sideOffset:B,align:H,alignOffset:te,arrowPadding:ie?0:p,collisionBoundary:d,collisionPadding:f,sticky:m,nodeId:F,keepMounted:b,disableAnchorTracking:h,collisionAvoidance:re,shift:ie?{crossAxis:!(`side`in re&&re.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(wn)))}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 oe=$e();l.useEffect(()=>{E||oe.clear()},[E,oe]),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?oe.isStarted()||oe.start(e,()=>{y.setOpen(!1,Z(wn))}):y.setOpen(!1,Z(wn))}else oe.clear()}}return w.events.on(`itemhover`,e),()=>{w.events.off(`itemhover`,e)}},[w.events,E,k,y,oe]),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]),U(()=>{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 se={open:E,side:ae.side,align:ae.align,anchorHidden:ae.anchorHidden,nested:S.type===`menu`,instant:M},ce=S.type===`menubar`&&S.context.modal;Gh(E&&(ce||D&&P!==`trigger-hover`),O===`touch`,j,k);let W=Vl(e,se,{styles:ae.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)(cy.Provider,{value:ae,children:[le&&(0,Q.jsx)(Hc,{ref:S.type===`context-menu`||S.type===`nested-context-menu`?S.context.internalBackdropRef:null,inert:Vc(!E),cutout:ue}),(0,Q.jsx)(va,{id:F,children:(0,Q.jsx)(Ah,{elementsRef:y.context.itemDomElements,labelsRef:y.context.itemLabels,children:W})})]})}),Cy=l.createContext(null);function wy(e){let t=l.useContext(Cy);if(t===null&&!e)throw Error(Ti(5));return t}var Ty={...Is,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`)}},Ey=class extends os{constructor(e,t,n=!1){let r=new ks,i=Oy(r,t,n,e);super(i,Dy(r),Ty),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 Dy(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 Oy(e,t,n=!1,r){return{...As(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 fa,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Ye,keyboardEventRelay:void 0,closeDelay:0,adaptiveOrigin:void 0,...r}}var ky=l.createContext(void 0);function Ay(){return l.useContext(ky)}var jy=Yo(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,_=sy(!0),v=dy(!0),y=wy(!0),b=Ay(),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=Ci(),C=Ci(),w=ha(),T=x.type===`menu`?x.store:void 0,E=(n??a)&&T?.state.transitionStatus===`starting`,D=Ke(()=>E?T?.state.instantType:void 0).current,O=My({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=_a(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`),ee=O.useState(`floatingParentNodeId`),B=l.useRef(null),te=l.useRef(L.type!==`context-menu`),ne=$e(),re=l.useRef(!0),V=$e(),H=ee!=null,{openMethod:ie,triggerProps:ae}=Jc(j);O.useSyncedValues({disabled:o,highlightItemOnHover:g,modal:L.type===void 0?s:void 0,openMethod:ie,rootId:S}),Ts(O);let{forceUnmount:oe,transitionStatus:se}=Es(j,O,()=>{O.set(`allowMouseEnter`,!1)},E),ce=ps(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(se!==void 0)return;if(O.context.popupRef.current==null){e();return}let t=new AbortController;return ce(e,t.signal),()=>{t.abort()}},[D,j,se,ce,O]),U(()=>{_&&!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||(B.current=null),L.type===`context-menu`){if(!j){ne.clear(),te.current=!1;return}ne.start(500,()=>{te.current=!0})}},[ne,j,L.type]),U(()=>{!j&&!P&&O.set(`hoverEnabled`,!0)},[j,P,O]);let W=$((e,t)=>{let n=t.reason;if(!e&&!O.select(`open`)||j===e&&t.trigger===M&&I===n)return;let i=Ss(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`&&!re.current)return;e&&n===`trigger-focus`?(re.current=!1,V.start(300,()=>{re.current=!0})):(re.current=!0,V.clear());let o=(n===`trigger-press`||n===`item-press`)&&a.detail===0,s=!e&&(n===`escape-key`||n==null);B.current=t.event;let c=xs(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=ls({popupStore:O,floatingRootContext:O.state.floatingRootContext,floatingId:C,nested:w!=null,onOpenChange:W}),ue=le.context.events;U(()=>{let e=({open:e,eventDetails:t})=>W(e,t);return ue.on(`setOpen`,e),()=>{ue?.off(`setOpen`,e)}},[ue,W]);let de=l.useCallback(()=>{O.setOpen(!1,Z(En))},[O]);l.useImperativeHandle(d,()=>({unmount:oe,close:de}),[oe,de]);let G;L.type===`context-menu`&&(G=L.context),l.useImperativeHandle(G?.positionerRef,()=>N,[N]),l.useImperativeHandle(G?.actionsRef,()=>({setOpen:W}),[W]);let K=Ia(le,{enabled:!F,bubbles:{escapeKey:f&&L.type===`menu`},outsidePress(){return L.type!==`context-menu`||B.current?.type===`contextmenu`||te.current},externalTree:H?k:void 0}),fe=Cl(),pe=l.useCallback(e=>{O.select(`activeIndex`)!==e&&O.set(`activeIndex`,e)},[O]),me=ic(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:fe===`rtl`,disabledIndices:Je,onNavigate:pe,openOnArrowKeyDown:L.type!==`context-menu`,externalTree:H?k:void 0,focusItemOnHover:g}),he=l.useCallback(e=>{O.context.typingRef.current=e},[O]),ge=ac(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:he}),_e=l.useMemo(()=>{let e=Pi(ge.reference,me.reference,K.reference,{onMouseMove(){O.set(`allowMouseEnter`,!0)}},ae);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=j,e},[O,ge.reference,me.reference,K.reference,ae,j]),ve=l.useMemo(()=>{let e=Pi(me.trigger,K.trigger,ae);return e[`aria-haspopup`]=`menu`,e[`aria-expanded`]=!1,e},[me.trigger,K.trigger,ae]);Ke(()=>(O.update({inactiveTriggerProps:ve}),null)),Ds(O,{floatingRootContext:le,activeTriggerProps:_e,inactiveTriggerProps:ve,popupProps:l.useMemo(()=>Pi(hs,{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)}},ge.floating,me.floating,K.floating),[M,C,u,L.type,O,ge.floating,me.floating,K.floating]),itemProps:me.item??Ye});let ye=l.useMemo(()=>({store:O,parent:x}),[O,x]),be=(0,Q.jsxs)(uy.Provider,{value:ye,children:[p&&(0,Q.jsx)(vs,{handle:p,store:O}),typeof t==`function`?t({payload:z}):t]});return L.type===void 0||L.type===`context-menu`?(0,Q.jsx)(ya,{externalTree:k,children:be}):be});function My(e,t,n){return Ke(()=>new Ey(e,t,n)).current}function Ny(e){let t=dy().store,n=l.useMemo(()=>({parentMenu:t}),[t]);return(0,Q.jsx)(ky.Provider,{value:n,children:(0,Q.jsx)(jy,{...e})})}function Py(e={}){let{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Tc(),{ref:i,index:a}=Yh(e),o=n===a,s=l.useRef(null),c=Nn(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 Fy(e){let{render:t,className:n,style:r,state:i=Ye,props:a=Je,refs:o=Je,metadata:s,stateAttributesMapping:c,tag:l=`div`,...u}=e,{compositeProps:d,compositeRef:f}=Py({metadata:s});return Ji(l,e,{state:i,ref:[f,...o],props:[d,...a,u],stateAttributesMapping:c})}function Iy(e){if(K(e)&&e.hasAttribute(`data-rootownerid`))return e.getAttribute(`data-rootownerid`);if(!Ce(e))return Iy(Ee(e))}function Ly(e,t){let n=l.useRef(null);function r(t){aa.flushSync(()=>{e.setOpen(!1,Z(vn,t.nativeEvent,t.currentTarget))}),$r(n.current)?.focus()}function i(n){let r=e.select(`positionerElement`);if(r&&ei(n,r))e.context.beforeContentFocusGuardRef.current?.focus();else{aa.flushSync(()=>{e.setOpen(!1,Z(vn,n.nativeEvent,n.currentTarget))});let i=Qr(e.context.triggerFocusTargetRef.current||t.current);for(;i!==null&&X(r,i);){let e=i;if(i=Yr(i),i===e)break}i?.focus()}}return{preFocusGuardRef:n,handlePreFocusGuardFocus:r,handleFocusTargetFocus:i}}function Ry(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())}}:Ye,[t,n,r])}var zy=Xo(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=dy(!0),g=Ls(f)??h?.store;if(!g)throw Error(Ti(85));let _=Mc(s),v=g.useState(`isTriggerActive`,_),y=g.useState(`floatingRootContext`),b=g.useState(`isOpenedByTrigger`,_),x=g.useState(`triggerPopupId`,_),S=l.useRef(null),C=Vy(),w=Tc(!0),T=ga(),E=l.useMemo(()=>T??new fa,[T]),{registerTrigger:D,isMountedByThisTrigger:O}=ws(_,S,g,{payload:p,closeDelay:d,parent:C,floatingTreeRoot:E,floatingNodeId:_a(E),floatingParentNodeId:ha(),keyboardEventRelay:w?.relayKeyboardEvent}),k=C.type===`menubar`,A=g.useState(`disabled`),j=a||A||k&&C.context.disabled,{getButtonProps:M,buttonRef:N}=Oc({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=$e(),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||Iy(t)!==g.select(`rootId`))&&(Sh(e,P.current)||E.events.emit(`close`,{domEvent:e,reason:Cn}))});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=Xs(y,{enabled:(c??L)&&!j&&(!k||L&&!O),handleClose:pc({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=By(b,g.select(`lastOpenChangeReason`)),ee=Aa(y,{enabled:!j,event:b&&k?`click`:`mousedown`,toggle:!0,ignoreMouse:!1,stickIfOpen:C.type===void 0&&z}),B=Hs(y,{enabled:!j&&L}),te=Ry({open:b,enabled:k,mouseDownAction:`open`}),ne=l.useMemo(()=>Pi(B.reference,ee.reference),[B.reference,ee.reference]),re=g.useState(`triggerProps`,O),{preFocusGuardRef:V,handlePreFocusGuardFocus:H,handleFocusTargetFocus:ie}=Ly(g,S),ae={disabled:j,open:b},oe=[P,t,N,D,S],se=[ne,R??Ye,re,{"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`}:{},te,m,M],U=Ji(`button`,e,{enabled:!k,stateAttributesMapping:Wt,state:ae,ref:oe,props:se});return k?(0,Q.jsx)(Fy,{tag:`button`,render:n,className:r,style:i,state:ae,refs:oe,props:se,stateAttributesMapping:Wt}):b?(0,Q.jsxs)(l.Fragment,{children:[(0,Q.jsx)(Yn,{ref:V,onFocus:H},`${_}-pre-focus-guard`),(0,Q.jsx)(l.Fragment,{children:U},_),(0,Q.jsx)(Yn,{ref:g.context.triggerFocusTargetRef,onFocus:ie},`${_}-post-focus-guard`)]}):(0,Q.jsx)(l.Fragment,{children:U},_)});function By(e,t){let n=$e(),[r,i]=l.useState(!1);return U(()=>{e&&t===`trigger-hover`?(i(!0),n.start(500,()=>{i(!1)})):e||(n.clear(),i(!1))},[e,t,n]),r}function Vy(){let e=wy(!0);return l.useMemo(()=>e?{type:`menubar`,context:e}:{type:void 0},[e])}var Hy={"aria-expanded":void 0},Uy=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=Ay();if(!m?.parentMenu)throw Error(Ti(37));let h=Yh({guess:!0,label:a}),g=ly(),{store:_}=dy(),v=Mc(o),y=_.useState(`open`),b=_.useState(`floatingRootContext`),x=_.useState(`floatingTreeRoot`),S=_.useState(`triggerPopupId`,v),C=bs(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)},[_]);U(()=>(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}=my({closeOnClick:!1,disabled:A,highlighted:M,id:v,store:_,typingRef:D.context.typingRef,nativeButton:s,itemMetadata:N,nodeId:g?.context.nodeId}),I=Xs(b,{enabled:_.useState(`hoverEnabled`)&&c&&!A,handleClose:pc({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=Aa(b,{enabled:!A,event:`mousedown`,toggle:!c,ignoreMouse:c,stickIfOpen:!1}).reference??Ye,R=_.useState(`triggerProps`,!0);delete R.id;let z={disabled:A,highlighted:M,open:y},ee=_.useState(`openMethod`),B=_.useState(`lastOpenChangeReason`)===`list-navigation`||ee===`keyboard`;return Ji(`div`,e,{state:z,stateAttributesMapping:Ut,props:[L,I,R,j,y&&B&&Ue?Hy: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 Wy(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=Ci(),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)(oy.Provider,{value:d,children:(0,Q.jsx)(uy.Provider,{value:void 0,children:(0,Q.jsx)(jy,{...e})})})}var Gy=500,Ky=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}=sy(!1),{store:h}=dy(!1),g=h.useState(`open`),_=h.useState(`disabled`),v=l.useRef(null),y=l.useRef(null),b=$e(),x=$e(),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(ln,n)),x.start(Gy,()=>{S.current=!0})}function T(e){if(_)return;f.current=!0,mt(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=xt(e);X(d.current,t)||m&&t&&Iy(t)===m||s.current?.setOpen(!1,Z(Cn,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(Gy,()=>{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=xt(e);(X(v.current,t)||X(c.current,t)||X(u.current,t))&&e.preventDefault()}return q(J(v.current),`contextmenu`,e)},[u,_,c]),Ji(`div`,e,{state:{open:g},ref:[v,t],props:[{onContextMenu:T,onTouchStart:D,onTouchMove:O,onTouchEnd:E,onTouchCancel:E,style:{WebkitTouchCallout:`none`}},a],stateAttributesMapping:Wt})}),qy=Sy,Jy={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,pi:`Pi`};function Yy(e){return Object.hasOwn(Jy,e)?Jy[e]:e}function Xy(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 Zy=[{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…`}],Qy=6e5,$y=e=>e===`checkout_complete`?2:Math.max(0,Zy.findIndex(t=>t.id===e)),eb=e=>[`pending`,`running`].includes(e.operation?.state??``)&&!e.panes.some(e=>e.kind===`agent`),tb=e=>[`failed`,`unknown`].includes(e.operation?.state??``)&&!e.panes.some(e=>e.kind===`agent`),nb=e=>Zy[$y(e.operation?.step??`validate`)].active,rb=(e,t)=>t-Date.parse(e.updatedAt)<Qy,ib=(e,t=Date.now())=>e.panes.some(e=>e.kind===`agent`)||eb(e)||tb(e)&&rb(e,t),ab=e=>new URLSearchParams({machineId:e.machineId??`local`,projectId:e.id}),ob=e=>e.branch??e.label,sb=e=>e.path.split(`/`).at(-1)??``,cb=(e,t)=>`${ob(e)} ${sb(e)}`.toLowerCase().includes(t.trim().toLowerCase()),lb=async(e,t)=>{let n=await fetch(`/api/worktrees?${ab(e)}`,{signal:t});if(!n.ok)throw Error(`Could not list worktrees.`);return await n.json()},ub=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},db=async(e,t)=>{try{await a(`/threads/${encodeURIComponent(await ub(e,t))}`)}catch(e){tl(e instanceof Error?e.message:`Could not open this worktree.`)}},fb=e=>{(e.key.length===1||e.key===`Backspace`)&&e.stopPropagation()};function pb({project:e}){let[t,n]=(0,l.useState)(``),r=M_({queryKey:[`worktrees`,e.machineId,e.id],queryFn:({signal:t})=>lb(e,t),staleTime:0,gcTime:0}),i=(r.data??[]).filter(e=>cb(e,t));return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`composer-select-search`,children:[(0,Q.jsx)(te,{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:fb})]}),(0,Q.jsxs)(`div`,{className:`worktree-menu-list`,children:[i.map(t=>(0,Q.jsx)(Wl,{label:t.path,side:`right`,children:(0,Q.jsxs)(hy,{className:`thread-menu-item`,onClick:()=>void db(e,t),children:[(0,Q.jsx)(k,{size:14,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{className:`worktree-menu-name`,children:[ob(t),(0,Q.jsx)(`small`,{children:sb(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 mb({projects:e}){return(0,Q.jsxs)(jy,{children:[(0,Q.jsx)(Wl,{label:`Open existing worktree`,children:(0,Q.jsx)(zy,{className:`sidebar-open-worktree`,"aria-label":`Open existing worktree`,disabled:!e.length,children:(0,Q.jsx)(te,{size:16,"aria-hidden":`true`})})}),(0,Q.jsx)(xy,{children:(0,Q.jsx)(Sy,{className:`thread-menu-positioner`,sideOffset:6,align:`start`,children:(0,Q.jsx)(vy,{className:`thread-menu`,children:e.map(e=>(0,Q.jsxs)(Ny,{children:[(0,Q.jsxs)(Uy,{className:`thread-menu-item`,children:[(0,Q.jsx)(sg,{project:e}),(0,Q.jsx)(`span`,{children:e.name}),(0,Q.jsx)(b,{size:14,"aria-hidden":`true`,className:`worktree-menu-chevron`})]}),(0,Q.jsx)(xy,{children:(0,Q.jsx)(Sy,{className:`thread-menu-positioner`,sideOffset:4,alignOffset:-4,children:(0,Q.jsx)(vy,{className:`thread-menu worktree-menu`,children:(0,Q.jsx)(pb,{project:e})})})})]},`${e.machineId}:${e.id}`))})})})]})}function hb({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&&tp(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)}})}var gb=220,_b=`[data-flip-id]`,vb=e=>{let t=e.getBoundingClientRect().top-e.scrollTop;return new Map([...e.querySelectorAll(_b)].map(e=>[e.dataset.flipId,{element:e,top:e.getBoundingClientRect().top-t}]))};function yb(e){let t=(0,l.useRef)(new Map);(0,l.useLayoutEffect)(()=>{if(!e.current)return;let n=vb(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:gb,easing:`cubic-bezier(.2, .8, .2, 1)`})}t.current=new Map([...n].map(([e,{top:t}])=>[e,t]))})}function bb(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 xb={working:`Working`,blocked:`Needs input`,done:`Done`,idle:`Idle`,unknown:`Unknown`},Sb={blocked:N,done:S,unknown:C},Cb=e=>tl(e instanceof Error?e.message:`Herdr could not complete this action.`),wb=async e=>{await el(sp([e]),{confirmLabel:`Delete`,danger:!0})&&await ip(e).catch(Cb)},Tb=(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)(hb,{thread:e,onDone:()=>u(!1),onError:Cb}):void 0;return(0,Q.jsxs)(Wy,{children:[(0,Q.jsxs)(Ky,{className:`thread-item`,"data-flip-id":e.id,onDoubleClick:e=>{e.preventDefault(),u(!0)},children:[(0,Q.jsx)(Eb,{thread:e,project:t,machineName:n,current:r,showProject:i,editor:d}),(0,Q.jsx)(Wl,{label:a?`Unarchive`:`Archive`,children:(0,Q.jsx)(`button`,{type:`button`,className:`thread-archive`,"aria-label":s,onClick:()=>void ep(e,!a).catch(Cb),children:(0,Q.jsx)(o,{size:15,strokeWidth:1.8,"aria-hidden":`true`})})})]}),(0,Q.jsx)(xy,{children:(0,Q.jsx)(qy,{className:`thread-menu-positioner`,children:(0,Q.jsx)(vy,{className:`thread-menu`,children:(0,Q.jsxs)(hy,{className:`thread-menu-item is-danger`,onClick:()=>void wb(e),children:[(0,Q.jsx)(ae,{size:14,"aria-hidden":`true`}),`Delete permanently`]})})})})]})});function Eb({thread:e,project:t,machineName:n,current:r,showProject:i,editor:a}){let o=eb(e),s=tb(e),c=s?oe:o?void 0:Sb[e.status],l=s||e.status===`blocked`||e.status===`done`,u=o?nb(e):s?`Launch stopped`:xb[e.status],d=o||s?u:i?t?.name:Yy(e.agent),f=a?`div`:`a`;return(0,Q.jsx)(Wl,{label:`${e.title} · ${t?.name??``} · ${n} · ${Yy(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)(Hf,{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.jsxs)(`span`,{className:`thread-copy`,children:[(0,Q.jsxs)(`span`,{className:`thread-context`,children:[i&&t&&!o&&!s&&(0,Q.jsx)(sg,{project:t}),e.worktree&&!o&&!s&&(0,Q.jsx)(k,{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:Xy(e.updatedAt)})]})})}function Db({threads:e,renderThread:t}){let[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(!1),o=async()=>{if(await el(sp(e),{confirmLabel:`Delete all`,danger:!0})){a(!0);try{let e=await ap();e.failed.length&&await tl(`${e.failed.length} archived ${e.failed.length===1?`thread`:`threads`} could not be deleted.`)}catch(e){Cb(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)(y,{size:14}):(0,Q.jsx)(b,{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 Ob({projects:e,threads:t,archived:n=[],machines:r,currentId:i,mode:a,onModeChange:o,collapsed:s,mobileOpen:c,onCollapse:u,onCloseMobile:d,onOpenPalette:f}){let[p,m]=(0,l.useState)([]),h=t.find(e=>e.id===i)?.projectId,g=bb(e,h),_=(0,l.useRef)(null);yb(_);let v=(t,n)=>{let a=e.find(e=>e.id===t.projectId);return(0,Q.jsx)(Tb,{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)(R,{size:16}):(0,Q.jsx)(L,{size:16})}),(0,Q.jsx)(`button`,{className:`icon-button mobile-close`,"aria-label":`Close sidebar`,onClick:d,children:(0,Q.jsx)(se,{size:16})})]}),(0,Q.jsxs)(`div`,{className:`sidebar-actions`,children:[(0,Q.jsx)(Wl,{label:`New thread`,children:(0,Q.jsxs)(`a`,{className:`sidebar-new-thread`,href:`/new${h?`?project=${encodeURIComponent(h)}`:``}`,"aria-label":`New thread`,children:[(0,Q.jsx)(V,{size:16,"aria-hidden":`true`}),!s&&(0,Q.jsx)(`span`,{children:`New thread`})]})}),(0,Q.jsx)(mb,{projects:e}),!s&&(0,Q.jsxs)(`div`,{className:`sidebar-view-switch`,role:`group`,"aria-label":`Sidebar layout`,children:[(0,Q.jsx)(Wl,{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)(j,{size:16,"aria-hidden":`true`})})}),(0,Q.jsx)(Wl,{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)(D,{size:16,"aria-hidden":`true`})})})]})]}),!s&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`nav`,{ref:_,className:`thread-navigation`,"aria-label":`Agent threads`,children:[a===`projects`?g.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.jsxs)(`div`,{className:`group-header`,children:[(0,Q.jsxs)(`button`,{className:`group-title`,onClick:()=>m(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),"aria-expanded":!p.includes(e),children:[(0,Q.jsx)(`span`,{className:`group-chevron`,"aria-hidden":`true`,children:p.includes(e)?(0,Q.jsx)(b,{size:14}):(0,Q.jsx)(y,{size:14})}),(0,Q.jsx)(sg,{project:n}),(0,Q.jsx)(`span`,{className:`group-name`,children:n.name})]}),(0,Q.jsx)(Wl,{label:`New thread in ${n.name}`,children:(0,Q.jsx)(`a`,{className:`group-new-thread`,href:`/new?project=${encodeURIComponent(n.id)}`,"aria-label":`New thread in ${n.name}`,children:(0,Q.jsx)(V,{size:15,"aria-hidden":`true`})})})]}),!p.includes(e)&&t.filter(e=>r.includes(e.projectId)).map(e=>v(e,!1))]},e)):t.map(e=>v(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)(Db,{threads:n,renderThread:e=>v(e,!0)}),(0,Q.jsxs)(`div`,{className:`sidebar-footer`,children:[(0,Q.jsxs)(`a`,{className:`sidebar-settings`,href:`/settings`,children:[(0,Q.jsx)(re,{size:15}),` Settings`]}),(0,Q.jsx)(Wl,{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`})})})]})]})]})]})}var kb=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},Ab=(e=>e?kb(e):kb),jb=e=>e;function Mb(e,t=jb){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 Nb=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Pb=(e,t)=>e&&Nb(e,t)?e:t;function Fb(e){let t=new Map,n=new Set,r=Ab((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`,panes:[],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]=Pb(a.threads[e.id],{...e,panes:e.panes.map(t=>Pb(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]=Pb(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:Pb(a.threadIds,d),projectIds:Pb(a.projectIds,f)})}}));for(let t of e.projections)r.getState().install(t);return r}var Ib=()=>Ab(e=>({focusedPanes:{},focus:(t,n)=>e(e=>({focusedPanes:{...e.focusedPanes,[t]:n}}))}));function Lb(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 Rb=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}},zb=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=hp();this.terminal.write(t,()=>{this.closed||(hp()-n,this.bytes-=e.bytes.length,this.writing=!1,this.acknowledge(e),this.flush())})}},Bb=(e,t=Math.random)=>Math.min(3e4,Math.round(Math.min(25e3,1e3*2**Math.min(e,5))*(.8+t()*.4))),Vb=`Another controller owns this terminal.`,Hb=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 Rb,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,hp()),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 Rb,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 Rb,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 Rb,this.open(t)))},scroll:(e,n,r,i)=>{let a=this.panes.get(t);a?.writable&&(this.scrollSentAt.set(t,hp()),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 Rb,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 zb(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&&(hp()-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,hp()),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=Qp();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 Rb,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`?Vb:String(e.reason).replaceAll(`_`,` `),!1),e.type===`stream.error`&&n.mode===`control`){n.reason=e.reason===`controller_conflict`?Vb:String(e.reason).replaceAll(`_`,` `),n.mode=`observe`,++n.generation,n.sequence=new Rb,this.open(e.streamId);return}e.reason===`stream_resync_required`&&n.attempts++<2&&(++n.generation,n.sequence=new Rb,n.mode=`observe`,this.open(e.streamId))}return}let e=hp(),n=Lb(new Uint8Array(t.data));t.data.byteLength,hp()-e;let r=this.inputSentAt.get(n.streamId);r!==void 0&&(hp()-r,this.inputSentAt.delete(n.streamId));let i=this.scrollSentAt.get(n.streamId);i!==void 0&&(hp()-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(),Bb(this.failures++)))}},Ub=(0,l.createContext)(null);function Wb({bootstrap:e,children:t}){let[n]=(0,l.useState)(()=>{let t=Fb(e);return{runtime:t,ui:Ib(),terminals:new Hb(e=>{let n=mp(`projectionInstallMs`);t.getState().install(e),n()},e=>t.getState().connection(e))}}),[r]=(0,l.useState)(()=>new y_({defaultOptions:{queries:{staleTime:15e3,retry:!1}}}));return(0,l.useEffect)(()=>(n.terminals.start(),()=>n.terminals.stop()),[n]),(0,Q.jsx)(Ub.Provider,{value:n,children:(0,Q.jsx)(pg,{client:r,children:t})})}function Gb(){let e=(0,l.useContext)(Ub);if(!e)throw Error(`Runtime provider is missing`);return e}function Kb(e){return Mb(Gb().runtime,e)}var qb={Enter:`\r`,Backspace:``,Tab:` `,Escape:`\x1B`,ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`};function Jb(e){let t=e.ctrlKey&&/^[a-z]$/i.test(e.key)?String.fromCharCode(e.key.toUpperCase().charCodeAt(0)-64):qb[e.key],n=e.key===`Enter`&&e.shiftKey;return t&&(e.altKey||n?`\x1B`+t:t)}var Yb=e=>/^[a-z@\[\\\]^_]$/i.test(e)?String.fromCharCode(e.toUpperCase().charCodeAt(0)&31):void 0;function Xb({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=Jb(t);n&&(t.preventDefault(),e(n))}})}var Zb=[{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`}],Qb=e=>e.preventDefault();function $b({ctrl:e,onToggleCtrl:t,onBytes:n}){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`:``,onPointerDown:Qb,onClick:t,children:`Ctrl`}),Zb.map(({label:e,key:t,name:r})=>(0,Q.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":r??t,onPointerDown:Qb,onClick:()=>{let e=Jb({key:t,ctrlKey:!1,altKey:!1});e&&n(e)},children:e},t))]})}var ex=`(pointer: coarse)`;function tx(){let e=window.visualViewport;if(!e||!matchMedia(ex).matches)return()=>{};let t=document.documentElement,n=()=>{t.style.setProperty(`--app-height`,`${e.height}px`),t.style.setProperty(`--app-top`,`${e.offsetTop}px`)};return n(),e.addEventListener(`resize`,n),e.addEventListener(`scroll`,n),()=>{e.removeEventListener(`resize`,n),e.removeEventListener(`scroll`,n),t.style.removeProperty(`--app-height`),t.style.removeProperty(`--app-top`)}}function nx(){return typeof matchMedia==`function`&&matchMedia(ex).matches}var rx=100,ix=20,ax=10,ox=e=>ax*(1+Math.min(2,Math.abs(e)/60));function sx(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:ix},u=()=>{o=0;let e=l(),t=Math.trunc(a/e);t&&(a-=t*e,n()?.scroll(t<0?`up`:`down`,Math.min(rx,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*ox(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 cx=`Only PNG, JPEG, GIF and WebP images can be attached.`,lx=e=>e===1?`Attaching image…`:`Attaching ${e} images…`,ux=e=>e===1?`Image attached`:`${e} images attached`;function dx({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(cx,`error`,4e3);return}if(!n.current){i(`Wait until the terminal accepts input, then attach the image again.`,`error`,4e3);return}i(lx(t.length),`info`);try{s.current(await Xp(e,t)),i(ux(t.length),`info`,1500)}catch(e){i(e instanceof Error?e.message:`The image could not be attached.`,`error`,5e3)}},[e,i,n]);return(0,l.useEffect)(()=>{if(!t)return;let e=0,n=t=>{Wp(t.dataTransfer)&&(t.preventDefault(),e+=1,o(!0))},r=e=>{Wp(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`))},i=t=>{Wp(t.dataTransfer)&&(e=Math.max(0,e-1),e||o(!1))},a=t=>{Wp(t.dataTransfer)&&(t.preventDefault(),e=0,o(!1),c(Up(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}}function fx(e,t){(e.metaKey||e.ctrlKey)&&window.open(t,`_blank`,`noopener,noreferrer`)}function px(){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 mx=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),hx=function(e){return`/`+e},gx={},_x=function(e){return e.pathname.endsWith(`.css`)},vx=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=hx(t,n);let r=s(t);if(r.href in gx)return;gx[r.href]=!0;let i=_x(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`:mx,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 yx(){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 bx=`"JetBrains Mono", "Webr Symbols", ui-monospace, Menlo, monospace`,xx=13,Sx=()=>typeof document>`u`||!document.fonts?Promise.resolve():Promise.all([document.fonts.load(`400 ${xx}px "JetBrains Mono"`),document.fonts.load(`700 ${xx}px "JetBrains Mono"`),document.fonts.load(`${xx}px "Webr Symbols"`,``)]).then(()=>void 0,()=>void 0),Cx=`\x1B[I`,wx=`\x1B[O`;function Tx({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}=Gb(),[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);(0,l.useEffect)(()=>C(nx()),[]);let{notice:w,show:T}=px(),E=dx({machineId:n,active:i,writable:_,show:T,send:e=>{d.current?.input(e,!0)}}),D=(0,l.useRef)(e=>{});D.current=e=>e?T(`Copied to clipboard`,`info`,1200):T(`The browser blocked clipboard access.`,`error`,4e3),(0,l.useEffect)(()=>{if(!s.current)return;let i=!1,o=()=>{};return Promise.all([vx(()=>import(`./xterm.B-l5AIf6.js`).then(t=>e(t.default,1)),__vite__mapDeps([0,1])),vx(()=>import(`./addon-fit.jgKqzwky.js`).then(t=>e(t.default,1)),__vite__mapDeps([2,1])),vx(()=>import(`./addon-web-links.C9lyQRxI.js`).then(t=>e(t.default,1)),__vite__mapDeps([3,1])),Sx()]).then(([e,{FitAddon:c},{WebLinksAddon:l}])=>{if(i||!s.current)return;let p=new e.Terminal({fontFamily:bx,fontSize:xx,lineHeight:1.2,letterSpacing:0,cursorBlink:!0,cursorInactiveStyle:`block`,allowTransparency:!1,scrollback:0,theme:yx(),disableStdin:!0,linkHandler:{activate:()=>{}}});p.open(s.current),p.attachCustomWheelEventHandler(()=>!1),u.current=p;let h=()=>{_.current&&s.current?.parentElement?.querySelector(`.terminal-input-capture`)?.focus()};p.textarea?.addEventListener(`focus`,h);let v=uv(s.current,p,()=>_.current,e=>D.current(e)),y=p.parser.registerOscHandler(8,()=>!0);if(!t.terminalId){v(),p.dispose();return}let b=new c;p.loadAddon(b),p.loadAddon(new l(fx));let x=()=>({cols:Math.floor((s.current?.clientWidth??640)/8),rows:Math.floor((s.current?.clientHeight??400)/20)}),S=()=>{try{return b.proposeDimensions()}catch{return}},C=()=>{let{cols:e,rows:t}=S()??x();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:p,mode:a?`control`:`observe`,...C(),onState:(e,t)=>{m(e),g(t),_.current=t}});let w=sx(s.current,()=>({element:p.element?.querySelector(`.xterm-screen`)??void 0,cols:p.cols,rows:p.rows}),()=>d.current,()=>_.current),T,E=new ResizeObserver(()=>{clearTimeout(T),T=setTimeout(()=>{let{cols:e,rows:t}=C();d.current?.resize(e,t)},150)});E.observe(s.current);let O=()=>{if(document.visibilityState!==`visible`||!document.hasFocus())return;let{cols:e,rows:t}=C();d.current?.resize(e,t,!0)};window.addEventListener(`focus`,O),document.addEventListener(`visibilitychange`,O);let k=new MutationObserver(()=>{p.options.theme=yx()});k.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]}),o=()=>{clearTimeout(T),d.current?.close(),d.current=null,_.current=!1,w(),window.removeEventListener(`focus`,O),document.removeEventListener(`visibilitychange`,O),p.textarea?.removeEventListener(`focus`,h),v(),y.dispose(),E.disconnect(),k.disconnect(),p.dispose(),u.current=null}}).catch(()=>m(`The terminal could not load.`)),()=>{i=!0,o()}},[t.id,t.terminalId,n,r,f,a]);let O=(e,t)=>{if(_.current){if(!b||t){d.current?.input(e,t);return}x(!1),d.current?.input(Yb(e)??e)}},k=()=>u.current?.focus(),j=()=>{h&&!u.current?.hasSelection()&&(k(),s.current?.parentElement?.querySelector(`.terminal-input-capture`)?.focus())};return(0,l.useEffect)(()=>{i&&j()},[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=Jb(t);n?(t.preventDefault(),t.stopPropagation(),d.current?.input(n)):t.key.length===1&&!t.ctrlKey&&j()},n=t=>{let n=t.target.classList?.contains(`terminal-input-capture`);if(!e(t)&&!n)return;let r=Up(t.clipboardData);if(r.length){t.preventDefault(),t.stopPropagation(),E.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,E.attach]),(0,l.useEffect)(()=>{let e=()=>{i&&j()};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(),j()},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(),el(`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`}),E.dragging&&(0,Q.jsxs)(`div`,{className:`terminal-drop-overlay`,"aria-hidden":`true`,children:[(0,Q.jsx)(A,{size:22,strokeWidth:1.6}),(0,Q.jsx)(`span`,{children:`Drop image to attach`})]}),w&&(0,Q.jsx)(`div`,{className:`terminal-attach-notice is-${w.tone}`,role:w.tone===`error`?`alert`:`status`,children:w.text}),(a||h)&&(0,Q.jsx)(Xb,{onInput:O,onFocusChange:e=>{y(e),u.current?.modes.sendFocusMode&&d.current?.input(e?Cx:wx)}}),a&&i&&S&&v&&(0,Q.jsx)($b,{ctrl:b,onToggleCtrl:()=>x(e=>!e),onBytes:e=>d.current?.input(e)})]})}function Ex({thread:e,tabs:t}){let[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(!1),c=t.find(e=>e.tabId===n&&!e.bound);return(0,Q.jsxs)(`form`,{className:`adoption-picker`,onSubmit:async t=>{if(t.preventDefault(),c&&!o){if(s(!0),!await el(`Bind this thread to ${c.label} (${c.tabId}) and its ${c.panes.length} current terminals without sending the old prompt?`,{confirmLabel:`Bind`})){s(!1);return}a(``);try{if(!(await fetch(`/api/threads/${encodeURIComponent(e.id)}/adopt`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({machineId:e.machineId,terminalIds:c.panes.map(e=>e.terminalId)})})).ok)throw Error(`The tab changed or is already bound; select it again after refresh.`)}catch(e){a(e instanceof Error?e.message:`Adoption failed.`)}finally{s(!1)}}},children:[(0,Q.jsxs)(`label`,{children:[`Select the current native tab to adopt `,(0,Q.jsxs)(`select`,{"aria-label":`Native tab to adopt`,value:n,onChange:e=>r(e.target.value),children:[(0,Q.jsx)(`option`,{value:``,children:`Select a tab…`}),t.map(e=>(0,Q.jsxs)(`option`,{value:e.tabId,disabled:e.bound||!e.panes.length,children:[e.label,` · `,e.tabId,e.bound?` · Already bound`:``]},e.tabId))]})]}),c&&(0,Q.jsx)(`p`,{children:c.panes.map(e=>`${e.title} (${e.terminalId})`).join(`, `)}),(0,Q.jsx)(`button`,{disabled:!c||o,children:`Adopt without restarting`}),i&&(0,Q.jsx)(`p`,{role:`alert`,children:i})]})}function Dx({thread:e}){let t=tb(e),n=$y(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:Zy.map((e,r)=>{let i=r<n?`done`:r===n?t?`failed`:`active`:`waiting`,a=i===`done`?S:i===`failed`?x:i===`active`?M:w;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 `,Zy[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 Ox=`28px`,kx=e=>e===`right`?{left:0,top:0,width:`calc(100% - ${Ox})`,height:`100%`}:{left:0,top:0,width:`100%`,height:`calc(100% - ${Ox})`};function Ax({side:e,onOpen:t}){return(0,Q.jsx)(Wl,{label:`Show terminal`,side:e===`right`?`left`:`top`,children:(0,Q.jsxs)(`button`,{type:`button`,className:`terminal-peek is-${e}`,"aria-label":`Show terminal`,onClick:t,children:[(0,Q.jsx)(H,{size:14,strokeWidth:1.8,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:`Terminal`})]})})}function jx({thread:e,layouts:t,tabs:n,connected:r,canControl:i,onFocusPane:a,focusedPane:o,onToggleTerminal:s}){let c=(t,n)=>(0,Q.jsx)(`div`,{className:`native-pane-position`,style:n,children:(0,Q.jsx)(Tx,{pane:t,machineId:e.machineId,threadId:e.id,active:o===t.id,canControl:i,onFocus:()=>a(t.id)})},`${t.id}:${t.terminalId}`);if(r&&(eb(e)||tb(e)))return(0,Q.jsx)(Dx,{thread:e});let l=t.filter(t=>t.panes.some(t=>e.panes.some(e=>e.id===t.paneId)));return(0,Q.jsxs)(`main`,{className:`native-thread-layout`,"aria-label":`${e.title} tab`,children:[(!r||e.bindingState!==`attached`)&&(0,Q.jsx)(`p`,{className:`runtime-notice`,role:`status`,children:r?e.bindingState===`detached`?`The saved terminal is not present; explicit adoption is required.`:`Waiting for the terminal to attach…`:`Disconnected; input is disabled.`}),r&&e.bindingState===`attached`&&!i&&(0,Q.jsx)(`p`,{className:`runtime-notice`,role:`status`,children:`Terminal input is unavailable because this Herdr version is not supported.`}),r&&e.bindingState===`detached`&&(0,Q.jsx)(Ex,{thread:e,tabs:n},e.id),r&&e.bindingState===`attached`&&l.map(t=>{let n=fp(e,t),r=!n&&t.panes.filter(t=>e.panes.some(e=>e.id===t.paneId)).length>1;return(0,Q.jsx)(`div`,{className:`native-pane-layout ${r?`is-split`:``}`,children:n?[c(n.agent,kx(n.side)),(0,Q.jsx)(Ax,{side:n.side,onOpen:s},`terminal-peek`)]:e.panes.map(e=>{let n=t.panes.find(t=>t.paneId===e.id)?.rect;return!n||!t.area.width||!t.area.height?null:c(e,{left:`${(n.x-t.area.x)/t.area.width*100}%`,top:`${(n.y-t.area.y)/t.area.height*100}%`,width:`${n.width/t.area.width*100}%`,height:`${n.height/t.area.height*100}%`})})},`${t.workspaceId}:${t.tabId}`)})]})}var Mx=e=>Symbol.iterator in e,Nx=e=>`entries`in e,Px=(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},Fx=(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 Ix(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Mx(e)&&Mx(t)?Nx(e)&&Nx(t)?Px(e,t):Fx(e,t):Px({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Lx(e){let t=l.useRef(void 0);return n=>{let r=e(n);return Ix(t.current,r)?t.current:t.current=r}}function Rx(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===Jf(e))?.[0]}function zx(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])}function Bx(e){return(0,Q.jsx)(zp,{children:(0,Q.jsx)(Wb,{bootstrap:e.bootstrap,children:(0,Q.jsx)(Vx,{...e})})})}function Vx({page:e,bootstrap:t,threadId:n,projectId:r}){let{ui:i,terminals:o}=Gb(),s=Kb(Lx(e=>e.projectIds.map(t=>e.projects[t]))),c=Kb(Lx(e=>e.threadIds.map(t=>e.threads[t]).filter(e=>!e.archivedAt&&ib(e)))),u=Kb(Lx(e=>e.threadIds.map(t=>e.threads[t]).filter(e=>!!e.archivedAt))),d=Kb(e=>e.threads[n??``]),f=Kb(e=>e.projections),p=Kb(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)(gp,[]),(0,l.useEffect)(tx,[]);let[x,S]=(0,l.useState)(`threads`),C=`${d?.machineId??``}:${d?.id??``}`,w=Mb(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]);zx(e===`thread`?d:void 0,T,p&&!!m.find(e=>e.id===d?.machineId)?.writable);let D=(0,l.useRef)(void 0);(0,l.useEffect)(()=>{d?D.current=d.id:e===`thread`&&D.current===n&&a(`/`)},[d,e,n]),(0,l.useEffect)(()=>{let e=e=>{Wp(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`&&Xf(`system`)};return t.addEventListener(`change`,n),()=>{t.removeEventListener(`change`,n),window.removeEventListener(`popstate`,e)}},[]);let O=d?f[d.machineId]?.layouts??[]:[],k=e=>void tl(e instanceof Error?e.message:`Herdr could not change the terminal.`),A=(0,l.useCallback)(e=>{if(!d)return;let t=e??pp(d,O,window.matchMedia(`(max-width: 760px)`).matches);np(d,t).then(({paneId:e,hidden:t})=>E(t?cp(d)?.id??e:e),k)},[d,O,E]),j=(0,l.useCallback)(e=>{d?.terminalHidden&&lp(d)?.id===e?A():E(e)},[d,A,E]),M=(0,l.useCallback)(()=>{d&&rp(d).then(()=>{let e=cp(d);e&&E(e.id)},k)},[d,E]),N=(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})},[]),P=(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=Rx(e,Gf());if(t){if(e.preventDefault(),t===`toggleSidebar`&&N(),t===`toggleTerminal`&&A(),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);j(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,N,A,j,T,E]),(0,Q.jsxs)(`div`,{className:`app-shell ${e===`thread`?`is-thread`:``}`,children:[(0,Q.jsx)(Ob,{projects:s,threads:c,archived:u,machines:m,currentId:d?.id,mode:x,onModeChange:P,collapsed:h,mobileOpen:_,onCollapse:N,onCloseMobile:()=>v(!1),onOpenPalette:()=>b(!0)}),(0,Q.jsxs)(`div`,{className:`main-panel`,children:[e===`thread`&&d&&(0,Q.jsx)(jx,{thread:d,layouts:f[d.machineId]?.layouts??[],tabs:f[d.machineId]?.availableTabs??[],connected:p&&!!f[d.machineId]?.connected,canControl:!!m.find(e=>e.id===d.machineId)?.writable,focusedPane:T,onFocusPane:j,onToggleTerminal:()=>A()}),e===`new`&&(0,Q.jsx)(nv,{projects:s,machines:m,selectedProjectId:r,onOpenSidebar:N},r),e===`settings`&&(0,Q.jsx)(ay,{onOpenSidebar:N}),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`,onClick:N,children:(0,Q.jsx)(z,{size:16})}),(0,Q.jsx)(`button`,{"aria-label":`Open command palette`,onClick:()=>b(!0),children:(0,Q.jsx)(te,{size:16})})]}),!1,(0,Q.jsx)(Rp,{}),(0,Q.jsx)(vp,{open:y,onClose:()=>b(!1),projects:s,threads:c,thread:d,focusedPane:T,mode:x,onModeChange:P,onToggleSidebar:N,onFocusPane:j,onTerminalAction:e=>{let t=d?.panes.find(e=>e.id===T);d&&t?.terminalId&&o.command(d.machineId,d.id,t.terminalId,e)},onToggleTerminal:A,onCloseTerminal:M})]})}export{Bx as default};
|