@k-electron/k-bench 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/src/server/app.js +1 -6
- package/dist/js/src/server/service.js +3 -9
- package/dist/web/assets/index-DZD8GLyI.css +1 -0
- package/dist/web/assets/{index-DX3nUxsV.js → index-GOfCl8ob.js} +4 -3
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-CWZyOJf0.css +0 -1
|
@@ -46,7 +46,8 @@ Error generating stack: `+e.message+`
|
|
|
46
46
|
`},qa=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},Ja=function(){D.useEffect(function(){return document.body.setAttribute(Ga,(qa()+1).toString()),function(){var e=qa()-1;e<=0?document.body.removeAttribute(Ga):document.body.setAttribute(Ga,e.toString())}},[])},Ya=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;Ja();var a=D.useMemo(function(){return Ua(i)},[i]);return D.createElement(Wa,{styles:Ka(a,!t,i,n?``:`!important`)})},Xa=!1;if(typeof window<`u`)try{var Za=Object.defineProperty({},"passive",{get:function(){return Xa=!0,!0}});window.addEventListener(`test`,Za,Za),window.removeEventListener(`test`,Za,Za)}catch{Xa=!1}var Qa=Xa?{passive:!1}:!1,$a=function(e){return e.tagName===`TEXTAREA`},eo=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!$a(e)&&n[t]===`visible`)},to=function(e){return eo(e,`overflowY`)},no=function(e){return eo(e,`overflowX`)},ro=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),oo(e,r)){var i=so(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},io=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},ao=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},oo=function(e,t){return e===`v`?to(t):no(t)},so=function(e,t){return e===`v`?io(t):ao(t)},co=function(e,t){return e===`h`&&t===`rtl`?-1:1},lo=function(e,t,n,r,i){var a=co(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=so(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&oo(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},uo=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},fo=function(e){return[e.deltaX,e.deltaY]},po=function(e){return e&&`current`in e?e.current:e},mo=function(e,t){return e[0]===t[0]&&e[1]===t[1]},ho=function(e){return`
|
|
47
47
|
.block-interactivity-${e} {pointer-events: none;}
|
|
48
48
|
.allow-interactivity-${e} {pointer-events: all;}
|
|
49
|
-
`},go=0,_o=[];function vo(e){var t=D.useRef([]),n=D.useRef([0,0]),r=D.useRef(),i=D.useState(go++)[0],a=D.useState(za)[0],o=D.useRef(e);D.useEffect(function(){o.current=e},[e]),D.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=ha([e.lockRef.current],(e.shards||[]).map(po),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=D.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=uo(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=ro(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=ro(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return lo(h,t,e,h===`h`?s:c,!0)},[]),c=D.useCallback(function(e){var n=e;if(_o.length&&_o[_o.length-1]===a){var r=`deltaY`in n?fo(n):uo(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&mo(e.delta,r)})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var c=(o.current.shards||[]).map(po).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=D.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:yo(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=D.useCallback(function(e){n.current=uo(e),r.current=void 0},[]),d=D.useCallback(function(t){l(t.type,fo(t),t.target,s(t,e.lockRef.current))},[]),f=D.useCallback(function(t){l(t.type,uo(t),t.target,s(t,e.lockRef.current))},[]);D.useEffect(function(){return _o.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Qa),document.addEventListener(`touchmove`,c,Qa),document.addEventListener(`touchstart`,u,Qa),function(){_o=_o.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Qa),document.removeEventListener(`touchmove`,c,Qa),document.removeEventListener(`touchstart`,u,Qa)}},[]);var p=e.removeScrollBar,m=e.inert;return D.createElement(D.Fragment,null,m?D.createElement(a,{styles:ho(i)}):null,p?D.createElement(Ya,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function yo(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var bo=ka(Aa,vo),xo=D.forwardRef(function(e,t){return D.createElement(Ma,pa({},e,{ref:t,sideCar:bo}))});xo.classNames=Ma.classNames;var So=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},Co=new WeakMap,wo=new WeakMap,To={},Eo=0,Do=function(e){return e&&(e.host||Do(e.parentNode))},Oo=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Do(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},ko=function(e,t,n,r){var i=Oo(t,Array.isArray(e)?e:[e]);To[n]||(To[n]=new WeakMap);var a=To[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(Co.get(e)||0)+1,l=(a.get(e)||0)+1;Co.set(e,c),a.set(e,l),o.push(e),c===1&&i&&wo.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),Eo++,function(){o.forEach(function(e){var t=Co.get(e)-1,i=a.get(e)-1;Co.set(e,t),a.set(e,i),t||(wo.has(e)||e.removeAttribute(r),wo.delete(e)),i||e.removeAttribute(n)}),Eo--,Eo||(Co=new WeakMap,Co=new WeakMap,wo=new WeakMap,To={})}},Ao=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||So(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),ko(r,i,n,`aria-hidden`)):function(){return null}},jo=Object.defineProperty,Mo=(e,t)=>jo(e,`name`,{value:t,configurable:!0}),No=`Dialog`,[Po,Fo]=vr(No),[J,Io]=Po(No),Lo=Mo(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=D.useRef(null),c=D.useRef(null),{nodes:l,registry:u}=Ki(),[d,f]=Xr({prop:r,defaultProp:i??!1,onChange:a,caller:No}),[p,m]=D.useState(0),[h,g]=D.useState(0);return(0,W.jsx)(J,{scope:t,triggerRef:s,contentRef:c,contentId:mi(),titleId:mi(),descriptionId:mi(),titlePresent:p>0,descriptionPresent:h>0,setTitleCount:m,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:D.useCallback(()=>f(e=>!e),[f]),modal:o,branchNodes:l,branchRegistry:u,children:n})},`Dialog`),Ro=`DialogTrigger`,zo=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,...r}=e,i=Io(Ro,n),a=Hn(t,i.triggerRef);return(0,W.jsx)(G.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":is(i.open),...r,ref:a,onClick:K(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),Bo=`DialogPortal`,[Vo,Ho]=Po(Bo,{forceMount:void 0}),Uo=Mo(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Io(Bo,t);return(0,W.jsx)(Vo,{scope:t,forceMount:n,children:D.Children.map(r,e=>(0,W.jsx)(ii,{present:n||a.open,children:(0,W.jsx)(aa,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Wo=`DialogOverlay`,Go=D.forwardRef(Mo(function(e,t){let n=Ho(Wo,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Io(Wo,e.__scopeDialog);return a.modal?(0,W.jsx)(ii,{present:r||a.open,children:(0,W.jsx)(qo,{...i,ref:t})}):null},`DialogOverlay`)),Ko=Kn(`DialogOverlay.RemoveScroll`),qo=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,...r}=e,i=Io(Wo,n),a=Hn(t,Mi());return(0,W.jsx)(xo,{as:Ko,allowPinchZoom:!0,shards:D.useMemo(()=>[i.contentRef,...i.branchNodes.map(e=>({current:e}))],[i.contentRef,i.branchNodes]),children:(0,W.jsx)(G.div,{"data-state":is(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Jo=`DialogContent`,Yo=D.forwardRef(Mo(function(e,t){let n=Ho(Jo,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Io(Jo,e.__scopeDialog);return(0,W.jsx)(ii,{present:r||a.open,children:a.modal?(0,W.jsx)(Xo,{...i,ref:t}):(0,W.jsx)(Zo,{...i,ref:t})})},`DialogContent`)),Xo=D.forwardRef(Mo(function(e,t){let n=Io(Jo,e.__scopeDialog),r=D.useRef(null),i=Hn(t,n.contentRef,r);return D.useEffect(()=>{let e=r.current;if(e)return Ao(e)},[]),(0,W.jsx)(Qo,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:K(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:K(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:K(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Zo=D.forwardRef(Mo(function(e,t){let n=Io(Jo,e.__scopeDialog),r=D.useRef(!1),i=D.useRef(!1);return(0,W.jsx)(Qo,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Qo=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,"aria-describedby":o,children:s,...c}=e,l=Io(Jo,n);return da(),(0,W.jsx)(Gi,{registry:l.branchRegistry,children:(0,W.jsx)(Ui,{asChild:!0,loop:!0,trapped:r,branches:l.branchNodes,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,W.jsx)(ji,{role:`dialog`,id:l.contentId,"aria-labelledby":l.titlePresent?l.titleId:void 0,"aria-describedby":l.descriptionPresent?rs(o,l.descriptionId):o,"data-state":is(l.open),...c,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1),children:s})})})},`DialogContentImpl`)),$o=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,...r}=e,i=Io(`DialogTitle`,n),{setTitleCount:a}=i;return br(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,W.jsx)(G.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),es=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,...r}=e,i=Io(`DialogDescription`,n),{setDescriptionCount:a}=i;return br(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,W.jsx)(G.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),ts=`DialogClose`,ns=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,...r}=e,i=Io(ts,n);return(0,W.jsx)(G.button,{type:`button`,...r,ref:t,onClick:K(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function rs(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}Mo(rs,`concatAriaDescribedby`);function is(e){return e?`open`:`closed`}Mo(is,`getState`);var as=Object.defineProperty,os=(e,t)=>as(e,`name`,{value:t,configurable:!0}),[ss,cs]=vr(`AlertDialog`,[Fo]),ls=Fo(),us=os(e=>{let{__scopeAlertDialog:t,...n}=e,r=ls(t);return(0,W.jsx)(Lo,{...r,...n,modal:!0})},`AlertDialog`);D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=ls(n);return(0,W.jsx)(zo,{...i,...r,ref:t})},`AlertDialogTrigger`));var ds=os(e=>{let{__scopeAlertDialog:t,...n}=e,r=ls(t);return(0,W.jsx)(Uo,{...r,...n})},`AlertDialogPortal`),fs=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=ls(n);return(0,W.jsx)(Go,{...i,...r,ref:t})},`AlertDialogOverlay`)),[ps,ms]=ss(`AlertDialogContent`),hs=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,children:r,...i}=e,a=ls(n),o=Hn(t,D.useRef(null)),s=D.useRef(null);return(0,W.jsx)(ps,{scope:n,cancelRef:s,children:(0,W.jsx)(Yo,{role:`alertdialog`,...a,...i,ref:o,onOpenAutoFocus:K(i.onOpenAutoFocus,e=>{e.preventDefault(),s.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})},`AlertDialogContent`)),gs=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=ls(n);return(0,W.jsx)($o,{...i,...r,ref:t})},`AlertDialogTitle`)),_s=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=ls(n);return(0,W.jsx)(es,{...i,...r,ref:t})},`AlertDialogDescription`)),vs=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=ls(n);return(0,W.jsx)(ns,{...i,...r,ref:t})},`AlertDialogAction`)),ys=`AlertDialogCancel`,bs=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=ms(ys,n),a=ls(n),o=Hn(t,i);return(0,W.jsx)(ns,{...a,...r,ref:o})},`AlertDialogCancel`)),xs=Object.defineProperty,Ss=(e,t)=>xs(e,`name`,{value:t,configurable:!0}),Cs=`Avatar`,[ws,Ts]=vr(Cs),Es={Idle:`idle`,Loading:`loading`,Loaded:`loaded`,Error:`error`},Ds=[0,()=>void 0],[Os,ks]=ws(Cs),As=D.forwardRef(Ss(function(e,t){let{__scopeAvatar:n,...r}=e,[i,a]=D.useState(Es.Idle),[o,s]=Fs();return(0,W.jsx)(Os,{scope:n,imageLoadingStatus:i,setImageLoadingStatus:a,imageCount:o,setImageCount:s,children:(0,W.jsx)(G.span,{...r,ref:t})})},`Avatar`)),js=`AvatarFallback`,Ms=D.forwardRef(Ss(function(e,t){let{__scopeAvatar:n,delayMs:r,...i}=e,a=ks(js,n),[o,s]=D.useState(r===void 0);return D.useEffect(()=>{if(r!==void 0){let e=window.setTimeout(()=>s(!0),r);return()=>window.clearTimeout(e)}},[r]),o&&a.imageLoadingStatus!==Es.Loaded?(0,W.jsx)(G.span,{...i,ref:t}):null},`AvatarFallback`));function Ns(e,{loadingStatus:t,setLoadingStatus:n,referrerPolicy:r,crossOrigin:i}){return br(()=>{if(!e){n(Es.Error);return}let t=new window.Image,a=Ss(e=>{let t=e.currentTarget;n(Ps(t))},`handleLoad`),o=Ss(()=>n(Es.Error),`handleError`);return t.addEventListener(`load`,a),t.addEventListener(`error`,o),r&&(t.referrerPolicy=r),t.crossOrigin=i??null,t.src=e,n(Ps(t)),()=>{t.removeEventListener(`load`,a),t.removeEventListener(`error`,o),n(Es.Idle)}},[e,i,r,n]),t}Ss(Ns,`useImageLoadingStatus`);function Ps(e){return e.complete?e.naturalWidth>0?Es.Loaded:Es.Error:Es.Loading}Ss(Ps,`getImageLoadingStatus`);function Fs(){return Ds}Ss(Fs,`useImageCount`);function Is(e){}Ss(Is,`useUpdateImageCount`);var Ls=Object.defineProperty,Rs=(e,t)=>Ls(e,`name`,{value:t,configurable:!0});function zs(e){let[t,n]=D.useState(void 0);return br(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=0,r=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;let i=r[0];window.cancelAnimationFrame(t),t=window.requestAnimationFrame(()=>{let t,r;if(`borderBoxSize`in i){let e=i.borderBoxSize,n=Array.isArray(e)?e[0]:e;t=n.inlineSize,r=n.blockSize}else t=e.offsetWidth,r=e.offsetHeight;n({width:t,height:r})})});return r.observe(e,{box:`border-box`}),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}n(void 0)},[e]),t}Rs(zs,`useSize`);var Bs=[`top`,`right`,`bottom`,`left`],Vs=Math.min,Hs=Math.max,Us=Math.round,Ws=Math.floor,Gs=e=>({x:e,y:e}),Ks={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function qs(e,t,n){return Hs(e,Vs(t,n))}function Js(e,t){return typeof e==`function`?e(t):e}function Ys(e){return e.split(`-`)[0]}function Xs(e){return e.split(`-`)[1]}function Zs(e){return e===`x`?`y`:`x`}function Qs(e){return e===`y`?`height`:`width`}function $s(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function ec(e){return Zs($s(e))}function tc(e,t,n){n===void 0&&(n=!1);let r=Xs(e),i=ec(e),a=Qs(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=uc(o)),[o,uc(o)]}function nc(e){let t=uc(e);return[rc(e),t,rc(t)]}function rc(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var ic=[`left`,`right`],ac=[`right`,`left`],oc=[`top`,`bottom`],sc=[`bottom`,`top`];function cc(e,t,n){switch(e){case`top`:case`bottom`:return n?t?ac:ic:t?ic:ac;case`left`:case`right`:return t?oc:sc;default:return[]}}function lc(e,t,n,r){let i=Xs(e),a=cc(Ys(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(rc)))),a}function uc(e){let t=Ys(e);return Ks[t]+e.slice(t.length)}function dc(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function fc(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:dc(e)}function pc(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 mc(e,t,n){let{reference:r,floating:i}=e,a=$s(t),o=ec(t),s=Qs(o),c=Ys(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=Xs(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function hc(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}=Js(t,e),p=fc(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=pc(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=pc(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 gc=50,_c=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:hc},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=mc(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<gc&&(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}=mc(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},vc=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}=Js(e,t)||{};if(l==null)return{};let d=fc(u),f={x:n,y:r},p=ec(i),m=Qs(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;C&&await(o.isElement==null?void 0:o.isElement(S))||(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Vs(d[_],T),D=Vs(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=qs(E,k,O),j=!c.arrow&&Xs(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),yc=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}=Js(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Ys(r),_=$s(o),v=Ys(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[uc(o)]:nc(o)),x=p!==`none`;!d&&x&&b.push(...lc(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=tc(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`||_===$s(t)||T.every(e=>$s(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=$s(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function bc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function xc(e){return Bs.some(t=>e[t]>=0)}var Sc=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Js(e,t);switch(i){case`referenceHidden`:{let e=bc(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:xc(e)}}}case`escaped`:{let e=bc(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:xc(e)}}}default:return{}}}}},Cc=new Set([`left`,`top`]);async function wc(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Ys(n),s=Xs(n),c=$s(n)===`y`,l=Cc.has(o)?-1:1,u=a&&c?-1:1,d=Js(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 Tc=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 wc(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}}}}},Ec=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}=Js(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=$s(i),p=Zs(f),m=u[p],h=u[f],g=(e,t)=>qs(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}}}}}},Dc=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}=Js(e,t),u={x:n,y:r},d=$s(i),f=Zs(d),p=u[f],m=u[d],h=Js(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=Cc.has(Ys(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}}}},Oc=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}=Js(e,t),c=await i.detectOverflow(t,s),l=Ys(n),u=Xs(n),d=$s(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=Vs(p-c[m],g),y=Vs(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*Hs(c.left,c.right):S=p-2*Hs(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 kc(){return typeof window<`u`}function Ac(e){return Nc(e)?(e.nodeName||``).toLowerCase():`#document`}function jc(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Mc(e){return((Nc(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Nc(e){return kc()?e instanceof Node||e instanceof jc(e).Node:!1}function Pc(e){return kc()?e instanceof Element||e instanceof jc(e).Element:!1}function Fc(e){return kc()?e instanceof HTMLElement||e instanceof jc(e).HTMLElement:!1}function Ic(e){return!kc()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof jc(e).ShadowRoot}function Lc(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Jc(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Rc(e){return/^(table|td|th)$/.test(Ac(e))}function zc(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Bc=/transform|translate|scale|rotate|perspective|filter/,Vc=/paint|layout|strict|content/,Hc=e=>!!e&&e!==`none`,Uc;function Wc(e){let t=Pc(e)?Jc(e):e;return Hc(t.transform)||Hc(t.translate)||Hc(t.scale)||Hc(t.rotate)||Hc(t.perspective)||!Kc()&&(Hc(t.backdropFilter)||Hc(t.filter))||Bc.test(t.willChange||``)||Vc.test(t.contain||``)}function Gc(e){let t=Xc(e);for(;Fc(t)&&!qc(t);){if(Wc(t))return t;if(zc(t))return null;t=Xc(t)}return null}function Kc(){return Uc??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Uc}function qc(e){return/^(html|body|#document)$/.test(Ac(e))}function Jc(e){return jc(e).getComputedStyle(e)}function Yc(e){return Pc(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Xc(e){if(Ac(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Ic(e)&&e.host||Mc(e);return Ic(t)?t.host:t}function Zc(e){let t=Xc(e);return qc(t)?(e.ownerDocument||e).body:Fc(t)&&Lc(t)?t:Zc(t)}function Qc(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Zc(e),i=r===e.ownerDocument?.body,a=jc(r);if(i){let e=$c(a);return t.concat(a,a.visualViewport||[],Lc(r)?r:[],e&&n?Qc(e):[])}return t.concat(r,Qc(r,[],n))}function $c(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function el(e){let t=Jc(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Fc(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Us(n)!==a||Us(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function tl(e){return Pc(e)?e:e.contextElement}function nl(e){let t=tl(e);if(!Fc(t))return Gs(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=el(t),o=(a?Us(n.width):n.width)/r,s=(a?Us(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var rl=Gs(0);function il(e){let t=jc(e);return!Kc()||!t.visualViewport?rl:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function al(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===jc(e)}function ol(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=tl(e),o=Gs(1);t&&(r?Pc(r)&&(o=nl(r)):o=nl(e));let s=al(a,n,r)?il(a):Gs(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=jc(a),t=Pc(r)?jc(r):r,n=e,i=$c(n);for(;i&&t!==n;){let e=nl(i),t=i.getBoundingClientRect(),r=Jc(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=jc(i),i=$c(n)}}return pc({width:u,height:d,x:c,y:l})}function sl(e,t){let n=Yc(e).scrollLeft;return t?t.left+n:ol(Mc(e)).left+n}function cl(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-sl(e,n),y:n.top+t.scrollTop}}function ll(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Mc(r),s=t?zc(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Gs(1),u=Gs(0),d=Fc(r);if((d||!a)&&((Ac(r)!==`body`||Lc(o))&&(c=Yc(r)),d)){let e=ol(r);l=nl(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?cl(o,c):Gs(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 ul(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function dl(e){let t=Yc(e),n=e.ownerDocument.body,r=Hs(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Hs(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+sl(e),o=-t.scrollTop;return Jc(n).direction===`rtl`&&(a+=Hs(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var fl=25;function pl(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=jc(e),a=Mc(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Kc()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(sl(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<=fl&&(s-=o)}return{width:s,height:c,x:l,y:u}}function ml(e,t){let n=ol(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=nl(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function hl(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=pl(e,n,t);else if(t===`document`)r=dl(Mc(e));else if(Pc(t))r=ml(t,n);else{let n=il(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return pc(r)}function gl(e,t){let n=t.get(e);if(n)return n;let r=Qc(e,[],!1).filter(e=>Pc(e)&&Ac(e)!==`body`),i=null,a=Jc(e).position===`fixed`,o=a?Xc(e):e;for(;Pc(o)&&!qc(o);){let e=Jc(o),t=Wc(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Xc(o)}return t.set(e,r),r}function _l(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?zc(t)?[]:gl(t,this._c):[].concat(n),r],o=hl(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=hl(t,a[e],i);s=Hs(n.top,s),c=Vs(n.right,c),l=Vs(n.bottom,l),u=Hs(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function vl(e){let{width:t,height:n}=el(e);return{width:t,height:n}}function yl(e,t,n){let r=Fc(t),i=Mc(t),a=n===`fixed`,o=ol(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Gs(0);if((r||!a)&&((Ac(t)!==`body`||Lc(i))&&(s=Yc(t)),r)){let e=ol(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=sl(i));let l=i&&!r&&!a?cl(i,s):Gs(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 bl(e){return Jc(e).position===`static`}function xl(e,t){if(!Fc(e)||Jc(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Mc(e)===n&&(n=n.ownerDocument.body),n}function Sl(e,t){let n=jc(e);if(zc(e))return n;if(!Fc(e)){let t=Xc(e);for(;t&&!qc(t);){if(Pc(t)&&!bl(t))return t;t=Xc(t)}return n}let r=xl(e,t);for(;r&&Rc(r)&&bl(r);)r=xl(r,t);return r&&qc(r)&&bl(r)&&!Wc(r)?n:r||Gc(e)||n}var Cl=async function(e){let t=this.getOffsetParent||Sl,n=this.getDimensions,r=await n(e.floating);return{reference:yl(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function wl(e){return Jc(e).direction===`rtl`}var Tl={convertOffsetParentRelativeRectToViewportRelativeRect:ll,getDocumentElement:Mc,getClippingRect:_l,getOffsetParent:Sl,getElementRects:Cl,getClientRects:ul,getDimensions:vl,getScale:nl,isElement:Pc,isRTL:wl};function El(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dl(e,t,n){let r=null,i,a=Mc(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=Ws(d),h=Ws(a.clientWidth-(u+f)),g=Ws(a.clientHeight-(d+p)),_=Ws(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Hs(0,Vs(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!El(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=jc(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Ol(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=tl(e),u=i||a?[...l?Qc(l):[],...t?Qc(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Dl(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?ol(e):null;c&&g();function g(){let t=ol(e);h&&!El(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 kl=Tc,Al=Ec,jl=yc,Ml=Oc,Nl=Sc,Pl=vc,Fl=Dc,Il=(e,t,n)=>{let r=new Map,i=n??{},a={...Tl,...i.platform,_c:r};return _c(e,t,{...i,platform:a})},Ll=typeof document<`u`?D.useLayoutEffect:function(){};function Rl(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(!Rl(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)&&!Rl(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function zl(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bl(e,t){let n=zl(e);return Math.round(t*n)/n}function Vl(e){let t=D.useRef(e);return Ll(()=>{t.current=e}),t}function Hl(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=D.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=D.useState(r);Rl(f,r)||p(r);let[m,h]=D.useState(null),[g,_]=D.useState(null),v=D.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=D.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=D.useRef(null),C=D.useRef(null),w=D.useRef(u),T=c!=null,E=Vl(c),O=Vl(i),k=Vl(l),A=D.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),Il(S.current,C.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Rl(w.current,t)&&(w.current=t,Un.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);Ll(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=D.useRef(!1);Ll(()=>(j.current=!0,()=>{j.current=!1}),[]),Ll(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,A);A()}},[b,x,A,E,T]);let M=D.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),N=D.useMemo(()=>({reference:b,floating:x}),[b,x]),P=D.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Bl(N.floating,u.x),r=Bl(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...zl(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return D.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var Ul=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Pl({element:r.current,padding:i}).fn(n):r?Pl({element:r,padding:i}).fn(n):{}}}},Wl=(e,t)=>{let n=kl(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gl=(e,t)=>{let n=Al(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kl=(e,t)=>({fn:Fl(e).fn,options:[e,t]}),ql=(e,t)=>{let n=jl(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jl=(e,t)=>{let n=Ml(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yl=(e,t)=>{let n=Nl(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xl=(e,t)=>{let n=Ul(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zl=Object.defineProperty,Ql=D.forwardRef(((e,t)=>Zl(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,W.jsx)(G.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,W.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),$l=Object.defineProperty,eu=(e,t)=>$l(e,`name`,{value:t,configurable:!0}),tu={Partial:`partial`,Always:`always`},nu={Optimized:`optimized`,Always:`always`},ru=`Popper`,[iu,au]=vr(ru),[ou,su]=iu(ru),cu=eu(e=>{let{__scopePopper:t,children:n}=e,[r,i]=D.useState(null),[a,o]=D.useState(void 0);return(0,W.jsx)(ou,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),lu=`PopperAnchor`,uu=D.forwardRef(eu(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=su(lu,n),o=D.useRef(null),s=a.onAnchorChange,c=Hn(t,D.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=D.useRef(null);D.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&bu(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,W.jsx)(G.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),du=`PopperContent`,[fu,pu]=iu(du),mu=D.forwardRef(eu(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=tu.Partial,hideWhenDetached:f=!1,updatePositionStrategy:p=nu.Optimized,onPlaced:m,...h}=e,g=su(du,n),[_,v]=D.useState(null),y=Hn(t,v),[b,x]=D.useState(null),S=zs(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},O=Array.isArray(l)?l:[l],k=O.length>0,A={padding:E,boundary:O.filter(vu),altBoundary:k},{refs:j,floatingStyles:M,placement:N,isPositioned:P,middlewareData:F}=Hl({strategy:`fixed`,placement:T,whileElementsMounted:eu((...e)=>Ol(...e,{animationFrame:p===nu.Always}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[Wl({mainAxis:i+w,alignmentAxis:o}),c&&Gl({mainAxis:!0,crossAxis:!1,...d===tu.Partial?{limiter:Kl()}:{},...A}),c&&ql({...A}),Jl({...A,apply:eu(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),b&&Xl({element:b,padding:s}),yu({arrowWidth:C,arrowHeight:w}),f&&Yl(k?{strategy:`referenceHidden`,...A}:{strategy:`referenceHidden`,padding:A.padding,altBoundary:A.altBoundary})]}),I=g.setPlacementState;br(()=>(I(N),()=>{I(void 0)}),[N,I]);let[ee,te]=bu(N),ne=Ci(m);br(()=>{P&&ne?.()},[P,ne]);let re=F.arrow?.x,L=F.arrow?.y,ie=F.arrow?.centerOffset!==0,[ae,oe]=D.useState();return br(()=>{_&&oe(window.getComputedStyle(_).zIndex)},[_]),(0,W.jsx)(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:P?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(` `),...F.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,W.jsx)(fu,{scope:n,placedSide:ee,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:L,shouldHideArrow:ie,children:(0,W.jsx)(G.div,{"data-side":ee,"data-align":te,...h,ref:y,style:{...h.style,animation:P?h.style?.animation:`none`}})})})},`PopperContent`)),hu=`PopperArrow`,gu={top:`bottom`,right:`left`,bottom:`top`,left:`right`},_u=D.forwardRef(eu(function(e,t){let{__scopePopper:n,...r}=e,i=pu(hu,n),a=gu[i.placedSide];return(0,W.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,W.jsx)(Ql,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function vu(e){return e!==null}eu(vu,`isNotNull`);var yu=eu(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=bu(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function bu(e){let[t,n=`center`]=e.split(`-`);return[t,n]}eu(bu,`getSideAndAlignFromPlacement`);var xu=Object.defineProperty,Su=(e,t)=>xu(e,`name`,{value:t,configurable:!0}),Cu=!1;function wu(){let[e,t]=D.useState(Cu);return D.useEffect(()=>{Cu||(Cu=!0,t(!0))},[]),e}Su(wu,`useIsHydrated`);var Tu=D.useSyncExternalStore;function Eu(){return()=>{}}Su(Eu,`subscribe`);function Du(){return Tu(Eu,()=>!0,()=>!1)}Su(Du,`useIsHydratedModern`);var Ou=typeof Tu==`function`?Du:wu,ku=Object.defineProperty,Au=(e,t)=>ku(e,`name`,{value:t,configurable:!0}),ju=`rovingFocusGroup.onEntryFocus`,Mu={bubbles:!1,cancelable:!0},Nu=`RovingFocusGroup`,[Pu,Fu,Iu]=Cr(Nu),[Lu,Ru]=vr(Nu,[Iu]),zu={Vertical:`vertical`,Horizontal:`horizontal`},Bu={LTR:`ltr`,RTL:`rtl`},[Vu,Hu]=Lu(Nu),Uu=D.forwardRef(Au(function(e,t){return(0,W.jsx)(Pu.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,W.jsx)(Pu.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,W.jsx)(Wu,{...e,ref:t})})})},`RovingFocusGroup`)),Wu=D.forwardRef(Au(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=D.useRef(null),p=Hn(t,f),m=yi(a),[h,g]=Xr({prop:o,defaultProp:s??null,onChange:c,caller:Nu}),[_,v]=D.useState(!1),y=Ci(l),b=Fu(n),x=D.useRef(!1),[S,C]=D.useState(0);return D.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(ju,y),()=>e.removeEventListener(ju,y)},[y]),(0,W.jsx)(Vu,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:D.useCallback(e=>g(e),[g]),onItemShiftTab:D.useCallback(()=>v(!0),[]),onFocusableItemAdd:D.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:D.useCallback(()=>C(e=>e-1),[]),children:(0,W.jsx)(G.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:K(e.onMouseDown,()=>{x.current=!0}),onFocus:K(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(ju,Mu);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Xu([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:K(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),Gu=`RovingFocusGroupItem`,Ku=D.forwardRef(Au(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=mi(),l=a||c,u=Hu(Gu,n),d=u.currentTabStopId===l,f=Fu(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=Ou();return br(()=>{if(g&&r)return p(),()=>m()},[g,r,p,m]),D.useEffect(()=>{if(!g&&r)return p(),()=>m()},[g,r,p,m]),(0,W.jsx)(Pu.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,W.jsx)(G.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:K(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:K(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:K(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Yu(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Zu(n,r+1):n.slice(r+1)}setTimeout(()=>Xu(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),qu={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Ju(e,t){return t===Bu.RTL?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}Au(Ju,`getDirectionAwareKey`);function Yu(e,t,n){let r=Ju(e.key,n);if(!(t===zu.Vertical&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===zu.Horizontal&&[`ArrowUp`,`ArrowDown`].includes(r)))return qu[r]}Au(Yu,`getFocusIntent`);function Xu(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Au(Xu,`focusFirst`);function Zu(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Au(Zu,`wrapArray`);var Qu=Object.defineProperty,Y=(e,t)=>Qu(e,`name`,{value:t,configurable:!0}),$u=[`Enter`,` `],ed=[`ArrowDown`,`PageUp`,`Home`],td=[`ArrowUp`,`PageDown`,`End`],nd=[...ed,...td];[...$u],[...$u];var rd=`Menu`,[id,ad,od]=Cr(rd),[sd,cd]=vr(rd,[od,au,Ru]),ld=au(),ud=Ru(),[dd,fd]=sd(rd),[pd,md]=sd(rd),hd=Y(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=ld(t),[c,l]=D.useState(null),u=D.useRef(!1),d=Ci(a),f=yi(i);return D.useEffect(()=>{let e=Y(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=Y(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),D.useEffect(()=>{if(!n)return;let e=Y(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,W.jsx)(cu,{...s,children:(0,W.jsx)(dd,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,W.jsx)(pd,{scope:t,onClose:D.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),gd=D.forwardRef(Y(function(e,t){let{__scopeMenu:n,...r}=e,i=ld(n);return(0,W.jsx)(uu,{...i,...r,ref:t})},`MenuAnchor`)),_d=`MenuPortal`,[vd,yd]=sd(_d,{forceMount:void 0}),bd=Y(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=fd(_d,t);return(0,W.jsx)(vd,{scope:t,forceMount:n,children:(0,W.jsx)(ii,{present:n||a.open,children:(0,W.jsx)(aa,{asChild:!0,container:i,children:r})})})},`MenuPortal`),xd=`MenuContent`,[Sd,Cd]=sd(xd),wd=D.forwardRef(Y(function(e,t){let n=yd(xd,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=fd(xd,e.__scopeMenu),o=md(xd,e.__scopeMenu);return(0,W.jsx)(id.Provider,{scope:e.__scopeMenu,children:(0,W.jsx)(ii,{present:r||a.open,children:(0,W.jsx)(id.Slot,{scope:e.__scopeMenu,children:o.modal?(0,W.jsx)(Td,{...i,ref:t}):(0,W.jsx)(Ed,{...i,ref:t})})})})},`MenuContent`)),Td=D.forwardRef(Y(function(e,t){let n=fd(xd,e.__scopeMenu),r=D.useRef(null),i=Hn(t,r);return D.useEffect(()=>{let e=r.current;if(e)return Ao(e)},[]),(0,W.jsx)(Od,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:K(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Ed=D.forwardRef(Y(function(e,t){let n=fd(xd,e.__scopeMenu);return(0,W.jsx)(Od,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Dd=Kn(`MenuContent.ScrollLock`),Od=D.forwardRef(Y(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=fd(xd,n),_=md(xd,n),v=ld(n),y=ud(n),b=ad(n),[x,S]=D.useState(null),C=D.useRef(null),[w,T]=D.useState(null);qi(w);let{nodes:E,registry:O}=Ki(),k=!!(i||m),A=Hn(t,C,g.onContentChange,T),j=D.useRef(0),M=D.useRef(``),N=D.useRef(0),P=D.useRef(null),F=D.useRef(`right`),I=D.useRef(0),ee=D.useMemo(()=>m?[C,...E.map(e=>({current:e}))]:[],[C,E,m]),te=m?xo:D.Fragment,ne=m?{as:Dd,allowPinchZoom:!0,shards:ee}:void 0,re=Y(e=>{let t=M.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Wd(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;function s(e){M.current=e,window.clearTimeout(j.current),e!==``&&(j.current=window.setTimeout(()=>s(``),1e3))}Y(s,`updateSearch`),s(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);D.useEffect(()=>()=>window.clearTimeout(j.current),[]),da();let L=D.useCallback(e=>F.current===P.current?.side&&Kd(e,P.current?.area),[]);return(0,W.jsx)(Sd,{scope:n,searchRef:M,onItemEnter:D.useCallback(e=>{L(e)&&e.preventDefault()},[L]),onItemLeave:D.useCallback(e=>{L(e)||(C.current?.focus(),S(null))},[L]),onTriggerLeave:D.useCallback(e=>{L(e)&&e.preventDefault()},[L]),pointerGraceTimerRef:N,onPointerGraceIntentChange:D.useCallback(e=>{P.current=e},[]),children:(0,W.jsx)(Gi,{registry:k?O:null,children:(0,W.jsx)(te,{...ne,children:(0,W.jsx)(Ui,{asChild:!0,trapped:i,branches:E,onMountAutoFocus:K(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,W.jsx)(ji,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,W.jsx)(Uu,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:K(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,W.jsx)(mu,{role:`menu`,"aria-orientation":`vertical`,"data-state":zd(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:A,style:{outline:`none`,...h.style},onKeyDown:K(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&re(e.key));let i=C.current;if(e.target!==i||!nd.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);td.includes(e.key)&&a.reverse(),Hd(a)}),onBlur:K(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(j.current),M.current=``)}),onPointerMove:K(e.onPointerMove,qd(e=>{let t=e.target,n=I.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>I.current?`right`:`left`;F.current=t,I.current=e.clientX}}))})})})})})})})},`MenuContentImpl`)),kd=`MenuItem`,Ad=`menu.itemSelect`,jd=D.forwardRef(Y(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=D.useRef(null),o=md(kd,e.__scopeMenu),s=Cd(kd,e.__scopeMenu),c=Hn(t,a),l=D.useRef(!1),u=Y(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Ad,{bubbles:!0,cancelable:!0});e.addEventListener(Ad,e=>r?.(e),{once:!0}),ur(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,W.jsx)(Md,{...i,ref:c,disabled:n,onClick:K(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:K(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:K(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&$u.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),Md=D.forwardRef(Y(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Cd(kd,n),s=ud(n),c=D.useRef(null),l=Hn(t,c),[u,d]=D.useState(!1),[f,p]=D.useState(``);return D.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,W.jsx)(id.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,W.jsx)(Ku,{asChild:!0,...s,focusable:!r,children:(0,W.jsx)(G.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:K(e.onPointerMove,qd(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:K(e.onPointerLeave,qd(e=>o.onItemLeave(e))),onFocus:K(e.onFocus,()=>d(!0)),onBlur:K(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[Nd,Pd]=sd(`MenuRadioGroup`,{value:void 0,onValueChange:Y(()=>{},`onValueChange`)}),[Fd,Id]=sd(`MenuItemIndicator`,{checked:!1}),[Ld,Rd]=sd(`MenuSub`);function zd(e){return e?`open`:`closed`}Y(zd,`getOpenState`);function Bd(e){return e===`indeterminate`}Y(Bd,`isIndeterminate`);function Vd(e){return Bd(e)?`indeterminate`:e?`checked`:`unchecked`}Y(Vd,`getCheckedState`);function Hd(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Y(Hd,`focusFirst`);function Ud(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Y(Ud,`wrapArray`);function Wd(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ud(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}Y(Wd,`getNextMatch`);function Gd(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Y(Gd,`isPointInPolygon`);function Kd(e,t){return t?Gd({x:e.clientX,y:e.clientY},t):!1}Y(Kd,`isPointerInGraceArea`);function qd(e){return t=>t.pointerType===`mouse`?e(t):void 0}Y(qd,`whenMouse`);var Jd=Object.defineProperty,Yd=(e,t)=>Jd(e,`name`,{value:t,configurable:!0}),Xd=`DropdownMenu`,[Zd,Qd]=vr(Xd,[cd]),$d=cd(),[ef,tf]=Zd(Xd),nf=Yd(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=$d(t),l=D.useRef(null),[u,d]=Xr({prop:i,defaultProp:a??!1,onChange:o,caller:Xd});return(0,W.jsx)(ef,{scope:t,triggerId:mi(),triggerRef:l,contentId:mi(),open:u,onOpenChange:d,onOpenToggle:D.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,W.jsx)(hd,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),rf=`DropdownMenuTrigger`,af=D.forwardRef(Yd(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=tf(rf,n),o=$d(n),s=Hn(t,a.triggerRef);return(0,W.jsx)(gd,{asChild:!0,...o,children:(0,W.jsx)(G.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:K(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:K(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),of=Yd(e=>{let{__scopeDropdownMenu:t,...n}=e,r=$d(t);return(0,W.jsx)(bd,{...r,...n})},`DropdownMenuPortal`),sf=`DropdownMenuContent`,cf=D.forwardRef(Yd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tf(sf,n),a=$d(n),o=D.useRef(!1);return(0,W.jsx)(wd,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:K(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:K(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),lf=D.forwardRef(Yd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$d(n);return(0,W.jsx)(jd,{...i,...r,ref:t})},`DropdownMenuItem`)),uf=Object.defineProperty,df=D.forwardRef(((e,t)=>uf(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,W.jsx)(G.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`)),ff=Object.defineProperty,pf=(e,t)=>ff(e,`name`,{value:t,configurable:!0});function mf(e,[t,n]){return Math.min(n,Math.max(t,e))}pf(mf,`clamp`);var hf=Object.defineProperty,gf=(e,t)=>hf(e,`name`,{value:t,configurable:!0}),_f={ItemAligned:`item-aligned`,Popper:`popper`},vf={LTR:`ltr`,RTL:`rtl`},yf=[` `,`Enter`,`ArrowUp`,`ArrowDown`],bf=[` `,`Enter`],xf=`Select`,[Sf,Cf,wf]=Cr(xf),[Tf,Ef]=vr(xf,[wf,au]),Df=au(),[Of,kf]=Tf(xf),[Af,jf]=Tf(xf);function Mf(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=Df(t),[_,v]=D.useState(null),[y,b]=D.useState(null),[x,S]=D.useState(!1),C=yi(l),[w,T]=Xr({prop:r,defaultProp:i??!1,onChange:a,caller:xf}),[E,O]=Xr({prop:o,defaultProp:s,onChange:c,caller:xf}),k=D.useRef(null),A=D.useRef(!1),[j,M]=D.useState(null),N=gf(e=>{M({value:e,hasConsumerStoppedPropagation:A.current}),O(e)},`handleUserSelect`),P=D.useRef(E);D.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=gf(()=>O(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,O]);let F=!_||!!m||!!_.closest(`form`),[I,ee]=D.useState(new Set),te=mi(),ne=Array.from(I).map(e=>e.props.value).join(`;`),re=D.useCallback(e=>{ee(t=>new Set(t).add(e))},[]),L=D.useCallback(e=>{ee(t=>{let n=new Set(t);return n.delete(e),n})},[]),ie={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:te,value:E,onValueChange:O,hasConsumerStoppedPropagationRef:A,userSelection:j,onUserSelect:N,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:k,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:I,nativeSelectKey:ne,isFormControl:F};return(0,W.jsx)(cu,{...g,children:(0,W.jsx)(Of,{scope:t,...ie,children:(0,W.jsx)(Sf.Provider,{scope:t,children:(0,W.jsx)(Af,{scope:t,onNativeOptionAdd:re,onNativeOptionRemove:L,children:yp(h)?h(ie):n})})})})}gf(Mf,`SelectProvider`);var Nf=gf(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,W.jsx)(Mf,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,W.jsxs)(W.Fragment,{children:[n,e?(0,W.jsx)(vp,{__scopeSelect:t}):null]})})},`Select`),Pf=`SelectTrigger`,Ff=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Df(n),o=kf(Pf,n),s=o.disabled||r,c=Hn(t,o.onTriggerChange),l=Cf(n),u=D.useRef(`touch`),[d,f,p]=xp(e=>{let t=l().filter(e=>!e.disabled),n=Sp(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onUserSelect(n.value)}),m=gf(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,W.jsx)(uu,{asChild:!0,...a,children:(0,W.jsx)(G.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":bp(o.value)?``:void 0,...i,ref:c,onClick:K(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:K(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:K(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(o.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),f(e.key)),t&&e.key===` `||yf.includes(e.key)&&(m(),e.preventDefault())})})})},`SelectTrigger`)),If=`SelectValue`,Lf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=kf(If,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Hn(t,c.onValueNodeChange);br(()=>{l(u)},[l,u]);let f=bp(c.value);return(0,W.jsx)(G.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,W.jsx)(D.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),Rf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,W.jsx)(G.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[zf,Bf]=Tf(`SelectPortal`,{forceMount:void 0}),Vf=gf(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,W.jsx)(zf,{scope:e.__scopeSelect,forceMount:n,children:(0,W.jsx)(aa,{asChild:!0,...r})})},`SelectPortal`),Hf=`SelectContent`,Uf=D.forwardRef(gf(function(e,t){let n=Bf(Hf,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=kf(Hf,e.__scopeSelect),[o,s]=D.useState();return br(()=>{s(new DocumentFragment)},[]),(0,W.jsx)(ii,{present:r||a.open,children:({present:e})=>e?(0,W.jsx)(Yf,{...i,ref:t}):(0,W.jsx)(Wf,{...i,fragment:o})})},`SelectContent`)),Wf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?Un.createPortal((0,W.jsx)(Kf,{scope:n,children:(0,W.jsx)(Sf.Slot,{scope:n,children:(0,W.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Gf=10,[Kf,qf]=Tf(Hf),Jf=Kn(`SelectContent.RemoveScroll`),Yf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n}=e,{position:r=_f.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=kf(Hf,n),[y,b]=D.useState(null),[x,S]=D.useState(null),C=Hn(t,b),[w,T]=D.useState(null),[E,O]=D.useState(null),k=Cf(n),[A,j]=D.useState(!1),M=D.useRef(!1),N=D.useRef(!1),P=D.useRef(!1);D.useEffect(()=>{if(y)return Ao(y)},[y]),da();let F=D.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,x]),I=D.useCallback(()=>F([w,y]),[F,w,y]);D.useEffect(()=>{A&&I()},[A,I]);let{onOpenChange:ee,triggerPointerDownPosRef:te}=v;D.useEffect(()=>{if(y){let e={x:0,y:0},t=gf(t=>{e={x:Math.abs(Math.round(t.pageX)-(te.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(te.current?.y??0))}},`handlePointerMove`),n=gf(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||ee(!1),document.removeEventListener(`pointermove`,t),te.current=null},`handlePointerUp`);return te.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,ee,te]),D.useEffect(()=>{let e=gf(()=>ee(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[ee]);let[ne,re]=xp(e=>{let t=k().filter(e=>!e.disabled),n=Sp(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),L=D.useCallback((e,t,n)=>{let r=!N.current;r&&(N.current=!0);let i=!M.current&&!n;v.value!==void 0&&v.value===t||i?(T(e),i&&(M.current=!0)):r&&T(e)},[v.value]),ie=D.useCallback(()=>y?.focus(),[y]),ae=D.useCallback((e,t,n)=>{if(!e)return;let r=!P.current;r&&(P.current=!0);let i=!M.current&&!n;(v.value!==void 0&&v.value===t||i||r)&&O(e)},[v.value]),oe=r===_f.Popper?Zf:Xf,R=oe===Zf?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,W.jsx)(Kf,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:L,selectedItem:w,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:I,selectedItemText:E,position:r,isPositioned:A,searchRef:ne,children:(0,W.jsx)(xo,{as:Jf,allowPinchZoom:!0,children:(0,W.jsx)(Ui,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:K(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,W.jsx)(ji,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,W.jsx)(oe,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...R,onPlaced:()=>j(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:K(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&re(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>F(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Xf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=kf(Hf,n),o=qf(Hf,n),[s,c]=D.useState(null),[l,u]=D.useState(null),d=Hn(t,u),f=Cf(n),p=D.useRef(!1),m=D.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=D.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==vf.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Gf,d=mf(a,[Gf,Math.max(Gf,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Gf,d=mf(a,[Gf,Math.max(Gf,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Gf*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Gf,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Gf}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);br(()=>y(),[y]);let[b,x]=D.useState();br(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]);let S=D.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]);return(0,W.jsx)(Qf,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:(0,W.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,W.jsx)(G.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Zf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Gf,...a}=e,o=Df(n);return(0,W.jsx)(mu,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[Qf,$f]=Tf(Hf,{}),ep=`SelectViewport`,tp=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=qf(ep,n),o=$f(ep,n),s=Hn(t,a.onViewportChange),c=D.useRef(0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,W.jsx)(Sf.Slot,{scope:n,children:(0,W.jsx)(G.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:K(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Gf*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[np,rp]=Tf(`SelectGroup`),ip=`SelectItem`,[ap,op]=Tf(ip),sp=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=kf(ip,n),c=qf(ip,n),l=s.value===r,[u,d]=D.useState(a??``),[f,p]=D.useState(!1),m=Hn(t,Ci(e=>c.itemRefCallback?.(e,r,i))),h=mi(),g=D.useRef(`touch`);function _(e){s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),s.onUserSelect(r),s.onOpenChange(!1)}return gf(_,`handleSelect`),(0,W.jsx)(ap,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:D.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,W.jsx)(Sf.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,W.jsx)(G.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:K(o.onFocus,()=>p(!0)),onBlur:K(o.onBlur,()=>p(!1)),onClick:K(o.onClick,e=>{i||g.current!==`mouse`&&_(e)}),onPointerUp:K(o.onPointerUp,e=>{i||g.current===`mouse`&&_(e)}),onPointerDown:K(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:K(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:K(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:K(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(bf.includes(e.key)&&_(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),cp=`SelectItemText`,lp=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=kf(cp,n),s=qf(cp,n),c=op(cp,n),l=jf(cp,n),[u,d]=D.useState(null),f=Ci(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=Hn(t,d,c.onItemTextChange,f),m=u?.textContent,h=D.useMemo(()=>(0,W.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return br(()=>(g(h),()=>_(h)),[g,_,h]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(G.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!bp(o.value)?Un.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),up=`SelectItemIndicator`,dp=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,...r}=e;return op(up,n).isSelected?(0,W.jsx)(G.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),fp=`SelectScrollUpButton`,pp=D.forwardRef(gf(function(e,t){let n=qf(fp,e.__scopeSelect),r=$f(fp,e.__scopeSelect),[i,a]=D.useState(!1),o=Hn(t,r.onScrollButtonChange);return br(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};gf(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(gp,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),mp=`SelectScrollDownButton`,hp=D.forwardRef(gf(function(e,t){let n=qf(mp,e.__scopeSelect),r=$f(mp,e.__scopeSelect),[i,a]=D.useState(!1),o=Hn(t,r.onScrollButtonChange);return br(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};gf(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(gp,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),gp=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=qf(`SelectScrollButton`,n),o=D.useRef(null),s=Cf(n),c=D.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return D.useEffect(()=>()=>c(),[c]),br(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,W.jsx)(G.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:K(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:K(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:K(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),_p=`SelectBubbleInput`,vp=D.forwardRef(gf(function({__scopeSelect:e,...t},n){let r=kf(_p,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u,userSelection:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=D.useRef(null),h=Hn(n,m),g=i??``,_=D.useRef(g),v=D.useRef(d),y=D.useRef(!1),b=Array.from(f).some(e=>(e.props.value??``)===``);return D.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=d!==null&&d!==v.current;v.current=d;let i=_.current!==g;_.current=g;let a=r&&i;if(r&&!i&&d.value!==g&&!d.hasConsumerStoppedPropagation&&n){y.current=!0;try{n.call(e,d.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{y.current=!1,n.call(e,g)}return}let o=a&&!d.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,g),e.dispatchEvent(t)}},[g,d]),(0,W.jsxs)(G.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>{y.current||a(e.target.value)},...t,style:{...pr,...t.style},ref:h,defaultValue:g,children:[bp(i)&&!b?(0,W.jsx)(`option`,{value:``}):null,Array.from(f)]},p)},`SelectBubbleInput`));function yp(e){return typeof e==`function`}gf(yp,`isFunction`);function bp(e){return e===``||e===void 0}gf(bp,`shouldShowPlaceholder`);function xp(e){let t=Ci(e),n=D.useRef(``),r=D.useRef(0),i=D.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}gf(a,`updateSearch`),a(i)},[t]),a=D.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return D.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}gf(xp,`useTypeaheadSearch`);function Sp(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Cp(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}gf(Sp,`findNextItem`);function Cp(e,t){return e.map((n,r)=>e[(t+r)%e.length])}gf(Cp,`wrapArray`);var wp=Object.defineProperty,Tp=(e,t)=>wp(e,`name`,{value:t,configurable:!0}),Ep={Horizontal:`horizontal`,Vertical:`vertical`},Dp=Ep.Horizontal,Op=Object.values(Ep),kp=D.forwardRef(Tp(function(e,t){let{decorative:n,orientation:r=Dp,...i}=e,a=Ap(r)?r:Dp,o=a===Ep.Vertical?a:void 0,s=n?{role:`none`}:{"aria-orientation":o,role:`separator`};return(0,W.jsx)(G.div,{"data-orientation":a,...s,...i,ref:t})},`Separator`));function Ap(e){return Op.includes(e)}Tp(Ap,`isValidOrientation`);var jp=Object.defineProperty,Mp=(e,t)=>jp(e,`name`,{value:t,configurable:!0}),Np=`Switch`,[Pp,Fp]=vr(Np),[Ip,Lp]=Pp(Np);function Rp(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=Xr({prop:n,defaultProp:i??!1,onChange:c,caller:Np}),[m,h]=D.useState(null),[g,_]=D.useState(null),[v,y]=D.useState(null),b={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,userClick:v,onUserClick:y,required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,W.jsx)(Ip,{scope:t,...b,children:Kp(d)?d(b):r})}Mp(Rp,`SwitchProvider`);var zp=`SwitchTrigger`,Bp=D.forwardRef(Mp(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,onUserClick:f,isFormControl:p,bubbleInput:m}=Lp(zp,e),h=Hn(r,u),g=D.useRef(c);return D.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=Mp(()=>d(g.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,W.jsx)(G.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":qp(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:h,onClick:K(t,e=>{let t=e.isPropagationStopped();f({requestedChecked:!c,hasConsumerStoppedPropagation:t}),d(e=>!e),m&&p&&(t||e.stopPropagation())})})},`SwitchTrigger`)),Vp=D.forwardRef(Mp(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,W.jsx)(Rp,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Bp,{...d,ref:t,__scopeSwitch:n}),e&&(0,W.jsx)(Gp,{__scopeSwitch:n})]})})},`Switch`)),Hp=`SwitchThumb`,Up=D.forwardRef(Mp(function(e,t){let{__scopeSwitch:n,...r}=e,i=Lp(Hp,n);return(0,W.jsx)(G.span,{"data-state":qp(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})},`SwitchThumb`)),Wp=`SwitchBubbleInput`,Gp=D.forwardRef(Mp(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,userClick:a,checked:o,defaultChecked:s,required:c,disabled:l,name:u,value:d,form:f,bubbleInput:p,setBubbleInput:m}=Lp(Wp,e),h=Hn(r,m),g=zs(i),_=D.useRef(!1),v=D.useRef(o),y=D.useRef(a),b=D.useRef(null);D.useEffect(()=>{let e=p;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set;if(!n)return;let r=v.current!==o;v.current=o;let i=a!==null&&a!==y.current;if(y.current=a,i)b.current=r?null:a,r&&n.call(e,o),e.dispatchEvent(new Event(`click`,{bubbles:!a.hasConsumerStoppedPropagation}));else if(r){let t=b.current;b.current=null;let r=t?.requestedChecked===o;_.current=!0,n.call(e,o),e.dispatchEvent(new Event(`click`,{bubbles:!(r&&t.hasConsumerStoppedPropagation)})),_.current=!1}},[p,o,a]);let x=D.useRef(o);return(0,W.jsx)(G.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:s??x.current,required:c,disabled:l,name:u,value:d,form:f,...n,tabIndex:-1,ref:h,onClick:K(t,e=>{_.current&&e.stopPropagation()}),style:{...n.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function Kp(e){return typeof e==`function`}Mp(Kp,`isFunction`);function qp(e){return e?`checked`:`unchecked`}Mp(qp,`getState`);var Jp=Object.defineProperty,Yp=(e,t)=>Jp(e,`name`,{value:t,configurable:!0}),Xp={Automatic:`automatic`,Manual:`manual`},Zp=`Tabs`,[Qp,$p]=vr(Zp,[Ru]),em=Ru(),[tm,nm]=Qp(Zp),rm=D.forwardRef(Yp(function(e,t){let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=Xp.Automatic,...l}=e,u=yi(s),[d,f]=Xr({prop:r,onChange:i,defaultProp:a??``,caller:Zp});return(0,W.jsx)(tm,{scope:n,baseId:mi(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,W.jsx)(G.div,{dir:u,"data-orientation":o,...l,ref:t})})},`Tabs`)),im=`TabsList`,am=D.forwardRef(Yp(function(e,t){let{__scopeTabs:n,loop:r=!0,...i}=e,a=nm(im,n),o=em(n);return(0,W.jsx)(Uu,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,W.jsx)(G.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})},`TabsList`)),om=`TabsTrigger`,sm=D.forwardRef(Yp(function(e,t){let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=nm(om,n),s=em(n),c=cm(o.baseId,r),l=lm(o.baseId,r),u=r===o.value;return(0,W.jsx)(Ku,{asChild:!0,...s,focusable:!i,active:u,children:(0,W.jsx)(G.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:K(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?(e.currentTarget.focus(),o.onValueChange(r)):e.preventDefault()}),onKeyDown:K(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:K(e.onFocus,()=>{let e=o.activationMode!==Xp.Manual;!u&&!i&&e&&o.onValueChange(r)})})})},`TabsTrigger`));function cm(e,t){return`${e}-trigger-${t}`}Yp(cm,`makeTriggerId`);function lm(e,t){return`${e}-content-${t}`}Yp(lm,`makeContentId`);var um=Object.defineProperty,dm=(e,t)=>um(e,`name`,{value:t,configurable:!0}),fm=`Toggle`,pm=D.forwardRef(dm(function(e,t){let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=Xr({prop:n,onChange:i,defaultProp:r??!1,caller:fm});return(0,W.jsx)(G.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:K(e.onClick,()=>{e.disabled||s(!o)})})},`Toggle`)),mm=Object.defineProperty,hm=(e,t)=>mm(e,`name`,{value:t,configurable:!0}),[gm,_m]=vr(`Tooltip`,[au]),vm=au(),ym=`TooltipProvider`,bm=700,xm=`tooltip.open`,[Sm,Cm]=gm(ym),wm=hm(e=>{let{__scopeTooltip:t,delayDuration:n=bm,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=D.useRef(!0),s=D.useRef(!1),c=D.useRef(0);return D.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,W.jsx)(Sm,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:D.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:D.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:D.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),Tm=`Tooltip`,[Em,Dm]=gm(Tm),Om=hm(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Cm(Tm,e.__scopeTooltip),l=vm(t),[u,d]=D.useState(null),[f,p]=D.useState(void 0),m=mi(),h=D.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=D.useRef(!1),[y,b]=Xr({prop:r,defaultProp:i??!1,onChange:hm(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(xm))):c.onClose(),a?.(e)},`onChange`),caller:Tm}),x=D.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=D.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=D.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=D.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);D.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,W.jsx)(cu,{...l,children:(0,W.jsx)(Em,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:D.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:D.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),km=`TooltipTrigger`,Am=D.forwardRef(hm(function(e,t){let{__scopeTooltip:n,"aria-describedby":r,...i}=e,a=Dm(km,n),o=Cm(km,n),s=vm(n),c=Hn(t,D.useRef(null),a.onTriggerChange),l=D.useRef(!1),u=D.useRef(!1),d=D.useCallback(()=>l.current=!1,[]);return D.useEffect(()=>()=>document.removeEventListener(`pointerup`,d),[d]),(0,W.jsx)(uu,{asChild:!0,...s,children:(0,W.jsx)(G.button,{"aria-describedby":a.open?qm(r,a.contentId):r,"data-state":a.stateAttribute,...i,ref:c,onPointerMove:K(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:K(e.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:K(e.onPointerDown,()=>{a.open&&a.onClose(),l.current=!0,document.addEventListener(`pointerup`,d,{once:!0})}),onFocus:K(e.onFocus,()=>{l.current||a.onOpen()}),onBlur:K(e.onBlur,a.onClose),onClick:K(e.onClick,a.onClose)})})},`TooltipTrigger`)),jm=`TooltipPortal`,[Mm,Nm]=gm(jm,{forceMount:void 0}),Pm=hm(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Dm(jm,t);return(0,W.jsx)(Mm,{scope:t,forceMount:n,children:(0,W.jsx)(ii,{present:n||a.open,children:(0,W.jsx)(aa,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),Fm=`TooltipContent`,Im=D.forwardRef(hm(function(e,t){let n=Nm(Fm,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Dm(Fm,e.__scopeTooltip);return(0,W.jsx)(ii,{present:r||o.open,children:o.disableHoverableContent?(0,W.jsx)(zm,{side:i,...a,ref:t}):(0,W.jsx)(Lm,{side:i,...a,ref:t})})},`TooltipContent`)),Lm=D.forwardRef(hm(function(e,t){let n=Dm(Fm,e.__scopeTooltip),r=Cm(Fm,e.__scopeTooltip),i=D.useRef(null),a=Hn(t,i),[o,s]=D.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=D.useCallback(()=>{s(null),d(!1)},[d]),p=D.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Hm(r,Vm(r,n.getBoundingClientRect())),a=Um(t.getBoundingClientRect()),o=Gm([...i,...a]);s(o),d(!0)},[d]);return D.useEffect(()=>()=>f(),[f]),D.useEffect(()=>{if(c&&u){let e=hm(e=>p(e,u),`handleTriggerLeave`),t=hm(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),D.useEffect(()=>{if(o){let e=hm(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Wm(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,W.jsx)(zm,{...e,ref:a})},`TooltipContentHoverable`)),Rm=Yn(`TooltipContent`),zm=D.forwardRef(hm(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=Dm(Fm,n),u=vm(n),{onClose:d}=l,[f,p]=D.useState(null),m=Hn(t,p);qi(f),D.useEffect(()=>(document.addEventListener(xm,d),()=>document.removeEventListener(xm,d)),[d]),D.useEffect(()=>{if(l.trigger){let e=hm(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:h}=l;return br(()=>(h(a),()=>{h(void 0)}),[a,h]),(0,W.jsx)(ji,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,W.jsxs)(mu,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:m,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,W.jsx)(Rm,{children:r}),i?(0,W.jsx)(mr,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),Bm=D.forwardRef(hm(function(e,t){let{__scopeTooltip:n,...r}=e,i=vm(n);return(0,W.jsx)(_u,{...i,...r,ref:t})},`TooltipArrow`));function Vm(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}hm(Vm,`getExitSideFromRect`);function Hm(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}hm(Hm,`getPaddedExitPoints`);function Um(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}hm(Um,`getPointsFromRect`);function Wm(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}hm(Wm,`isPointInPolygon`);function Gm(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Km(t)}hm(Gm,`getHull`);function Km(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}hm(Km,`getHullPresorted`);function qm(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}hm(qm,`concatAriaDescribedby`);function Jm({...e}){return(0,W.jsx)(`nav`,{"aria-label":`breadcrumb`,"data-slot":`breadcrumb`,...e})}function Ym({className:e,...t}){return(0,W.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:U(`flex flex-wrap items-center gap-1.5 text-sm break-words text-muted-foreground sm:gap-2.5`,e),...t})}function Xm({className:e,...t}){return(0,W.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:U(`inline-flex items-center gap-1.5`,e),...t})}function Zm({asChild:e,className:t,...n}){let r=e?qn:`a`;return(0,W.jsx)(r,{"data-slot":`breadcrumb-link`,className:U(`transition-colors hover:text-foreground`,t),...n})}function Qm({className:e,...t}){return(0,W.jsx)(`span`,{"data-slot":`breadcrumb-page`,role:`link`,"aria-disabled":`true`,"aria-current":`page`,className:U(`font-normal text-foreground`,e),...t})}function $m({children:e,className:t,...n}){return(0,W.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:U(`[&>svg]:size-3.5`,t),...n,children:e??(0,W.jsx)(R,{})})}var eh={waiting:`is waiting for you`,bell:`rang the bell`,working:`is working`,idle:`is idle`},th={waiting:`bg-status-waiting`,bell:`bg-status-bell`,idle:`bg-status-idle`};function nh({marker:e,className:t}){return(0,W.jsx)(`span`,{className:U(`relative size-2 shrink-0 rounded-full`,th[e],t),children:e===`waiting`&&(0,W.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-status-waiting/70`})})}function rh({className:e,size:t=`default`,...n}){return(0,W.jsx)(As,{"data-slot":`avatar`,"data-size":t,className:U(`group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6`,e),...n})}function ih({className:e,...t}){return(0,W.jsx)(Ms,{"data-slot":`avatar-fallback`,className:U(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}function ah(e){let[t=``,n]=e.split(/[^\p{L}\p{N}]+/u).filter(Boolean);return n===void 0?t.slice(0,2).toUpperCase()||`?`:((t[0]??``)+(n[0]??``)).toUpperCase()}function oh(e){let t=0;for(let n of e)t=(t*31+(n.codePointAt(0)??0))%360;return t}function sh({workspace:e,size:t=`sm`,marker:n=null,className:r}){let i=oh(e.name),a=t===`md`;return(0,W.jsxs)(`span`,{className:U(`relative inline-flex shrink-0`,r),children:[(0,W.jsx)(rh,{"aria-hidden":`true`,className:a?`size-8 rounded-lg`:`size-5 rounded-md`,children:(0,W.jsx)(ih,{className:U(`rounded-[inherit] font-semibold tracking-tight`,a?`text-xs`:`text-[9px]`),style:{background:`oklch(0.36 0.07 ${i})`,color:`oklch(0.92 0.06 ${i})`},children:ah(e.name)})}),n&&(0,W.jsx)(`span`,{role:`img`,"aria-label":`${e.name} has a session that ${eh[n]}`,className:U(`absolute -top-0.5 -right-0.5 grid`,a?`size-2.5`:`size-2`),children:(0,W.jsx)(nh,{marker:n,className:`size-full ring-2 ring-sidebar`})}),e.missing&&(0,W.jsx)(`span`,{role:`img`,"aria-label":`${e.name} is Missing`,className:`absolute -right-1 -bottom-1 rounded-full bg-sidebar text-destructive`,children:(0,W.jsx)($e,{className:a?`size-3.5`:`size-3`})})]})}function ch({workspace:e,session:t}){return(0,W.jsx)(Jm,{className:`min-w-0 px-1`,children:(0,W.jsxs)(Ym,{className:`flex-nowrap gap-1.5 sm:gap-2`,children:[(0,W.jsxs)(Xm,{className:`min-w-0`,children:[(0,W.jsx)(sh,{workspace:e}),(0,W.jsx)(`h1`,{className:`truncate text-sm font-medium text-foreground`,title:e.folder,children:e.name})]}),t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)($m,{}),(0,W.jsxs)(Xm,{className:`min-w-0`,children:[(0,W.jsx)(Ln,{session:t,className:`size-3.5`}),(0,W.jsx)(Qm,{className:`truncate text-sm text-muted-foreground`,children:t.name})]})]})]})})}var lh=`(max-width: 767px)`;function uh(){return(0,D.useSyncExternalStore)(e=>{let t=window.matchMedia(lh);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(lh).matches)}var dh=`k-bench.smart-typing`;function fh(){try{let e=JSON.parse(localStorage.getItem(dh)??`[]`);return new Set(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])}catch{return new Set}}function ph(e){try{e.size===0?localStorage.removeItem(dh):localStorage.setItem(dh,JSON.stringify([...e]))}catch{}}var mh=fh(),hh=new Set;function gh(e){mh=e,ph(mh);for(let e of hh)e()}function _h(e){return hh.add(e),()=>hh.delete(e)}function vh(e){return(0,D.useSyncExternalStore)(_h,()=>!mh.has(e))}function yh(e,t){if(mh.has(e)===!t)return;let n=new Set(mh);t?n.delete(e):n.add(e),gh(n)}function bh(e){let t=new Set([...mh].filter(t=>e.has(t)));t.size!==mh.size&&gh(t)}function xh(){return/iPhone/.test(navigator.userAgent)}function Sh(){return uh()&&xh()}var Ch=null;function wh(e){return Ch=e,()=>{Ch===e&&(Ch=null)}}function Th(){Ch?.blur()}var Eh={esc:`\x1B`,tab:` `,shiftTab:`\x1B[Z`,enter:`\r`,left:`\x1B[D`,up:`\x1B[A`,down:`\x1B[B`,right:`\x1B[C`};function Dh(e){Ch?.send(e),Ch?.clearTypedLine()}function Oh(){return typeof navigator<`u`&&typeof navigator.clipboard?.readText==`function`}async function kh(){if(!Oh())return;let e;try{e=await navigator.clipboard.readText()}catch{return}e&&(Mh(!1),Ch?.paste(e),Ch?.clearTypedLine())}var Ah=!1,jh=new Set;function Mh(e){if(Ah!==e){Ah=e;for(let e of jh)e()}}function Nh(){return(0,D.useSyncExternalStore)(e=>(jh.add(e),()=>jh.delete(e)),()=>Ah)}function Ph(){return Ah}function Fh(){Ch?.clearTypedLine(),Mh(!Ah)}var Ih={" ":`\0`,"@":`\0`,"[":`\x1B`,"\\":``,"]":``,"^":``,_:``,"?":``};function Lh(e){return e.length===1?/^[a-z]$/i.test(e)?String.fromCharCode(e.toLowerCase().charCodeAt(0)-96):Ih[e]??e:e}function Rh(e){return Ah?(Mh(!1),Lh(e)):e}var zh=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Bh=it,Vh=(e,t)=>n=>{if(t?.variants==null)return Bh(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=zh(t)||zh(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Bh(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},Hh=Vh(`inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function Uh({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?qn:`button`;return(0,W.jsx)(a,{"data-slot":`button`,"data-variant":t,"data-size":n,className:U(Hh({variant:t,size:n,className:e})),...i})}function Wh({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,W.jsx)(kp,{"data-slot":`separator`,decorative:n,orientation:t,className:U(`shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}var Gh=Vh(`flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none`,vertical:`flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none`}},defaultVariants:{orientation:`horizontal`}});function Kh({className:e,orientation:t,...n}){return(0,W.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:U(Gh({orientation:t}),e),...n})}var qh=Vh(`inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground`},size:{default:`h-9 min-w-9 px-2`,sm:`h-8 min-w-8 px-1.5`,lg:`h-10 min-w-10 px-2.5`}},defaultVariants:{variant:`default`,size:`default`}});function Jh({className:e,variant:t,size:n,...r}){return(0,W.jsx)(pm,{"data-slot":`toggle`,className:U(qh({variant:t,size:n,className:e})),...r})}var Yh=e=>e.preventDefault(),Xh=`h-10 min-w-0 px-0`,Zh=U(Xh,`data-[state=on]:border-primary data-[state=on]:bg-primary data-[state=on]:text-primary-foreground`);function Qh({name:e,data:t,children:n}){return(0,W.jsx)(Uh,{variant:`outline`,"aria-label":e,className:Xh,onMouseDown:Yh,onClick:()=>Dh(t),children:n})}function $h({sessionId:e}){let t=Nh(),n=Sh(),r=vh(e);return(0,W.jsxs)(Kh,{"aria-label":`Extra keys`,className:`grid w-full shrink-0 auto-cols-fr grid-flow-col border-t bg-sidebar p-1`,children:[(0,W.jsx)(Qh,{name:`Esc`,data:Eh.esc,children:`⎋`}),(0,W.jsx)(Qh,{name:`Tab`,data:Eh.tab,children:`⇥`}),(0,W.jsx)(Qh,{name:`Shift Tab`,data:Eh.shiftTab,children:`⇤`}),(0,W.jsx)(Jh,{variant:`outline`,pressed:t,className:Zh,onMouseDown:Yh,onPressedChange:Fh,children:`Ctrl`}),(0,W.jsx)(Qh,{name:`Left`,data:Eh.left,children:(0,W.jsx)(F,{})}),(0,W.jsx)(Qh,{name:`Up`,data:Eh.up,children:(0,W.jsx)(ne,{})}),(0,W.jsx)(Qh,{name:`Down`,data:Eh.down,children:(0,W.jsx)(N,{})}),(0,W.jsx)(Qh,{name:`Right`,data:Eh.right,children:(0,W.jsx)(ee,{})}),(0,W.jsx)(Qh,{name:`Enter`,data:Eh.enter,children:`⏎`}),n&&(0,W.jsx)(Jh,{variant:`outline`,"aria-label":`Smart typing`,pressed:r,className:Zh,onMouseDown:Yh,onPressedChange:t=>yh(e,t),children:(0,W.jsx)(Ge,{})})]})}var eg=Vh(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function tg({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?qn:`span`;return(0,W.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:U(eg({variant:t}),e),...r})}function ng(e){let t=document.activeElement;t&&t!==document.body&&e.preventDefault()}function rg({...e}){return(0,W.jsx)(Lo,{"data-slot":`sheet`,...e})}function ig({...e}){return(0,W.jsx)(zo,{"data-slot":`sheet-trigger`,...e})}function ag({...e}){return(0,W.jsx)(Uo,{"data-slot":`sheet-portal`,...e})}function og({className:e,...t}){return(0,W.jsx)(Go,{"data-slot":`sheet-overlay`,className:U(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function sg({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,W.jsxs)(ag,{children:[(0,W.jsx)(og,{}),(0,W.jsxs)(Yo,{"data-slot":`sheet-content`,onCloseAutoFocus:ng,className:U(`fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,e),...i,children:[t,r&&(0,W.jsxs)(ns,{className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,W.jsx)(tt,{className:`size-4`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function cg({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`sheet-header`,className:U(`flex flex-col gap-1.5 p-4`,e),...t})}function lg({className:e,...t}){return(0,W.jsx)($o,{"data-slot":`sheet-title`,className:U(`font-semibold text-foreground`,e),...t})}function ug({className:e,...t}){return(0,W.jsx)(es,{"data-slot":`sheet-description`,className:U(`text-sm text-muted-foreground`,e),...t})}function dg(e){let t=e.find(e=>e.role===`prime`),n=e.find(e=>e.role===`worker`);return{prime:t,worker:n,primeAndWorker:[t,n].filter(e=>e!==void 0),others:e.filter(e=>e.role===null)}}function fg(e){return e.status===`stopped`?null:e.activity===`waiting`?`waiting`:e.bell?`bell`:e.activity}function pg(e){return e?.workspaces.find(t=>t.id===e.openWorkspaceId)}function mg(e){return e.some(e=>fg(e)===`waiting`)?`waiting`:e.some(e=>e.bell)?`bell`:null}function hg(e){return mg(e.sessions)}function gg({className:e,...t}){return(0,W.jsx)(Te,{role:`status`,"aria-label":`Loading`,className:U(`size-4 animate-spin`,e),...t})}function _g({session:e,className:t}){let n=fg(e);if(!n)return null;let r=`${e.name} ${eh[n]}`;return(0,W.jsx)(`span`,{role:`img`,"aria-label":r,title:r,className:U(`relative grid size-3.5 shrink-0 place-items-center`,t),children:n===`working`?(0,W.jsx)(gg,{"aria-hidden":`true`,className:`size-3.5 text-primary`}):(0,W.jsx)(nh,{marker:n})})}var vg=`/api/events`;function yg(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t==`object`&&t&&typeof t.revision==`number`&&Array.isArray(t.workspaces))return t}function bg(e){return Number(e.get(`State-Revision`)??NaN)}var xg=class extends Error{status;body;constructor(e,t,n={}){super(e),this.status=t,this.body=n}get folderOwner(){let e=this.body.workspace;return this.status===409&&typeof e?.id==`string`&&typeof e.name==`string`?{id:e.id,name:e.name}:void 0}};async function Sg(e,t){let n=await fetch(e,t),r=await n.json().catch(()=>({}));if(!n.ok)throw new xg(typeof r.error==`string`?r.error:`Request failed (${n.status})`,n.status,r);return{value:r,revision:bg(n.headers)}}async function Cg(e){return(await Sg(e)).value}function wg(e,t,n){return Sg(t,{method:e,headers:n===void 0?void 0:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)})}var Tg={listDirectories:(e,{hidden:t=!1}={})=>{let n=new URLSearchParams;return e!==void 0&&n.set(`path`,e),t&&n.set(`hidden`,`1`),Cg(`/api/directories?${n}`)},createWorkspace:e=>wg(`POST`,`/api/workspaces`,e),updateWorkspace:(e,t)=>wg(`PATCH`,`/api/workspaces/${e}`,t),reorderWorkspaces:e=>wg(`PUT`,`/api/workspaces/order`,{ids:e}),openWorkspace:(e,t={})=>wg(`POST`,`/api/workspaces/${e}/open`,t),setRightPane:(e,t)=>wg(`PUT`,`/api/workspaces/${e}/right-pane`,t),deleteWorkspace:e=>wg(`DELETE`,`/api/workspaces/${e}`),lastLaunchOptions:()=>Cg(`/api/claude/launch-options`),createSession:(e,t={})=>wg(`POST`,`/api/workspaces/${e}/sessions`,t),renameSession:(e,t)=>wg(`PATCH`,`/api/sessions/${e}`,{name:t}),deleteSession:e=>wg(`DELETE`,`/api/sessions/${e}`),reorderSessions:(e,t)=>wg(`PUT`,`/api/workspaces/${e}/sessions/order`,{ids:t}),restartSession:e=>wg(`POST`,`/api/sessions/${e}/restart`,{})},Eg=500,Dg=1e4,Og=5e3;function kg(e){let{openSocket:t,showTimeoutMs:n=Og}=e,r=new Set,i=new Set,a,o,s,c=Eg,l=!1,u=0,d,f=()=>{clearTimeout(s),o&&=(o.onopen=null,o.onmessage=null,o.onclose=null,o.close(),void 0)},p=()=>{if(l)return;f();let e=++u;d=void 0;let n=t();o=n,n.onopen=()=>{c=Eg},n.onmessage=t=>{if(typeof t.data!=`string`)return;let n=yg(t.data);if(!n)return;let{revision:o,...s}=n;a=s,d=o;for(let e of r)e(s);for(let t of[...i])(t.connection<e||o>=t.revision)&&t.done(!0)},n.onclose=()=>{d=void 0,s=setTimeout(p,c),c=Math.min(c*2,Dg)}};return p(),{get state(){return a},subscribe(e){return r.add(e),a&&e(a),()=>{r.delete(e)}},whenShown({revision:e}){return l?Promise.resolve(!1):(d??-1)>=e?Promise.resolve(!0):new Promise(t=>{let r=setTimeout(()=>a.done(!1),n),a={revision:e,connection:u,done:e=>{clearTimeout(r),i.delete(a),t(e)}};i.add(a)})},resync:p,close(){l=!0,f(),r.clear();for(let e of[...i])e.done(!1)}}}function Ag(){let e=new URL(vg,window.location.href);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.toString()}function jg(e,t){return!e||t.length===0?e:{...e,workspaces:e.workspaces.map(e=>({...e,rightPane:t.reduce((t,n)=>n.workspaceId===e.id?n.change(t):t,e.rightPane)}))}}function Mg(){let[e,t]=(0,D.useState)(),[n,r]=(0,D.useState)([]),[i,a]=(0,D.useState)(),o=(0,D.useRef)(void 0);(0,D.useEffect)(()=>{let e=kg({openSocket:()=>new WebSocket(Ag())});o.current=e;let n=e.subscribe(t),r=()=>e.resync();return window.addEventListener(`focus`,r),()=>{window.removeEventListener(`focus`,r),n(),e.close(),o.current=void 0}},[]);let s=(0,D.useMemo)(()=>{let e=e=>o.current?.whenShown(e)??Promise.resolve(!1),n=async t=>{await e(await t)},i=async(e,t,n)=>{let i={workspaceId:e,change:t};r(e=>[...e,i]);try{await n()}finally{r(e=>e.filter(e=>e!==i))}},s=async e=>{a(void 0);try{return await e()}catch(e){if(!(e instanceof xg))throw e;a(e.message);return}};return{createWorkspace:async(e,t)=>{try{await n(Tg.createWorkspace(e))}catch(e){if(!(e instanceof xg)||!e.folderOwner)throw e;t(e.folderOwner.id),a(e.message)}},updateWorkspace:(e,t)=>n(Tg.updateWorkspace(e,t)),reorderWorkspaces:e=>(t(t=>t&&{...t,workspaces:e.flatMap(e=>t.workspaces.find(t=>t.id===e)??[])}),n(Tg.reorderWorkspaces(e)).catch(()=>o.current?.resync())),openWorkspace:async(e,t={})=>{let r=()=>s(()=>n(Tg.openWorkspace(e,t)));t.showWorker?await i(e,e=>({...e,shown:null}),r):await r()},setRightPane:(e,t)=>i(e,()=>t,()=>n(Tg.setRightPane(e,t)).catch(()=>o.current?.resync())),deleteWorkspace:e=>n(Tg.deleteWorkspace(e)),createSession:t=>s(async()=>{let n=await Tg.createSession(t);return await e(n)?n.value.id:void 0}),createClaudeSession:async(t,n)=>{let r=await Tg.createSession(t,n);return await e(r)?r.value.id:void 0},renameSession:(e,t)=>n(Tg.renameSession(e,t)),deleteSession:e=>n(Tg.deleteSession(e)),restartSession:async e=>{await s(()=>n(Tg.restartSession(e)))},reorderSessions:(e,r)=>(t(t=>t&&{...t,workspaces:t.workspaces.map(t=>t.id===e?{...t,sessions:[...dg(t.sessions).primeAndWorker,...r.flatMap(e=>t.sessions.find(t=>t.id===e)??[])]}:t)}),n(Tg.reorderSessions(e,r)).catch(()=>o.current?.resync()))}},[]);return{state:(0,D.useMemo)(()=>jg(e,n),[e,n]),actions:s,error:i}}var Ng=(0,D.createContext)(void 0),Pg=Ng.Provider;function Fg(){let e=(0,D.useContext)(Ng);if(!e)throw Error(`useActions needs an ActionsProvider above it`);return e}var Ig=`#161616`,Lg={background:Ig,foreground:`#e4e4e4`,cursor:`#e4e4e4`,cursorAccent:Ig,selectionBackground:`#3a3a3a`,black:`#2a2a2a`,red:`#ff6369`,green:`#62c073`,yellow:`#f3c15f`,blue:`#52a8ff`,magenta:`#bf7af0`,cyan:`#4fc3c7`,white:`#d0d0d0`,brightBlack:`#6b6b6b`,brightRed:`#ff8a8e`,brightGreen:`#85d897`,brightYellow:`#ffd88a`,brightBlue:`#7cbcff`,brightMagenta:`#d29ff6`,brightCyan:`#7ad9dc`,brightWhite:`#ffffff`},Rg=`"JetBrains Mono"`,zg=`${Rg}, ui-monospace, Menlo, monospace`,Bg=4.5;async function Vg(){try{await Promise.all([document.fonts.load(`400 13px ${Rg}`),document.fonts.load(`700 13px ${Rg}`)])}catch{}}function Hg(e){return e.slice(e.lastIndexOf(`/`)+1)}function Ug(e){return e.slice(0,e.lastIndexOf(`/`))||`/`}function Wg(e,...t){return t.reduce((e,t)=>e===`/`?`/${t}`:`${e}/${t}`,e)}function Gg({base:e,newFolders:t}){return Wg(e,...t)}function Kg(e){if(e===``)return`Type a name`;if(e.includes(`/`))return`A folder name can't contain /`;if(e===`.`||e===`..`)return`Not a folder name`}function qg(e,t){return e===t?`~`:e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function Jg(e,t){let n=e.trim(),[r,i]=n===`~`?[t,``]:n.startsWith(`~/`)?[t,n.slice(2)]:n.startsWith(`/`)?[`/`,n]:[t,n];return i.split(`/`).reduce((e,t)=>t===``||t===`.`?e:t===`..`?Ug(e):Wg(e,t),r)}function Yg(e,t){let n=e.lastIndexOf(`/`);if(n<0){let n=e.trim()===`~`;return{head:n?`~/`:``,parent:t,partial:n?``:e}}let r=e.slice(0,n+1);return{head:r,parent:Jg(r,t),partial:e.slice(n+1)}}function Xg(e,t){return e===t||e.startsWith(t===`/`?`/`:`${t}/`)}var Zg=5;function Qg(e,t){let n=new Map;for(let r of e){let e=Ug(r.folder);if(e===t||e===`/`)continue;let i=n.get(e)??{count:0,newest:-1/0};n.set(e,{count:i.count+1,newest:Math.max(i.newest,r.createdAt)})}let r=[...n.entries()].sort(([,e],[,t])=>t.count-e.count||t.newest-e.newest).slice(0,Zg).map(([e])=>({kind:`workspaces`,label:Hg(e),path:e}));return[{kind:`home`,label:`Home`,path:t},...r,{kind:`computer`,label:`Computer`,path:`/`}]}function $g(e,t){let n=Xg(e,t)?{label:`~`,path:t}:{label:`/`,path:`/`},r=[n];for(let t of e.slice(n.path.length).split(`/`).filter(Boolean)){let e=r.at(-1)?.path??n.path;r.push({label:t,path:e===`/`?`/${t}`:`${e}/${t}`})}return r}var e_=1,t_=.9,n_=.8,r_=.17,i_=.1,a_=.999,o_=.9999,s_=.99,c_=/[\\\/_+.#"@\[\(\{&]/,l_=/[\\\/_+.#"@\[\(\{&]/g,u_=/[\s-]/,d_=/[\s-]/g;function f_(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?e_:s_;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=f_(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=e_:c_.test(e.charAt(l-1))?(d*=n_,p=e.slice(i,l-1).match(l_),p&&i>0&&(d*=a_**+p.length)):u_.test(e.charAt(l-1))?(d*=t_,m=e.slice(i,l-1).match(d_),m&&i>0&&(d*=a_**+m.length)):(d*=r_,i>0&&(d*=a_**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=o_)),(d<i_&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=f_(e,t,n,r,l+1,a+2,o),f*i_>d&&(d=f*i_)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function p_(e){return e.toLowerCase().replace(d_,` `)}function m_(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,f_(e,t,p_(e),p_(t),0,0,{})}var h_=`[cmdk-group=""]`,g_=`[cmdk-group-items=""]`,__=`[cmdk-group-heading=""]`,v_=`[cmdk-item=""]`,y_=`${v_}:not([aria-disabled="true"])`,b_=`cmdk-item-select`,x_=`data-value`,S_=(e,t,n)=>m_(e,t,n),C_=D.createContext(void 0),w_=()=>D.useContext(C_),T_=D.createContext(void 0),E_=()=>D.useContext(T_),D_=D.createContext(void 0),O_=D.forwardRef((e,t)=>{let n=H_(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=H_(()=>new Set),i=H_(()=>new Map),a=H_(()=>new Map),o=H_(()=>new Set),s=B_(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=mi(),y=mi(),b=mi(),x=D.useRef(null),S=G_();V_(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),V_(()=>{S(6,A)},[]);let C=D.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),E(),S(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=j()?.id,C.emit()}),r||S(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=D.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{k(),E(),n.current.value||O(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();S(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??S_;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(g_);t?t.appendChild(e.parentElement===t?e:e.closest(`${g_} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${g_} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${h_}[${x_}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(x_);C.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(h_)?.querySelector(__))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return x.current?.querySelector(`${v_}[aria-selected="true"]`)}function M(){return Array.from(x.current?.querySelectorAll(y_)||[])}function N(e){let t=M()[e];t&&C.setState(`value`,t.getAttribute(x_))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(x_))}function F(e){let t=j()?.closest(h_),n;for(;t&&!n;)t=e>0?R_(t,h_):z_(t,h_),n=t?.querySelector(y_);n?C.setState(`value`,n.getAttribute(x_)):P(e)}let I=()=>N(M().length-1),ee=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},te=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return D.createElement(G.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ee(e);break;case`ArrowDown`:ee(e);break;case`p`:case`k`:g&&e.ctrlKey&&te(e);break;case`ArrowUp`:te(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(b_);t.dispatchEvent(e)}}}}},D.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:J_},c),q_(e,e=>D.createElement(T_.Provider,{value:C},D.createElement(C_.Provider,{value:w},e))))}),k_=D.forwardRef((e,t)=>{let n=mi(),r=D.useRef(null),i=D.useContext(D_),a=w_(),o=B_(e),s=o.current?.forceMount??i?.forceMount;V_(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=W_(n,r,[e.value,e.children,r],e.keywords),l=E_(),u=U_(e=>e.value&&e.value===c.current),d=U_(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);D.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(b_,f),()=>t.removeEventListener(b_,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return D.createElement(G.div,{ref:Vn(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),A_=D.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=mi(),s=D.useRef(null),c=D.useRef(null),l=mi(),u=w_(),d=U_(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));V_(()=>u.group(o),[]),W_(o,s,[e.value,e.heading,c]);let f=D.useMemo(()=>({id:o,forceMount:i}),[i]);return D.createElement(G.div,{ref:Vn(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&D.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),q_(e,e=>D.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},D.createElement(D_.Provider,{value:f},e))))}),j_=D.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=D.useRef(null),a=U_(e=>!e.search);return!n&&!a?null:D.createElement(G.div,{ref:Vn(i,t),...r,"cmdk-separator":``,role:`separator`})}),M_=D.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=E_(),o=U_(e=>e.search),s=U_(e=>e.selectedItemId),c=w_();return D.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),D.createElement(G.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),N_=D.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=D.useRef(null),o=D.useRef(null),s=U_(e=>e.selectedItemId),c=w_();return D.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),D.createElement(G.div,{ref:Vn(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},q_(e,e=>D.createElement(`div`,{ref:Vn(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),P_=D.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return D.createElement(Lo,{open:n,onOpenChange:r},D.createElement(Uo,{container:o},D.createElement(Go,{"cmdk-overlay":``,className:i}),D.createElement(Yo,{"aria-label":e.label,"cmdk-dialog":``,className:a},D.createElement(O_,{ref:t,...s}))))}),F_=D.forwardRef((e,t)=>U_(e=>e.filtered.count===0)?D.createElement(G.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),I_=D.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return D.createElement(G.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},q_(e,e=>D.createElement(`div`,{"aria-hidden":!0},e)))}),L_=Object.assign(O_,{List:N_,Item:k_,Input:M_,Group:A_,Separator:j_,Dialog:P_,Empty:F_,Loading:I_});function R_(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function z_(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function B_(e){let t=D.useRef(e);return V_(()=>{t.current=e}),t}var V_=typeof window>`u`?D.useEffect:D.useLayoutEffect;function H_(e){let t=D.useRef();return t.current===void 0&&(t.current=e()),t}function U_(e){let t=E_(),n=()=>e(t.snapshot());return D.useSyncExternalStore(t.subscribe,n,n)}function W_(e,t,n,r=[]){let i=D.useRef(),a=w_();return V_(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(x_,s),i.current=s}),i}var G_=()=>{let[e,t]=D.useState(),n=H_(()=>new Map);return V_(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function K_(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function q_({asChild:e,children:t},n){return e&&D.isValidElement(t)?D.cloneElement(K_(t),{ref:t.ref},n(t.props.children)):n(t)}var J_={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Y_({...e}){return(0,W.jsx)(Lo,{"data-slot":`dialog`,...e})}function X_({...e}){return(0,W.jsx)(zo,{"data-slot":`dialog-trigger`,...e})}function Z_({...e}){return(0,W.jsx)(Uo,{"data-slot":`dialog-portal`,...e})}function Q_({className:e,...t}){return(0,W.jsx)(Go,{"data-slot":`dialog-overlay`,className:U(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function $_({className:e,children:t,showCloseButton:n=!0,...r}){return(0,W.jsxs)(Z_,{"data-slot":`dialog-portal`,children:[(0,W.jsx)(Q_,{}),(0,W.jsxs)(Yo,{"data-slot":`dialog-content`,onCloseAutoFocus:ng,className:U(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,W.jsxs)(ns,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,W.jsx)(tt,{}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function ev({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`dialog-header`,className:U(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function tv({className:e,showCloseButton:t=!1,children:n,...r}){return(0,W.jsxs)(`div`,{"data-slot":`dialog-footer`,className:U(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,W.jsx)(ns,{asChild:!0,children:(0,W.jsx)(Uh,{variant:`outline`,children:`Close`})})]})}function nv({className:e,...t}){return(0,W.jsx)($o,{"data-slot":`dialog-title`,className:U(`text-lg leading-none font-semibold`,e),...t})}function rv({className:e,...t}){return(0,W.jsx)(es,{"data-slot":`dialog-description`,className:U(`text-sm text-muted-foreground`,e),...t})}function iv({className:e,...t}){return(0,W.jsx)(L_,{"data-slot":`command`,className:U(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function av({className:e,...t}){return(0,W.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,W.jsx)(Ve,{className:`size-4 shrink-0 opacity-50`}),(0,W.jsx)(L_.Input,{"data-slot":`command-input`,className:U(`flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function ov({className:e,...t}){return(0,W.jsx)(L_.List,{"data-slot":`command-list`,className:U(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t})}function sv({className:e,...t}){return(0,W.jsx)(L_.Group,{"data-slot":`command-group`,className:U(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function cv({className:e,...t}){return(0,W.jsx)(L_.Item,{"data-slot":`command-item`,className:U(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function lv({className:e,type:t,...n}){return(0,W.jsx)(`input`,{type:t,"data-slot":`input`,className:U(`h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40`,e),...n})}var uv=`max-h-[92dvh] overflow-y-auto md:max-w-3xl max-md:top-0 max-md:left-0 max-md:flex max-md:h-dvh max-md:max-h-none max-md:max-w-none max-md:translate-none max-md:flex-col max-md:rounded-none max-md:border-0 max-md:p-4`;function dv(e,{climb:t=!1,hidden:n=!1}={}){let[r,i]=(0,D.useState)(),[a,o]=(0,D.useState)();return(0,D.useEffect)(()=>{i(void 0),o(void 0);let r=!0,a=e=>Tg.listDirectories(e,{hidden:n}).catch(n=>{if(t&&e!==void 0&&e!==`/`)return a(Ug(e));throw n});return a(e).then(e=>r&&i(e),e=>r&&o(e instanceof Error?e.message:String(e))),()=>{r=!1}},[e,t,n]),{listing:r,error:a}}async function fv(e){let t=[];for(let n=e;;n=Ug(n))try{return{base:(await Tg.listDirectories(n)).path,newFolders:t}}catch(e){if(n===`/`)throw e;t.unshift(Hg(n))}}function pv(e,t){let n=(0,D.useRef)(t);n.current=t,(0,D.useEffect)(()=>{let t=t=>{t.key===`Escape`&&t.target===e.current&&(t.stopPropagation(),n.current())};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e])}function mv({workspaces:e,start:t,onChange:n}){let[r,i]=(0,D.useState)(t),[a,o]=(0,D.useState)(t!==void 0),[s,c]=(0,D.useState)([]),[l,u]=(0,D.useState)(!1),[d,f]=(0,D.useState)(``),[p,m]=(0,D.useState)(!1),{listing:h,error:g}=dv(r,{climb:a}),[_,v]=(0,D.useState)(),y=r===void 0||a?h?.path:r;(0,D.useEffect)(()=>{h?.root&&v(h.root)},[h]);let b=(0,D.useRef)(n);b.current=n,(0,D.useEffect)(()=>{b.current(y===void 0?void 0:{base:y,newFolders:s},l)},[y,s,l]);let x=e=>{(e.base!==y||a)&&(i(e.base),o(!1)),c(e.newFolders),u(!0),f(``),m(!1)},S=e=>x({base:e,newFolders:[]}),C=e=>{if(y===void 0)return;let t=s.length===0?h?.directories.find(t=>t.name.toLowerCase()===e.toLowerCase()):void 0;t?S(t.path):x({base:y,newFolders:[...s,e]})};if(g&&!y)return(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:g});if(!y||!_)return(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`});let w=s.at(-1);return(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 md:grid md:grid-cols-[10rem_1fr]`,children:[(0,W.jsx)(_v,{places:Qg(e,_),root:_,here:w===void 0?y:void 0,onGo:S}),(0,W.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.jsx)(vv,{choice:{base:y,newFolders:s},root:_,onChoose:x})}),(0,W.jsxs)(Uh,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(!0),children:[(0,W.jsx)(_e,{}),`New folder`]})]}),p&&(0,W.jsx)(wv,{onAdd:C,onCancel:()=>m(!1)}),w===void 0?(0,W.jsx)(Cv,{listing:h,error:g,filter:d,onFilter:f,workspaces:e,onGo:S}):(0,W.jsx)(Sv,{name:w}),(0,W.jsx)(xv,{choice:{base:y,newFolders:s},root:_})]})]})}var hv=`bg-transparent [&:not(:focus-within):not(:hover)_[data-selected=true]:not([aria-current])]:bg-transparent`,gv={home:Ce,workspaces:ye,computer:ke};function _v({places:e,root:t,here:n,onGo:r}){return(0,W.jsx)(iv,{tabIndex:0,vimBindings:!1,className:U(hv,`h-auto shrink-0 outline-none md:rounded-none md:border-r md:pr-2`),children:(0,W.jsx)(ov,{label:`Places`,className:`max-h-none overflow-x-auto overflow-y-hidden`,children:(0,W.jsx)(sv,{heading:`Places`,className:`overflow-visible p-0 max-md:[&_[cmdk-group-heading]]:hidden [&_[cmdk-group-items]]:flex [&_[cmdk-group-items]]:gap-1 md:[&_[cmdk-group-items]]:flex-col`,children:e.map(e=>{let i=gv[e.kind];return(0,W.jsxs)(cv,{value:e.path,title:qg(e.path,t),"aria-current":n===e.path?`location`:void 0,onSelect:()=>r(e.path),className:`shrink-0 rounded-full border px-3 py-1 aria-[current=location]:bg-accent aria-[current=location]:font-medium md:rounded-sm md:border-transparent md:px-2`,children:[(0,W.jsx)(i,{}),(0,W.jsx)(`span`,{className:`truncate`,children:e.label})]},e.path)})})})})}function vv({choice:e,root:t,onChoose:n}){let[r,i]=(0,D.useState)(!1),a=(0,D.useRef)(null),o=(0,D.useRef)(!1),s=e=>{o.current=e,i(!1)};return(0,D.useEffect)(()=>{!r&&o.current&&(o.current=!1,a.current?.focus())},[r]),r?(0,W.jsx)(yv,{choice:e,root:t,onChoose:e=>{s(!0),n(e)},onEscape:()=>s(!0),onCancel:()=>s(!1)}):(0,W.jsxs)(`div`,{className:`flex min-h-8 items-center rounded-md border px-1`,children:[(0,W.jsx)(bv,{choice:e,root:t,onGo:e=>n({base:e,newFolders:[]}),onTrim:t=>n({base:e.base,newFolders:e.newFolders.slice(0,t)})}),(0,W.jsx)(`button`,{ref:a,type:`button`,"aria-label":`Type a path`,title:`Type a path`,onClick:()=>i(!0),className:`flex min-h-7 min-w-8 flex-1 items-center justify-end self-stretch rounded-sm px-1 text-muted-foreground hover:bg-accent`,children:(0,W.jsx)(Ye,{className:`size-4`})})]})}function yv({choice:e,root:t,onChoose:n,onEscape:r,onCancel:i}){let[a,o]=(0,D.useState)(()=>{let n=qg(Gg(e),t);return n.endsWith(`/`)?n:`${n}/`}),[s,c]=(0,D.useState)(),[l,u]=(0,D.useState)(),[d,f]=(0,D.useState)(!1),p=(0,D.useRef)(null),m=(0,D.useId)(),h=(0,D.useId)();pv(p,r);let{head:g,parent:_,partial:v}=Yg(a,t),{listing:y}=dv(_,{hidden:v.startsWith(`.`)}),b=v.toLowerCase(),x=e=>Number(!e.toLowerCase().startsWith(b)),S=(y?.directories??[]).filter(e=>e.name.toLowerCase().includes(b)).sort((e,t)=>x(e.name)-x(t.name)),C=s??0,w=e=>{o(e),c(void 0),u(void 0),f(!1)};if(d&&y!==void 0){let e=S[0];e?w(`${g}${e.name}/`):f(!1)}let T=e=>{w(`${g}${e}/`),p.current?.focus()},E=e=>{fv(e).then(n,e=>u(e instanceof Error?e.message:String(e)))};return(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(lv,{ref:p,autoFocus:!0,role:`combobox`,"aria-label":`Folder path`,"aria-autocomplete":`list`,"aria-expanded":S.length>0,"aria-controls":S.length>0?m:void 0,"aria-activedescendant":s===void 0?void 0:`${m}-${s}`,"aria-invalid":l!==void 0,"aria-describedby":l===void 0?void 0:h,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`~/projects/new-app`,className:`h-8 font-mono text-sm`,value:a,onFocus:e=>e.target.select(),onBlur:i,onChange:e=>w(e.target.value),onKeyDown:e=>{let n=S.length;if(e.key===`Enter`){e.preventDefault();let n=s===void 0?void 0:S[s];E(n?Wg(_,n.name):Jg(a,t))}else if(e.key===`Tab`&&!e.shiftKey){e.preventDefault();let t=S[C];t?T(t.name):y===void 0&&f(!0)}else e.key===`ArrowDown`&&n>0?(e.preventDefault(),c(e=>e===void 0?0:(e+1)%n)):e.key===`ArrowUp`&&n>0&&(e.preventDefault(),c(e=>e===void 0?n-1:(e-1+n)%n))}}),S.length>0&&(0,W.jsx)(`div`,{id:m,role:`listbox`,"aria-label":`Suggestions`,className:`absolute top-full z-10 mt-1 max-h-60 w-full overflow-y-auto rounded-md border bg-popover p-1 shadow-md`,children:S.map((e,t)=>(0,W.jsxs)(`div`,{id:`${m}-${t}`,role:`option`,tabIndex:-1,"aria-selected":t===s,onMouseDown:e=>e.preventDefault(),onClick:()=>T(e.name),className:U(`flex cursor-default items-center gap-2 rounded-sm px-2 py-1 text-sm`,t===s?`bg-accent`:`hover:bg-accent`,e.name.startsWith(`.`)&&`text-muted-foreground`),children:[(0,W.jsx)(ye,{className:`size-4 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e.name}),t===C&&(0,W.jsx)(`kbd`,{"aria-hidden":!0,className:`rounded border px-1 text-[10px] text-muted-foreground`,children:`Tab`})]},e.path))})]}),l&&(0,W.jsx)(`p`,{id:h,role:`alert`,className:`text-xs text-destructive`,children:l})]})}function bv({choice:e,root:t,onGo:n,onTrim:r}){let i=[...$g(e.base,t).map(e=>({...e,isNew:!1,go:()=>n(e.path)})),...e.newFolders.map((t,n)=>({label:t,path:Wg(e.base,...e.newFolders.slice(0,n+1)),isNew:!0,go:()=>r(n+1)}))];return(0,W.jsx)(Jm,{"aria-label":`Breadcrumbs`,className:`min-w-0`,children:(0,W.jsx)(Ym,{className:`min-h-7 gap-0.5 sm:gap-0.5`,children:i.map((e,t)=>(0,W.jsxs)(D.Fragment,{children:[t>0&&(0,W.jsx)($m,{className:`[&>svg]:size-3`}),(0,W.jsx)(Xm,{children:(0,W.jsx)(Zm,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,title:e.isNew?`${e.path} (doesn't exist yet)`:e.path,"aria-current":t===i.length-1?`location`:void 0,onClick:e.go,className:U(`rounded-sm px-1 hover:bg-accent aria-[current]:font-medium aria-[current]:text-foreground`,e.isNew&&`italic`),children:e.label})})})]},e.path))})})}function xv({choice:e,root:t}){let n=e.newFolders.length;return(0,W.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 text-xs text-muted-foreground`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 break-all font-mono`,children:[qg(e.base,t),e.newFolders.map((t,n)=>(0,W.jsxs)(D.Fragment,{children:[e.base===`/`&&n===0?``:`/`,(0,W.jsx)(`em`,{className:`text-foreground`,children:t})]},Wg(e.base,...e.newFolders.slice(0,n+1))))]}),n>0&&(0,W.jsx)(`span`,{children:n===1?`1 new folder`:`${n} new folders`})]})}function Sv({name:e}){return(0,W.jsxs)(`div`,{className:`grid min-h-40 flex-1 place-items-center content-center gap-1 rounded-md border p-6 text-center text-sm text-muted-foreground md:h-72 md:flex-none`,children:[(0,W.jsx)(_e,{className:`size-6`}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`em`,{className:`text-foreground`,children:e}),` doesn't exist yet. It'll be made along with the Workspace.`]}),(0,W.jsx)(`span`,{className:`text-xs`,children:`Add another New folder to go deeper.`})]})}function Cv({listing:e,error:t,filter:n,onFilter:r,workspaces:i,onGo:a}){let o=(0,D.useId)(),s=new Map(i.map(e=>[e.folder,e.name])),c=(e?.directories??[]).filter(e=>e.name.toLowerCase().includes(n.trim().toLowerCase()));return(0,W.jsxs)(iv,{label:`Filter folders`,shouldFilter:!1,vimBindings:!1,className:U(hv,`min-h-40 flex-1 border md:h-72 md:flex-none`),children:[(0,W.jsx)(av,{placeholder:`Filter`,value:n,onValueChange:r}),(0,W.jsxs)(ov,{label:`Folders`,className:`max-h-none flex-1 p-1`,children:[t&&(0,W.jsx)(`p`,{role:`alert`,className:`p-1 text-sm text-destructive`,children:t}),!e&&!t&&(0,W.jsx)(`p`,{className:`p-1 text-sm text-muted-foreground`,children:`Loading…`}),c.map((e,t)=>{let n=s.get(e.path),r=`${o}-${t}`;return(0,W.jsxs)(cv,{value:e.path,onSelect:()=>a(e.path),"aria-describedby":n===void 0?void 0:r,children:[(0,W.jsx)(ye,{}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),n!==void 0&&(0,W.jsxs)(`span`,{id:r,"aria-hidden":!0,className:`max-w-[40%] shrink-0 truncate rounded-sm bg-secondary px-1.5 text-xs text-muted-foreground`,children:[(0,W.jsx)(`span`,{className:`sr-only`,children:`Workspace `}),n]}),(0,W.jsx)(R,{className:`size-3 opacity-50`})]},e.path)}),e&&c.length===0&&(0,W.jsx)(`p`,{className:`p-1 text-sm text-muted-foreground`,children:n.trim()?`No folder matches`:`No subfolders`})]})]})}function wv({onAdd:e,onCancel:t}){let[n,r]=(0,D.useState)(``),[i,a]=(0,D.useState)(),o=(0,D.useRef)(null),s=(0,D.useId)();return pv(o,t),(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-2`,children:[(0,W.jsx)(_e,{className:`size-4 shrink-0`}),(0,W.jsx)(lv,{ref:o,autoFocus:!0,"aria-label":`New folder name`,"aria-invalid":i!==void 0,"aria-describedby":i===void 0?void 0:s,placeholder:`New folder name`,className:`h-7 text-sm`,value:n,onChange:e=>{r(e.target.value),a(void 0)},onKeyDown:t=>{if(t.key!==`Enter`)return;t.preventDefault();let r=n.trim(),i=Kg(r);i?a(i):e(r)},onBlur:()=>n.trim()===``&&t()})]}),i&&(0,W.jsx)(`p`,{id:s,className:`px-7 text-xs text-destructive`,children:i})]})}function Tv({className:e,...t}){return(0,W.jsx)(df,{"data-slot":`label`,className:U(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var Ev=Vh(`group/field flex w-full gap-3 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:[`flex-col [&>*]:w-full [&>.sr-only]:w-auto`],horizontal:[`flex-row items-center`,`[&>[data-slot=field-label]]:flex-auto`,`has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`],responsive:[`flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto`,`@md/field-group:[&>[data-slot=field-label]]:flex-auto`,`@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`]}},defaultVariants:{orientation:`vertical`}});function Dv({className:e,orientation:t=`vertical`,...n}){return(0,W.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":t,className:U(Ev({orientation:t}),e),...n})}function Ov({className:e,...t}){return(0,W.jsx)(Tv,{"data-slot":`field-label`,className:U(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4`,`has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10`,e),...t})}function kv({className:e,children:t,errors:n,...r}){let i=(0,D.useMemo)(()=>{if(t)return t;if(!n?.length)return null;let e=[...new Map(n.map(e=>[e?.message,e])).values()];return e?.length==1?e[0]?.message:(0,W.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:e.map((e,t)=>e?.message&&(0,W.jsx)(`li`,{children:e.message},t))})},[t,n]);return i?(0,W.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:U(`text-sm font-normal text-destructive`,e),...r,children:i}):null}function Av({workspace:e,workspaces:t,edit:n,onSave:r,onClose:i}){let a=n===`rename`,[o,s]=(0,D.useState)(e.name),[c,l]=(0,D.useState)(),[u,d]=(0,D.useState)(),f=(0,D.useId)(),p=c&&Gg(c),m=a?o.trim():p===e.folder?void 0:p,h=async()=>{if(m)try{await r(a?{name:m}:{folder:m,...(c?.newFolders.length??0)>0&&{createMissingFolders:!0}}),i()}catch(e){d(e instanceof Error?e.message:String(e))}};return(0,W.jsx)(Y_,{open:!0,onOpenChange:e=>!e&&i(),children:(0,W.jsx)($_,{className:a?void 0:uv,children:(0,W.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,W.jsxs)(ev,{children:[(0,W.jsx)(nv,{children:a?`Rename Workspace`:`Change folder`}),(0,W.jsx)(rv,{children:a?`Choose a new name for ${e.name}.`:`Point ${e.name} at another folder on the Host. Running Sessions carry on where they are.`})]}),a?(0,W.jsxs)(Dv,{children:[(0,W.jsx)(Ov,{htmlFor:f,children:`Name`}),(0,W.jsx)(lv,{id:f,value:o,onChange:e=>{s(e.target.value),d(void 0)},autoFocus:!0})]}):(0,W.jsx)(mv,{workspaces:t,start:e.folder,onChange:(e,t)=>{l(t?e:void 0),d(void 0)}}),u&&(0,W.jsx)(kv,{children:u}),(0,W.jsx)(tv,{children:(0,W.jsx)(Uh,{type:`submit`,disabled:!m,children:`Save`})})]})})})}var jv=2,Mv=1,Nv=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(jv,Math.floor(u/e.css.cell.width)),rows:Math.max(Mv,Math.floor(l/e.css.cell.height))}}},Pv=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Fv=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Iv;function Lv(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var Rv=class{constructor(){if(this.version=`6`,!Iv){Iv=new Uint8Array(65536),Iv.fill(1),Iv[0]=0,Iv.fill(0,1,32),Iv.fill(0,127,160),Iv.fill(2,4352,4448),Iv[9001]=2,Iv[9002]=2,Iv.fill(2,11904,42192),Iv[12351]=1,Iv.fill(2,44032,55204),Iv.fill(2,63744,64256),Iv.fill(2,65040,65050),Iv.fill(2,65072,65136),Iv.fill(2,65280,65377),Iv.fill(2,65504,65511);for(let e=0;e<Pv.length;++e)Iv.fill(0,Pv[e][0],Pv[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Iv[e]:Lv(e,Fv)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=Sy.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Sy.createPropertyValue(0,n,r)}},zv=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Wv.isErrorNoTelemetry(e)?new Wv(e.message+`
|
|
49
|
+
`},go=0,_o=[];function vo(e){var t=D.useRef([]),n=D.useRef([0,0]),r=D.useRef(),i=D.useState(go++)[0],a=D.useState(za)[0],o=D.useRef(e);D.useEffect(function(){o.current=e},[e]),D.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=ha([e.lockRef.current],(e.shards||[]).map(po),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=D.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=uo(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=ro(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=ro(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return lo(h,t,e,h===`h`?s:c,!0)},[]),c=D.useCallback(function(e){var n=e;if(_o.length&&_o[_o.length-1]===a){var r=`deltaY`in n?fo(n):uo(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&mo(e.delta,r)})[0];if(i&&i.should)n.cancelable&&n.preventDefault();else if(!i){var c=(o.current.shards||[]).map(po).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=D.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:yo(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=D.useCallback(function(e){n.current=uo(e),r.current=void 0},[]),d=D.useCallback(function(t){l(t.type,fo(t),t.target,s(t,e.lockRef.current))},[]),f=D.useCallback(function(t){l(t.type,uo(t),t.target,s(t,e.lockRef.current))},[]);D.useEffect(function(){return _o.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,Qa),document.addEventListener(`touchmove`,c,Qa),document.addEventListener(`touchstart`,u,Qa),function(){_o=_o.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,Qa),document.removeEventListener(`touchmove`,c,Qa),document.removeEventListener(`touchstart`,u,Qa)}},[]);var p=e.removeScrollBar,m=e.inert;return D.createElement(D.Fragment,null,m?D.createElement(a,{styles:ho(i)}):null,p?D.createElement(Ya,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function yo(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var bo=ka(Aa,vo),xo=D.forwardRef(function(e,t){return D.createElement(Ma,pa({},e,{ref:t,sideCar:bo}))});xo.classNames=Ma.classNames;var So=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},Co=new WeakMap,wo=new WeakMap,To={},Eo=0,Do=function(e){return e&&(e.host||Do(e.parentNode))},Oo=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=Do(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},ko=function(e,t,n,r){var i=Oo(t,Array.isArray(e)?e:[e]);To[n]||(To[n]=new WeakMap);var a=To[n],o=[],s=new Set,c=new Set(i),l=function(e){e&&!s.has(e)&&(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){e&&!c.has(e)&&Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(Co.get(e)||0)+1,l=(a.get(e)||0)+1;Co.set(e,c),a.set(e,l),o.push(e),c===1&&i&&wo.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),Eo++,function(){o.forEach(function(e){var t=Co.get(e)-1,i=a.get(e)-1;Co.set(e,t),a.set(e,i),t||(wo.has(e)||e.removeAttribute(r),wo.delete(e)),i||e.removeAttribute(n)}),Eo--,Eo||(Co=new WeakMap,Co=new WeakMap,wo=new WeakMap,To={})}},Ao=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||So(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),ko(r,i,n,`aria-hidden`)):function(){return null}},jo=Object.defineProperty,Mo=(e,t)=>jo(e,`name`,{value:t,configurable:!0}),No=`Dialog`,[Po,Fo]=vr(No),[J,Io]=Po(No),Lo=Mo(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=D.useRef(null),c=D.useRef(null),{nodes:l,registry:u}=Ki(),[d,f]=Xr({prop:r,defaultProp:i??!1,onChange:a,caller:No}),[p,m]=D.useState(0),[h,g]=D.useState(0);return(0,W.jsx)(J,{scope:t,triggerRef:s,contentRef:c,contentId:mi(),titleId:mi(),descriptionId:mi(),titlePresent:p>0,descriptionPresent:h>0,setTitleCount:m,setDescriptionCount:g,open:d,onOpenChange:f,onOpenToggle:D.useCallback(()=>f(e=>!e),[f]),modal:o,branchNodes:l,branchRegistry:u,children:n})},`Dialog`),Ro=`DialogTrigger`,zo=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,...r}=e,i=Io(Ro,n),a=Hn(t,i.triggerRef);return(0,W.jsx)(G.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":is(i.open),...r,ref:a,onClick:K(e.onClick,i.onOpenToggle)})},`DialogTrigger`)),Bo=`DialogPortal`,[Vo,Ho]=Po(Bo,{forceMount:void 0}),Uo=Mo(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=Io(Bo,t);return(0,W.jsx)(Vo,{scope:t,forceMount:n,children:D.Children.map(r,e=>(0,W.jsx)(ii,{present:n||a.open,children:(0,W.jsx)(aa,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),Wo=`DialogOverlay`,Go=D.forwardRef(Mo(function(e,t){let n=Ho(Wo,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Io(Wo,e.__scopeDialog);return a.modal?(0,W.jsx)(ii,{present:r||a.open,children:(0,W.jsx)(qo,{...i,ref:t})}):null},`DialogOverlay`)),Ko=Kn(`DialogOverlay.RemoveScroll`),qo=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,...r}=e,i=Io(Wo,n),a=Hn(t,Mi());return(0,W.jsx)(xo,{as:Ko,allowPinchZoom:!0,shards:D.useMemo(()=>[i.contentRef,...i.branchNodes.map(e=>({current:e}))],[i.contentRef,i.branchNodes]),children:(0,W.jsx)(G.div,{"data-state":is(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),Jo=`DialogContent`,Yo=D.forwardRef(Mo(function(e,t){let n=Ho(Jo,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=Io(Jo,e.__scopeDialog);return(0,W.jsx)(ii,{present:r||a.open,children:a.modal?(0,W.jsx)(Xo,{...i,ref:t}):(0,W.jsx)(Zo,{...i,ref:t})})},`DialogContent`)),Xo=D.forwardRef(Mo(function(e,t){let n=Io(Jo,e.__scopeDialog),r=D.useRef(null),i=Hn(t,n.contentRef,r);return D.useEffect(()=>{let e=r.current;if(e)return Ao(e)},[]),(0,W.jsx)(Qo,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:K(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:K(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:K(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),Zo=D.forwardRef(Mo(function(e,t){let n=Io(Jo,e.__scopeDialog),r=D.useRef(!1),i=D.useRef(!1);return(0,W.jsx)(Qo,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),Qo=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,"aria-describedby":o,children:s,...c}=e,l=Io(Jo,n);return da(),(0,W.jsx)(Gi,{registry:l.branchRegistry,children:(0,W.jsx)(Ui,{asChild:!0,loop:!0,trapped:r,branches:l.branchNodes,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,W.jsx)(ji,{role:`dialog`,id:l.contentId,"aria-labelledby":l.titlePresent?l.titleId:void 0,"aria-describedby":l.descriptionPresent?rs(o,l.descriptionId):o,"data-state":is(l.open),...c,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1),children:s})})})},`DialogContentImpl`)),$o=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,...r}=e,i=Io(`DialogTitle`,n),{setTitleCount:a}=i;return br(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,W.jsx)(G.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),es=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,...r}=e,i=Io(`DialogDescription`,n),{setDescriptionCount:a}=i;return br(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,W.jsx)(G.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),ts=`DialogClose`,ns=D.forwardRef(Mo(function(e,t){let{__scopeDialog:n,...r}=e,i=Io(ts,n);return(0,W.jsx)(G.button,{type:`button`,...r,ref:t,onClick:K(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function rs(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}Mo(rs,`concatAriaDescribedby`);function is(e){return e?`open`:`closed`}Mo(is,`getState`);var as=Object.defineProperty,os=(e,t)=>as(e,`name`,{value:t,configurable:!0}),[ss,cs]=vr(`AlertDialog`,[Fo]),ls=Fo(),us=os(e=>{let{__scopeAlertDialog:t,...n}=e,r=ls(t);return(0,W.jsx)(Lo,{...r,...n,modal:!0})},`AlertDialog`);D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=ls(n);return(0,W.jsx)(zo,{...i,...r,ref:t})},`AlertDialogTrigger`));var ds=os(e=>{let{__scopeAlertDialog:t,...n}=e,r=ls(t);return(0,W.jsx)(Uo,{...r,...n})},`AlertDialogPortal`),fs=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=ls(n);return(0,W.jsx)(Go,{...i,...r,ref:t})},`AlertDialogOverlay`)),[ps,ms]=ss(`AlertDialogContent`),hs=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,children:r,...i}=e,a=ls(n),o=Hn(t,D.useRef(null)),s=D.useRef(null);return(0,W.jsx)(ps,{scope:n,cancelRef:s,children:(0,W.jsx)(Yo,{role:`alertdialog`,...a,...i,ref:o,onOpenAutoFocus:K(i.onOpenAutoFocus,e=>{e.preventDefault(),s.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})},`AlertDialogContent`)),gs=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=ls(n);return(0,W.jsx)($o,{...i,...r,ref:t})},`AlertDialogTitle`)),_s=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=ls(n);return(0,W.jsx)(es,{...i,...r,ref:t})},`AlertDialogDescription`)),vs=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,i=ls(n);return(0,W.jsx)(ns,{...i,...r,ref:t})},`AlertDialogAction`)),ys=`AlertDialogCancel`,bs=D.forwardRef(os(function(e,t){let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=ms(ys,n),a=ls(n),o=Hn(t,i);return(0,W.jsx)(ns,{...a,...r,ref:o})},`AlertDialogCancel`)),xs=Object.defineProperty,Ss=(e,t)=>xs(e,`name`,{value:t,configurable:!0}),Cs=`Avatar`,[ws,Ts]=vr(Cs),Es={Idle:`idle`,Loading:`loading`,Loaded:`loaded`,Error:`error`},Ds=[0,()=>void 0],[Os,ks]=ws(Cs),As=D.forwardRef(Ss(function(e,t){let{__scopeAvatar:n,...r}=e,[i,a]=D.useState(Es.Idle),[o,s]=Fs();return(0,W.jsx)(Os,{scope:n,imageLoadingStatus:i,setImageLoadingStatus:a,imageCount:o,setImageCount:s,children:(0,W.jsx)(G.span,{...r,ref:t})})},`Avatar`)),js=`AvatarFallback`,Ms=D.forwardRef(Ss(function(e,t){let{__scopeAvatar:n,delayMs:r,...i}=e,a=ks(js,n),[o,s]=D.useState(r===void 0);return D.useEffect(()=>{if(r!==void 0){let e=window.setTimeout(()=>s(!0),r);return()=>window.clearTimeout(e)}},[r]),o&&a.imageLoadingStatus!==Es.Loaded?(0,W.jsx)(G.span,{...i,ref:t}):null},`AvatarFallback`));function Ns(e,{loadingStatus:t,setLoadingStatus:n,referrerPolicy:r,crossOrigin:i}){return br(()=>{if(!e){n(Es.Error);return}let t=new window.Image,a=Ss(e=>{let t=e.currentTarget;n(Ps(t))},`handleLoad`),o=Ss(()=>n(Es.Error),`handleError`);return t.addEventListener(`load`,a),t.addEventListener(`error`,o),r&&(t.referrerPolicy=r),t.crossOrigin=i??null,t.src=e,n(Ps(t)),()=>{t.removeEventListener(`load`,a),t.removeEventListener(`error`,o),n(Es.Idle)}},[e,i,r,n]),t}Ss(Ns,`useImageLoadingStatus`);function Ps(e){return e.complete?e.naturalWidth>0?Es.Loaded:Es.Error:Es.Loading}Ss(Ps,`getImageLoadingStatus`);function Fs(){return Ds}Ss(Fs,`useImageCount`);function Is(e){}Ss(Is,`useUpdateImageCount`);var Ls=Object.defineProperty,Rs=(e,t)=>Ls(e,`name`,{value:t,configurable:!0});function zs(e){let[t,n]=D.useState(void 0);return br(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=0,r=new ResizeObserver(r=>{if(!Array.isArray(r)||!r.length)return;let i=r[0];window.cancelAnimationFrame(t),t=window.requestAnimationFrame(()=>{let t,r;if(`borderBoxSize`in i){let e=i.borderBoxSize,n=Array.isArray(e)?e[0]:e;t=n.inlineSize,r=n.blockSize}else t=e.offsetWidth,r=e.offsetHeight;n({width:t,height:r})})});return r.observe(e,{box:`border-box`}),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}n(void 0)},[e]),t}Rs(zs,`useSize`);var Bs=[`top`,`right`,`bottom`,`left`],Vs=Math.min,Hs=Math.max,Us=Math.round,Ws=Math.floor,Gs=e=>({x:e,y:e}),Ks={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function qs(e,t,n){return Hs(e,Vs(t,n))}function Js(e,t){return typeof e==`function`?e(t):e}function Ys(e){return e.split(`-`)[0]}function Xs(e){return e.split(`-`)[1]}function Zs(e){return e===`x`?`y`:`x`}function Qs(e){return e===`y`?`height`:`width`}function $s(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function ec(e){return Zs($s(e))}function tc(e,t,n){n===void 0&&(n=!1);let r=Xs(e),i=ec(e),a=Qs(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=uc(o)),[o,uc(o)]}function nc(e){let t=uc(e);return[rc(e),t,rc(t)]}function rc(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var ic=[`left`,`right`],ac=[`right`,`left`],oc=[`top`,`bottom`],sc=[`bottom`,`top`];function cc(e,t,n){switch(e){case`top`:case`bottom`:return n?t?ac:ic:t?ic:ac;case`left`:case`right`:return t?oc:sc;default:return[]}}function lc(e,t,n,r){let i=Xs(e),a=cc(Ys(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(rc)))),a}function uc(e){let t=Ys(e);return Ks[t]+e.slice(t.length)}function dc(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function fc(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:dc(e)}function pc(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 mc(e,t,n){let{reference:r,floating:i}=e,a=$s(t),o=ec(t),s=Qs(o),c=Ys(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=Xs(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function hc(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}=Js(t,e),p=fc(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=pc(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=pc(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 gc=50,_c=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:hc},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=mc(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<gc&&(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}=mc(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},vc=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}=Js(e,t)||{};if(l==null)return{};let d=fc(u),f={x:n,y:r},p=ec(i),m=Qs(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;C&&await(o.isElement==null?void 0:o.isElement(S))||(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=Vs(d[_],T),D=Vs(d[v],T),O=C-h[m]-D,k=C/2-h[m]/2+w,A=qs(E,k,O),j=!c.arrow&&Xs(i)!=null&&k!==A&&a.reference[m]/2-(k<E?E:D)-h[m]/2<0,M=j?k<E?k-E:k-O:0;return{[p]:f[p]+M,data:{[p]:A,centerOffset:k-A-M,...j&&{alignmentOffset:M}},reset:j}}}),yc=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}=Js(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=Ys(r),_=$s(o),v=Ys(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[uc(o)]:nc(o)),x=p!==`none`;!d&&x&&b.push(...lc(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=tc(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`||_===$s(t)||T.every(e=>$s(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=$s(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o}if(r!==n)return{reset:{placement:n}}}return{}}}};function bc(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function xc(e){return Bs.some(t=>e[t]>=0)}var Sc=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=Js(e,t);switch(i){case`referenceHidden`:{let e=bc(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:xc(e)}}}case`escaped`:{let e=bc(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:xc(e)}}}default:return{}}}}},Cc=new Set([`left`,`top`]);async function wc(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Ys(n),s=Xs(n),c=$s(n)===`y`,l=Cc.has(o)?-1:1,u=a&&c?-1:1,d=Js(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 Tc=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 wc(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}}}}},Ec=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}=Js(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=$s(i),p=Zs(f),m=u[p],h=u[f],g=(e,t)=>qs(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}}}}}},Dc=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}=Js(e,t),u={x:n,y:r},d=$s(i),f=Zs(d),p=u[f],m=u[d],h=Js(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=Cc.has(Ys(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}}}},Oc=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}=Js(e,t),c=await i.detectOverflow(t,s),l=Ys(n),u=Xs(n),d=$s(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=Vs(p-c[m],g),y=Vs(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*Hs(c.left,c.right):S=p-2*Hs(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 kc(){return typeof window<`u`}function Ac(e){return Nc(e)?(e.nodeName||``).toLowerCase():`#document`}function jc(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Mc(e){return((Nc(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Nc(e){return kc()?e instanceof Node||e instanceof jc(e).Node:!1}function Pc(e){return kc()?e instanceof Element||e instanceof jc(e).Element:!1}function Fc(e){return kc()?e instanceof HTMLElement||e instanceof jc(e).HTMLElement:!1}function Ic(e){return!kc()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof jc(e).ShadowRoot}function Lc(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Jc(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Rc(e){return/^(table|td|th)$/.test(Ac(e))}function zc(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Bc=/transform|translate|scale|rotate|perspective|filter/,Vc=/paint|layout|strict|content/,Hc=e=>!!e&&e!==`none`,Uc;function Wc(e){let t=Pc(e)?Jc(e):e;return Hc(t.transform)||Hc(t.translate)||Hc(t.scale)||Hc(t.rotate)||Hc(t.perspective)||!Kc()&&(Hc(t.backdropFilter)||Hc(t.filter))||Bc.test(t.willChange||``)||Vc.test(t.contain||``)}function Gc(e){let t=Xc(e);for(;Fc(t)&&!qc(t);){if(Wc(t))return t;if(zc(t))return null;t=Xc(t)}return null}function Kc(){return Uc??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Uc}function qc(e){return/^(html|body|#document)$/.test(Ac(e))}function Jc(e){return jc(e).getComputedStyle(e)}function Yc(e){return Pc(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Xc(e){if(Ac(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Ic(e)&&e.host||Mc(e);return Ic(t)?t.host:t}function Zc(e){let t=Xc(e);return qc(t)?(e.ownerDocument||e).body:Fc(t)&&Lc(t)?t:Zc(t)}function Qc(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Zc(e),i=r===e.ownerDocument?.body,a=jc(r);if(i){let e=$c(a);return t.concat(a,a.visualViewport||[],Lc(r)?r:[],e&&n?Qc(e):[])}return t.concat(r,Qc(r,[],n))}function $c(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function el(e){let t=Jc(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Fc(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=Us(n)!==a||Us(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function tl(e){return Pc(e)?e:e.contextElement}function nl(e){let t=tl(e);if(!Fc(t))return Gs(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=el(t),o=(a?Us(n.width):n.width)/r,s=(a?Us(n.height):n.height)/i;return o&&Number.isFinite(o)||(o=1),s&&Number.isFinite(s)||(s=1),{x:o,y:s}}var rl=Gs(0);function il(e){let t=jc(e);return!Kc()||!t.visualViewport?rl:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function al(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===jc(e)}function ol(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=tl(e),o=Gs(1);t&&(r?Pc(r)&&(o=nl(r)):o=nl(e));let s=al(a,n,r)?il(a):Gs(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=jc(a),t=Pc(r)?jc(r):r,n=e,i=$c(n);for(;i&&t!==n;){let e=nl(i),t=i.getBoundingClientRect(),r=Jc(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=jc(i),i=$c(n)}}return pc({width:u,height:d,x:c,y:l})}function sl(e,t){let n=Yc(e).scrollLeft;return t?t.left+n:ol(Mc(e)).left+n}function cl(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-sl(e,n),y:n.top+t.scrollTop}}function ll(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Mc(r),s=t?zc(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=Gs(1),u=Gs(0),d=Fc(r);if((d||!a)&&((Ac(r)!==`body`||Lc(o))&&(c=Yc(r)),d)){let e=ol(r);l=nl(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?cl(o,c):Gs(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 ul(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function dl(e){let t=Yc(e),n=e.ownerDocument.body,r=Hs(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=Hs(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+sl(e),o=-t.scrollTop;return Jc(n).direction===`rtl`&&(a+=Hs(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var fl=25;function pl(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=jc(e),a=Mc(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Kc()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(sl(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<=fl&&(s-=o)}return{width:s,height:c,x:l,y:u}}function ml(e,t){let n=ol(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=nl(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function hl(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=pl(e,n,t);else if(t===`document`)r=dl(Mc(e));else if(Pc(t))r=ml(t,n);else{let n=il(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return pc(r)}function gl(e,t){let n=t.get(e);if(n)return n;let r=Qc(e,[],!1).filter(e=>Pc(e)&&Ac(e)!==`body`),i=null,a=Jc(e).position===`fixed`,o=a?Xc(e):e;for(;Pc(o)&&!qc(o);){let e=Jc(o),t=Wc(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Xc(o)}return t.set(e,r),r}function _l(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?zc(t)?[]:gl(t,this._c):[].concat(n),r],o=hl(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=hl(t,a[e],i);s=Hs(n.top,s),c=Vs(n.right,c),l=Vs(n.bottom,l),u=Hs(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function vl(e){let{width:t,height:n}=el(e);return{width:t,height:n}}function yl(e,t,n){let r=Fc(t),i=Mc(t),a=n===`fixed`,o=ol(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=Gs(0);if((r||!a)&&((Ac(t)!==`body`||Lc(i))&&(s=Yc(t)),r)){let e=ol(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=sl(i));let l=i&&!r&&!a?cl(i,s):Gs(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 bl(e){return Jc(e).position===`static`}function xl(e,t){if(!Fc(e)||Jc(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Mc(e)===n&&(n=n.ownerDocument.body),n}function Sl(e,t){let n=jc(e);if(zc(e))return n;if(!Fc(e)){let t=Xc(e);for(;t&&!qc(t);){if(Pc(t)&&!bl(t))return t;t=Xc(t)}return n}let r=xl(e,t);for(;r&&Rc(r)&&bl(r);)r=xl(r,t);return r&&qc(r)&&bl(r)&&!Wc(r)?n:r||Gc(e)||n}var Cl=async function(e){let t=this.getOffsetParent||Sl,n=this.getDimensions,r=await n(e.floating);return{reference:yl(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function wl(e){return Jc(e).direction===`rtl`}var Tl={convertOffsetParentRelativeRectToViewportRelativeRect:ll,getDocumentElement:Mc,getClippingRect:_l,getOffsetParent:Sl,getElementRects:Cl,getClientRects:ul,getDimensions:vl,getScale:nl,isElement:Pc,isRTL:wl};function El(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Dl(e,t,n){let r=null,i,a=Mc(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=Ws(d),h=Ws(a.clientWidth-(u+f)),g=Ws(a.clientHeight-(d+p)),_=Ws(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:Hs(0,Vs(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(!El(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=jc(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function Ol(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=tl(e),u=i||a?[...l?Qc(l):[],...t?Qc(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?Dl(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?ol(e):null;c&&g();function g(){let t=ol(e);h&&!El(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 kl=Tc,Al=Ec,jl=yc,Ml=Oc,Nl=Sc,Pl=vc,Fl=Dc,Il=(e,t,n)=>{let r=new Map,i=n??{},a={...Tl,...i.platform,_c:r};return _c(e,t,{...i,platform:a})},Ll=typeof document<`u`?D.useLayoutEffect:function(){};function Rl(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(!Rl(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)&&!Rl(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function zl(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bl(e,t){let n=zl(e);return Math.round(t*n)/n}function Vl(e){let t=D.useRef(e);return Ll(()=>{t.current=e}),t}function Hl(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=D.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=D.useState(r);Rl(f,r)||p(r);let[m,h]=D.useState(null),[g,_]=D.useState(null),v=D.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=D.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=D.useRef(null),C=D.useRef(null),w=D.useRef(u),T=c!=null,E=Vl(c),O=Vl(i),k=Vl(l),A=D.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),Il(S.current,C.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!Rl(w.current,t)&&(w.current=t,Un.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);Ll(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=D.useRef(!1);Ll(()=>(j.current=!0,()=>{j.current=!1}),[]),Ll(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,A);A()}},[b,x,A,E,T]);let M=D.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),N=D.useMemo(()=>({reference:b,floating:x}),[b,x]),P=D.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=Bl(N.floating,u.x),r=Bl(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...zl(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return D.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var Ul=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:Pl({element:r.current,padding:i}).fn(n):r?Pl({element:r,padding:i}).fn(n):{}}}},Wl=(e,t)=>{let n=kl(e);return{name:n.name,fn:n.fn,options:[e,t]}},Gl=(e,t)=>{let n=Al(e);return{name:n.name,fn:n.fn,options:[e,t]}},Kl=(e,t)=>({fn:Fl(e).fn,options:[e,t]}),ql=(e,t)=>{let n=jl(e);return{name:n.name,fn:n.fn,options:[e,t]}},Jl=(e,t)=>{let n=Ml(e);return{name:n.name,fn:n.fn,options:[e,t]}},Yl=(e,t)=>{let n=Nl(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xl=(e,t)=>{let n=Ul(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zl=Object.defineProperty,Ql=D.forwardRef(((e,t)=>Zl(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,W.jsx)(G.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,W.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),$l=Object.defineProperty,eu=(e,t)=>$l(e,`name`,{value:t,configurable:!0}),tu={Partial:`partial`,Always:`always`},nu={Optimized:`optimized`,Always:`always`},ru=`Popper`,[iu,au]=vr(ru),[ou,su]=iu(ru),cu=eu(e=>{let{__scopePopper:t,children:n}=e,[r,i]=D.useState(null),[a,o]=D.useState(void 0);return(0,W.jsx)(ou,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),lu=`PopperAnchor`,uu=D.forwardRef(eu(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=su(lu,n),o=D.useRef(null),s=a.onAnchorChange,c=Hn(t,D.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=D.useRef(null);D.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&bu(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,W.jsx)(G.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),du=`PopperContent`,[fu,pu]=iu(du),mu=D.forwardRef(eu(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=tu.Partial,hideWhenDetached:f=!1,updatePositionStrategy:p=nu.Optimized,onPlaced:m,...h}=e,g=su(du,n),[_,v]=D.useState(null),y=Hn(t,v),[b,x]=D.useState(null),S=zs(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},O=Array.isArray(l)?l:[l],k=O.length>0,A={padding:E,boundary:O.filter(vu),altBoundary:k},{refs:j,floatingStyles:M,placement:N,isPositioned:P,middlewareData:F}=Hl({strategy:`fixed`,placement:T,whileElementsMounted:eu((...e)=>Ol(...e,{animationFrame:p===nu.Always}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[Wl({mainAxis:i+w,alignmentAxis:o}),c&&Gl({mainAxis:!0,crossAxis:!1,...d===tu.Partial?{limiter:Kl()}:{},...A}),c&&ql({...A}),Jl({...A,apply:eu(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),b&&Xl({element:b,padding:s}),yu({arrowWidth:C,arrowHeight:w}),f&&Yl(k?{strategy:`referenceHidden`,...A}:{strategy:`referenceHidden`,padding:A.padding,altBoundary:A.altBoundary})]}),I=g.setPlacementState;br(()=>(I(N),()=>{I(void 0)}),[N,I]);let[ee,te]=bu(N),ne=Ci(m);br(()=>{P&&ne?.()},[P,ne]);let re=F.arrow?.x,L=F.arrow?.y,ie=F.arrow?.centerOffset!==0,[ae,oe]=D.useState();return br(()=>{_&&oe(window.getComputedStyle(_).zIndex)},[_]),(0,W.jsx)(`div`,{ref:j.setFloating,"data-radix-popper-content-wrapper":``,style:{...M,transform:P?M.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(` `),...F.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,W.jsx)(fu,{scope:n,placedSide:ee,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:L,shouldHideArrow:ie,children:(0,W.jsx)(G.div,{"data-side":ee,"data-align":te,...h,ref:y,style:{...h.style,animation:P?h.style?.animation:`none`}})})})},`PopperContent`)),hu=`PopperArrow`,gu={top:`bottom`,right:`left`,bottom:`top`,left:`right`},_u=D.forwardRef(eu(function(e,t){let{__scopePopper:n,...r}=e,i=pu(hu,n),a=gu[i.placedSide];return(0,W.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,W.jsx)(Ql,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function vu(e){return e!==null}eu(vu,`isNotNull`);var yu=eu(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=bu(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function bu(e){let[t,n=`center`]=e.split(`-`);return[t,n]}eu(bu,`getSideAndAlignFromPlacement`);var xu=Object.defineProperty,Su=(e,t)=>xu(e,`name`,{value:t,configurable:!0}),Cu=!1;function wu(){let[e,t]=D.useState(Cu);return D.useEffect(()=>{Cu||(Cu=!0,t(!0))},[]),e}Su(wu,`useIsHydrated`);var Tu=D.useSyncExternalStore;function Eu(){return()=>{}}Su(Eu,`subscribe`);function Du(){return Tu(Eu,()=>!0,()=>!1)}Su(Du,`useIsHydratedModern`);var Ou=typeof Tu==`function`?Du:wu,ku=Object.defineProperty,Au=(e,t)=>ku(e,`name`,{value:t,configurable:!0}),ju=`rovingFocusGroup.onEntryFocus`,Mu={bubbles:!1,cancelable:!0},Nu=`RovingFocusGroup`,[Pu,Fu,Iu]=Cr(Nu),[Lu,Ru]=vr(Nu,[Iu]),zu={Vertical:`vertical`,Horizontal:`horizontal`},Bu={LTR:`ltr`,RTL:`rtl`},[Vu,Hu]=Lu(Nu),Uu=D.forwardRef(Au(function(e,t){return(0,W.jsx)(Pu.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,W.jsx)(Pu.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,W.jsx)(Wu,{...e,ref:t})})})},`RovingFocusGroup`)),Wu=D.forwardRef(Au(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=D.useRef(null),p=Hn(t,f),m=yi(a),[h,g]=Xr({prop:o,defaultProp:s??null,onChange:c,caller:Nu}),[_,v]=D.useState(!1),y=Ci(l),b=Fu(n),x=D.useRef(!1),[S,C]=D.useState(0);return D.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(ju,y),()=>e.removeEventListener(ju,y)},[y]),(0,W.jsx)(Vu,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:D.useCallback(e=>g(e),[g]),onItemShiftTab:D.useCallback(()=>v(!0),[]),onFocusableItemAdd:D.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:D.useCallback(()=>C(e=>e-1),[]),children:(0,W.jsx)(G.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:K(e.onMouseDown,()=>{x.current=!0}),onFocus:K(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(ju,Mu);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);Xu([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:K(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),Gu=`RovingFocusGroupItem`,Ku=D.forwardRef(Au(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=mi(),l=a||c,u=Hu(Gu,n),d=u.currentTabStopId===l,f=Fu(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=Ou();return br(()=>{if(g&&r)return p(),()=>m()},[g,r,p,m]),D.useEffect(()=>{if(!g&&r)return p(),()=>m()},[g,r,p,m]),(0,W.jsx)(Pu.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,W.jsx)(G.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:K(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:K(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:K(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Yu(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Zu(n,r+1):n.slice(r+1)}setTimeout(()=>Xu(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),qu={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Ju(e,t){return t===Bu.RTL?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}Au(Ju,`getDirectionAwareKey`);function Yu(e,t,n){let r=Ju(e.key,n);if(!(t===zu.Vertical&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===zu.Horizontal&&[`ArrowUp`,`ArrowDown`].includes(r)))return qu[r]}Au(Yu,`getFocusIntent`);function Xu(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Au(Xu,`focusFirst`);function Zu(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Au(Zu,`wrapArray`);var Qu=Object.defineProperty,Y=(e,t)=>Qu(e,`name`,{value:t,configurable:!0}),$u=[`Enter`,` `],ed=[`ArrowDown`,`PageUp`,`Home`],td=[`ArrowUp`,`PageDown`,`End`],nd=[...ed,...td];[...$u],[...$u];var rd=`Menu`,[id,ad,od]=Cr(rd),[sd,cd]=vr(rd,[od,au,Ru]),ld=au(),ud=Ru(),[dd,fd]=sd(rd),[pd,md]=sd(rd),hd=Y(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=ld(t),[c,l]=D.useState(null),u=D.useRef(!1),d=Ci(a),f=yi(i);return D.useEffect(()=>{let e=Y(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=Y(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),D.useEffect(()=>{if(!n)return;let e=Y(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,W.jsx)(cu,{...s,children:(0,W.jsx)(dd,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,W.jsx)(pd,{scope:t,onClose:D.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),gd=D.forwardRef(Y(function(e,t){let{__scopeMenu:n,...r}=e,i=ld(n);return(0,W.jsx)(uu,{...i,...r,ref:t})},`MenuAnchor`)),_d=`MenuPortal`,[vd,yd]=sd(_d,{forceMount:void 0}),bd=Y(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=fd(_d,t);return(0,W.jsx)(vd,{scope:t,forceMount:n,children:(0,W.jsx)(ii,{present:n||a.open,children:(0,W.jsx)(aa,{asChild:!0,container:i,children:r})})})},`MenuPortal`),xd=`MenuContent`,[Sd,Cd]=sd(xd),wd=D.forwardRef(Y(function(e,t){let n=yd(xd,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=fd(xd,e.__scopeMenu),o=md(xd,e.__scopeMenu);return(0,W.jsx)(id.Provider,{scope:e.__scopeMenu,children:(0,W.jsx)(ii,{present:r||a.open,children:(0,W.jsx)(id.Slot,{scope:e.__scopeMenu,children:o.modal?(0,W.jsx)(Td,{...i,ref:t}):(0,W.jsx)(Ed,{...i,ref:t})})})})},`MenuContent`)),Td=D.forwardRef(Y(function(e,t){let n=fd(xd,e.__scopeMenu),r=D.useRef(null),i=Hn(t,r);return D.useEffect(()=>{let e=r.current;if(e)return Ao(e)},[]),(0,W.jsx)(Od,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:K(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Ed=D.forwardRef(Y(function(e,t){let n=fd(xd,e.__scopeMenu);return(0,W.jsx)(Od,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Dd=Kn(`MenuContent.ScrollLock`),Od=D.forwardRef(Y(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=fd(xd,n),_=md(xd,n),v=ld(n),y=ud(n),b=ad(n),[x,S]=D.useState(null),C=D.useRef(null),[w,T]=D.useState(null);qi(w);let{nodes:E,registry:O}=Ki(),k=!!(i||m),A=Hn(t,C,g.onContentChange,T),j=D.useRef(0),M=D.useRef(``),N=D.useRef(0),P=D.useRef(null),F=D.useRef(`right`),I=D.useRef(0),ee=D.useMemo(()=>m?[C,...E.map(e=>({current:e}))]:[],[C,E,m]),te=m?xo:D.Fragment,ne=m?{as:Dd,allowPinchZoom:!0,shards:ee}:void 0,re=Y(e=>{let t=M.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Wd(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;function s(e){M.current=e,window.clearTimeout(j.current),e!==``&&(j.current=window.setTimeout(()=>s(``),1e3))}Y(s,`updateSearch`),s(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);D.useEffect(()=>()=>window.clearTimeout(j.current),[]),da();let L=D.useCallback(e=>F.current===P.current?.side&&Kd(e,P.current?.area),[]);return(0,W.jsx)(Sd,{scope:n,searchRef:M,onItemEnter:D.useCallback(e=>{L(e)&&e.preventDefault()},[L]),onItemLeave:D.useCallback(e=>{L(e)||(C.current?.focus(),S(null))},[L]),onTriggerLeave:D.useCallback(e=>{L(e)&&e.preventDefault()},[L]),pointerGraceTimerRef:N,onPointerGraceIntentChange:D.useCallback(e=>{P.current=e},[]),children:(0,W.jsx)(Gi,{registry:k?O:null,children:(0,W.jsx)(te,{...ne,children:(0,W.jsx)(Ui,{asChild:!0,trapped:i,branches:E,onMountAutoFocus:K(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,W.jsx)(ji,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,W.jsx)(Uu,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:K(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,W.jsx)(mu,{role:`menu`,"aria-orientation":`vertical`,"data-state":zd(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:A,style:{outline:`none`,...h.style},onKeyDown:K(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&re(e.key));let i=C.current;if(e.target!==i||!nd.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);td.includes(e.key)&&a.reverse(),Hd(a)}),onBlur:K(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(j.current),M.current=``)}),onPointerMove:K(e.onPointerMove,qd(e=>{let t=e.target,n=I.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>I.current?`right`:`left`;F.current=t,I.current=e.clientX}}))})})})})})})})},`MenuContentImpl`)),kd=`MenuItem`,Ad=`menu.itemSelect`,jd=D.forwardRef(Y(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=D.useRef(null),o=md(kd,e.__scopeMenu),s=Cd(kd,e.__scopeMenu),c=Hn(t,a),l=D.useRef(!1),u=Y(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Ad,{bubbles:!0,cancelable:!0});e.addEventListener(Ad,e=>r?.(e),{once:!0}),ur(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,W.jsx)(Md,{...i,ref:c,disabled:n,onClick:K(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:K(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:K(e.onKeyDown,e=>{n||e.target!==e.currentTarget||(s.searchRef.current===``||e.key!==` `)&&$u.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),Md=D.forwardRef(Y(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Cd(kd,n),s=ud(n),c=D.useRef(null),l=Hn(t,c),[u,d]=D.useState(!1),[f,p]=D.useState(``);return D.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,W.jsx)(id.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,W.jsx)(Ku,{asChild:!0,...s,focusable:!r,children:(0,W.jsx)(G.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:K(e.onPointerMove,qd(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:K(e.onPointerLeave,qd(e=>o.onItemLeave(e))),onFocus:K(e.onFocus,()=>d(!0)),onBlur:K(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[Nd,Pd]=sd(`MenuRadioGroup`,{value:void 0,onValueChange:Y(()=>{},`onValueChange`)}),[Fd,Id]=sd(`MenuItemIndicator`,{checked:!1}),[Ld,Rd]=sd(`MenuSub`);function zd(e){return e?`open`:`closed`}Y(zd,`getOpenState`);function Bd(e){return e===`indeterminate`}Y(Bd,`isIndeterminate`);function Vd(e){return Bd(e)?`indeterminate`:e?`checked`:`unchecked`}Y(Vd,`getCheckedState`);function Hd(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}Y(Hd,`focusFirst`);function Ud(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Y(Ud,`wrapArray`);function Wd(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Ud(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}Y(Wd,`getNextMatch`);function Gd(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}Y(Gd,`isPointInPolygon`);function Kd(e,t){return t?Gd({x:e.clientX,y:e.clientY},t):!1}Y(Kd,`isPointerInGraceArea`);function qd(e){return t=>t.pointerType===`mouse`?e(t):void 0}Y(qd,`whenMouse`);var Jd=Object.defineProperty,Yd=(e,t)=>Jd(e,`name`,{value:t,configurable:!0}),Xd=`DropdownMenu`,[Zd,Qd]=vr(Xd,[cd]),$d=cd(),[ef,tf]=Zd(Xd),nf=Yd(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=$d(t),l=D.useRef(null),[u,d]=Xr({prop:i,defaultProp:a??!1,onChange:o,caller:Xd});return(0,W.jsx)(ef,{scope:t,triggerId:mi(),triggerRef:l,contentId:mi(),open:u,onOpenChange:d,onOpenToggle:D.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,W.jsx)(hd,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),rf=`DropdownMenuTrigger`,af=D.forwardRef(Yd(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=tf(rf,n),o=$d(n),s=Hn(t,a.triggerRef);return(0,W.jsx)(gd,{asChild:!0,...o,children:(0,W.jsx)(G.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:K(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:K(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),of=Yd(e=>{let{__scopeDropdownMenu:t,...n}=e,r=$d(t);return(0,W.jsx)(bd,{...r,...n})},`DropdownMenuPortal`),sf=`DropdownMenuContent`,cf=D.forwardRef(Yd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=tf(sf,n),a=$d(n),o=D.useRef(!1);return(0,W.jsx)(wd,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:K(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:K(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`DropdownMenuContent`)),lf=D.forwardRef(Yd(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=$d(n);return(0,W.jsx)(jd,{...i,...r,ref:t})},`DropdownMenuItem`)),uf=Object.defineProperty,df=D.forwardRef(((e,t)=>uf(e,`name`,{value:t,configurable:!0}))(function(e,t){return(0,W.jsx)(G.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}})},`Label`)),ff=Object.defineProperty,pf=(e,t)=>ff(e,`name`,{value:t,configurable:!0});function mf(e,[t,n]){return Math.min(n,Math.max(t,e))}pf(mf,`clamp`);var hf=Object.defineProperty,gf=(e,t)=>hf(e,`name`,{value:t,configurable:!0}),_f={ItemAligned:`item-aligned`,Popper:`popper`},vf={LTR:`ltr`,RTL:`rtl`},yf=[` `,`Enter`,`ArrowUp`,`ArrowDown`],bf=[` `,`Enter`],xf=`Select`,[Sf,Cf,wf]=Cr(xf),[Tf,Ef]=vr(xf,[wf,au]),Df=au(),[Of,kf]=Tf(xf),[Af,jf]=Tf(xf);function Mf(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:l,name:u,autoComplete:d,disabled:f,required:p,form:m,internal_do_not_use_render:h}=e,g=Df(t),[_,v]=D.useState(null),[y,b]=D.useState(null),[x,S]=D.useState(!1),C=yi(l),[w,T]=Xr({prop:r,defaultProp:i??!1,onChange:a,caller:xf}),[E,O]=Xr({prop:o,defaultProp:s,onChange:c,caller:xf}),k=D.useRef(null),A=D.useRef(!1),[j,M]=D.useState(null),N=gf(e=>{M({value:e,hasConsumerStoppedPropagation:A.current}),O(e)},`handleUserSelect`),P=D.useRef(E);D.useEffect(()=>{let e=m?_?.ownerDocument.getElementById(m):_?.form;if(e instanceof HTMLFormElement){let t=gf(()=>O(P.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[m,_,O]);let F=!_||!!m||!!_.closest(`form`),[I,ee]=D.useState(new Set),te=mi(),ne=Array.from(I).map(e=>e.props.value).join(`;`),re=D.useCallback(e=>{ee(t=>new Set(t).add(e))},[]),L=D.useCallback(e=>{ee(t=>{let n=new Set(t);return n.delete(e),n})},[]),ie={required:p,trigger:_,onTriggerChange:v,valueNode:y,onValueNodeChange:b,valueNodeHasChildren:x,onValueNodeHasChildrenChange:S,contentId:te,value:E,onValueChange:O,hasConsumerStoppedPropagationRef:A,userSelection:j,onUserSelect:N,open:w,onOpenChange:T,dir:C,triggerPointerDownPosRef:k,disabled:f,name:u,autoComplete:d,form:m,nativeOptions:I,nativeSelectKey:ne,isFormControl:F};return(0,W.jsx)(cu,{...g,children:(0,W.jsx)(Of,{scope:t,...ie,children:(0,W.jsx)(Sf.Provider,{scope:t,children:(0,W.jsx)(Af,{scope:t,onNativeOptionAdd:re,onNativeOptionRemove:L,children:yp(h)?h(ie):n})})})})}gf(Mf,`SelectProvider`);var Nf=gf(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,W.jsx)(Mf,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,W.jsxs)(W.Fragment,{children:[n,e?(0,W.jsx)(vp,{__scopeSelect:t}):null]})})},`Select`),Pf=`SelectTrigger`,Ff=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=Df(n),o=kf(Pf,n),s=o.disabled||r,c=Hn(t,o.onTriggerChange),l=Cf(n),u=D.useRef(`touch`),[d,f,p]=xp(e=>{let t=l().filter(e=>!e.disabled),n=Sp(t,e,t.find(e=>e.value===o.value));n!==void 0&&o.onUserSelect(n.value)}),m=gf(e=>{s||(o.onOpenChange(!0),p()),e&&(o.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,W.jsx)(uu,{asChild:!0,...a,children:(0,W.jsx)(G.button,{type:`button`,role:`combobox`,"aria-controls":o.open?o.contentId:void 0,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":`none`,dir:o.dir,"data-state":o.open?`open`:`closed`,disabled:s,"data-disabled":s?``:void 0,"data-placeholder":bp(o.value)?``:void 0,...i,ref:c,onClick:K(i.onClick,e=>{e.currentTarget.focus(),u.current!==`mouse`&&m(e)}),onPointerDown:K(i.onPointerDown,e=>{u.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(m(e),e.preventDefault())}),onKeyDown:K(i.onKeyDown,e=>{let t=d.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(o.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),f(e.key)),t&&e.key===` `||yf.includes(e.key)&&(m(),e.preventDefault())})})})},`SelectTrigger`)),If=`SelectValue`,Lf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:o=``,...s}=e,c=kf(If,n),{onValueNodeHasChildrenChange:l}=c,u=a!==void 0,d=Hn(t,c.onValueNodeChange);br(()=>{l(u)},[l,u]);let f=bp(c.value);return(0,W.jsx)(G.span,{...s,asChild:!f&&s.asChild,ref:d,style:{pointerEvents:`none`},children:(0,W.jsx)(D.Fragment,{children:f?o:a},f?`placeholder`:`value`)})},`SelectValue`)),Rf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,W.jsx)(G.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[zf,Bf]=Tf(`SelectPortal`,{forceMount:void 0}),Vf=gf(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,W.jsx)(zf,{scope:e.__scopeSelect,forceMount:n,children:(0,W.jsx)(aa,{asChild:!0,...r})})},`SelectPortal`),Hf=`SelectContent`,Uf=D.forwardRef(gf(function(e,t){let n=Bf(Hf,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=kf(Hf,e.__scopeSelect),[o,s]=D.useState();return br(()=>{s(new DocumentFragment)},[]),(0,W.jsx)(ii,{present:r||a.open,children:({present:e})=>e?(0,W.jsx)(Yf,{...i,ref:t}):(0,W.jsx)(Wf,{...i,fragment:o})})},`SelectContent`)),Wf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?Un.createPortal((0,W.jsx)(Kf,{scope:n,children:(0,W.jsx)(Sf.Slot,{scope:n,children:(0,W.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Gf=10,[Kf,qf]=Tf(Hf),Jf=Kn(`SelectContent.RemoveScroll`),Yf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n}=e,{position:r=_f.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:a,onPointerDownOutside:o,side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g,..._}=e,v=kf(Hf,n),[y,b]=D.useState(null),[x,S]=D.useState(null),C=Hn(t,b),[w,T]=D.useState(null),[E,O]=D.useState(null),k=Cf(n),[A,j]=D.useState(!1),M=D.useRef(!1),N=D.useRef(!1),P=D.useRef(!1);D.useEffect(()=>{if(y)return Ao(y)},[y]),da();let F=D.useCallback(e=>{let[t,...n]=k().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&x&&(x.scrollTop=0),n===r&&x&&(x.scrollTop=x.scrollHeight),n?.focus(),document.activeElement!==i))return},[k,x]),I=D.useCallback(()=>F([w,y]),[F,w,y]);D.useEffect(()=>{A&&I()},[A,I]);let{onOpenChange:ee,triggerPointerDownPosRef:te}=v;D.useEffect(()=>{if(y){let e={x:0,y:0},t=gf(t=>{e={x:Math.abs(Math.round(t.pageX)-(te.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(te.current?.y??0))}},`handlePointerMove`),n=gf(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(y)||ee(!1),document.removeEventListener(`pointermove`,t),te.current=null},`handlePointerUp`);return te.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[y,ee,te]),D.useEffect(()=>{let e=gf(()=>ee(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[ee]);let[ne,re]=xp(e=>{let t=k().filter(e=>!e.disabled),n=Sp(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),L=D.useCallback((e,t,n)=>{let r=!N.current;r&&(N.current=!0);let i=!M.current&&!n;v.value!==void 0&&v.value===t||i?(T(e),i&&(M.current=!0)):r&&T(e)},[v.value]),ie=D.useCallback(()=>y?.focus(),[y]),ae=D.useCallback((e,t,n)=>{if(!e)return;let r=!P.current;r&&(P.current=!0);let i=!M.current&&!n;(v.value!==void 0&&v.value===t||i||r)&&O(e)},[v.value]),oe=r===_f.Popper?Zf:Xf,R=oe===Zf?{side:s,sideOffset:c,align:l,alignOffset:u,arrowPadding:d,collisionBoundary:f,collisionPadding:p,sticky:m,hideWhenDetached:h,avoidCollisions:g}:{};return(0,W.jsx)(Kf,{scope:n,content:y,viewport:x,onViewportChange:S,itemRefCallback:L,selectedItem:w,onItemLeave:ie,itemTextRefCallback:ae,focusSelectedItem:I,selectedItemText:E,position:r,isPositioned:A,searchRef:ne,children:(0,W.jsx)(xo,{as:Jf,allowPinchZoom:!0,children:(0,W.jsx)(Ui,{asChild:!0,trapped:v.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:K(i,e=>{v.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,W.jsx)(ji,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>v.onOpenChange(!1),children:(0,W.jsx)(oe,{role:`listbox`,id:v.contentId,"data-state":v.open?`open`:`closed`,dir:v.dir,onContextMenu:e=>e.preventDefault(),..._,...R,onPlaced:()=>j(!0),ref:C,style:{display:`flex`,flexDirection:`column`,outline:`none`,..._.style},onKeyDown:K(_.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&re(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=k().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>F(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Xf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=kf(Hf,n),o=qf(Hf,n),[s,c]=D.useState(null),[l,u]=D.useState(null),d=Hn(t,u),f=Cf(n),p=D.useRef(!1),m=D.useRef(!0),{viewport:h,selectedItem:g,selectedItemText:_,focusSelectedItem:v}=o,y=D.useCallback(()=>{if(a.trigger&&a.valueNode&&s&&l&&h&&g&&_){let e=a.trigger.getBoundingClientRect(),t=l.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=_.getBoundingClientRect();if(a.dir!==vf.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Gf,d=mf(a,[Gf,Math.max(Gf,u-l)]);s.style.minWidth=c+`px`,s.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,c=e.width+o,l=Math.max(c,t.width),u=window.innerWidth-Gf,d=mf(a,[Gf,Math.max(Gf,u-l)]);s.style.minWidth=c+`px`,s.style.right=d+`px`}let o=f(),c=window.innerHeight-Gf*2,u=h.scrollHeight,d=window.getComputedStyle(l),m=parseInt(d.borderTopWidth,10),v=parseInt(d.paddingTop,10),y=parseInt(d.borderBottomWidth,10),b=parseInt(d.paddingBottom,10),x=m+v+u+b+y,S=Math.min(g.offsetHeight*5,x),C=window.getComputedStyle(h),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Gf,D=c-E,O=g.offsetHeight/2,k=g.offsetTop+O,A=m+v+k,j=x-A;if(A<=E){let e=o.length>0&&g===o[o.length-1].ref.current;s.style.bottom=`0px`;let t=l.clientHeight-h.offsetTop-h.offsetHeight,n=A+Math.max(D,O+(e?T:0)+t+y);s.style.height=n+`px`}else{let e=o.length>0&&g===o[0].ref.current;s.style.top=`0px`;let t=Math.max(E,m+h.offsetTop+(e?w:0)+O)+j;s.style.height=t+`px`,h.scrollTop=A-E+h.offsetTop}s.style.margin=`${Gf}px 0`,s.style.minHeight=S+`px`,s.style.maxHeight=c+`px`,r?.(),requestAnimationFrame(()=>p.current=!0)}},[f,a.trigger,a.valueNode,s,l,h,g,_,a.dir,r]);br(()=>y(),[y]);let[b,x]=D.useState();br(()=>{l&&x(window.getComputedStyle(l).zIndex)},[l]);let S=D.useCallback(e=>{e&&m.current===!0&&(y(),v?.(),m.current=!1)},[y,v]);return(0,W.jsx)(Qf,{scope:n,contentWrapper:s,shouldExpandOnScrollRef:p,onScrollButtonChange:S,children:(0,W.jsx)(`div`,{ref:c,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:b},children:(0,W.jsx)(G.div,{...i,ref:d,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Zf=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Gf,...a}=e,o=Df(n);return(0,W.jsx)(mu,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[Qf,$f]=Tf(Hf,{}),ep=`SelectViewport`,tp=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=qf(ep,n),o=$f(ep,n),s=Hn(t,a.onViewportChange),c=D.useRef(0);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,W.jsx)(Sf.Slot,{scope:n,children:(0,W.jsx)(G.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:s,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:K(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=o;if(r?.current&&n){let e=Math.abs(c.current-t.scrollTop);if(e>0){let r=window.innerHeight-Gf*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}c.current=t.scrollTop})})})]})},`SelectViewport`)),[np,rp]=Tf(`SelectGroup`),ip=`SelectItem`,[ap,op]=Tf(ip),sp=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...o}=e,s=kf(ip,n),c=qf(ip,n),l=s.value===r,[u,d]=D.useState(a??``),[f,p]=D.useState(!1),m=Hn(t,Ci(e=>c.itemRefCallback?.(e,r,i))),h=mi(),g=D.useRef(`touch`);function _(e){s.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),s.onUserSelect(r),s.onOpenChange(!1)}return gf(_,`handleSelect`),(0,W.jsx)(ap,{scope:n,value:r,disabled:i,textId:h,isSelected:l,onItemTextChange:D.useCallback(e=>{d(t=>t||(e?.textContent??``).trim())},[]),children:(0,W.jsx)(Sf.ItemSlot,{scope:n,value:r,disabled:i,textValue:u,children:(0,W.jsx)(G.div,{role:`option`,"aria-labelledby":h,"data-highlighted":f?``:void 0,"aria-selected":l&&f,"data-state":l?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...o,ref:m,onFocus:K(o.onFocus,()=>p(!0)),onBlur:K(o.onBlur,()=>p(!1)),onClick:K(o.onClick,e=>{i||g.current!==`mouse`&&_(e)}),onPointerUp:K(o.onPointerUp,e=>{i||g.current===`mouse`&&_(e)}),onPointerDown:K(o.onPointerDown,e=>{g.current=e.pointerType}),onPointerMove:K(o.onPointerMove,e=>{g.current=e.pointerType,i?c.onItemLeave?.():g.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:K(o.onPointerLeave,e=>{e.currentTarget===document.activeElement&&c.onItemLeave?.()}),onKeyDown:K(o.onKeyDown,e=>{i||e.target!==e.currentTarget||(c.searchRef?.current===``||e.key!==` `)&&(bf.includes(e.key)&&_(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),cp=`SelectItemText`,lp=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,o=kf(cp,n),s=qf(cp,n),c=op(cp,n),l=jf(cp,n),[u,d]=D.useState(null),f=Ci(e=>s.itemTextRefCallback?.(e,c.value,c.disabled)),p=Hn(t,d,c.onItemTextChange,f),m=u?.textContent,h=D.useMemo(()=>(0,W.jsx)(`option`,{value:c.value,disabled:c.disabled,children:m},c.value),[c.disabled,c.value,m]),{onNativeOptionAdd:g,onNativeOptionRemove:_}=l;return br(()=>(g(h),()=>_(h)),[g,_,h]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(G.span,{id:c.textId,...a,ref:p}),c.isSelected&&o.valueNode&&!o.valueNodeHasChildren&&!bp(o.value)?Un.createPortal(a.children,o.valueNode):null]})},`SelectItemText`)),up=`SelectItemIndicator`,dp=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,...r}=e;return op(up,n).isSelected?(0,W.jsx)(G.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),fp=`SelectScrollUpButton`,pp=D.forwardRef(gf(function(e,t){let n=qf(fp,e.__scopeSelect),r=$f(fp,e.__scopeSelect),[i,a]=D.useState(!1),o=Hn(t,r.onScrollButtonChange);return br(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};gf(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(gp,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),mp=`SelectScrollDownButton`,hp=D.forwardRef(gf(function(e,t){let n=qf(mp,e.__scopeSelect),r=$f(mp,e.__scopeSelect),[i,a]=D.useState(!1),o=Hn(t,r.onScrollButtonChange);return br(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};gf(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,W.jsx)(gp,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),gp=D.forwardRef(gf(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=qf(`SelectScrollButton`,n),o=D.useRef(null),s=Cf(n),c=D.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return D.useEffect(()=>()=>c(),[c]),br(()=>{s().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[s]),(0,W.jsx)(G.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:K(i.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:K(i.onPointerMove,()=>{a.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:K(i.onPointerLeave,()=>{c()})})},`SelectScrollButtonImpl`)),_p=`SelectBubbleInput`,vp=D.forwardRef(gf(function({__scopeSelect:e,...t},n){let r=kf(_p,e),{value:i,onValueChange:a,required:o,disabled:s,name:c,autoComplete:l,form:u,userSelection:d}=r,{nativeOptions:f,nativeSelectKey:p}=r,m=D.useRef(null),h=Hn(n,m),g=i??``,_=D.useRef(g),v=D.useRef(d),y=D.useRef(!1),b=Array.from(f).some(e=>(e.props.value??``)===``);return D.useEffect(()=>{let e=m.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=d!==null&&d!==v.current;v.current=d;let i=_.current!==g;_.current=g;let a=r&&i;if(r&&!i&&d.value!==g&&!d.hasConsumerStoppedPropagation&&n){y.current=!0;try{n.call(e,d.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{y.current=!1,n.call(e,g)}return}let o=a&&!d.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,g),e.dispatchEvent(t)}},[g,d]),(0,W.jsxs)(G.select,{"aria-hidden":!0,required:o,tabIndex:-1,name:c,autoComplete:l,disabled:s,form:u,onChange:e=>{y.current||a(e.target.value)},...t,style:{...pr,...t.style},ref:h,defaultValue:g,children:[bp(i)&&!b?(0,W.jsx)(`option`,{value:``}):null,Array.from(f)]},p)},`SelectBubbleInput`));function yp(e){return typeof e==`function`}gf(yp,`isFunction`);function bp(e){return e===``||e===void 0}gf(bp,`shouldShowPlaceholder`);function xp(e){let t=Ci(e),n=D.useRef(``),r=D.useRef(0),i=D.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}gf(a,`updateSearch`),a(i)},[t]),a=D.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return D.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}gf(xp,`useTypeaheadSearch`);function Sp(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Cp(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}gf(Sp,`findNextItem`);function Cp(e,t){return e.map((n,r)=>e[(t+r)%e.length])}gf(Cp,`wrapArray`);var wp=Object.defineProperty,Tp=(e,t)=>wp(e,`name`,{value:t,configurable:!0}),Ep={Horizontal:`horizontal`,Vertical:`vertical`},Dp=Ep.Horizontal,Op=Object.values(Ep),kp=D.forwardRef(Tp(function(e,t){let{decorative:n,orientation:r=Dp,...i}=e,a=Ap(r)?r:Dp,o=a===Ep.Vertical?a:void 0,s=n?{role:`none`}:{"aria-orientation":o,role:`separator`};return(0,W.jsx)(G.div,{"data-orientation":a,...s,...i,ref:t})},`Separator`));function Ap(e){return Op.includes(e)}Tp(Ap,`isValidOrientation`);var jp=Object.defineProperty,Mp=(e,t)=>jp(e,`name`,{value:t,configurable:!0}),Np=`Switch`,[Pp,Fp]=vr(Np),[Ip,Lp]=Pp(Np);function Rp(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=Xr({prop:n,defaultProp:i??!1,onChange:c,caller:Np}),[m,h]=D.useState(null),[g,_]=D.useState(null),[v,y]=D.useState(null),b={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,userClick:v,onUserClick:y,required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,W.jsx)(Ip,{scope:t,...b,children:Kp(d)?d(b):r})}Mp(Rp,`SwitchProvider`);var zp=`SwitchTrigger`,Bp=D.forwardRef(Mp(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,onUserClick:f,isFormControl:p,bubbleInput:m}=Lp(zp,e),h=Hn(r,u),g=D.useRef(c);return D.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=Mp(()=>d(g.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,W.jsx)(G.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":qp(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:h,onClick:K(t,e=>{let t=e.isPropagationStopped();f({requestedChecked:!c,hasConsumerStoppedPropagation:t}),d(e=>!e),m&&p&&(t||e.stopPropagation())})})},`SwitchTrigger`)),Vp=D.forwardRef(Mp(function(e,t){let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,W.jsx)(Rp,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Bp,{...d,ref:t,__scopeSwitch:n}),e&&(0,W.jsx)(Gp,{__scopeSwitch:n})]})})},`Switch`)),Hp=`SwitchThumb`,Up=D.forwardRef(Mp(function(e,t){let{__scopeSwitch:n,...r}=e,i=Lp(Hp,n);return(0,W.jsx)(G.span,{"data-state":qp(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})},`SwitchThumb`)),Wp=`SwitchBubbleInput`,Gp=D.forwardRef(Mp(function({__scopeSwitch:e,onClick:t,...n},r){let{control:i,userClick:a,checked:o,defaultChecked:s,required:c,disabled:l,name:u,value:d,form:f,bubbleInput:p,setBubbleInput:m}=Lp(Wp,e),h=Hn(r,m),g=zs(i),_=D.useRef(!1),v=D.useRef(o),y=D.useRef(a),b=D.useRef(null);D.useEffect(()=>{let e=p;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set;if(!n)return;let r=v.current!==o;v.current=o;let i=a!==null&&a!==y.current;if(y.current=a,i)b.current=r?null:a,r&&n.call(e,o),e.dispatchEvent(new Event(`click`,{bubbles:!a.hasConsumerStoppedPropagation}));else if(r){let t=b.current;b.current=null;let r=t?.requestedChecked===o;_.current=!0,n.call(e,o),e.dispatchEvent(new Event(`click`,{bubbles:!(r&&t.hasConsumerStoppedPropagation)})),_.current=!1}},[p,o,a]);let x=D.useRef(o);return(0,W.jsx)(G.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:s??x.current,required:c,disabled:l,name:u,value:d,form:f,...n,tabIndex:-1,ref:h,onClick:K(t,e=>{_.current&&e.stopPropagation()}),style:{...n.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`SwitchBubbleInput`));function Kp(e){return typeof e==`function`}Mp(Kp,`isFunction`);function qp(e){return e?`checked`:`unchecked`}Mp(qp,`getState`);var Jp=Object.defineProperty,Yp=(e,t)=>Jp(e,`name`,{value:t,configurable:!0}),Xp={Automatic:`automatic`,Manual:`manual`},Zp=`Tabs`,[Qp,$p]=vr(Zp,[Ru]),em=Ru(),[tm,nm]=Qp(Zp),rm=D.forwardRef(Yp(function(e,t){let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=Xp.Automatic,...l}=e,u=yi(s),[d,f]=Xr({prop:r,onChange:i,defaultProp:a??``,caller:Zp});return(0,W.jsx)(tm,{scope:n,baseId:mi(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,W.jsx)(G.div,{dir:u,"data-orientation":o,...l,ref:t})})},`Tabs`)),im=`TabsList`,am=D.forwardRef(Yp(function(e,t){let{__scopeTabs:n,loop:r=!0,...i}=e,a=nm(im,n),o=em(n);return(0,W.jsx)(Uu,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,W.jsx)(G.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})},`TabsList`)),om=`TabsTrigger`,sm=D.forwardRef(Yp(function(e,t){let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=nm(om,n),s=em(n),c=cm(o.baseId,r),l=lm(o.baseId,r),u=r===o.value;return(0,W.jsx)(Ku,{asChild:!0,...s,focusable:!i,active:u,children:(0,W.jsx)(G.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:K(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?(e.currentTarget.focus(),o.onValueChange(r)):e.preventDefault()}),onKeyDown:K(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:K(e.onFocus,()=>{let e=o.activationMode!==Xp.Manual;!u&&!i&&e&&o.onValueChange(r)})})})},`TabsTrigger`));function cm(e,t){return`${e}-trigger-${t}`}Yp(cm,`makeTriggerId`);function lm(e,t){return`${e}-content-${t}`}Yp(lm,`makeContentId`);var um=Object.defineProperty,dm=(e,t)=>um(e,`name`,{value:t,configurable:!0}),fm=`Toggle`,pm=D.forwardRef(dm(function(e,t){let{pressed:n,defaultPressed:r,onPressedChange:i,...a}=e,[o,s]=Xr({prop:n,onChange:i,defaultProp:r??!1,caller:fm});return(0,W.jsx)(G.button,{type:`button`,"aria-pressed":o,"data-state":o?`on`:`off`,"data-disabled":e.disabled?``:void 0,...a,ref:t,onClick:K(e.onClick,()=>{e.disabled||s(!o)})})},`Toggle`)),mm=Object.defineProperty,hm=(e,t)=>mm(e,`name`,{value:t,configurable:!0}),[gm,_m]=vr(`Tooltip`,[au]),vm=au(),ym=`TooltipProvider`,bm=700,xm=`tooltip.open`,[Sm,Cm]=gm(ym),wm=hm(e=>{let{__scopeTooltip:t,delayDuration:n=bm,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=D.useRef(!0),s=D.useRef(!1),c=D.useRef(0);return D.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,W.jsx)(Sm,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:D.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:D.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:D.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),Tm=`Tooltip`,[Em,Dm]=gm(Tm),Om=hm(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Cm(Tm,e.__scopeTooltip),l=vm(t),[u,d]=D.useState(null),[f,p]=D.useState(void 0),m=mi(),h=D.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=D.useRef(!1),[y,b]=Xr({prop:r,defaultProp:i??!1,onChange:hm(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(xm))):c.onClose(),a?.(e)},`onChange`),caller:Tm}),x=D.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=D.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=D.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=D.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);D.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,W.jsx)(cu,{...l,children:(0,W.jsx)(Em,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:D.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:D.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),km=`TooltipTrigger`,Am=D.forwardRef(hm(function(e,t){let{__scopeTooltip:n,"aria-describedby":r,...i}=e,a=Dm(km,n),o=Cm(km,n),s=vm(n),c=Hn(t,D.useRef(null),a.onTriggerChange),l=D.useRef(!1),u=D.useRef(!1),d=D.useCallback(()=>l.current=!1,[]);return D.useEffect(()=>()=>document.removeEventListener(`pointerup`,d),[d]),(0,W.jsx)(uu,{asChild:!0,...s,children:(0,W.jsx)(G.button,{"aria-describedby":a.open?qm(r,a.contentId):r,"data-state":a.stateAttribute,...i,ref:c,onPointerMove:K(e.onPointerMove,e=>{e.pointerType!==`touch`&&!u.current&&!o.isPointerInTransitRef.current&&(a.onTriggerEnter(),u.current=!0)}),onPointerLeave:K(e.onPointerLeave,()=>{a.onTriggerLeave(),u.current=!1}),onPointerDown:K(e.onPointerDown,()=>{a.open&&a.onClose(),l.current=!0,document.addEventListener(`pointerup`,d,{once:!0})}),onFocus:K(e.onFocus,()=>{l.current||a.onOpen()}),onBlur:K(e.onBlur,a.onClose),onClick:K(e.onClick,a.onClose)})})},`TooltipTrigger`)),jm=`TooltipPortal`,[Mm,Nm]=gm(jm,{forceMount:void 0}),Pm=hm(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Dm(jm,t);return(0,W.jsx)(Mm,{scope:t,forceMount:n,children:(0,W.jsx)(ii,{present:n||a.open,children:(0,W.jsx)(aa,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),Fm=`TooltipContent`,Im=D.forwardRef(hm(function(e,t){let n=Nm(Fm,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Dm(Fm,e.__scopeTooltip);return(0,W.jsx)(ii,{present:r||o.open,children:o.disableHoverableContent?(0,W.jsx)(zm,{side:i,...a,ref:t}):(0,W.jsx)(Lm,{side:i,...a,ref:t})})},`TooltipContent`)),Lm=D.forwardRef(hm(function(e,t){let n=Dm(Fm,e.__scopeTooltip),r=Cm(Fm,e.__scopeTooltip),i=D.useRef(null),a=Hn(t,i),[o,s]=D.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=D.useCallback(()=>{s(null),d(!1)},[d]),p=D.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Hm(r,Vm(r,n.getBoundingClientRect())),a=Um(t.getBoundingClientRect()),o=Gm([...i,...a]);s(o),d(!0)},[d]);return D.useEffect(()=>()=>f(),[f]),D.useEffect(()=>{if(c&&u){let e=hm(e=>p(e,u),`handleTriggerLeave`),t=hm(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),D.useEffect(()=>{if(o){let e=hm(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Wm(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,W.jsx)(zm,{...e,ref:a})},`TooltipContentHoverable`)),Rm=Yn(`TooltipContent`),zm=D.forwardRef(hm(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=Dm(Fm,n),u=vm(n),{onClose:d}=l,[f,p]=D.useState(null),m=Hn(t,p);qi(f),D.useEffect(()=>(document.addEventListener(xm,d),()=>document.removeEventListener(xm,d)),[d]),D.useEffect(()=>{if(l.trigger){let e=hm(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:h}=l;return br(()=>(h(a),()=>{h(void 0)}),[a,h]),(0,W.jsx)(ji,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,W.jsxs)(mu,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:m,style:{...c.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,W.jsx)(Rm,{children:r}),i?(0,W.jsx)(mr,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),Bm=D.forwardRef(hm(function(e,t){let{__scopeTooltip:n,...r}=e,i=vm(n);return(0,W.jsx)(_u,{...i,...r,ref:t})},`TooltipArrow`));function Vm(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}hm(Vm,`getExitSideFromRect`);function Hm(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n})}return r}hm(Hm,`getPaddedExitPoints`);function Um(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}hm(Um,`getPointsFromRect`);function Wm(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}hm(Wm,`isPointInPolygon`);function Gm(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Km(t)}hm(Gm,`getHull`);function Km(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}hm(Km,`getHullPresorted`);function qm(...e){let t=new Set;for(let n of e)if(typeof n==`string`)for(let e of String(n).trim().split(/\s+/))e&&t.add(e);return t.size>0?Array.from(t).join(` `):void 0}hm(qm,`concatAriaDescribedby`);function Jm({...e}){return(0,W.jsx)(`nav`,{"aria-label":`breadcrumb`,"data-slot":`breadcrumb`,...e})}function Ym({className:e,...t}){return(0,W.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:U(`flex flex-wrap items-center gap-1.5 text-sm break-words text-muted-foreground sm:gap-2.5`,e),...t})}function Xm({className:e,...t}){return(0,W.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:U(`inline-flex items-center gap-1.5`,e),...t})}function Zm({asChild:e,className:t,...n}){let r=e?qn:`a`;return(0,W.jsx)(r,{"data-slot":`breadcrumb-link`,className:U(`transition-colors hover:text-foreground`,t),...n})}function Qm({className:e,...t}){return(0,W.jsx)(`span`,{"data-slot":`breadcrumb-page`,role:`link`,"aria-disabled":`true`,"aria-current":`page`,className:U(`font-normal text-foreground`,e),...t})}function $m({children:e,className:t,...n}){return(0,W.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:U(`[&>svg]:size-3.5`,t),...n,children:e??(0,W.jsx)(R,{})})}var eh={waiting:`is waiting for you`,bell:`rang the bell`,working:`is working`,idle:`is idle`},th={waiting:`bg-status-waiting`,bell:`bg-status-bell`,idle:`bg-status-idle`};function nh({marker:e,className:t}){return(0,W.jsx)(`span`,{className:U(`relative size-2 shrink-0 rounded-full`,th[e],t),children:e===`waiting`&&(0,W.jsx)(`span`,{className:`absolute inset-0 animate-ping rounded-full bg-status-waiting/70`})})}function rh({className:e,size:t=`default`,...n}){return(0,W.jsx)(As,{"data-slot":`avatar`,"data-size":t,className:U(`group/avatar relative flex size-8 shrink-0 overflow-hidden rounded-full select-none data-[size=lg]:size-10 data-[size=sm]:size-6`,e),...n})}function ih({className:e,...t}){return(0,W.jsx)(Ms,{"data-slot":`avatar-fallback`,className:U(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}function ah(e){let[t=``,n]=e.split(/[^\p{L}\p{N}]+/u).filter(Boolean);return n===void 0?t.slice(0,2).toUpperCase()||`?`:((t[0]??``)+(n[0]??``)).toUpperCase()}function oh(e){let t=0;for(let n of e)t=(t*31+(n.codePointAt(0)??0))%360;return t}function sh({workspace:e,size:t=`sm`,marker:n=null,className:r}){let i=oh(e.name),a=t===`md`;return(0,W.jsxs)(`span`,{className:U(`relative inline-flex shrink-0`,r),children:[(0,W.jsx)(rh,{"aria-hidden":`true`,className:a?`size-8 rounded-lg`:`size-5 rounded-md`,children:(0,W.jsx)(ih,{className:U(`rounded-[inherit] font-semibold tracking-tight`,a?`text-xs`:`text-[9px]`),style:{background:`oklch(0.36 0.07 ${i})`,color:`oklch(0.92 0.06 ${i})`},children:ah(e.name)})}),n&&(0,W.jsx)(`span`,{role:`img`,"aria-label":`${e.name} has a session that ${eh[n]}`,className:U(`absolute -top-0.5 -right-0.5 grid`,a?`size-2.5`:`size-2`),children:(0,W.jsx)(nh,{marker:n,className:`size-full ring-2 ring-sidebar`})}),e.missing&&(0,W.jsx)(`span`,{role:`img`,"aria-label":`${e.name} is Missing`,className:`absolute -right-1 -bottom-1 rounded-full bg-sidebar text-destructive`,children:(0,W.jsx)($e,{className:a?`size-3.5`:`size-3`})})]})}function ch({workspace:e,session:t}){return(0,W.jsx)(Jm,{className:`min-w-0 px-1`,children:(0,W.jsxs)(Ym,{className:`flex-nowrap gap-1.5 sm:gap-2`,children:[(0,W.jsxs)(Xm,{className:`min-w-0`,children:[(0,W.jsx)(sh,{workspace:e}),(0,W.jsx)(`h1`,{className:`truncate text-sm font-medium text-foreground`,title:e.folder,children:e.name})]}),t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)($m,{}),(0,W.jsxs)(Xm,{className:`min-w-0`,children:[(0,W.jsx)(Ln,{session:t,className:`size-3.5`}),(0,W.jsx)(Qm,{className:`truncate text-sm text-muted-foreground`,children:t.name})]})]})]})})}var lh=`(max-width: 767px)`;function uh(){return(0,D.useSyncExternalStore)(e=>{let t=window.matchMedia(lh);return t.addEventListener(`change`,e),()=>t.removeEventListener(`change`,e)},()=>window.matchMedia(lh).matches)}var dh=`k-bench.smart-typing`;function fh(){try{let e=JSON.parse(localStorage.getItem(dh)??`[]`);return new Set(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])}catch{return new Set}}function ph(e){try{e.size===0?localStorage.removeItem(dh):localStorage.setItem(dh,JSON.stringify([...e]))}catch{}}var mh=fh(),hh=new Set;function gh(e){mh=e,ph(mh);for(let e of hh)e()}function _h(e){return hh.add(e),()=>hh.delete(e)}function vh(e){return(0,D.useSyncExternalStore)(_h,()=>!mh.has(e))}function yh(e,t){if(mh.has(e)===!t)return;let n=new Set(mh);t?n.delete(e):n.add(e),gh(n)}function bh(e){let t=new Set([...mh].filter(t=>e.has(t)));t.size!==mh.size&&gh(t)}function xh(){return/iPhone/.test(navigator.userAgent)}function Sh(){return uh()&&xh()}var Ch=null;function wh(e){return Ch=e,()=>{Ch===e&&(Ch=null)}}function Th(){Ch?.blur()}var Eh={esc:`\x1B`,tab:` `,shiftTab:`\x1B[Z`,enter:`\r`,newLine:`
|
|
50
|
+
`,left:`\x1B[D`,up:`\x1B[A`,down:`\x1B[B`,right:`\x1B[C`};function Dh(e){Ch?.send(e),Ch?.clearTypedLine()}function Oh(){return typeof navigator<`u`&&typeof navigator.clipboard?.readText==`function`}async function kh(){if(!Oh())return;let e;try{e=await navigator.clipboard.readText()}catch{return}e&&(Mh(!1),Ch?.paste(e),Ch?.clearTypedLine())}var Ah=!1,jh=new Set;function Mh(e){if(Ah!==e){Ah=e;for(let e of jh)e()}}function Nh(){return(0,D.useSyncExternalStore)(e=>(jh.add(e),()=>jh.delete(e)),()=>Ah)}function Ph(){return Ah}function Fh(){Ch?.clearTypedLine(),Mh(!Ah)}var Ih={" ":`\0`,"@":`\0`,"[":`\x1B`,"\\":``,"]":``,"^":``,_:``,"?":``};function Lh(e){return e.length===1?/^[a-z]$/i.test(e)?String.fromCharCode(e.toLowerCase().charCodeAt(0)-96):Ih[e]??e:e}function Rh(e){return Ah?(Mh(!1),Lh(e)):e}var zh=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Bh=it,Vh=(e,t)=>n=>{if(t?.variants==null)return Bh(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=zh(t)||zh(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Bh(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},Hh=Vh(`inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function Uh({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?qn:`button`;return(0,W.jsx)(a,{"data-slot":`button`,"data-variant":t,"data-size":n,className:U(Hh({variant:t,size:n,className:e})),...i})}function Wh({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,W.jsx)(kp,{"data-slot":`separator`,decorative:n,orientation:t,className:U(`shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px`,e),...r})}var Gh=Vh(`flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1`,{variants:{orientation:{horizontal:`[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none`,vertical:`flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none`}},defaultVariants:{orientation:`horizontal`}});function Kh({className:e,orientation:t,...n}){return(0,W.jsx)(`div`,{role:`group`,"data-slot":`button-group`,"data-orientation":t,className:U(Gh({orientation:t}),e),...n})}var qh=Vh(`inline-flex items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-[color,box-shadow] outline-none hover:bg-muted hover:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-transparent`,outline:`border border-input bg-transparent shadow-xs hover:bg-accent hover:text-accent-foreground`},size:{default:`h-9 min-w-9 px-2`,sm:`h-8 min-w-8 px-1.5`,lg:`h-10 min-w-10 px-2.5`}},defaultVariants:{variant:`default`,size:`default`}});function Jh({className:e,variant:t,size:n,...r}){return(0,W.jsx)(pm,{"data-slot":`toggle`,className:U(qh({variant:t,size:n,className:e})),...r})}var Yh=e=>e.preventDefault(),Xh=`h-10 min-w-0 px-0`,Zh=U(Xh,`data-[state=on]:border-primary data-[state=on]:bg-primary data-[state=on]:text-primary-foreground`);function Qh({name:e,data:t,children:n}){return(0,W.jsx)(Uh,{variant:`outline`,"aria-label":e,className:Xh,onMouseDown:Yh,onClick:()=>Dh(t),children:n})}function $h({sessionId:e}){let t=Nh(),n=Sh(),r=vh(e);return(0,W.jsxs)(Kh,{"aria-label":`Extra keys`,className:`grid w-full shrink-0 auto-cols-fr grid-flow-col border-t bg-sidebar p-1`,children:[(0,W.jsx)(Qh,{name:`Esc`,data:Eh.esc,children:`⎋`}),(0,W.jsx)(Qh,{name:`Tab`,data:Eh.tab,children:`⇥`}),(0,W.jsx)(Qh,{name:`Shift Tab`,data:Eh.shiftTab,children:`⇤`}),(0,W.jsx)(Jh,{variant:`outline`,pressed:t,className:Zh,onMouseDown:Yh,onPressedChange:Fh,children:`Ctrl`}),(0,W.jsx)(Qh,{name:`Left`,data:Eh.left,children:(0,W.jsx)(F,{})}),(0,W.jsx)(Qh,{name:`Up`,data:Eh.up,children:(0,W.jsx)(ne,{})}),(0,W.jsx)(Qh,{name:`Down`,data:Eh.down,children:(0,W.jsx)(N,{})}),(0,W.jsx)(Qh,{name:`Right`,data:Eh.right,children:(0,W.jsx)(ee,{})}),(0,W.jsx)(Qh,{name:`Enter`,data:Eh.enter,children:`⏎`}),n&&(0,W.jsx)(Jh,{variant:`outline`,"aria-label":`Smart typing`,pressed:r,className:Zh,onMouseDown:Yh,onPressedChange:t=>yh(e,t),children:(0,W.jsx)(Ge,{})})]})}var eg=Vh(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function tg({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?qn:`span`;return(0,W.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:U(eg({variant:t}),e),...r})}function ng(e){let t=document.activeElement;t&&t!==document.body&&e.preventDefault()}function rg({...e}){return(0,W.jsx)(Lo,{"data-slot":`sheet`,...e})}function ig({...e}){return(0,W.jsx)(zo,{"data-slot":`sheet-trigger`,...e})}function ag({...e}){return(0,W.jsx)(Uo,{"data-slot":`sheet-portal`,...e})}function og({className:e,...t}){return(0,W.jsx)(Go,{"data-slot":`sheet-overlay`,className:U(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function sg({className:e,children:t,side:n=`right`,showCloseButton:r=!0,...i}){return(0,W.jsxs)(ag,{children:[(0,W.jsx)(og,{}),(0,W.jsxs)(Yo,{"data-slot":`sheet-content`,onCloseAutoFocus:ng,className:U(`fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,e),...i,children:[t,r&&(0,W.jsxs)(ns,{className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,W.jsx)(tt,{className:`size-4`}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function cg({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`sheet-header`,className:U(`flex flex-col gap-1.5 p-4`,e),...t})}function lg({className:e,...t}){return(0,W.jsx)($o,{"data-slot":`sheet-title`,className:U(`font-semibold text-foreground`,e),...t})}function ug({className:e,...t}){return(0,W.jsx)(es,{"data-slot":`sheet-description`,className:U(`text-sm text-muted-foreground`,e),...t})}function dg(e){let t=e.find(e=>e.role===`prime`),n=e.find(e=>e.role===`worker`);return{prime:t,worker:n,primeAndWorker:[t,n].filter(e=>e!==void 0),others:e.filter(e=>e.role===null)}}function fg(e){return e.status===`stopped`?null:e.activity===`waiting`?`waiting`:e.bell?`bell`:e.activity}function pg(e){return e?.workspaces.find(t=>t.id===e.openWorkspaceId)}function mg(e){return e.some(e=>fg(e)===`waiting`)?`waiting`:e.some(e=>e.bell)?`bell`:null}function hg(e){return mg(e.sessions)}function gg({className:e,...t}){return(0,W.jsx)(Te,{role:`status`,"aria-label":`Loading`,className:U(`size-4 animate-spin`,e),...t})}function _g({session:e,className:t}){let n=fg(e);if(!n)return null;let r=`${e.name} ${eh[n]}`;return(0,W.jsx)(`span`,{role:`img`,"aria-label":r,title:r,className:U(`relative grid size-3.5 shrink-0 place-items-center`,t),children:n===`working`?(0,W.jsx)(gg,{"aria-hidden":`true`,className:`size-3.5 text-primary`}):(0,W.jsx)(nh,{marker:n})})}var vg=`/api/events`;function yg(e){let t;try{t=JSON.parse(e)}catch{return}if(typeof t==`object`&&t&&typeof t.revision==`number`&&Array.isArray(t.workspaces))return t}function bg(e){return Number(e.get(`State-Revision`)??NaN)}var xg=class extends Error{status;body;constructor(e,t,n={}){super(e),this.status=t,this.body=n}get folderOwner(){let e=this.body.workspace;return this.status===409&&typeof e?.id==`string`&&typeof e.name==`string`?{id:e.id,name:e.name}:void 0}};async function Sg(e,t){let n=await fetch(e,t),r=await n.json().catch(()=>({}));if(!n.ok)throw new xg(typeof r.error==`string`?r.error:`Request failed (${n.status})`,n.status,r);return{value:r,revision:bg(n.headers)}}async function Cg(e){return(await Sg(e)).value}function wg(e,t,n){return Sg(t,{method:e,headers:n===void 0?void 0:{"content-type":`application/json`},body:n===void 0?void 0:JSON.stringify(n)})}var Tg={listDirectories:(e,{hidden:t=!1}={})=>{let n=new URLSearchParams;return e!==void 0&&n.set(`path`,e),t&&n.set(`hidden`,`1`),Cg(`/api/directories?${n}`)},createWorkspace:e=>wg(`POST`,`/api/workspaces`,e),updateWorkspace:(e,t)=>wg(`PATCH`,`/api/workspaces/${e}`,t),reorderWorkspaces:e=>wg(`PUT`,`/api/workspaces/order`,{ids:e}),openWorkspace:e=>wg(`POST`,`/api/workspaces/${e}/open`),setRightPane:(e,t)=>wg(`PUT`,`/api/workspaces/${e}/right-pane`,t),deleteWorkspace:e=>wg(`DELETE`,`/api/workspaces/${e}`),lastLaunchOptions:()=>Cg(`/api/claude/launch-options`),createSession:(e,t={})=>wg(`POST`,`/api/workspaces/${e}/sessions`,t),renameSession:(e,t)=>wg(`PATCH`,`/api/sessions/${e}`,{name:t}),deleteSession:e=>wg(`DELETE`,`/api/sessions/${e}`),reorderSessions:(e,t)=>wg(`PUT`,`/api/workspaces/${e}/sessions/order`,{ids:t}),restartSession:e=>wg(`POST`,`/api/sessions/${e}/restart`,{})},Eg=500,Dg=1e4,Og=5e3;function kg(e){let{openSocket:t,showTimeoutMs:n=Og}=e,r=new Set,i=new Set,a,o,s,c=Eg,l=!1,u=0,d,f=()=>{clearTimeout(s),o&&=(o.onopen=null,o.onmessage=null,o.onclose=null,o.close(),void 0)},p=()=>{if(l)return;f();let e=++u;d=void 0;let n=t();o=n,n.onopen=()=>{c=Eg},n.onmessage=t=>{if(typeof t.data!=`string`)return;let n=yg(t.data);if(!n)return;let{revision:o,...s}=n;a=s,d=o;for(let e of r)e(s);for(let t of[...i])(t.connection<e||o>=t.revision)&&t.done(!0)},n.onclose=()=>{d=void 0,s=setTimeout(p,c),c=Math.min(c*2,Dg)}};return p(),{get state(){return a},subscribe(e){return r.add(e),a&&e(a),()=>{r.delete(e)}},whenShown({revision:e}){return l?Promise.resolve(!1):(d??-1)>=e?Promise.resolve(!0):new Promise(t=>{let r=setTimeout(()=>a.done(!1),n),a={revision:e,connection:u,done:e=>{clearTimeout(r),i.delete(a),t(e)}};i.add(a)})},resync:p,close(){l=!0,f(),r.clear();for(let e of[...i])e.done(!1)}}}function Ag(){let e=new URL(vg,window.location.href);return e.protocol=e.protocol===`https:`?`wss:`:`ws:`,e.toString()}function jg(e,t){return!e||t.length===0?e:{...e,workspaces:e.workspaces.map(e=>({...e,rightPane:t.reduce((t,n)=>n.workspaceId===e.id?n.change(t):t,e.rightPane)}))}}function Mg(){let[e,t]=(0,D.useState)(),[n,r]=(0,D.useState)([]),[i,a]=(0,D.useState)(),o=(0,D.useRef)(void 0);(0,D.useEffect)(()=>{let e=kg({openSocket:()=>new WebSocket(Ag())});o.current=e;let n=e.subscribe(t),r=()=>e.resync();return window.addEventListener(`focus`,r),()=>{window.removeEventListener(`focus`,r),n(),e.close(),o.current=void 0}},[]);let s=(0,D.useMemo)(()=>{let e=e=>o.current?.whenShown(e)??Promise.resolve(!1),n=async t=>{await e(await t)},i=async(e,t,n)=>{let i={workspaceId:e,change:t};r(e=>[...e,i]);try{await n()}finally{r(e=>e.filter(e=>e!==i))}},s=async e=>{a(void 0);try{return await e()}catch(e){if(!(e instanceof xg))throw e;a(e.message);return}};return{createWorkspace:async(e,t)=>{try{await n(Tg.createWorkspace(e))}catch(e){if(!(e instanceof xg)||!e.folderOwner)throw e;t(e.folderOwner.id),a(e.message)}},updateWorkspace:(e,t)=>n(Tg.updateWorkspace(e,t)),reorderWorkspaces:e=>(t(t=>t&&{...t,workspaces:e.flatMap(e=>t.workspaces.find(t=>t.id===e)??[])}),n(Tg.reorderWorkspaces(e)).catch(()=>o.current?.resync())),openWorkspace:async e=>{await s(()=>n(Tg.openWorkspace(e)))},setRightPane:(e,t)=>i(e,()=>t,()=>n(Tg.setRightPane(e,t)).catch(()=>o.current?.resync())),deleteWorkspace:e=>n(Tg.deleteWorkspace(e)),createSession:t=>s(async()=>{let n=await Tg.createSession(t);return await e(n)?n.value.id:void 0}),createClaudeSession:async(t,n)=>{let r=await Tg.createSession(t,n);return await e(r)?r.value.id:void 0},renameSession:(e,t)=>n(Tg.renameSession(e,t)),deleteSession:e=>n(Tg.deleteSession(e)),restartSession:async e=>{await s(()=>n(Tg.restartSession(e)))},reorderSessions:(e,r)=>(t(t=>t&&{...t,workspaces:t.workspaces.map(t=>t.id===e?{...t,sessions:[...dg(t.sessions).primeAndWorker,...r.flatMap(e=>t.sessions.find(t=>t.id===e)??[])]}:t)}),n(Tg.reorderSessions(e,r)).catch(()=>o.current?.resync()))}},[]);return{state:(0,D.useMemo)(()=>jg(e,n),[e,n]),actions:s,error:i}}var Ng=(0,D.createContext)(void 0),Pg=Ng.Provider;function Fg(){let e=(0,D.useContext)(Ng);if(!e)throw Error(`useActions needs an ActionsProvider above it`);return e}var Ig=`#161616`,Lg={background:Ig,foreground:`#e4e4e4`,cursor:`#e4e4e4`,cursorAccent:Ig,selectionBackground:`#3a3a3a`,black:`#2a2a2a`,red:`#ff6369`,green:`#62c073`,yellow:`#f3c15f`,blue:`#52a8ff`,magenta:`#bf7af0`,cyan:`#4fc3c7`,white:`#d0d0d0`,brightBlack:`#6b6b6b`,brightRed:`#ff8a8e`,brightGreen:`#85d897`,brightYellow:`#ffd88a`,brightBlue:`#7cbcff`,brightMagenta:`#d29ff6`,brightCyan:`#7ad9dc`,brightWhite:`#ffffff`},Rg=`"JetBrains Mono"`,zg=`${Rg}, ui-monospace, Menlo, monospace`,Bg=4.5;async function Vg(){try{await Promise.all([document.fonts.load(`400 13px ${Rg}`),document.fonts.load(`700 13px ${Rg}`)])}catch{}}function Hg(e){return e.slice(e.lastIndexOf(`/`)+1)}function Ug(e){return e.slice(0,e.lastIndexOf(`/`))||`/`}function Wg(e,...t){return t.reduce((e,t)=>e===`/`?`/${t}`:`${e}/${t}`,e)}function Gg({base:e,newFolders:t}){return Wg(e,...t)}function Kg(e){if(e===``)return`Type a name`;if(e.includes(`/`))return`A folder name can't contain /`;if(e===`.`||e===`..`)return`Not a folder name`}function qg(e,t){return e===t?`~`:e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}function Jg(e,t){let n=e.trim(),[r,i]=n===`~`?[t,``]:n.startsWith(`~/`)?[t,n.slice(2)]:n.startsWith(`/`)?[`/`,n]:[t,n];return i.split(`/`).reduce((e,t)=>t===``||t===`.`?e:t===`..`?Ug(e):Wg(e,t),r)}function Yg(e,t){let n=e.lastIndexOf(`/`);if(n<0){let n=e.trim()===`~`;return{head:n?`~/`:``,parent:t,partial:n?``:e}}let r=e.slice(0,n+1);return{head:r,parent:Jg(r,t),partial:e.slice(n+1)}}function Xg(e,t){return e===t||e.startsWith(t===`/`?`/`:`${t}/`)}var Zg=5;function Qg(e,t){let n=new Map;for(let r of e){let e=Ug(r.folder);if(e===t||e===`/`)continue;let i=n.get(e)??{count:0,newest:-1/0};n.set(e,{count:i.count+1,newest:Math.max(i.newest,r.createdAt)})}let r=[...n.entries()].sort(([,e],[,t])=>t.count-e.count||t.newest-e.newest).slice(0,Zg).map(([e])=>({kind:`workspaces`,label:Hg(e),path:e}));return[{kind:`home`,label:`Home`,path:t},...r,{kind:`computer`,label:`Computer`,path:`/`}]}function $g(e,t){let n=Xg(e,t)?{label:`~`,path:t}:{label:`/`,path:`/`},r=[n];for(let t of e.slice(n.path.length).split(`/`).filter(Boolean)){let e=r.at(-1)?.path??n.path;r.push({label:t,path:e===`/`?`/${t}`:`${e}/${t}`})}return r}var e_=1,t_=.9,n_=.8,r_=.17,i_=.1,a_=.999,o_=.9999,s_=.99,c_=/[\\\/_+.#"@\[\(\{&]/,l_=/[\\\/_+.#"@\[\(\{&]/g,u_=/[\s-]/,d_=/[\s-]/g;function f_(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?e_:s_;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=f_(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=e_:c_.test(e.charAt(l-1))?(d*=n_,p=e.slice(i,l-1).match(l_),p&&i>0&&(d*=a_**+p.length)):u_.test(e.charAt(l-1))?(d*=t_,m=e.slice(i,l-1).match(d_),m&&i>0&&(d*=a_**+m.length)):(d*=r_,i>0&&(d*=a_**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=o_)),(d<i_&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=f_(e,t,n,r,l+1,a+2,o),f*i_>d&&(d=f*i_)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function p_(e){return e.toLowerCase().replace(d_,` `)}function m_(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,f_(e,t,p_(e),p_(t),0,0,{})}var h_=`[cmdk-group=""]`,g_=`[cmdk-group-items=""]`,__=`[cmdk-group-heading=""]`,v_=`[cmdk-item=""]`,y_=`${v_}:not([aria-disabled="true"])`,b_=`cmdk-item-select`,x_=`data-value`,S_=(e,t,n)=>m_(e,t,n),C_=D.createContext(void 0),w_=()=>D.useContext(C_),T_=D.createContext(void 0),E_=()=>D.useContext(T_),D_=D.createContext(void 0),O_=D.forwardRef((e,t)=>{let n=H_(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=H_(()=>new Set),i=H_(()=>new Map),a=H_(()=>new Map),o=H_(()=>new Set),s=B_(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=mi(),y=mi(),b=mi(),x=D.useRef(null),S=G_();V_(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),V_(()=>{S(6,A)},[]);let C=D.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)k(),E(),S(1,O);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=j()?.id,C.emit()}),r||S(5,A),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=D.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{k(),E(),n.current.value||O(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=j();S(4,()=>{k(),t?.getAttribute(`id`)===e&&O(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??S_;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;M().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(g_);t?t.appendChild(e.parentElement===t?e:e.closest(`${g_} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${g_} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${h_}[${x_}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function O(){let e=M().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(x_);C.setState(`value`,e||void 0)}function k(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function A(){var e;let t=j();t&&(t.parentElement?.firstChild===t&&((e=t.closest(h_)?.querySelector(__))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function j(){return x.current?.querySelector(`${v_}[aria-selected="true"]`)}function M(){return Array.from(x.current?.querySelectorAll(y_)||[])}function N(e){let t=M()[e];t&&C.setState(`value`,t.getAttribute(x_))}function P(e){var t;let n=j(),r=M(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(x_))}function F(e){let t=j()?.closest(h_),n;for(;t&&!n;)t=e>0?R_(t,h_):z_(t,h_),n=t?.querySelector(y_);n?C.setState(`value`,n.getAttribute(x_)):P(e)}let I=()=>N(M().length-1),ee=e=>{e.preventDefault(),e.metaKey?I():e.altKey?F(1):P(1)},te=e=>{e.preventDefault(),e.metaKey?N(0):e.altKey?F(-1):P(-1)};return D.createElement(G.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ee(e);break;case`ArrowDown`:ee(e);break;case`p`:case`k`:g&&e.ctrlKey&&te(e);break;case`ArrowUp`:te(e);break;case`Home`:e.preventDefault(),N(0);break;case`End`:e.preventDefault(),I();break;case`Enter`:{e.preventDefault();let t=j();if(t){let e=new Event(b_);t.dispatchEvent(e)}}}}},D.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:J_},c),q_(e,e=>D.createElement(T_.Provider,{value:C},D.createElement(C_.Provider,{value:w},e))))}),k_=D.forwardRef((e,t)=>{let n=mi(),r=D.useRef(null),i=D.useContext(D_),a=w_(),o=B_(e),s=o.current?.forceMount??i?.forceMount;V_(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=W_(n,r,[e.value,e.children,r],e.keywords),l=E_(),u=U_(e=>e.value&&e.value===c.current),d=U_(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);D.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(b_,f),()=>t.removeEventListener(b_,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return D.createElement(G.div,{ref:Vn(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),A_=D.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=mi(),s=D.useRef(null),c=D.useRef(null),l=mi(),u=w_(),d=U_(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));V_(()=>u.group(o),[]),W_(o,s,[e.value,e.heading,c]);let f=D.useMemo(()=>({id:o,forceMount:i}),[i]);return D.createElement(G.div,{ref:Vn(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&D.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),q_(e,e=>D.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},D.createElement(D_.Provider,{value:f},e))))}),j_=D.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=D.useRef(null),a=U_(e=>!e.search);return!n&&!a?null:D.createElement(G.div,{ref:Vn(i,t),...r,"cmdk-separator":``,role:`separator`})}),M_=D.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=E_(),o=U_(e=>e.search),s=U_(e=>e.selectedItemId),c=w_();return D.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),D.createElement(G.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),N_=D.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=D.useRef(null),o=D.useRef(null),s=U_(e=>e.selectedItemId),c=w_();return D.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),D.createElement(G.div,{ref:Vn(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},q_(e,e=>D.createElement(`div`,{ref:Vn(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),P_=D.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return D.createElement(Lo,{open:n,onOpenChange:r},D.createElement(Uo,{container:o},D.createElement(Go,{"cmdk-overlay":``,className:i}),D.createElement(Yo,{"aria-label":e.label,"cmdk-dialog":``,className:a},D.createElement(O_,{ref:t,...s}))))}),F_=D.forwardRef((e,t)=>U_(e=>e.filtered.count===0)?D.createElement(G.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),I_=D.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return D.createElement(G.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},q_(e,e=>D.createElement(`div`,{"aria-hidden":!0},e)))}),L_=Object.assign(O_,{List:N_,Item:k_,Input:M_,Group:A_,Separator:j_,Dialog:P_,Empty:F_,Loading:I_});function R_(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function z_(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function B_(e){let t=D.useRef(e);return V_(()=>{t.current=e}),t}var V_=typeof window>`u`?D.useEffect:D.useLayoutEffect;function H_(e){let t=D.useRef();return t.current===void 0&&(t.current=e()),t}function U_(e){let t=E_(),n=()=>e(t.snapshot());return D.useSyncExternalStore(t.subscribe,n,n)}function W_(e,t,n,r=[]){let i=D.useRef(),a=w_();return V_(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(x_,s),i.current=s}),i}var G_=()=>{let[e,t]=D.useState(),n=H_(()=>new Map);return V_(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function K_(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function q_({asChild:e,children:t},n){return e&&D.isValidElement(t)?D.cloneElement(K_(t),{ref:t.ref},n(t.props.children)):n(t)}var J_={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Y_({...e}){return(0,W.jsx)(Lo,{"data-slot":`dialog`,...e})}function X_({...e}){return(0,W.jsx)(zo,{"data-slot":`dialog-trigger`,...e})}function Z_({...e}){return(0,W.jsx)(Uo,{"data-slot":`dialog-portal`,...e})}function Q_({className:e,...t}){return(0,W.jsx)(Go,{"data-slot":`dialog-overlay`,className:U(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function $_({className:e,children:t,showCloseButton:n=!0,...r}){return(0,W.jsxs)(Z_,{"data-slot":`dialog-portal`,children:[(0,W.jsx)(Q_,{}),(0,W.jsxs)(Yo,{"data-slot":`dialog-content`,onCloseAutoFocus:ng,className:U(`fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...r,children:[t,n&&(0,W.jsxs)(ns,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,W.jsx)(tt,{}),(0,W.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function ev({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`dialog-header`,className:U(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function tv({className:e,showCloseButton:t=!1,children:n,...r}){return(0,W.jsxs)(`div`,{"data-slot":`dialog-footer`,className:U(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...r,children:[n,t&&(0,W.jsx)(ns,{asChild:!0,children:(0,W.jsx)(Uh,{variant:`outline`,children:`Close`})})]})}function nv({className:e,...t}){return(0,W.jsx)($o,{"data-slot":`dialog-title`,className:U(`text-lg leading-none font-semibold`,e),...t})}function rv({className:e,...t}){return(0,W.jsx)(es,{"data-slot":`dialog-description`,className:U(`text-sm text-muted-foreground`,e),...t})}function iv({className:e,...t}){return(0,W.jsx)(L_,{"data-slot":`command`,className:U(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function av({className:e,...t}){return(0,W.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,W.jsx)(Ve,{className:`size-4 shrink-0 opacity-50`}),(0,W.jsx)(L_.Input,{"data-slot":`command-input`,className:U(`flex h-10 w-full rounded-md bg-transparent py-3 text-sm outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function ov({className:e,...t}){return(0,W.jsx)(L_.List,{"data-slot":`command-list`,className:U(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...t})}function sv({className:e,...t}){return(0,W.jsx)(L_.Group,{"data-slot":`command-group`,className:U(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function cv({className:e,...t}){return(0,W.jsx)(L_.Item,{"data-slot":`command-item`,className:U(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function lv({className:e,type:t,...n}){return(0,W.jsx)(`input`,{type:t,"data-slot":`input`,className:U(`h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40`,e),...n})}var uv=`max-h-[92dvh] overflow-y-auto md:max-w-3xl max-md:top-0 max-md:left-0 max-md:flex max-md:h-dvh max-md:max-h-none max-md:max-w-none max-md:translate-none max-md:flex-col max-md:rounded-none max-md:border-0 max-md:p-4`;function dv(e,{climb:t=!1,hidden:n=!1}={}){let[r,i]=(0,D.useState)(),[a,o]=(0,D.useState)();return(0,D.useEffect)(()=>{i(void 0),o(void 0);let r=!0,a=e=>Tg.listDirectories(e,{hidden:n}).catch(n=>{if(t&&e!==void 0&&e!==`/`)return a(Ug(e));throw n});return a(e).then(e=>r&&i(e),e=>r&&o(e instanceof Error?e.message:String(e))),()=>{r=!1}},[e,t,n]),{listing:r,error:a}}async function fv(e){let t=[];for(let n=e;;n=Ug(n))try{return{base:(await Tg.listDirectories(n)).path,newFolders:t}}catch(e){if(n===`/`)throw e;t.unshift(Hg(n))}}function pv(e,t){let n=(0,D.useRef)(t);n.current=t,(0,D.useEffect)(()=>{let t=t=>{t.key===`Escape`&&t.target===e.current&&(t.stopPropagation(),n.current())};return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e])}function mv({workspaces:e,start:t,onChange:n}){let[r,i]=(0,D.useState)(t),[a,o]=(0,D.useState)(t!==void 0),[s,c]=(0,D.useState)([]),[l,u]=(0,D.useState)(!1),[d,f]=(0,D.useState)(``),[p,m]=(0,D.useState)(!1),{listing:h,error:g}=dv(r,{climb:a}),[_,v]=(0,D.useState)(),y=r===void 0||a?h?.path:r;(0,D.useEffect)(()=>{h?.root&&v(h.root)},[h]);let b=(0,D.useRef)(n);b.current=n,(0,D.useEffect)(()=>{b.current(y===void 0?void 0:{base:y,newFolders:s},l)},[y,s,l]);let x=e=>{(e.base!==y||a)&&(i(e.base),o(!1)),c(e.newFolders),u(!0),f(``),m(!1)},S=e=>x({base:e,newFolders:[]}),C=e=>{if(y===void 0)return;let t=s.length===0?h?.directories.find(t=>t.name.toLowerCase()===e.toLowerCase()):void 0;t?S(t.path):x({base:y,newFolders:[...s,e]})};if(g&&!y)return(0,W.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:g});if(!y||!_)return(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`});let w=s.at(-1);return(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-2 md:grid md:grid-cols-[10rem_1fr]`,children:[(0,W.jsx)(_v,{places:Qg(e,_),root:_,here:w===void 0?y:void 0,onGo:S}),(0,W.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,W.jsx)(vv,{choice:{base:y,newFolders:s},root:_,onChoose:x})}),(0,W.jsxs)(Uh,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>m(!0),children:[(0,W.jsx)(_e,{}),`New folder`]})]}),p&&(0,W.jsx)(wv,{onAdd:C,onCancel:()=>m(!1)}),w===void 0?(0,W.jsx)(Cv,{listing:h,error:g,filter:d,onFilter:f,workspaces:e,onGo:S}):(0,W.jsx)(Sv,{name:w}),(0,W.jsx)(xv,{choice:{base:y,newFolders:s},root:_})]})]})}var hv=`bg-transparent [&:not(:focus-within):not(:hover)_[data-selected=true]:not([aria-current])]:bg-transparent`,gv={home:Ce,workspaces:ye,computer:ke};function _v({places:e,root:t,here:n,onGo:r}){return(0,W.jsx)(iv,{tabIndex:0,vimBindings:!1,className:U(hv,`h-auto shrink-0 outline-none md:rounded-none md:border-r md:pr-2`),children:(0,W.jsx)(ov,{label:`Places`,className:`max-h-none overflow-x-auto overflow-y-hidden`,children:(0,W.jsx)(sv,{heading:`Places`,className:`overflow-visible p-0 max-md:[&_[cmdk-group-heading]]:hidden [&_[cmdk-group-items]]:flex [&_[cmdk-group-items]]:gap-1 md:[&_[cmdk-group-items]]:flex-col`,children:e.map(e=>{let i=gv[e.kind];return(0,W.jsxs)(cv,{value:e.path,title:qg(e.path,t),"aria-current":n===e.path?`location`:void 0,onSelect:()=>r(e.path),className:`shrink-0 rounded-full border px-3 py-1 aria-[current=location]:bg-accent aria-[current=location]:font-medium md:rounded-sm md:border-transparent md:px-2`,children:[(0,W.jsx)(i,{}),(0,W.jsx)(`span`,{className:`truncate`,children:e.label})]},e.path)})})})})}function vv({choice:e,root:t,onChoose:n}){let[r,i]=(0,D.useState)(!1),a=(0,D.useRef)(null),o=(0,D.useRef)(!1),s=e=>{o.current=e,i(!1)};return(0,D.useEffect)(()=>{!r&&o.current&&(o.current=!1,a.current?.focus())},[r]),r?(0,W.jsx)(yv,{choice:e,root:t,onChoose:e=>{s(!0),n(e)},onEscape:()=>s(!0),onCancel:()=>s(!1)}):(0,W.jsxs)(`div`,{className:`flex min-h-8 items-center rounded-md border px-1`,children:[(0,W.jsx)(bv,{choice:e,root:t,onGo:e=>n({base:e,newFolders:[]}),onTrim:t=>n({base:e.base,newFolders:e.newFolders.slice(0,t)})}),(0,W.jsx)(`button`,{ref:a,type:`button`,"aria-label":`Type a path`,title:`Type a path`,onClick:()=>i(!0),className:`flex min-h-7 min-w-8 flex-1 items-center justify-end self-stretch rounded-sm px-1 text-muted-foreground hover:bg-accent`,children:(0,W.jsx)(Ye,{className:`size-4`})})]})}function yv({choice:e,root:t,onChoose:n,onEscape:r,onCancel:i}){let[a,o]=(0,D.useState)(()=>{let n=qg(Gg(e),t);return n.endsWith(`/`)?n:`${n}/`}),[s,c]=(0,D.useState)(),[l,u]=(0,D.useState)(),[d,f]=(0,D.useState)(!1),p=(0,D.useRef)(null),m=(0,D.useId)(),h=(0,D.useId)();pv(p,r);let{head:g,parent:_,partial:v}=Yg(a,t),{listing:y}=dv(_,{hidden:v.startsWith(`.`)}),b=v.toLowerCase(),x=e=>Number(!e.toLowerCase().startsWith(b)),S=(y?.directories??[]).filter(e=>e.name.toLowerCase().includes(b)).sort((e,t)=>x(e.name)-x(t.name)),C=s??0,w=e=>{o(e),c(void 0),u(void 0),f(!1)};if(d&&y!==void 0){let e=S[0];e?w(`${g}${e.name}/`):f(!1)}let T=e=>{w(`${g}${e}/`),p.current?.focus()},E=e=>{fv(e).then(n,e=>u(e instanceof Error?e.message:String(e)))};return(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(lv,{ref:p,autoFocus:!0,role:`combobox`,"aria-label":`Folder path`,"aria-autocomplete":`list`,"aria-expanded":S.length>0,"aria-controls":S.length>0?m:void 0,"aria-activedescendant":s===void 0?void 0:`${m}-${s}`,"aria-invalid":l!==void 0,"aria-describedby":l===void 0?void 0:h,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`~/projects/new-app`,className:`h-8 font-mono text-sm`,value:a,onFocus:e=>e.target.select(),onBlur:i,onChange:e=>w(e.target.value),onKeyDown:e=>{let n=S.length;if(e.key===`Enter`){e.preventDefault();let n=s===void 0?void 0:S[s];E(n?Wg(_,n.name):Jg(a,t))}else if(e.key===`Tab`&&!e.shiftKey){e.preventDefault();let t=S[C];t?T(t.name):y===void 0&&f(!0)}else e.key===`ArrowDown`&&n>0?(e.preventDefault(),c(e=>e===void 0?0:(e+1)%n)):e.key===`ArrowUp`&&n>0&&(e.preventDefault(),c(e=>e===void 0?n-1:(e-1+n)%n))}}),S.length>0&&(0,W.jsx)(`div`,{id:m,role:`listbox`,"aria-label":`Suggestions`,className:`absolute top-full z-10 mt-1 max-h-60 w-full overflow-y-auto rounded-md border bg-popover p-1 shadow-md`,children:S.map((e,t)=>(0,W.jsxs)(`div`,{id:`${m}-${t}`,role:`option`,tabIndex:-1,"aria-selected":t===s,onMouseDown:e=>e.preventDefault(),onClick:()=>T(e.name),className:U(`flex cursor-default items-center gap-2 rounded-sm px-2 py-1 text-sm`,t===s?`bg-accent`:`hover:bg-accent`,e.name.startsWith(`.`)&&`text-muted-foreground`),children:[(0,W.jsx)(ye,{className:`size-4 shrink-0`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e.name}),t===C&&(0,W.jsx)(`kbd`,{"aria-hidden":!0,className:`rounded border px-1 text-[10px] text-muted-foreground`,children:`Tab`})]},e.path))})]}),l&&(0,W.jsx)(`p`,{id:h,role:`alert`,className:`text-xs text-destructive`,children:l})]})}function bv({choice:e,root:t,onGo:n,onTrim:r}){let i=[...$g(e.base,t).map(e=>({...e,isNew:!1,go:()=>n(e.path)})),...e.newFolders.map((t,n)=>({label:t,path:Wg(e.base,...e.newFolders.slice(0,n+1)),isNew:!0,go:()=>r(n+1)}))];return(0,W.jsx)(Jm,{"aria-label":`Breadcrumbs`,className:`min-w-0`,children:(0,W.jsx)(Ym,{className:`min-h-7 gap-0.5 sm:gap-0.5`,children:i.map((e,t)=>(0,W.jsxs)(D.Fragment,{children:[t>0&&(0,W.jsx)($m,{className:`[&>svg]:size-3`}),(0,W.jsx)(Xm,{children:(0,W.jsx)(Zm,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,title:e.isNew?`${e.path} (doesn't exist yet)`:e.path,"aria-current":t===i.length-1?`location`:void 0,onClick:e.go,className:U(`rounded-sm px-1 hover:bg-accent aria-[current]:font-medium aria-[current]:text-foreground`,e.isNew&&`italic`),children:e.label})})})]},e.path))})})}function xv({choice:e,root:t}){let n=e.newFolders.length;return(0,W.jsxs)(`p`,{className:`flex flex-wrap items-baseline gap-x-2 text-xs text-muted-foreground`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 break-all font-mono`,children:[qg(e.base,t),e.newFolders.map((t,n)=>(0,W.jsxs)(D.Fragment,{children:[e.base===`/`&&n===0?``:`/`,(0,W.jsx)(`em`,{className:`text-foreground`,children:t})]},Wg(e.base,...e.newFolders.slice(0,n+1))))]}),n>0&&(0,W.jsx)(`span`,{children:n===1?`1 new folder`:`${n} new folders`})]})}function Sv({name:e}){return(0,W.jsxs)(`div`,{className:`grid min-h-40 flex-1 place-items-center content-center gap-1 rounded-md border p-6 text-center text-sm text-muted-foreground md:h-72 md:flex-none`,children:[(0,W.jsx)(_e,{className:`size-6`}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`em`,{className:`text-foreground`,children:e}),` doesn't exist yet. It'll be made along with the Workspace.`]}),(0,W.jsx)(`span`,{className:`text-xs`,children:`Add another New folder to go deeper.`})]})}function Cv({listing:e,error:t,filter:n,onFilter:r,workspaces:i,onGo:a}){let o=(0,D.useId)(),s=new Map(i.map(e=>[e.folder,e.name])),c=(e?.directories??[]).filter(e=>e.name.toLowerCase().includes(n.trim().toLowerCase()));return(0,W.jsxs)(iv,{label:`Filter folders`,shouldFilter:!1,vimBindings:!1,className:U(hv,`min-h-40 flex-1 border md:h-72 md:flex-none`),children:[(0,W.jsx)(av,{placeholder:`Filter`,value:n,onValueChange:r}),(0,W.jsxs)(ov,{label:`Folders`,className:`max-h-none flex-1 p-1`,children:[t&&(0,W.jsx)(`p`,{role:`alert`,className:`p-1 text-sm text-destructive`,children:t}),!e&&!t&&(0,W.jsx)(`p`,{className:`p-1 text-sm text-muted-foreground`,children:`Loading…`}),c.map((e,t)=>{let n=s.get(e.path),r=`${o}-${t}`;return(0,W.jsxs)(cv,{value:e.path,onSelect:()=>a(e.path),"aria-describedby":n===void 0?void 0:r,children:[(0,W.jsx)(ye,{}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),n!==void 0&&(0,W.jsxs)(`span`,{id:r,"aria-hidden":!0,className:`max-w-[40%] shrink-0 truncate rounded-sm bg-secondary px-1.5 text-xs text-muted-foreground`,children:[(0,W.jsx)(`span`,{className:`sr-only`,children:`Workspace `}),n]}),(0,W.jsx)(R,{className:`size-3 opacity-50`})]},e.path)}),e&&c.length===0&&(0,W.jsx)(`p`,{className:`p-1 text-sm text-muted-foreground`,children:n.trim()?`No folder matches`:`No subfolders`})]})]})}function wv({onAdd:e,onCancel:t}){let[n,r]=(0,D.useState)(``),[i,a]=(0,D.useState)(),o=(0,D.useRef)(null),s=(0,D.useId)();return pv(o,t),(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 px-2`,children:[(0,W.jsx)(_e,{className:`size-4 shrink-0`}),(0,W.jsx)(lv,{ref:o,autoFocus:!0,"aria-label":`New folder name`,"aria-invalid":i!==void 0,"aria-describedby":i===void 0?void 0:s,placeholder:`New folder name`,className:`h-7 text-sm`,value:n,onChange:e=>{r(e.target.value),a(void 0)},onKeyDown:t=>{if(t.key!==`Enter`)return;t.preventDefault();let r=n.trim(),i=Kg(r);i?a(i):e(r)},onBlur:()=>n.trim()===``&&t()})]}),i&&(0,W.jsx)(`p`,{id:s,className:`px-7 text-xs text-destructive`,children:i})]})}function Tv({className:e,...t}){return(0,W.jsx)(df,{"data-slot":`label`,className:U(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var Ev=Vh(`group/field flex w-full gap-3 data-[invalid=true]:text-destructive`,{variants:{orientation:{vertical:[`flex-col [&>*]:w-full [&>.sr-only]:w-auto`],horizontal:[`flex-row items-center`,`[&>[data-slot=field-label]]:flex-auto`,`has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`],responsive:[`flex-col @md/field-group:flex-row @md/field-group:items-center [&>*]:w-full @md/field-group:[&>*]:w-auto [&>.sr-only]:w-auto`,`@md/field-group:[&>[data-slot=field-label]]:flex-auto`,`@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`]}},defaultVariants:{orientation:`vertical`}});function Dv({className:e,orientation:t=`vertical`,...n}){return(0,W.jsx)(`div`,{role:`group`,"data-slot":`field`,"data-orientation":t,className:U(Ev({orientation:t}),e),...n})}function Ov({className:e,...t}){return(0,W.jsx)(Tv,{"data-slot":`field-label`,className:U(`group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>*]:data-[slot=field]:p-4`,`has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10`,e),...t})}function kv({className:e,children:t,errors:n,...r}){let i=(0,D.useMemo)(()=>{if(t)return t;if(!n?.length)return null;let e=[...new Map(n.map(e=>[e?.message,e])).values()];return e?.length==1?e[0]?.message:(0,W.jsx)(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:e.map((e,t)=>e?.message&&(0,W.jsx)(`li`,{children:e.message},t))})},[t,n]);return i?(0,W.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:U(`text-sm font-normal text-destructive`,e),...r,children:i}):null}function Av({workspace:e,workspaces:t,edit:n,onSave:r,onClose:i}){let a=n===`rename`,[o,s]=(0,D.useState)(e.name),[c,l]=(0,D.useState)(),[u,d]=(0,D.useState)(),f=(0,D.useId)(),p=c&&Gg(c),m=a?o.trim():p===e.folder?void 0:p,h=async()=>{if(m)try{await r(a?{name:m}:{folder:m,...(c?.newFolders.length??0)>0&&{createMissingFolders:!0}}),i()}catch(e){d(e instanceof Error?e.message:String(e))}};return(0,W.jsx)(Y_,{open:!0,onOpenChange:e=>!e&&i(),children:(0,W.jsx)($_,{className:a?void 0:uv,children:(0,W.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,W.jsxs)(ev,{children:[(0,W.jsx)(nv,{children:a?`Rename Workspace`:`Change folder`}),(0,W.jsx)(rv,{children:a?`Choose a new name for ${e.name}.`:`Point ${e.name} at another folder on the Host. Running Sessions carry on where they are.`})]}),a?(0,W.jsxs)(Dv,{children:[(0,W.jsx)(Ov,{htmlFor:f,children:`Name`}),(0,W.jsx)(lv,{id:f,value:o,onChange:e=>{s(e.target.value),d(void 0)},autoFocus:!0})]}):(0,W.jsx)(mv,{workspaces:t,start:e.folder,onChange:(e,t)=>{l(t?e:void 0),d(void 0)}}),u&&(0,W.jsx)(kv,{children:u}),(0,W.jsx)(tv,{children:(0,W.jsx)(Uh,{type:`submit`,disabled:!m,children:`Save`})})]})})})}var jv=2,Mv=1,Nv=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(jv,Math.floor(u/e.css.cell.width)),rows:Math.max(Mv,Math.floor(l/e.css.cell.height))}}},Pv=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Fv=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Iv;function Lv(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var Rv=class{constructor(){if(this.version=`6`,!Iv){Iv=new Uint8Array(65536),Iv.fill(1),Iv[0]=0,Iv.fill(0,1,32),Iv.fill(0,127,160),Iv.fill(2,4352,4448),Iv[9001]=2,Iv[9002]=2,Iv.fill(2,11904,42192),Iv[12351]=1,Iv.fill(2,44032,55204),Iv.fill(2,63744,64256),Iv.fill(2,65040,65050),Iv.fill(2,65072,65136),Iv.fill(2,65280,65377),Iv.fill(2,65504,65511);for(let e=0;e<Pv.length;++e)Iv.fill(0,Pv[e][0],Pv[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Iv[e]:Lv(e,Fv)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=Sy.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Sy.createPropertyValue(0,n,r)}},zv=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Wv.isErrorNoTelemetry(e)?new Wv(e.message+`
|
|
50
51
|
|
|
51
52
|
`+e.stack):Error(e.message+`
|
|
52
53
|
|
|
@@ -67,8 +68,8 @@ WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){t
|
|
|
67
68
|
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),HT&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]<n[1]||t[1]===n[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<n[0]||t[1]<n[1]&&e[1]===n[1]&&e[0]<n[0]||t[1]<n[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=dE(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=ET(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-fE),fE),t/=fE,t/Math.abs(t)+Math.round(t*(pE-1)))}shouldForceSelection(e){return RT?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),mE)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(RT&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]<n.lines.length){let e=n.lines.get(this._model.selectionEnd[1]);e&&e.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}t&&t[0]===this._model.selectionEnd[0]&&t[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<hE&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=ZT(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);n?!e||!t||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&t[0]===this._oldSelectionEnd[0]&&t[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,t,n):this._oldHasSelection&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c<o.length&&o.charAt(c+1)===` `;)c++}else{let t=e[0],n=e[0];a.getWidth(t)===0&&(u++,t--),a.getWidth(n)===2&&(d++,n++);let r=a.getString(n).length;for(r>1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n<a.length&&c+1<o.length&&!this._isCharWordSeparator(a.loadCell(n+1,this._workCell));){a.loadCell(n+1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===2?(d++,n++):e>1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=dE(n,this._bufferService.cols)}};_E=Ib([X(3,lx),X(4,dx),X(5,Cx),X(6,hx),X(7,wx),X(8,Sx)],_E);var vE=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},yE=class{constructor(){this._color=new vE,this._css=new vE}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},bE=Object.freeze((()=>{let e=[Jw.toColor(`#2e3436`),Jw.toColor(`#cc0000`),Jw.toColor(`#4e9a06`),Jw.toColor(`#c4a000`),Jw.toColor(`#3465a4`),Jw.toColor(`#75507b`),Jw.toColor(`#06989a`),Jw.toColor(`#d3d7cf`),Jw.toColor(`#555753`),Jw.toColor(`#ef2929`),Jw.toColor(`#8ae234`),Jw.toColor(`#fce94f`),Jw.toColor(`#729fcf`),Jw.toColor(`#ad7fa8`),Jw.toColor(`#34e2e2`),Jw.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:Kw.toCss(r,i,a),rgba:Kw.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:Kw.toCss(n,n,n),rgba:Kw.toRgba(n,n,n)})}return e})()),xE=Jw.toColor(`#ffffff`),SE=Jw.toColor(`#000000`),CE=Jw.toColor(`#ffffff`),wE=SE,TE={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},EE=xE,DE=class extends Qx{constructor(e){super(),this._optionsService=e,this._contrastCache=new yE,this._halfContrastCache=new yE,this._onChangeColors=this._register(new Z),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:xE,background:SE,cursor:CE,cursorAccent:wE,selectionForeground:void 0,selectionBackgroundTransparent:TE,selectionBackgroundOpaque:qw.blend(SE,TE),selectionInactiveBackgroundTransparent:TE,selectionInactiveBackgroundOpaque:qw.blend(SE,TE),scrollbarSliderBackground:qw.opacity(xE,.2),scrollbarSliderHoverBackground:qw.opacity(xE,.4),scrollbarSliderActiveBackground:qw.opacity(xE,.5),overviewRulerBorder:xE,ansi:bE.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=OE(e.foreground,xE),t.background=OE(e.background,SE),t.cursor=qw.blend(t.background,OE(e.cursor,CE)),t.cursorAccent=qw.blend(t.background,OE(e.cursorAccent,wE)),t.selectionBackgroundTransparent=OE(e.selectionBackground,TE),t.selectionBackgroundOpaque=qw.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=OE(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=qw.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?OE(e.selectionForeground,Gw):void 0,t.selectionForeground===Gw&&(t.selectionForeground=void 0),qw.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=qw.opacity(t.selectionBackgroundTransparent,.3)),qw.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=qw.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=OE(e.scrollbarSliderBackground,qw.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=OE(e.scrollbarSliderHoverBackground,qw.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=OE(e.scrollbarSliderActiveBackground,qw.opacity(t.foreground,.5)),t.overviewRulerBorder=OE(e.overviewRulerBorder,EE),t.ansi=bE.slice(),t.ansi[0]=OE(e.black,bE[0]),t.ansi[1]=OE(e.red,bE[1]),t.ansi[2]=OE(e.green,bE[2]),t.ansi[3]=OE(e.yellow,bE[3]),t.ansi[4]=OE(e.blue,bE[4]),t.ansi[5]=OE(e.magenta,bE[5]),t.ansi[6]=OE(e.cyan,bE[6]),t.ansi[7]=OE(e.white,bE[7]),t.ansi[8]=OE(e.brightBlack,bE[8]),t.ansi[9]=OE(e.brightRed,bE[9]),t.ansi[10]=OE(e.brightGreen,bE[10]),t.ansi[11]=OE(e.brightYellow,bE[11]),t.ansi[12]=OE(e.brightBlue,bE[12]),t.ansi[13]=OE(e.brightMagenta,bE[13]),t.ansi[14]=OE(e.brightCyan,bE[14]),t.ansi[15]=OE(e.brightWhite,bE[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;r<n;r++)t.ansi[r+16]=OE(e.extendedAnsi[r],bE[r+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0)for(let e=0;e<this._restoreColors.ansi.length;++e)this._colors.ansi[e]=this._restoreColors.ansi[e];else switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};DE=Ib([X(0,hx)],DE);function OE(e,t){if(e!==void 0)try{return Jw.toColor(e)}catch{}return t}var kE=class{constructor(...e){this._entries=new Map;for(let[t,n]of e)this.set(t,n)}set(e,t){let n=this._entries.get(e);return this._entries.set(e,t),n}forEach(e){for(let[t,n]of this._entries.entries())e(t,n)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},AE=class{constructor(){this._services=new kE,this._services.set(px,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let n=ox(e).sort((e,t)=>e.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},jE={trace:0,debug:1,info:2,warn:3,error:4,off:5},ME=`xterm.js: `,NE=class extends Qx{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),PE=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=jE[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:ME)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};NE=Ib([X(0,hx)],NE);var PE,FE=class extends Qx{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new Z),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new Z),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new Z),this.onTrim=this.onTrimEmitter.event,this._array=Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=Array(e);for(let n=0;n<Math.min(e,this.length);n++)t[n]=this._array[this._getCyclicIndex(n)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw Error(`Can only recycle when the buffer is full`);return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...n){if(t){for(let n=e;n<this._length-t;n++)this._array[this._getCyclicIndex(n)]=this._array[this._getCyclicIndex(n+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let t=this._length-1;t>=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;t<n.length;t++)this._array[this._getCyclicIndex(e+t)]=n[t];if(n.length&&this.onInsertEmitter.fire({index:e,amount:n.length}),this._length+n.length>this._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<t;r++)this.set(e+r+n,this.get(e+r))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},IE=3,LE=Object.freeze(new ex),RE=0,zE=2,BE=class e{constructor(e,t,n=!1){this.isWrapped=n,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(e*IE);let r=t||nx.fromCharData([0,Qb,1,0]);for(let t=0;t<e;++t)this.setCell(t,r);this.length=e}get(e){let t=this._data[e*IE+0],n=t&2097151;return[this._data[e*IE+1],t&2097152?this._combined[e]:n?Jb(n):``,t>>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*IE+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*IE+0]=e|2097152|t[2]<<22):this._data[e*IE+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*IE+0]>>22}hasWidth(e){return this._data[e*IE+0]&12582912}getFg(e){return this._data[e*IE+1]}getBg(e){return this._data[e*IE+2]}hasContent(e){return this._data[e*IE+0]&4194303}getCodePoint(e){let t=this._data[e*IE+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*IE+0]&2097152}getString(e){let t=this._data[e*IE+0];return t&2097152?this._combined[e]:t&2097151?Jb(t&2097151):``}isProtected(e){return this._data[e*IE+2]&536870912}loadCell(e,t){return RE=e*IE,t.content=this._data[RE+0],t.fg=this._data[RE+1],t.bg=this._data[RE+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*IE+0]=t.content,this._data[e*IE+1]=t.fg,this._data[e*IE+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*IE+0]=t|n<<22,this._data[e*IE+1]=r.fg,this._data[e*IE+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*IE+0];r&2097152?this._combined[e]+=Jb(t):r&2097151?(this._combined[e]=Jb(r&2097151)+Jb(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*IE+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length-e){let r=new nx;for(let n=this.length-e-t-1;n>=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;r<t;++r)this.setCell(e+r,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,n)}deleteCells(e,t,n){if(e%=this.length,t<this.length-e){let r=new nx;for(let n=0;n<this.length-e-t;++n)this.setCell(e+n,this.loadCell(e+t+n,r));for(let e=this.length-t;e<this.length;++e)this.setCell(e,n)}else for(let t=e;t<this.length;++t)this.setCell(t,n);e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),this.getWidth(e)===0&&!this.hasContent(e)&&this.setCellFromCodepoint(e,0,1,n)}replaceCells(e,t,n,r=!1){if(r)for(e&&this.getWidth(e-1)===2&&!this.isProtected(e-1)&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&!this.isProtected(t)&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.isProtected(e)||this.setCell(e,n),e++;else for(e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t<this.length&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t,0,1,n);e<t&&e<this.length;)this.setCell(e++,n)}resize(e,t){if(e===this.length)return this._data.length*4*zE<this._data.buffer.byteLength;let n=e*IE;if(e>this.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n<e;++n)this.setCell(n,t)}else{this._data=this._data.subarray(0,n);let t=Object.keys(this._combined);for(let n=0;n<t.length;n++){let r=parseInt(t[n],10);r>=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t<r.length;t++){let n=parseInt(r[t],10);n>=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*zE<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*zE<this._data.buffer.byteLength){let e=new Uint32Array(this._data.length);return e.set(this._data),this._data=e,1}return 0}fill(e,t=!1){if(t)for(let t=0;t<this.length;++t)this.isProtected(t)||this.setCell(t,e);else{this._combined={},this._extendedAttrs={};for(let t=0;t<this.length;++t)this.setCell(t,e)}}copyFrom(e){this.length===e.length?this._data.set(e._data):this._data=new Uint32Array(e._data),this.length=e.length,this._combined={};for(let t in e._combined)this._combined[t]=e._combined[t];this._extendedAttrs={};for(let t in e._extendedAttrs)this._extendedAttrs[t]=e._extendedAttrs[t];this.isWrapped=e.isWrapped}clone(){let t=new e(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let e in this._combined)t._combined[e]=this._combined[e];for(let e in this._extendedAttrs)t._extendedAttrs[e]=this._extendedAttrs[e];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*IE+0]&4194303)return e+(this._data[e*IE+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*IE+0]&4194303||this._data[e*IE+2]&50331648)return e+(this._data[e*IE+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e<IE;e++)this._data[(n+i)*IE+e]=a[(t+i)*IE+e];a[(t+i)*IE+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}else for(let i=0;i<r;i++){for(let e=0;e<IE;e++)this._data[(n+i)*IE+e]=a[(t+i)*IE+e];a[(t+i)*IE+2]&268435456&&(this._extendedAttrs[n+i]=e._extendedAttrs[t+i])}let o=Object.keys(e._combined);for(let r=0;r<o.length;r++){let i=parseInt(o[r],10);i>=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t<n;){let e=this._data[t*IE+0],n=e&2097151,a=e&2097152?this._combined[t]:n?Jb(n):$b;if(i+=a,r)for(let e=0;e<a.length;++e)r.push(t);t+=e>>22||1}return r&&r.push(t),i}};function VE(e,t,n,r,i,a){let o=[];for(let s=0;s<e.length-1;s++){let c=s,l=e.get(++c);if(!l.isWrapped)continue;let u=[e.get(s)];for(;c<e.length&&l.isWrapped;)u.push(l),l=e.get(++c);if(!a&&r>=s&&r<c){s+=u.length-1;continue}let d=0,f=GE(u,d,t),p=1,m=0;for(;p<u.length;){let e=GE(u,p,t),r=e-m,a=n-f,o=Math.min(r,a);u[d].copyCellsFrom(u[p],m,f,o,!1),f+=o,f===n&&(d++,f=0),m+=o,m===e&&(p++,m=0),f===0&&d!==0&&u[d-1].getWidth(n-1)===2&&(u[d].copyCellsFrom(u[d-1],n-1,f++,1,!1),u[d-1].setCell(n-1,i))}u[d].replaceCells(f,n,i);let h=0;for(let e=u.length-1;e>0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function HE(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;o<e.length;o++)if(i===o){let n=t[++r];e.onDeleteEmitter.fire({index:o-a,amount:n}),o+=n-1,a+=n,i=t[++r]}else n.push(o);return{layout:n,countRemoved:a}}function UE(e,t){let n=[];for(let r=0;r<t.length;r++)n.push(e.get(t[r]));for(let t=0;t<n.length;t++)e.set(t,n[t]);e.length=t.length}function WE(e,t,n){let r=[],i=e.map((n,r)=>GE(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;s<i;){if(i-s<n){r.push(i-s);break}a+=n;let c=GE(e,o,t);a>c&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function GE(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var KE=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new Z),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),qx(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};KE._nextId=1;var qE=KE,JE={},YE=JE.B;JE[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:``,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},JE.A={"#":`£`},JE.B=void 0,JE[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},JE.C=JE[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},JE.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},JE.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},JE.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},JE.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},JE.E=JE[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},JE.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},JE.H=JE[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},JE[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var XE=4294967295,ZE=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=LE.clone(),this.savedCharset=YE,this.markers=[],this._nullCell=nx.fromCharData([0,Qb,1,0]),this._whitespaceCell=nx.fromCharData([0,$b,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new qT,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new FE(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new tx),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new tx),this._whitespaceCell}getBlankLine(e,t){return new BE(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>XE?XE:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=LE);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new FE(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(LE),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols<e)for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);let a=0;if(this._rows<t)for(let r=this._rows;r<t;r++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new BE(e,n)):this.ybase>0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new BE(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i<this.lines.maxLength){let e=this.lines.length-i;e>0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t<this.lines.length;t++)r+=+this.lines.get(t).resize(e,n);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),r>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=VE(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(LE),n);if(r.length>0){let n=HE(this.lines,r);UE(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(LE),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new BE(e,r))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-n,0)}_reflowSmaller(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=this.getNullCell(LE),i=[],a=0;for(let o=this.lines.length-1;o>=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e<o+c.length)continue}let l=c[c.length-1].getTrimmedLength(),u=WE(c,this._cols,e),d=u.length-c.length,f;f=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+d):Math.max(0,this.lines.length-this.lines.maxLength+d);let p=[];for(let e=0;e<d;e++){let e=this.getBlankLine(LE,!0);p.push(e)}p.length>0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=GE(c,Math.max(g,0),this._cols))}for(let t=0;t<c.length;t++)u[t]<e&&c[t].setCell(u[t],r);let v=d-f;for(;v-->0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+a)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+d,this.ybase+t-1)}if(i.length>0){let e=[],t=[];for(let e=0;e<this.lines.length;e++)t.push(this.lines.get(e));let n=this.lines.length,r=n-1,o=0,s=i[o];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+a);let c=0;for(let l=Math.min(this.lines.maxLength-1,n+a-1);l>=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+1<this.lines.length&&this.lines.get(n+1).isWrapped;)n++;return{first:t,last:n}}setupTabStops(e){for(e==null?(this.tabs={},e=0):this.tabs[e]||(e=this.prevStop(e));e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e??=this.x;!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new qE(e);return this.markers.push(t),t.register(this.lines.onTrim(e=>{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.line<e.index+e.amount&&t.dispose(),t.line>e.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},QE=class extends Qx{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new Z),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new ZE(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ZE(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},$E=2,eD=1,tD=class extends Qx{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,$E),this.rows=Math.max(e.rawOptions.rows||0,eD),this.buffers=this._register(new QE(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,r&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};tD=Ib([X(0,hx)],tD);var nD={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:RT,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},rD=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],iD=class extends Qx{constructor(e){super(),this._onOptionChange=this._register(new Z),this.onOptionChange=this._onOptionChange.event;let t={...nD};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(Yx(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in nD))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in nD))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=nD[e],!aD(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=nD[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=rD.includes(t)?t:nD[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function aD(e){return e===`block`||e===`underline`||e===`bar`}function oD(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&oD(e[r],t-1);return n}var sD=Object.freeze({insertMode:!1}),cD=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),lD=class extends Qx{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new Z),this.onData=this._onData.event,this._onUserInput=this._register(new Z),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new Z),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=oD(sD),this.decPrivateModes=oD(cD)}reset(){this.modes=oD(sD),this.decPrivateModes=oD(cD)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};lD=Ib([X(0,lx),X(1,mx),X(2,hx)],lD);var uD={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function dD(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var fD=String.fromCharCode,pD={DEFAULT:e=>{let t=[dD(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${fD(t[0])}${fD(t[1])}${fD(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${dD(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${dD(e,!0)};${e.x};${e.y}${t}`}},mD=class extends Qx{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new Z),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(uD))this.addProtocol(e,uD[e]);for(let e of Object.keys(pD))this.addEncoding(e,pD[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};mD=Ib([X(0,lx),X(1,dx),X(2,hx)],mD);var hD=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],gD=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],_D;function vD(e,t){let n=0,r=t.length-1,i;if(e<t[0][0]||e>t[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e<t[i][0])r=i-1;else return!0;return!1}var yD=class{constructor(){if(this.version=`6`,!_D){_D=new Uint8Array(65536),_D.fill(1),_D[0]=0,_D.fill(0,1,32),_D.fill(0,127,160),_D.fill(2,4352,4448),_D[9001]=2,_D[9002]=2,_D.fill(2,11904,42192),_D[12351]=1,_D.fill(2,44032,55204),_D.fill(2,63744,64256),_D.fill(2,65040,65050),_D.fill(2,65072,65136),_D.fill(2,65280,65377),_D.fill(2,65504,65511);for(let e=0;e<hD.length;++e)_D.fill(0,hD[e][0],hD[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?_D[e]:vD(e,gD)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=bD.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return bD.createPropertyValue(0,n,r)}},bD=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new Z,this.onChange=this._onChange.event;let e=new yD;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a<i;++a){let o=t.charCodeAt(a);if(55296<=o&&o<=56319){if(++a>=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},xD=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function SD(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var CD=2147483647,wD=256,TD=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>wD)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e<t.length;++e){let r=t[e];if(Array.isArray(r))for(let e=0;e<r.length;++e)n.addSubParam(r[e]);else n.addParam(r)}return n}clone(){let t=new e(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let e=[];for(let t=0;t<this.length;++t){e.push(this.params[t]);let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>CD?CD:e}}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>CD?CD:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t<this.length;++t){let n=this._subParamsIdx[t]>>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,CD):e}},ED=[],DD=class{constructor(){this._state=0,this._active=ED,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ED}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ED,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ED,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,Yb(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t<n;){let n=e[t++];if(n===59){this._state=2,this._start();break}if(n<48||57<n){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+n-48}this._state===2&&n-t>0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=ED,this._id=-1,this._state=0}}},OD=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Yb(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},kD=[],AD=class{constructor(){this._handlers=Object.create(null),this._active=kD,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=kD}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=kD,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||kD,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,Yb(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=kD,this._ident=0}},jD=new TD;jD.addParam(0);var MD=class{constructor(e){this._handler=e,this._data=``,this._params=jD,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():jD,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Yb(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=jD,this._data=``,this._hitLimit=!1,e));return this._params=jD,this._data=``,this._hitLimit=!1,t}},ND=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;i<e.length;i++)this.table[t<<8|e[i]]=n<<4|r}},PD=160,FD=function(){let e=new ND(4095),t=Array.apply(null,Array(256)).map((e,t)=>t),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(PD,0,2,0),e.add(PD,8,5,8),e.add(PD,6,0,6),e.add(PD,11,0,11),e.add(PD,13,13,13),e}(),ID=class extends Qx{constructor(e=FD){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new TD,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(Yx(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new DD),this._dcsParser=this._register(new AD),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;t<e.intermediates.length;++t){let r=e.intermediates.charCodeAt(t);if(32>r||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n<t;++n){switch(r=e[n],i=this._transitions.table[this.currentState<<8|(r<160?r:PD)],i>>4){case 2:for(let i=n+1;;++i)if(i>=t||(r=e[i])<32||r>126&&r<PD||++i>=t||(r=e[i])<32||r>126&&r<PD||++i>=t||(r=e[i])<32||r>126&&r<PD||++i>=t||(r=e[i])<32||r>126&&r<PD){this._printHandler(e,n,i),n=i-1;break}break;case 3:this._executeHandlers[r]?this._executeHandlers[r]():this._executeHandlerFb(r),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:n,code:r,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let a=this._csiHandlers[this._collect<<8|r],s=a?a.length-1:-1;for(;s>=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n<t&&(r=e[n])>47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r<PD){this._dcsParser.put(e,n,i),n=i-1;break}break;case 14:if(o=this._dcsParser.unhook(r!==24&&r!==26),o)return this._preserveStack(6,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let i=n+1;;i++)if(i>=t||(r=e[i])<32||r>127&&r<PD){this._oscParser.put(e,n,i),n=i-1;break}break;case 6:if(o=this._oscParser.end(r!==24&&r!==26),o)return this._preserveStack(5,[],0,i,n),o;r===27&&(i|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=i&15}}},LD=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,RD=/^[\da-f]+$/;function zD(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf(`rgb:`)===0){t=t.slice(4);let e=LD.exec(t);if(e){let t=e[1]?15:e[4]?255:e[7]?4095:65535;return[Math.round(parseInt(e[1]||e[4]||e[7]||e[10],16)/t*255),Math.round(parseInt(e[2]||e[5]||e[8]||e[11],16)/t*255),Math.round(parseInt(e[3]||e[6]||e[9]||e[12],16)/t*255)]}}else if(t.indexOf(`#`)===0&&(t=t.slice(1),RD.exec(t)&&[3,6,9,12].includes(t.length))){let e=t.length/3,n=[0,0,0];for(let r=0;r<3;++r){let i=parseInt(t.slice(e*r,e*r+e),16);n[r]=e===1?i<<4:e===2?i:e===3?i>>4:i>>8}return n}}function BD(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function VD(e,t=16){let[n,r,i]=e;return`rgb:${BD(n,t)}/${BD(r,t)}/${BD(i,t)}`}var HD={"(":0,")":1,"*":2,"+":3,"-":1,".":2},UD=131072,WD=10;function GD(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var KD=5e3,qD=0,JD=class extends Qx{constructor(e,t,n,r,i,a,o,s,c=new ID){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Xb,this._utf8Decoder=new Zb,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=LE.clone(),this._eraseAttrDataInternal=LE.clone(),this._onRequestBell=this._register(new Z),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new Z),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new Z),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new Z),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new Z),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new Z),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new Z),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new Z),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new Z),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new Z),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new YD(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler($.BEL,()=>this.bell()),this._parser.setExecuteHandler($.LF,()=>this.lineFeed()),this._parser.setExecuteHandler($.VT,()=>this.lineFeed()),this._parser.setExecuteHandler($.FF,()=>this.lineFeed()),this._parser.setExecuteHandler($.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler($.BS,()=>this.backspace()),this._parser.setExecuteHandler($.HT,()=>this.tab()),this._parser.setExecuteHandler($.SO,()=>this.shiftOut()),this._parser.setExecuteHandler($.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Rw.IND,()=>this.index()),this._parser.setExecuteHandler(Rw.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Rw.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new OD(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new OD(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new OD(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new OD(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new OD(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new OD(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new OD(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new OD(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new OD(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new OD(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new OD(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new OD(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in JE)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new MD((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),KD))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${KD} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>UD&&(a=this._parseStack.position+UD)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<UD&&(this._parseBuffer=new Uint32Array(Math.min(e.length,UD))),o||this._dirtyRowTracker.clearRange(),e.length>UD)for(let t=a;t<e.length;t+=UD){let a=t+UD<e.length?t+UD:e.length,o=typeof e==`string`?this._stringDecoder.decode(e.substring(t,a),this._parseBuffer):this._utf8Decoder.decode(e.subarray(t,a),this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,o))return this._preserveStack(r,i,o,t),this._logSlowResolvingAsync(n),n}else if(!o){let t=typeof e==`string`?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(n=this._parser.parse(this._parseBuffer,t))return this._preserveStack(r,i,t,0),this._logSlowResolvingAsync(n),n}(this._activeBuffer.x!==r||this._activeBuffer.y!==i)&&this._onCursorMove.fire();let s=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),c=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);c<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(c,this._bufferService.rows-1),end:Math.min(s,this._bufferService.rows-1)})}print(e,t,n){let r,i,a=this._charsetService.charset,o=this._optionsService.rawOptions.screenReaderMode,s=this._bufferService.cols,c=this._coreService.decPrivateModes.wraparound,l=this._coreService.modes.insertMode,u=this._curAttrData,d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&n-t>0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;p<n;++p){if(r=e[p],r<127&&a){let e=a[String.fromCharCode(r)];e&&(r=e.charCodeAt(0))}let t=this._unicodeService.charProperties(r,f);i=bD.extractWidth(t);let n=bD.extractShouldJoin(t),m=n?bD.extractWidth(f):0;if(f=t,o&&this._onA11yChar.fire(Jb(r)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+i-m>s){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof BE&&d.copyCellsFrom(e,t,0,m,!1);t<s;)e.setCellFromCodepoint(t++,0,1,u)}else if(this._activeBuffer.x=s-1,i===2)continue}if(n&&this._activeBuffer.x){let e=d.getWidth(this._activeBuffer.x-1)?1:2;d.addCodepointToCell(this._activeBuffer.x-e,r,i);for(let e=i-m;--e>=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}else if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x<s&&n-t>0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!GD(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new MD(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new OD(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n<this._bufferService.rows;n++)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(n);break;case 1:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-r+1;for(;t--;)this._activeBuffer.lines.splice(i-1,1),this._activeBuffer.lines.splice(n,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=this._activeBuffer.ybase+this._activeBuffer.y,r;for(r=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-r;t--;)this._activeBuffer.lines.splice(n,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(LE));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let e=this._activeBuffer.scrollTop;e<=this._activeBuffer.scrollBottom;++e){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),n.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let n=e.params[0]||1,r=bD.extractWidth(t),i=this._activeBuffer.x-r,a=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(i),o=new Uint32Array(a.length*n),s=0;for(let e=0;e<a.length;){let t=a.codePointAt(e)||0;o[s++]=t,e+=t>65535?2:1}let c=s;for(let e=1;e<n;++e)o.copyWithin(c,0,s),c+=s;return this.print(o,0,c),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent($.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent($.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent($.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent($.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent($.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,YE),this._charsetService.setgCharset(1,YE),this._charsetService.setgCharset(2,YE),this._charsetService.setgCharset(3,YE);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol=`X10`;break;case 1e3:this._coreMouseService.activeProtocol=`VT200`;break;case 1002:this._coreMouseService.activeProtocol=`DRAG`;break;case 1003:this._coreMouseService.activeProtocol=`ANY`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug(`DECSET 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`SGR`;break;case 1015:this._logService.debug(`DECSET 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`SGR_PIXELS`;break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol=`NONE`;break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug(`DECRST 1005 not supported (see #2507)`);break;case 1006:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 1015:this._logService.debug(`DECRST 1015 not supported (see #2507)`);break;case 1016:this._coreMouseService.activeEncoding=`DEFAULT`;break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0)}return!0}requestMode(e,t){let n;(e=>(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${$.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=ex.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o<n.length&&o+a+1+i<r.length);break}if(r[1]===5&&a+i>=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t<e.length&&a+i<r.length);for(let e=2;e<r.length;++e)r[e]===-1&&(r[e]=0);switch(r[0]){case 38:n.fg=this._updateAttrColor(n.fg,r[1],r[3],r[4],r[5]);break;case 48:n.bg=this._updateAttrColor(n.bg,r[1],r[3],r[4],r[5]);break;case 58:n.extended=n.extended.clone(),n.extended.underlineColor=this._updateAttrColor(n.extended.underlineColor,r[1],r[3],r[4],r[5])}return a}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=LE.fg,e.bg=LE.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i<t;i++)n=e.params[i],n>=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=LE.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=LE.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=LE.fg&16777215,r.bg&=-67108864,r.bg|=LE.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${$.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${$.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=LE.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!GD(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${$.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>WD&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>WD&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(XD(n)){if(r===`?`)t.push({type:0,index:n});else{let e=zD(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e<n.length&&!(t>=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=zD(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e<n.length;++e)if(/^\d+$/.exec(n[e])){let r=parseInt(n[e]);XD(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug(`Serial port requested application keypad.`),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug(`Switching back to normal keypad.`),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,YE),!0}selectCharset(e){return e.length===2?(e[0]===`/`||this._charsetService.setgCharset(HD[e[0]],JE[e[1]]||YE),!0):(this.selectDefaultCharset(),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=LE.clone(),this._eraseAttrDataInternal=LE.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new nx;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let n=this._activeBuffer.ybase+this._activeBuffer.y+t,r=this._activeBuffer.lines.get(n);r&&(r.fill(e),r.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let n=e=>(this._coreService.triggerDataEvent(`${$.ESC}${e}${$.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},YD=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(qD=e,e=t,t=qD),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};YD=Ib([X(0,lx)],YD);function XD(e){return 0<=e&&e<256}var ZD=5e7,QD=12,$D=50,eO=class extends Qx{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new Z),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>ZD)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=QD?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=QD)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>$D&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},tO=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};tO=Ib([X(0,lx)],tO);var nO=!1,rO=class extends Qx{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new $x),this._onBinary=this._register(new Z),this.onBinary=this._onBinary.event,this._onData=this._register(new Z),this.onData=this._onData.event,this._onLineFeed=this._register(new Z),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new Z),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new Z),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new Z),this._instantiationService=new AE,this.optionsService=this._register(new iD(e)),this._instantiationService.setService(hx,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(tD)),this._instantiationService.setService(lx,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(NE)),this._instantiationService.setService(mx,this._logService),this.coreService=this._register(this._instantiationService.createInstance(lD)),this._instantiationService.setService(dx,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(mD)),this._instantiationService.setService(ux,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(bD)),this._instantiationService.setService(_x,this.unicodeService),this._charsetService=this._instantiationService.createInstance(xD),this._instantiationService.setService(fx,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(tO),this._instantiationService.setService(gx,this._oscLinkService),this._inputHandler=this._register(new JD(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(oS.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(oS.forward(this._bufferService.onResize,this._onResize)),this._register(oS.forward(this.coreService.onData,this._onData)),this._register(oS.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new eO((e,t)=>this._inputHandler.parse(e,t))),this._register(oS.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new Z),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!nO&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),nO=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,$E),t=Math.max(t,eD),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(SD.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(SD(this._bufferService),!1))),this._windowsWrappingHeuristics.value=Yx(()=>{for(let t of e)t.dispose()})}}},iO={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function aO(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?$.ESC+`OA`:$.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?$.ESC+`OD`:$.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?$.ESC+`OC`:$.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?$.ESC+`OB`:$.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:$.DEL,e.altKey&&(i.key=$.ESC+i.key);break;case 9:if(e.shiftKey){i.key=$.ESC+`[Z`;break}i.key=$.HT,i.cancel=!0;break;case 13:i.key=e.altKey?$.ESC+$.CR:$.CR,i.cancel=!0;break;case 27:i.key=$.ESC,e.altKey&&(i.key=$.ESC+$.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`D`:t?$.ESC+`OD`:$.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`C`:t?$.ESC+`OC`:$.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`A`:t?$.ESC+`OA`:$.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?$.ESC+`[1;`+(a+1)+`B`:t?$.ESC+`OB`:$.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=$.ESC+`[2~`);break;case 46:i.key=a?$.ESC+`[3;`+(a+1)+`~`:$.ESC+`[3~`;break;case 36:i.key=a?$.ESC+`[1;`+(a+1)+`H`:t?$.ESC+`OH`:$.ESC+`[H`;break;case 35:i.key=a?$.ESC+`[1;`+(a+1)+`F`:t?$.ESC+`OF`:$.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?$.ESC+`[5;`+(a+1)+`~`:$.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?$.ESC+`[6;`+(a+1)+`~`:$.ESC+`[6~`;break;case 112:i.key=a?$.ESC+`[1;`+(a+1)+`P`:$.ESC+`OP`;break;case 113:i.key=a?$.ESC+`[1;`+(a+1)+`Q`:$.ESC+`OQ`;break;case 114:i.key=a?$.ESC+`[1;`+(a+1)+`R`:$.ESC+`OR`;break;case 115:i.key=a?$.ESC+`[1;`+(a+1)+`S`:$.ESC+`OS`;break;case 116:i.key=a?$.ESC+`[15;`+(a+1)+`~`:$.ESC+`[15~`;break;case 117:i.key=a?$.ESC+`[17;`+(a+1)+`~`:$.ESC+`[17~`;break;case 118:i.key=a?$.ESC+`[18;`+(a+1)+`~`:$.ESC+`[18~`;break;case 119:i.key=a?$.ESC+`[19;`+(a+1)+`~`:$.ESC+`[19~`;break;case 120:i.key=a?$.ESC+`[20;`+(a+1)+`~`:$.ESC+`[20~`;break;case 121:i.key=a?$.ESC+`[21;`+(a+1)+`~`:$.ESC+`[21~`;break;case 122:i.key=a?$.ESC+`[23;`+(a+1)+`~`:$.ESC+`[23~`;break;case 123:i.key=a?$.ESC+`[24;`+(a+1)+`~`:$.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=$.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=$.DEL:e.keyCode===219?i.key=$.ESC:e.keyCode===220?i.key=$.FS:e.keyCode===221&&(i.key=$.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=iO[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=$.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=$.ESC+n}else if(e.keyCode===32)i.key=$.ESC+(e.ctrlKey?$.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=$.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=$.US),e.key===`@`&&(i.key=$.NUL))}return i}var oO=0,sO=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new qT,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new qT,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i<r.length;i++)n>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(oO=this._search(t),oO===-1)||this._getKey(this._array[oO])!==t)return!1;do if(this._array[oO]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(oO),!0;while(++oO<this._array.length&&this._getKey(this._array[oO])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((e,t)=>e-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i<this._array.length;i++)e[t]===i?t++:n[r++]=this._array[i];this._array=n,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(oO=this._search(e),!(oO<0||oO>=this._array.length)&&this._getKey(this._array[oO])===e))do yield this._array[oO];while(++oO<this._array.length&&this._getKey(this._array[oO])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(oO=this._search(e),!(oO<0||oO>=this._array.length)&&this._getKey(this._array[oO])===e))do t(this._array[oO]);while(++oO<this._array.length&&this._getKey(this._array[oO])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,n=this._array.length-1;for(;n>=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i<e)t=r+1;else{for(;r>0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},cO=0,lO=0,uO=class extends Qx{constructor(){super(),this._decorations=new sO(e=>e?.marker.line),this._onDecorationRegistered=this._register(new Z),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new Z),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(Yx(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new dO(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e<i&&(!n||(a.options.layer??`bottom`)===n)&&(yield a)}forEachDecorationAtCell(e,t,n,r){this._decorations.forEachByKey(t,t=>{cO=t.options.x??0,lO=cO+(t.options.width??1),e>=cO&&e<lO&&(!n||(t.options.layer??`bottom`)===n)&&r(t)})}},dO=class extends Zx{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new Z),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new Z),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position=`full`)}get backgroundColorRGB(){return this._cachedBg===null&&(this._cachedBg=this.options.backgroundColor?Jw.toColor(this.options.backgroundColor):void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this._cachedFg=this.options.foregroundColor?Jw.toColor(this.options.foregroundColor):void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},fO=1e3,pO=class{constructor(e,t=fO){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t);let r=performance.now();if(r-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},mO=20,hO=class extends Qx{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);if(this._topBoundaryFocusListener=e=>this._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new pO(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
68
69
|
`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Q(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(Yx(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<mO+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
69
70
|
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===mO+1&&(this._liveRegion.textContent+=Bb.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t<i.length?i[t]:i.slice(-1)[0]+1;return a>=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;e<this._terminal.rows;e++)this._rowElements[e]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[e]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){e.style.transform=``;let t=e.getBoundingClientRect().width,n=this._rowColumns.get(e)?.slice(-1)?.[0];if(!n)return;let r=n*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${r/t})`}};hO=Ib([X(1,px),X(2,Sx),X(3,wx)],hO);var gO=class extends Qx{constructor(e,t,n,r,i){super(),this._element=e,this._mouseService=t,this._renderService=n,this._bufferService=r,this._linkProviderService=i,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new Z),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new Z),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(Yx(()=>{qx(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Q(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Q(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(Q(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(Q(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e<n.length;e++){let t=n[e];if(t.classList.contains(`xterm`))break;if(t.classList.contains(`xterm-hover`))return}this._lastBufferCell&&t.x===this._lastBufferCell.x&&t.y===this._lastBufferCell.y||(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){this._activeLine!==e.y||this._wasResized?(this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1):this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){this._activeProviderReplies&&t||(this._activeProviderReplies?.forEach(e=>{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;r<t.size;r++){let i=t.get(r);if(i)for(let t=0;t<i.length;t++){let r=i[t],a=r.link.range.start.y<e?0:r.link.range.start.x,o=r.link.range.end.y>e?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;t<e;t++)(!this._activeProviderReplies.has(t)||this._activeProviderReplies.get(t))&&(i=!0);if(!i&&r){let e=r.find(e=>this._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;e<this._activeProviderReplies.size;e++){let r=this._activeProviderReplies.get(e)?.find(e=>this._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&_O(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,qx(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};gO=Ib([X(1,Cx),X(2,wx),X(3,lx),X(4,Ox)],gO);function _O(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var vO=class extends rO{constructor(e={}){super(e),this._linkifier=this._register(new $x),this.browser=AT,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new $x),this._onCursorMove=this._register(new Z),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new Z),this.onKey=this._onKey.event,this._onRender=this._register(new Z),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new Z),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new Z),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new Z),this.onBell=this._onBell.event,this._onFocus=this._register(new Z),this._onBlur=this._register(new Z),this._onA11yCharEmitter=this._register(new Z),this._onA11yTabEmitter=this._register(new Z),this._onWillOpen=this._register(new Z),this._setup(),this._decorationService=this._instantiationService.createInstance(uO),this._instantiationService.setService(vx,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(TT),this._instantiationService.setService(Ox,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(yx)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(oS.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(oS.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(oS.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(oS.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(Yx(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=qw.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${$.ESC}]${n};${VD(r)}${zw.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=Kw.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=Kw.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(hO,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(Q(this.element,`copy`,e=>{this.hasSelection()&&Ub(e,this._selectionService)}));let e=e=>Wb(e,this.textarea,this.coreService,this.optionsService);this._register(Q(this.textarea,`paste`,e)),this._register(Q(this.element,`paste`,e)),PT?this._register(Q(this.element,`mousedown`,e=>{e.button===2&&qb(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Q(this.element,`contextmenu`,e=>{qb(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),HT&&this._register(Q(this.element,`auxclick`,e=>{e.button===1&&Kb(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Q(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(Q(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(Q(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(Q(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(Q(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(Q(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(Q(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(Q(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,Rb.get()),UT||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(CT,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(Sx,this._coreBrowserService),this._register(Q(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(Q(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(yT,this._document,this._helperContainer),this._instantiationService.setService(xx,this._charSizeService),this._themeService=this._instantiationService.createInstance(DE),this._instantiationService.setService(Dx,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(eT),this._instantiationService.setService(Ex,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(YT,this.rows,this.screenElement)),this._instantiationService.setService(wx,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(Bw,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(OT),this._instantiationService.setService(Cx,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(gO,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(jw,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(_E,this.element,this.screenElement,r)),this._instantiationService.setService(Tx,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(oS.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(Mw,this.screenElement)),this._register(Q(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(hO,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Lw,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Lw,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(vT,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Q(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(Q(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=$.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Gb(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;t||e.key!==`Dead`&&e.key!==`AltGraph`||(this._unprocessedDeadKey=!0);let n=aO(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===$.ETX||n.key===$.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(yO(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e===this.cols&&t===this.rows?this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure():super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(LE));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),this._selectionService?.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent($.ESC+`[I`):this.coreService.triggerDataEvent($.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[4;${t};${e}t`);break;case 1:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}};function yO(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var bO=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n<this._addons.length;n++)if(this._addons[n]===e){t=n;break}if(t===-1)throw Error(`Could not dispose an addon that has not been loaded`);e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},xO=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new nx)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},SO=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new xO(t)}getNullCell(){return new nx}},CO=class extends Qx{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new Z),this.onBufferChange=this._onBufferChange.event,this._normal=new SO(this._core.buffers.normal,`normal`),this._alternate=new SO(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},wO=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},TO=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},EO=[`cols`,`rows`],DO=0,OO=class extends Qx{constructor(e){super(),this._core=this._register(new vO(e)),this._addonManager=this._register(new bO),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(EO.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new wO(this._core),this._parser}get unicode(){return this._checkProposedApi(),new TO(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new CO(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
|
|
70
|
-
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Rb.get()},set promptLabel(e){Rb.set(e)},get tooMuchOutput(){return Bb.get()},set tooMuchOutput(e){Bb.set(e)}}}_verifyIntegers(...e){for(DO of e)if(DO===1/0||isNaN(DO)||DO%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(DO of e)if(DO&&(DO===1/0||isNaN(DO)||DO%1!=0||DO<0))throw Error(`This API only accepts positive integers`)}},kO={"‘":`'`,"’":`'`,"“":`"`,"”":`"`,"—":`--`,"–":`-`,"…":`...`,"\xA0":` `},AO=/[‘’“”—–…\u00a0]/g;function jO(e){return e.replace(AO,e=>kO[e]??e)}function MO(e,t){let n=Array.from(jO(e)),r=Array.from(jO(t)),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;let a=r.slice(i),o=a.filter(e=>e!==``);return{backspaces:n.length-i,text:o.join(``),fillerLeft:o.length!==a.length}}var NO=new Set([`Shift`,`Control`,`Alt`,`AltGraph`,`Meta`,`CapsLock`,`Fn`,`FnLock`,`NumLock`,`ScrollLock`]),PO=new Set([`Dead`,`Process`,`Unidentified`,`Compose`]),FO={shell:{autocorrect:`off`,autocapitalize:`none`,spellcheck:`true`},claude:{autocorrect:`on`,autocapitalize:`sentences`,spellcheck:`true`}},IO=``.repeat(120),LO={autocorrect:`off`,autocapitalize:`off`,spellcheck:`false`},RO=/^insertFrom(Paste|Drop|Yank)/;function zO(e,t){for(let[n,r]of Object.entries(t))e.setAttribute(n,r)}function BO(e,t){let{element:n,textarea:r}=e;if(!n||!r){console.warn(`xterm.js no longer exposes its input field; Smart typing is off`);return}let i=r,a=``;function o(){i.value=``,i.value=IO,i.setSelectionRange(IO.length,IO.length),a=i.value}function s(t){let n=Ph();e.input(t,!0),n&&o()}e.attachCustomKeyEventHandler(e=>{let{key:t}=e;if(NO.has(t))return!0;let n=()=>!e.ctrlKey&&!e.metaKey;if(t===`Backspace`){if(n()&&i.value!==``)return!1}else if(t===`Enter`){if(!e.shiftKey&&!e.altKey&&n())return!1}else if(PO.has(t)||t.length===1&&n())return!1;return e.type===`keydown`&&o(),!0});let c=e=>{if(e.target!==i)return;e.stopPropagation();let{inputType:t}=e;if(t===`insertLineBreak`||t===`insertParagraph`)s(`\r`),o();else if(RO.test(t))o();else{let e=i.value,{backspaces:t,text:n,fillerLeft:r}=MO(a,e);a=e;let c=``.repeat(t)+n.replace(/\r?\n/g,`\r`);c&&s(c),r&&o()}},l=!1,u=e=>{e.target===i&&(l=e.type!==`compositionend`,e.stopPropagation())},d=e=>{e.target===i&&o()},f=()=>o(),p=()=>{if(l||document.activeElement!==i)return;let{selectionStart:e,selectionEnd:t,value:n}=i;e===t&&e!==n.length&&i.setSelectionRange(n.length,n.length)},m=[[`input`,c],[`compositionstart`,u],[`compositionupdate`,u],[`compositionend`,u],[`paste`,d]];for(let[e,t]of m)n.addEventListener(e,t,!0);return i.addEventListener(`blur`,f),document.addEventListener(`selectionchange`,p),zO(i,FO[t]),o(),{clear:o,dispose(){for(let[e,t]of m)n.removeEventListener(e,t,!0);i.removeEventListener(`blur`,f),document.removeEventListener(`selectionchange`,p),n.isConnected&&e.attachCustomKeyEventHandler(()=>!0),zO(i,LO),i.value=``}}}function VO(e,t){return`/api/sessions/${e}/terminal?${new URLSearchParams({cols:String(t.cols),rows:String(t.rows)})}`}function HO(e){return JSON.stringify(e)}var UO=0,WO=1,GO=500,KO=5e3;function qO(e){let{sessionId:t,openSocket:n,wake:r,retryFirstMs:i=GO,retryMaxMs:a=KO}=e,o=new Set,s=e.size,c,l,u=0,d=!1,f=!1,p=!1,m=[],h=e=>{if(d!==e){d=e;for(let t of[...o])t.reconnecting?.(e)}},g=e=>{let t=HO(e);c?.readyState===WO?c.send(t):c?.readyState===UO&&m.push(t)},_=()=>{clearTimeout(l);let e=n(VO(t,s));c=e,e.binaryType=`arraybuffer`,e.onopen=()=>{u=0,h(!1);for(let t of m.splice(0))e.send(t)},e.onmessage=e=>{if(!(e.data instanceof ArrayBuffer))return;let t=new Uint8Array(e.data);for(let e of[...o])e.output?.(t)},e.onclose=t=>{if(f||c!==e)return;if(t.code===4410){p=!0;for(let e of[...o])e.ended?.();return}h(!0);let n=Math.min(i*2**u,a);u+=1,l=setTimeout(_,n)}},v=r?.(()=>{c&&c.readyState!==WO&&c.readyState!==UO&&!f&&!p&&u>0&&_()});return _(),{input(e,t){g(t?{type:`input`,data:e,automatic:t}:{type:`input`,data:e})},resize(e,t){s={cols:e,rows:t},g({type:`resize`,cols:e,rows:t})},subscribe(e){return o.add(e),()=>{o.delete(e)}},close(){f=!0,clearTimeout(l),v?.(),o.clear(),c?.close()}}}var JO=100,YO=50,XO=.05,ZO=.9985,QO=2,$O=400,ek=300,tk=1e3/60;function nk(e,t){let n=0,r=[],i,a=0,o=0,s,c=0,l=0,u=e=>{n+=e;let r=t.lineHeight(),i=Math.trunc(n/r);i!==0&&(n-=i*r,t.scroll(i))},d=()=>e.clientHeight/tk,f=()=>{s!==void 0&&cancelAnimationFrame(s),s=void 0,o=0},p=e=>{let n=Math.min(e-c,4*tk);c=e;let r=QO*t.lineHeight()/tk,i=Math.abs(o),a=i>r?i*ZO**n:i-r/$O*n;a<=0?f():(o=Math.sign(o)*a,u(o*n),s=requestAnimationFrame(p))},m=e=>{let t=d();o=Math.max(-t,Math.min(t,e)),c=performance.now(),s=requestAnimationFrame(p)},h=e=>{let t=r.filter(t=>e-t.time<=JO),n=t[0],i=t[t.length-1];return!n||!i||n===i||e-i.time>YO?0:(n.y-i.y)/Math.max(i.time-n.time,1)},g=e=>{l=0,s!==void 0&&(l=o,f(),e.preventDefault());let t=e.touches.length===1?e.touches[0]:void 0;i=t?.clientY,a=performance.now(),r=t?[{time:a,y:t.clientY}]:[]},_=e=>{let t=e.touches[0];if(i===void 0||!t||e.touches.length!==1)return;e.preventDefault(),u(i-t.clientY),i=t.clientY;let n=performance.now();r.push({time:n,y:t.clientY}),r=r.filter(e=>n-e.time<=JO)},v=e=>{if(i===void 0||e.touches.length>0)return;i=void 0;let t=performance.now(),n=h(t);Math.sign(n)===Math.sign(l)&&t-a<=ek&&(n+=l),l=0,Math.abs(n)>=XO&&m(n)},y=()=>{i=void 0,l=0};return e.addEventListener(`touchstart`,g,{passive:!1}),e.addEventListener(`touchmove`,_,{passive:!1}),e.addEventListener(`touchend`,v),e.addEventListener(`touchcancel`,y),()=>{f(),e.removeEventListener(`touchstart`,g),e.removeEventListener(`touchmove`,_),e.removeEventListener(`touchend`,v),e.removeEventListener(`touchcancel`,y)}}var rk=5,ik=50,ak=.3;function ok(e){let t=!1,n=0,r=()=>{let t=(e.element?.querySelector(`.xterm-screen`)?.clientHeight??0)/e.rows;return t>0?t:1},i=n=>{let r=e.element;if(!r||n===0)return;let i=r.getBoundingClientRect(),a={bubbles:!0,cancelable:!0,clientX:i.left+i.width/2,clientY:i.top+i.height/2,deltaY:Math.sign(n),deltaMode:WheelEvent.DOM_DELTA_LINE};t=!0;try{for(let e=0;e<Math.abs(n);e++)r.dispatchEvent(new WheelEvent(`wheel`,a))}finally{t=!1}},a=t=>{let{fastScrollSensitivity:i=5,scrollSensitivity:a=1}=e.options,o=t.altKey||t.ctrlKey?i:1,s=t.deltaY*o*a;if(t.deltaMode!==WheelEvent.DOM_DELTA_PIXEL)return Math.sign(s);s/=r(),Math.abs(t.deltaY)<ik&&(s*=ak),n+=s;let c=Math.trunc(n);return n-=c,Math.sign(c)};return e.attachCustomWheelEventHandler(e=>t||e.shiftKey||e.deltaY===0?!0:(i(a(e)*rk),e.preventDefault(),!1)),{scroll:i,lineHeight:r,dispose:()=>e.attachCustomWheelEventHandler(()=>!0)}}function sk(e){let t=new URL(e,window.location.href);return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}function ck(e){let t=()=>{document.visibilityState!==`hidden`&&e()};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`online`,t),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`online`,t)}}function lk(e,t){let n=e._core?.coreService?.onUserInput;if(!n)return console.warn(`xterm.js no longer reports user input; treating all input as typed`),e.onData(e=>t(e,!1));let r=!1,i=n(()=>{r=!0}),a=e.onData(e=>{let n=!r;r=!1,t(e,n)});return{dispose:()=>{i.dispose(),a.dispose()}}}function uk(e){let t=e.slice(e.indexOf(`;`)+1);if(t!==`?`&&t!==``)try{let e=Uint8Array.from(atob(t),e=>e.charCodeAt(0));return new TextDecoder().decode(e)}catch{return}}function dk(e){if(!/Mac/.test(navigator.platform))return()=>{};let t=e=>{e.shiftKey&&!e.altKey&&(e.stopImmediatePropagation(),e.preventDefault(),e.target?.dispatchEvent(new MouseEvent(`mousedown`,{bubbles:!0,cancelable:!0,composed:!0,view:window,button:e.button,buttons:e.buttons,clientX:e.clientX,clientY:e.clientY,detail:e.detail,shiftKey:!0,altKey:!0})))};return e.addEventListener(`mousedown`,t,!0),()=>e.removeEventListener(`mousedown`,t,!0)}function fk({sessionId:e,kind:t,focused:n}){let r=(0,D.useRef)(null),[i,a]=(0,D.useState)(!1),o=(0,D.useRef)(null),[s,c]=(0,D.useState)(null),l=(0,D.useRef)(n);l.current=n;let u=Sh(),d=vh(e),f=u&&d,p=(0,D.useRef)(null);return(0,D.useEffect)(()=>{n&&o.current?.focus()},[n]),(0,D.useEffect)(()=>{if(n)return wh({send:e=>o.current?.input(e,!0),paste:e=>o.current?.paste(e),blur:()=>o.current?.blur(),clearTypedLine:()=>p.current?.clear()})},[n]),(0,D.useEffect)(()=>{let t=r.current;if(!t)return;let n=!1,i;return Vg().then(()=>{n||(i=s(t))}),()=>{n=!0,i?.()};function s(t){let n=new OO({fontFamily:zg,fontSize:13,theme:Lg,minimumContrastRatio:Bg,cursorBlink:!0,scrollback:0,macOptionClickForcesSelection:!0,allowProposedApi:!0}),r=new Nv;n.loadAddon(r),n.loadAddon(new Mb),n.open(t),r.fit();let i=n.parser.registerOscHandler(52,e=>{let t=uk(e);return t!==void 0&&navigator.clipboard?.writeText(t).catch(()=>{}),!0}),s=dk(t),u=ok(n),d=nk(t,u),f=qO({sessionId:e,size:{cols:n.cols,rows:n.rows},openSocket:e=>new WebSocket(sk(e)),wake:ck}),m=f.subscribe({output:e=>n.write(e),reconnecting:e=>{a(e),p.current?.clear(),e||n.reset()}}),h=lk(n,(e,t)=>f.input(t?e:Rh(e),t)),g=n.onResize(({cols:e,rows:t})=>f.resize(e,t)),_=new ResizeObserver(()=>r.fit());return _.observe(t),o.current=n,c(n),l.current&&n.focus(),()=>{o.current=null,c(null),_.disconnect(),h.dispose(),g.dispose(),i.dispose(),s(),d(),u.dispose(),m(),f.close(),n.dispose()}}},[e]),(0,D.useEffect)(()=>{if(!f||!s)return;let e=BO(s,t);return p.current=e??null,()=>{p.current=null,e?.dispose()}},[s,t,f]),(0,W.jsxs)(`div`,{className:`relative h-full w-full`,children:[(0,W.jsx)(`div`,{ref:r,className:`h-full w-full touch-none`}),i&&(0,W.jsx)(`div`,{role:`status`,className:`absolute top-2 left-2 rounded bg-amber-500 px-2 py-1 text-xs font-medium text-black`,children:`reconnecting…`})]})}function pk({session:e,focused:t,starting:n=!1}){return(0,W.jsx)(`section`,{"aria-label":`Terminal ${e.name}`,className:`h-full min-h-0 p-2`,style:{backgroundColor:Ig},children:e.status===`running`?(0,W.jsx)(fk,{sessionId:e.id,kind:e.kind,focused:t}):!n&&(0,W.jsx)(hk,{session:e})})}function mk({children:e}){return(0,W.jsx)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-4 text-center text-sm text-muted-foreground`,children:e})}function hk({session:e}){let t=Fg(),[n,r]=(0,D.useState)(!1);return(0,W.jsxs)(mk,{children:[(0,W.jsxs)(`p`,{children:[e.name,` is Stopped.`]}),(0,W.jsxs)(Uh,{variant:`secondary`,size:`sm`,disabled:n,onClick:async()=>{r(!0);try{await t.restartSession(e.id)}finally{r(!1)}},children:[(0,W.jsx)(ze,{}),`Restart`]})]})}function gk({workspace:e,workspaces:t}){let n=Fg(),[r,i]=(0,D.useState)(!1);return(0,W.jsxs)(`section`,{"aria-label":`Missing folder`,className:`h-full min-h-0 p-2`,style:{backgroundColor:Ig},children:[(0,W.jsxs)(mk,{children:[(0,W.jsxs)(`p`,{className:`flex items-center gap-1.5 text-destructive`,children:[(0,W.jsx)($e,{className:`size-4 shrink-0`}),`This Workspace's folder is missing`]}),(0,W.jsxs)(Uh,{variant:`secondary`,size:`sm`,onClick:()=>i(!0),children:[(0,W.jsx)(he,{}),`Change folder`]})]}),r&&(0,W.jsx)(Av,{workspace:e,workspaces:t,edit:`folder`,onSave:t=>n.updateWorkspace(e.id,t),onClose:()=>i(!1)})]})}function _k({delayDuration:e=0,...t}){return(0,W.jsx)(wm,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function vk({...e}){return(0,W.jsx)(Om,{"data-slot":`tooltip`,...e})}function yk({...e}){return(0,W.jsx)(Am,{"data-slot":`tooltip-trigger`,...e})}function bk({className:e,sideOffset:t=0,children:n,...r}){return(0,W.jsx)(Pm,{children:(0,W.jsxs)(Im,{"data-slot":`tooltip-content`,sideOffset:t,className:U(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,W.jsx)(Bm,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function xk({label:e,tooltip:t=e,className:n,children:r,...i}){let a=uh(),o=(0,W.jsx)(Uh,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":e,className:U(`size-7 text-muted-foreground hover:text-foreground`,n),...i,onFocus:e=>{i.onFocus?.(e),e.currentTarget.matches(`:focus-visible`)||e.preventDefault()},children:r});return a?o:(0,W.jsxs)(vk,{children:[(0,W.jsx)(yk,{asChild:!0,children:o}),(0,W.jsx)(bk,{children:t})]})}function Sk({className:e,orientation:t=`horizontal`,...n}){return(0,W.jsx)(rm,{"data-slot":`tabs`,"data-orientation":t,orientation:t,className:U(`group/tabs flex gap-2 data-[orientation=horizontal]:flex-col`,e),...n})}var Ck=Vh(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function wk({className:e,variant:t=`default`,...n}){return(0,W.jsx)(am,{"data-slot":`tabs-list`,"data-variant":t,className:U(Ck({variant:t}),e),...n})}function Tk({className:e,...t}){return(0,W.jsx)(sm,{"data-slot":`tabs-trigger`,className:U(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent`,`data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100`,e),...t})}function Ek({session:e,shown:t,close:n}){return(0,W.jsxs)(`span`,{className:`relative flex h-full shrink-0 items-center`,children:[(0,W.jsxs)(Tk,{value:e.id,"aria-label":e.name,"aria-current":t||void 0,className:U(`h-full max-w-56 flex-none rounded-none pl-2.5 font-normal`,`after:bg-primary group-data-[orientation=horizontal]/tabs:after:bottom-0`,n?`pr-12`:`pr-6`),children:[(0,W.jsx)(Ln,{session:e,className:`size-3.5`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,W.jsxs)(`span`,{className:`absolute right-1 flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:`pointer-events-none flex w-3.5 justify-center`,children:(0,W.jsx)(_g,{session:e})}),n]})]})}function Dk({worker:e,tabs:t,shownId:n,onShowWorker:r,onShowTab:i,onCloseTab:a}){return(0,W.jsx)(Sk,{value:n??``,onValueChange:t=>t===e?.id?r():i(t),activationMode:`manual`,className:`h-full min-w-0 gap-0`,children:(0,W.jsxs)(wk,{variant:`line`,className:`h-full w-full justify-start gap-0 overflow-x-auto overflow-y-hidden p-0 group-data-[orientation=horizontal]/tabs:h-full`,children:[e&&(0,W.jsx)(Ek,{session:e,shown:n===e.id}),t.map(e=>(0,W.jsx)(Ek,{session:e,shown:n===e.id,close:(0,W.jsx)(xk,{label:`Close tab ${e.name}`,tooltip:`Close tab (the Session keeps running)`,className:`size-5`,onClick:()=>a(e.id),children:(0,W.jsx)(tt,{className:`size-3`})})},e.id))]})})}var Ok=`36px`;function kk(e,t){return t===`left`?`${Ok} 6px minmax(0, 1fr)`:t===`right`?`minmax(0, 1fr) 6px ${Ok}`:`minmax(0, ${e}fr) 6px minmax(0, ${1-e}fr)`}function Ak({side:e,session:t,onOpen:n}){let r=`Show ${t.name}`;return(0,W.jsxs)(`div`,{className:`relative h-full border-x bg-sidebar`,children:[(0,W.jsxs)(vk,{children:[(0,W.jsx)(yk,{asChild:!0,children:(0,W.jsxs)(Uh,{variant:`ghost`,"aria-label":r,onClick:n,className:`h-full w-full flex-col justify-start gap-2 rounded-none px-0 py-3 text-xs font-normal text-muted-foreground`,children:[(0,W.jsx)(Ln,{session:t,className:`size-4`}),(0,W.jsx)(`span`,{className:`min-h-0 truncate`,style:{writingMode:`vertical-rl`},children:t.name})]})}),(0,W.jsx)(bk,{side:e===`left`?`right`:`left`,children:r})]}),(0,W.jsx)(`span`,{className:`pointer-events-none absolute bottom-3 left-1/2 flex -translate-x-1/2`,children:(0,W.jsx)(_g,{session:t})})]})}function jk({session:e,workspace:t,workspaces:n,focused:r,starting:i}){let a=i&&e.role!==null;return e.status!==`running`&&!a&&t.missing?(0,W.jsx)(gk,{workspace:t,workspaces:n}):(0,W.jsx)(pk,{session:e,focused:r,starting:a},e.id)}function Mk({children:e}){return(0,W.jsx)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b px-2 text-xs`,children:e})}function Nk({view:e,workspaces:t}){let n=(0,D.useRef)(null),r=(0,D.useRef)(e.ratio),[i,a]=(0,D.useState)(!1),{workspace:o}=e;if(!o)return(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Create a Workspace to get started.`});let s=(n,r)=>(0,W.jsx)(jk,{session:r,workspace:o,workspaces:t,focused:e.focusedTerminal===n,starting:e.starting}),c=(t,n,r)=>(0,W.jsx)(`div`,{role:`group`,"aria-label":t===`left`?`Left Pane`:`Right Pane`,onFocusCapture:()=>e.focusTerminal(t),className:`flex min-h-0 min-w-0 flex-col`,children:e.shut===t&&n.kind===`session`?(0,W.jsx)(Ak,{side:t,session:n.session,onOpen:()=>e.reopen(t)}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Mk,{children:r}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1`,children:n.kind===`session`&&s(t,n.session)})]})}),{left:l,right:u,ratio:d,shut:f}=e,p=t=>{let i=n.current?.getBoundingClientRect();i&&i.width>0&&e.setRatio((t-i.left)/i.width,r.current)},m=f===`left`?0:f===`right`?1:d;return(0,W.jsxs)(`div`,{ref:n,className:`grid min-h-0 flex-1`,style:{gridTemplateColumns:kk(d,f)},children:[c(`left`,l,(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 px-1 text-sm font-medium`,children:[(0,W.jsx)(Ln,{session:{role:`prime`,kind:`claude`},className:`size-3.5`}),`Prime`,l.kind===`session`&&(0,W.jsx)(_g,{session:l.session})]})),(0,W.jsx)(`div`,{role:`separator`,"aria-label":`Resize panes`,"aria-orientation":`vertical`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(m*100),title:`Drag to resize, or to an edge to shut a Pane. Double-click for half and half.`,tabIndex:0,"data-dragging":i||void 0,className:`cursor-col-resize touch-none bg-border transition-colors hover:bg-primary focus-visible:bg-primary data-dragging:bg-primary`,onPointerDown:e=>{r.current=d,e.currentTarget.setPointerCapture(e.pointerId),a(!0)},onLostPointerCapture:()=>a(!1),onPointerMove:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&p(e.clientX)},onDoubleClick:()=>e.setRatio(.5),onKeyDown:t=>{let n=t.key===`ArrowLeft`?-.02:t.key===`ArrowRight`?.02:0;n&&(t.preventDefault(),f?f===`left`==n>0&&e.reopen(f):e.setRatio(d+n))}}),c(`right`,u,(0,W.jsx)(Dk,{worker:e.worker,tabs:e.tabs,shownId:u.kind===`session`?u.session.id:void 0,onShowWorker:e.showWorker,onShowTab:t=>e.openOtherSession(o.id,t),onCloseTab:e.closeTab}))]})}function Pk({marker:e,who:t,className:n}){return(0,W.jsx)(`span`,{role:`img`,"aria-label":`${t} ${eh[e]}`,className:U(`grid size-2 shrink-0 rounded-full`,n),children:(0,W.jsx)(nh,{marker:e,className:`size-full`})})}function Fk({view:e,onOpen:t}){return(0,W.jsxs)(`span`,{className:`relative ml-2 inline-flex`,children:[(0,W.jsx)(Uh,{variant:`ghost`,size:`sm`,"aria-label":`Menu`,onClick:t,children:(0,W.jsx)(De,{})}),e.hintElsewhere&&(0,W.jsx)(Pk,{marker:e.hintElsewhere,who:`A session in another workspace`,className:`pointer-events-none absolute top-1 right-1.5 ring-2 ring-background`})]})}function Ik({view:e}){let[t,n]=(0,D.useState)(!1),{workspace:r,session:i}=e;return r?(0,W.jsxs)(rg,{open:t,onOpenChange:n,children:[(0,W.jsxs)(`h1`,{className:`flex min-w-0 items-center gap-1 text-sm`,children:[(0,W.jsx)(ig,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,"aria-label":i?`${r.name} › ${i.name}`:r.name,className:`flex min-w-0 items-center gap-1 rounded-md px-1.5 py-1 outline-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,W.jsxs)(`span`,{className:U(`relative flex min-w-0`,e.bellHere&&`pr-2`),children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,title:r.folder,children:r.name}),e.bellHere&&(0,W.jsx)(Pk,{marker:`bell`,who:`Another session here`,className:`absolute top-0 right-0`})]}),i&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-muted-foreground`,children:` › `}),(0,W.jsx)(`span`,{className:`shrink-0 text-foreground`,children:i.name})]}),(0,W.jsx)(ae,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]})}),i&&(0,W.jsx)(_g,{session:i})]}),(0,W.jsxs)(sg,{side:`bottom`,className:`max-h-[80dvh] gap-0 rounded-t-2xl pb-[max(12px,env(safe-area-inset-bottom))]`,children:[(0,W.jsxs)(cg,{className:`pb-2`,children:[(0,W.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto mb-2 h-1 w-10 rounded-full bg-muted-foreground/40`}),(0,W.jsxs)(lg,{className:`flex min-w-0 items-center gap-2 text-sm`,title:r.folder,children:[(0,W.jsx)(sh,{workspace:r}),(0,W.jsx)(`span`,{className:`truncate`,children:r.name})]}),(0,W.jsx)(ug,{className:`sr-only`,children:`Choose a Session to show it.`})]}),(0,W.jsx)(Lk,{view:e,workspace:r,onClose:()=>n(!1)})]})]}):null}function Lk({view:e,workspace:t,onClose:n}){let{primeAndWorker:r,others:i}=dg(t.sessions),a=r=>(0,W.jsx)(Rk,{session:r,current:r.id===e.session?.id,onChoose:()=>{e.show(t.id,r.id),n()}},r.id);return(0,W.jsxs)(`ul`,{"aria-label":`Sessions`,className:`grid gap-1 overflow-y-auto px-3`,children:[r.map(a),r.length>0&&i.length>0&&(0,W.jsx)(`li`,{"aria-hidden":`true`,className:`px-2 py-1`,children:(0,W.jsx)(Wh,{})}),i.map(a)]})}function Rk({session:e,current:t,onChoose:n}){let r=e.status===`stopped`;return(0,W.jsxs)(`li`,{className:`relative`,children:[(0,W.jsxs)(Uh,{variant:`ghost`,"aria-label":e.name,"aria-current":t?`true`:void 0,className:U(`h-12 w-full justify-start gap-3 pr-9 pl-3 font-normal`,t&&`bg-accent shadow-[inset_3px_0_0_var(--primary)]`,r&&!t&&`text-muted-foreground`),onClick:n,children:[(0,W.jsx)(Ln,{session:e,className:U(`size-4`,r&&`opacity-50`)}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.name}),r&&(0,W.jsx)(tg,{variant:`outline`,className:`text-[10px] font-normal tracking-wide text-muted-foreground uppercase`,children:`stopped`})]}),(0,W.jsx)(_g,{session:e,className:`pointer-events-none absolute top-1/2 right-3 -translate-y-1/2`})]})}function zk({view:e,workspaces:t}){let{workspace:n,session:r}=e;return n?(0,W.jsx)(`div`,{className:`min-h-0 flex-1`,children:r&&(0,W.jsx)(jk,{session:r,workspace:n,workspaces:t,focused:!0,starting:e.starting})}):(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Create a Workspace to get started.`})}function Bk({workspaces:e,onCreate:t,trigger:n}){let[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(),s=a&&Gg(a),c=a?.newFolders.length??0,[l,u]=(0,D.useState)(``),[d,f]=(0,D.useState)(),p=(0,D.useId)(),m=async()=>{if(s!==void 0)try{await t({folder:s,name:l.trim()||void 0,...c>0&&{createMissingFolders:!0}}),i(!1)}catch(e){f(e instanceof Error?e.message:String(e))}};return(0,W.jsxs)(Y_,{open:r,onOpenChange:e=>{i(e),e&&(u(``),f(void 0))},children:[(0,W.jsx)(X_,{asChild:!0,children:n}),(0,W.jsx)($_,{className:uv,children:(0,W.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,W.jsxs)(ev,{children:[(0,W.jsx)(nv,{children:`New Workspace`}),(0,W.jsx)(rv,{children:`Pick a project folder on the Host, or make new ones for it.`})]}),(0,W.jsx)(mv,{workspaces:e,onChange:e=>{o(e),f(void 0)}}),(0,W.jsxs)(Dv,{children:[(0,W.jsx)(Ov,{htmlFor:p,children:`Name`}),(0,W.jsx)(lv,{id:p,placeholder:s===void 0?``:Hg(s)||`/`,value:l,onChange:e=>{u(e.target.value),f(void 0)}})]}),d&&(0,W.jsx)(kv,{children:d}),(0,W.jsx)(tv,{children:(0,W.jsx)(Uh,{type:`submit`,disabled:s===void 0,children:c===0?`Create Workspace`:c===1?`Create folder and Workspace`:`Create ${c} folders and Workspace`})})]})})]})}function Vk(){var e=[...arguments];return(0,D.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var Hk=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Uk(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Wk(e){return`nodeType`in e}function Gk(e){return e?Uk(e)?e:Wk(e)?e.ownerDocument?.defaultView??window:window:window}function Kk(e){let{Document:t}=Gk(e);return e instanceof t}function qk(e){return!Uk(e)&&e instanceof Gk(e).HTMLElement}function Jk(e){return e instanceof Gk(e).SVGElement}function Yk(e){return e?Uk(e)?e.document:Wk(e)?Kk(e)?e:qk(e)||Jk(e)?e.ownerDocument:document:document:document}var Xk=Hk?D.useLayoutEffect:D.useEffect;function Zk(e){let t=(0,D.useRef)(e);return Xk(()=>{t.current=e}),(0,D.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function Qk(){let e=(0,D.useRef)(null);return[(0,D.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,D.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function $k(e,t){t===void 0&&(t=[e]);let n=(0,D.useRef)(e);return Xk(()=>{n.current!==e&&(n.current=e)},t),n}function eA(e,t){let n=(0,D.useRef)();return(0,D.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function tA(e){let t=Zk(e),n=(0,D.useRef)(null);return[n,(0,D.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function nA(e){let t=(0,D.useRef)();return(0,D.useEffect)(()=>{t.current=e},[e]),t.current}var rA={};function iA(e,t){return(0,D.useMemo)(()=>{if(t)return t;let n=rA[e]==null?0:rA[e]+1;return rA[e]=n,e+`-`+n},[e,t])}function aA(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var oA=aA(1),sA=aA(-1);function cA(e){return`clientX`in e&&`clientY`in e}function lA(e){if(!e)return!1;let{KeyboardEvent:t}=Gk(e.target);return t&&e instanceof t}function uA(e){if(!e)return!1;let{TouchEvent:t}=Gk(e.target);return t&&e instanceof t}function dA(e){if(uA(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return cA(e)?{x:e.clientX,y:e.clientY}:null}var fA=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[fA.Translate.toString(e),fA.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),pA=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function mA(e){return e.matches(pA)?e:e.querySelector(pA)}var hA={display:`none`};function gA(e){let{id:t,value:n}=e;return D.createElement(`div`,{id:t,style:hA},n)}function _A(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return D.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function vA(){let[e,t]=(0,D.useState)(``);return{announce:(0,D.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var yA=(0,D.createContext)(null);function bA(e){let t=(0,D.useContext)(yA);(0,D.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function xA(){let[e]=(0,D.useState)(()=>new Set),t=(0,D.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,D.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var SA={draggable:`
|
|
71
|
+
`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Rb.get()},set promptLabel(e){Rb.set(e)},get tooMuchOutput(){return Bb.get()},set tooMuchOutput(e){Bb.set(e)}}}_verifyIntegers(...e){for(DO of e)if(DO===1/0||isNaN(DO)||DO%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(DO of e)if(DO&&(DO===1/0||isNaN(DO)||DO%1!=0||DO<0))throw Error(`This API only accepts positive integers`)}},kO={"‘":`'`,"’":`'`,"“":`"`,"”":`"`,"—":`--`,"–":`-`,"…":`...`,"\xA0":` `},AO=/[‘’“”—–…\u00a0]/g;function jO(e){return e.replace(AO,e=>kO[e]??e)}function MO(e,t){let n=Array.from(jO(e)),r=Array.from(jO(t)),i=0;for(;i<n.length&&i<r.length&&n[i]===r[i];)i++;let a=r.slice(i),o=a.filter(e=>e!==``);return{backspaces:n.length-i,text:o.join(``),fillerLeft:o.length!==a.length}}var NO=new Set([`Shift`,`Control`,`Alt`,`AltGraph`,`Meta`,`CapsLock`,`Fn`,`FnLock`,`NumLock`,`ScrollLock`]),PO=new Set([`Dead`,`Process`,`Unidentified`,`Compose`]),FO={shell:{autocorrect:`off`,autocapitalize:`none`,spellcheck:`true`},claude:{autocorrect:`on`,autocapitalize:`sentences`,spellcheck:`true`}},IO=``.repeat(120),LO={autocorrect:`off`,autocapitalize:`off`,spellcheck:`false`},RO=/^insertFrom(Paste|Drop|Yank)/;function zO(e,t){for(let[n,r]of Object.entries(t))e.setAttribute(n,r)}function BO(e,t){let{element:n,textarea:r}=e;if(!n||!r){console.warn(`xterm.js no longer exposes its input field; Smart typing is off`);return}let i=r,a=``;function o(){i.value=``,i.value=IO,i.setSelectionRange(IO.length,IO.length),a=i.value}function s(t){let n=Ph();e.input(t,!0),n&&o()}e.attachCustomKeyEventHandler(e=>{let{key:t}=e;if(NO.has(t))return!0;let n=()=>!e.ctrlKey&&!e.metaKey;if(t===`Backspace`){if(n()&&i.value!==``)return!1}else if(t===`Enter`){if(!e.shiftKey&&!e.altKey&&n())return!1}else if(PO.has(t)||t.length===1&&n())return!1;return e.type===`keydown`&&o(),!0});let c=e=>{if(e.target!==i)return;e.stopPropagation();let{inputType:t}=e;if(t===`insertLineBreak`||t===`insertParagraph`)s(`\r`),o();else if(RO.test(t))o();else{let e=i.value,{backspaces:t,text:n,fillerLeft:r}=MO(a,e);a=e;let c=``.repeat(t)+n.replace(/\r?\n/g,`\r`);c&&s(c),r&&o()}},l=!1,u=e=>{e.target===i&&(l=e.type!==`compositionend`,e.stopPropagation())},d=e=>{e.target===i&&o()},f=()=>o(),p=()=>{if(l||document.activeElement!==i)return;let{selectionStart:e,selectionEnd:t,value:n}=i;e===t&&e!==n.length&&i.setSelectionRange(n.length,n.length)},m=[[`input`,c],[`compositionstart`,u],[`compositionupdate`,u],[`compositionend`,u],[`paste`,d]];for(let[e,t]of m)n.addEventListener(e,t,!0);return i.addEventListener(`blur`,f),document.addEventListener(`selectionchange`,p),zO(i,FO[t]),o(),{clear:o,dispose(){for(let[e,t]of m)n.removeEventListener(e,t,!0);i.removeEventListener(`blur`,f),document.removeEventListener(`selectionchange`,p),n.isConnected&&e.attachCustomKeyEventHandler(()=>!0),zO(i,LO),i.value=``}}}function VO(e,t){return`/api/sessions/${e}/terminal?${new URLSearchParams({cols:String(t.cols),rows:String(t.rows)})}`}function HO(e){return JSON.stringify(e)}var UO=0,WO=1,GO=500,KO=5e3;function qO(e){let{sessionId:t,openSocket:n,wake:r,retryFirstMs:i=GO,retryMaxMs:a=KO}=e,o=new Set,s=e.size,c,l,u=0,d=!1,f=!1,p=!1,m=[],h=e=>{if(d!==e){d=e;for(let t of[...o])t.reconnecting?.(e)}},g=e=>{let t=HO(e);c?.readyState===WO?c.send(t):c?.readyState===UO&&m.push(t)},_=()=>{clearTimeout(l);let e=n(VO(t,s));c=e,e.binaryType=`arraybuffer`,e.onopen=()=>{u=0,h(!1);for(let t of m.splice(0))e.send(t)},e.onmessage=e=>{if(!(e.data instanceof ArrayBuffer))return;let t=new Uint8Array(e.data);for(let e of[...o])e.output?.(t)},e.onclose=t=>{if(f||c!==e)return;if(t.code===4410){p=!0;for(let e of[...o])e.ended?.();return}h(!0);let n=Math.min(i*2**u,a);u+=1,l=setTimeout(_,n)}},v=r?.(()=>{c&&c.readyState!==WO&&c.readyState!==UO&&!f&&!p&&u>0&&_()});return _(),{input(e,t){g(t?{type:`input`,data:e,automatic:t}:{type:`input`,data:e})},resize(e,t){s={cols:e,rows:t},g({type:`resize`,cols:e,rows:t})},subscribe(e){return o.add(e),()=>{o.delete(e)}},close(){f=!0,clearTimeout(l),v?.(),o.clear(),c?.close()}}}var JO=100,YO=50,XO=.05,ZO=.9985,QO=2,$O=400,ek=300,tk=1e3/60;function nk(e,t){let n=0,r=[],i,a=0,o=0,s,c=0,l=0,u=e=>{n+=e;let r=t.lineHeight(),i=Math.trunc(n/r);i!==0&&(n-=i*r,t.scroll(i))},d=()=>e.clientHeight/tk,f=()=>{s!==void 0&&cancelAnimationFrame(s),s=void 0,o=0},p=e=>{let n=Math.min(e-c,4*tk);c=e;let r=QO*t.lineHeight()/tk,i=Math.abs(o),a=i>r?i*ZO**n:i-r/$O*n;a<=0?f():(o=Math.sign(o)*a,u(o*n),s=requestAnimationFrame(p))},m=e=>{let t=d();o=Math.max(-t,Math.min(t,e)),c=performance.now(),s=requestAnimationFrame(p)},h=e=>{let t=r.filter(t=>e-t.time<=JO),n=t[0],i=t[t.length-1];return!n||!i||n===i||e-i.time>YO?0:(n.y-i.y)/Math.max(i.time-n.time,1)},g=e=>{l=0,s!==void 0&&(l=o,f(),e.preventDefault());let t=e.touches.length===1?e.touches[0]:void 0;i=t?.clientY,a=performance.now(),r=t?[{time:a,y:t.clientY}]:[]},_=e=>{let t=e.touches[0];if(i===void 0||!t||e.touches.length!==1)return;e.preventDefault(),u(i-t.clientY),i=t.clientY;let n=performance.now();r.push({time:n,y:t.clientY}),r=r.filter(e=>n-e.time<=JO)},v=e=>{if(i===void 0||e.touches.length>0)return;i=void 0;let t=performance.now(),n=h(t);Math.sign(n)===Math.sign(l)&&t-a<=ek&&(n+=l),l=0,Math.abs(n)>=XO&&m(n)},y=()=>{i=void 0,l=0};return e.addEventListener(`touchstart`,g,{passive:!1}),e.addEventListener(`touchmove`,_,{passive:!1}),e.addEventListener(`touchend`,v),e.addEventListener(`touchcancel`,y),()=>{f(),e.removeEventListener(`touchstart`,g),e.removeEventListener(`touchmove`,_),e.removeEventListener(`touchend`,v),e.removeEventListener(`touchcancel`,y)}}var rk=5,ik=50,ak=.3;function ok(e){let t=!1,n=0,r=()=>{let t=(e.element?.querySelector(`.xterm-screen`)?.clientHeight??0)/e.rows;return t>0?t:1},i=n=>{let r=e.element;if(!r||n===0)return;let i=r.getBoundingClientRect(),a={bubbles:!0,cancelable:!0,clientX:i.left+i.width/2,clientY:i.top+i.height/2,deltaY:Math.sign(n),deltaMode:WheelEvent.DOM_DELTA_LINE};t=!0;try{for(let e=0;e<Math.abs(n);e++)r.dispatchEvent(new WheelEvent(`wheel`,a))}finally{t=!1}},a=t=>{let{fastScrollSensitivity:i=5,scrollSensitivity:a=1}=e.options,o=t.altKey||t.ctrlKey?i:1,s=t.deltaY*o*a;if(t.deltaMode!==WheelEvent.DOM_DELTA_PIXEL)return Math.sign(s);s/=r(),Math.abs(t.deltaY)<ik&&(s*=ak),n+=s;let c=Math.trunc(n);return n-=c,Math.sign(c)};return e.attachCustomWheelEventHandler(e=>t||e.shiftKey||e.deltaY===0?!0:(i(a(e)*rk),e.preventDefault(),!1)),{scroll:i,lineHeight:r,dispose:()=>e.attachCustomWheelEventHandler(()=>!0)}}function sk(e){let t=new URL(e,window.location.href);return t.protocol=t.protocol===`https:`?`wss:`:`ws:`,t.toString()}function ck(e){let t=()=>{document.visibilityState!==`hidden`&&e()};return document.addEventListener(`visibilitychange`,t),window.addEventListener(`online`,t),()=>{document.removeEventListener(`visibilitychange`,t),window.removeEventListener(`online`,t)}}function lk(e,t){let n=e._core?.coreService?.onUserInput;if(!n)return console.warn(`xterm.js no longer reports user input; treating all input as typed`),e.onData(e=>t(e,!1));let r=!1,i=n(()=>{r=!0}),a=e.onData(e=>{let n=!r;r=!1,t(e,n)});return{dispose:()=>{i.dispose(),a.dispose()}}}function uk(e){let t=e.slice(e.indexOf(`;`)+1);if(t!==`?`&&t!==``)try{let e=Uint8Array.from(atob(t),e=>e.charCodeAt(0));return new TextDecoder().decode(e)}catch{return}}function dk(e){if(!/Mac/.test(navigator.platform))return()=>{};let t=e=>{e.shiftKey&&!e.altKey&&(e.stopImmediatePropagation(),e.preventDefault(),e.target?.dispatchEvent(new MouseEvent(`mousedown`,{bubbles:!0,cancelable:!0,composed:!0,view:window,button:e.button,buttons:e.buttons,clientX:e.clientX,clientY:e.clientY,detail:e.detail,shiftKey:!0,altKey:!0})))};return e.addEventListener(`mousedown`,t,!0),()=>e.removeEventListener(`mousedown`,t,!0)}function fk(e,t){let n=e=>{e.key!==`Enter`||e.isComposing||e.keyCode===229||!e.shiftKey||e.ctrlKey||e.altKey||e.metaKey||(e.stopPropagation(),e.preventDefault(),t())};return e.addEventListener(`keydown`,n,!0),()=>e.removeEventListener(`keydown`,n,!0)}function pk({sessionId:e,kind:t,focused:n,takesFocus:r=!0}){let i=(0,D.useRef)(null),[a,o]=(0,D.useState)(!1),s=(0,D.useRef)(null),[c,l]=(0,D.useState)(null),u=(0,D.useRef)(n&&r);u.current=n&&r;let d=Sh(),f=vh(e),p=d&&f,m=(0,D.useRef)(null);return(0,D.useEffect)(()=>{n&&r&&s.current?.focus()},[n,r]),(0,D.useEffect)(()=>{if(n)return wh({send:e=>s.current?.input(e,!0),paste:e=>s.current?.paste(e),blur:()=>s.current?.blur(),clearTypedLine:()=>m.current?.clear()})},[n]),(0,D.useEffect)(()=>{let t=i.current;if(!t)return;let n=!1,r;return Vg().then(()=>{n||(r=a(t))}),()=>{n=!0,r?.()};function a(t){let n=new OO({fontFamily:zg,fontSize:13,theme:Lg,minimumContrastRatio:Bg,cursorBlink:!0,scrollback:0,macOptionClickForcesSelection:!0,allowProposedApi:!0}),r=new Nv;n.loadAddon(r),n.loadAddon(new Mb),n.open(t),r.fit();let i=n.parser.registerOscHandler(52,e=>{let t=uk(e);return t!==void 0&&navigator.clipboard?.writeText(t).catch(()=>{}),!0}),a=dk(t),c=fk(t,()=>{n.input(Eh.newLine,!0),m.current?.clear()}),d=ok(n),f=nk(t,d),p=qO({sessionId:e,size:{cols:n.cols,rows:n.rows},openSocket:e=>new WebSocket(sk(e)),wake:ck}),h=p.subscribe({output:e=>n.write(e),reconnecting:e=>{o(e),m.current?.clear(),e||n.reset()}}),g=lk(n,(e,t)=>p.input(t?e:Rh(e),t)),_=n.onResize(({cols:e,rows:t})=>p.resize(e,t)),v=new ResizeObserver(()=>r.fit());return v.observe(t),s.current=n,l(n),u.current&&n.focus(),()=>{s.current=null,l(null),v.disconnect(),g.dispose(),_.dispose(),i.dispose(),a(),c(),f(),d.dispose(),h(),p.close(),n.dispose()}}},[e]),(0,D.useEffect)(()=>{if(!p||!c)return;let e=BO(c,t);return m.current=e??null,()=>{m.current=null,e?.dispose()}},[c,t,p]),(0,W.jsxs)(`div`,{className:`relative h-full w-full`,children:[(0,W.jsx)(`div`,{ref:i,className:`h-full w-full touch-none`}),a&&(0,W.jsx)(`div`,{role:`status`,className:`absolute top-2 left-2 rounded bg-amber-500 px-2 py-1 text-xs font-medium text-black`,children:`reconnecting…`})]})}function mk({session:e,focused:t,takesFocus:n,starting:r=!1}){return(0,W.jsx)(`section`,{"aria-label":`Terminal ${e.name}`,className:`h-full min-h-0 p-2`,style:{backgroundColor:Ig},children:e.status===`running`?(0,W.jsx)(pk,{sessionId:e.id,kind:e.kind,focused:t,takesFocus:n}):!r&&(0,W.jsx)(gk,{session:e})})}function hk({children:e}){return(0,W.jsx)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 p-4 text-center text-sm text-muted-foreground`,children:e})}function gk({session:e}){let t=Fg(),[n,r]=(0,D.useState)(!1);return(0,W.jsxs)(hk,{children:[(0,W.jsxs)(`p`,{children:[e.name,` is Stopped.`]}),(0,W.jsxs)(Uh,{variant:`secondary`,size:`sm`,disabled:n,onClick:async()=>{r(!0);try{await t.restartSession(e.id)}finally{r(!1)}},children:[(0,W.jsx)(ze,{}),`Restart`]})]})}function _k({workspace:e,workspaces:t}){let n=Fg(),[r,i]=(0,D.useState)(!1);return(0,W.jsxs)(`section`,{"aria-label":`Missing folder`,className:`h-full min-h-0 p-2`,style:{backgroundColor:Ig},children:[(0,W.jsxs)(hk,{children:[(0,W.jsxs)(`p`,{className:`flex items-center gap-1.5 text-destructive`,children:[(0,W.jsx)($e,{className:`size-4 shrink-0`}),`This Workspace's folder is missing`]}),(0,W.jsxs)(Uh,{variant:`secondary`,size:`sm`,onClick:()=>i(!0),children:[(0,W.jsx)(he,{}),`Change folder`]})]}),r&&(0,W.jsx)(Av,{workspace:e,workspaces:t,edit:`folder`,onSave:t=>n.updateWorkspace(e.id,t),onClose:()=>i(!1)})]})}function vk({delayDuration:e=0,...t}){return(0,W.jsx)(wm,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function yk({...e}){return(0,W.jsx)(Om,{"data-slot":`tooltip`,...e})}function bk({...e}){return(0,W.jsx)(Am,{"data-slot":`tooltip-trigger`,...e})}function xk({className:e,sideOffset:t=0,children:n,...r}){return(0,W.jsx)(Pm,{children:(0,W.jsxs)(Im,{"data-slot":`tooltip-content`,sideOffset:t,className:U(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-md bg-foreground px-3 py-1.5 text-xs text-balance text-background fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,W.jsx)(Bm,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}function Sk({label:e,tooltip:t=e,className:n,children:r,...i}){let a=uh(),o=(0,W.jsx)(Uh,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":e,className:U(`size-7 text-muted-foreground hover:text-foreground`,n),...i,onFocus:e=>{i.onFocus?.(e),e.currentTarget.matches(`:focus-visible`)||e.preventDefault()},children:r});return a?o:(0,W.jsxs)(yk,{children:[(0,W.jsx)(bk,{asChild:!0,children:o}),(0,W.jsx)(xk,{children:t})]})}function Ck({className:e,orientation:t=`horizontal`,...n}){return(0,W.jsx)(rm,{"data-slot":`tabs`,"data-orientation":t,orientation:t,className:U(`group/tabs flex gap-2 data-[orientation=horizontal]:flex-col`,e),...n})}var wk=Vh(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Tk({className:e,variant:t=`default`,...n}){return(0,W.jsx)(am,{"data-slot":`tabs-list`,"data-variant":t,className:U(wk({variant:t}),e),...n})}function Ek({className:e,...t}){return(0,W.jsx)(sm,{"data-slot":`tabs-trigger`,className:U(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent`,`data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100`,e),...t})}function Dk({session:e,shown:t,close:n}){return(0,W.jsxs)(`span`,{className:`relative flex h-full shrink-0 items-center`,children:[(0,W.jsxs)(Ek,{value:e.id,"aria-label":e.name,"aria-current":t||void 0,className:U(`h-full max-w-56 flex-none rounded-none pl-2.5 font-normal`,`after:bg-primary group-data-[orientation=horizontal]/tabs:after:bottom-0`,n?`pr-12`:`pr-6`),children:[(0,W.jsx)(Ln,{session:e,className:`size-3.5`}),(0,W.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,W.jsxs)(`span`,{className:`absolute right-1 flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:`pointer-events-none flex w-3.5 justify-center`,children:(0,W.jsx)(_g,{session:e})}),n]})]})}function Ok({worker:e,tabs:t,shownId:n,onShowWorker:r,onShowTab:i,onCloseTab:a}){return(0,W.jsx)(Ck,{value:n??``,onValueChange:t=>t===e?.id?r():i(t),activationMode:`manual`,className:`h-full min-w-0 gap-0`,children:(0,W.jsxs)(Tk,{variant:`line`,className:`h-full w-full justify-start gap-0 overflow-x-auto overflow-y-hidden p-0 group-data-[orientation=horizontal]/tabs:h-full`,children:[e&&(0,W.jsx)(Dk,{session:e,shown:n===e.id}),t.map(e=>(0,W.jsx)(Dk,{session:e,shown:n===e.id,close:(0,W.jsx)(Sk,{label:`Close tab ${e.name}`,tooltip:`Close tab (the Session keeps running)`,className:`size-5`,onClick:()=>a(e.id),children:(0,W.jsx)(tt,{className:`size-3`})})},e.id))]})})}var kk=`36px`;function Ak(e,t){return t===`left`?`${kk} 6px minmax(0, 1fr)`:t===`right`?`minmax(0, 1fr) 6px ${kk}`:`minmax(0, ${e}fr) 6px minmax(0, ${1-e}fr)`}function jk({side:e,session:t,onOpen:n}){let r=`Show ${t.name}`;return(0,W.jsxs)(`div`,{className:`relative h-full border-x bg-sidebar`,children:[(0,W.jsxs)(yk,{children:[(0,W.jsx)(bk,{asChild:!0,children:(0,W.jsxs)(Uh,{variant:`ghost`,"aria-label":r,onClick:n,className:`h-full w-full flex-col justify-start gap-2 rounded-none px-0 py-3 text-xs font-normal text-muted-foreground`,children:[(0,W.jsx)(Ln,{session:t,className:`size-4`}),(0,W.jsx)(`span`,{className:`min-h-0 truncate`,style:{writingMode:`vertical-rl`},children:t.name})]})}),(0,W.jsx)(xk,{side:e===`left`?`right`:`left`,children:r})]}),(0,W.jsx)(`span`,{className:`pointer-events-none absolute bottom-3 left-1/2 flex -translate-x-1/2`,children:(0,W.jsx)(_g,{session:t})})]})}function Mk({session:e,workspace:t,workspaces:n,focused:r,takesFocus:i,starting:a}){let o=a&&e.role!==null;return e.status!==`running`&&!o&&t.missing?(0,W.jsx)(_k,{workspace:t,workspaces:n}):(0,W.jsx)(mk,{session:e,focused:r,takesFocus:i,starting:o},e.id)}function Nk({children:e}){return(0,W.jsx)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b px-2 text-xs`,children:e})}function Pk({view:e,workspaces:t}){let n=(0,D.useRef)(null),r=(0,D.useRef)(e.ratio),[i,a]=(0,D.useState)(!1),{workspace:o}=e;if(!o)return(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Create a Workspace to get started.`});let s=(n,r)=>(0,W.jsx)(Mk,{session:r,workspace:o,workspaces:t,focused:e.focusedTerminal===n,starting:e.starting}),c=(t,n,r)=>(0,W.jsx)(`div`,{role:`group`,"aria-label":t===`left`?`Left Pane`:`Right Pane`,onFocusCapture:()=>e.focusTerminal(t),className:`flex min-h-0 min-w-0 flex-col`,children:e.shut===t&&n.kind===`session`?(0,W.jsx)(jk,{side:t,session:n.session,onOpen:()=>e.reopen(t)}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Nk,{children:r}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1`,children:n.kind===`session`&&s(t,n.session)})]})}),{left:l,right:u,ratio:d,shut:f}=e,p=t=>{let i=n.current?.getBoundingClientRect();i&&i.width>0&&e.setRatio((t-i.left)/i.width,r.current)},m=f===`left`?0:f===`right`?1:d;return(0,W.jsxs)(`div`,{ref:n,className:`grid min-h-0 flex-1`,style:{gridTemplateColumns:Ak(d,f)},children:[c(`left`,l,(0,W.jsxs)(`span`,{className:`flex items-center gap-1.5 px-1 text-sm font-medium`,children:[(0,W.jsx)(Ln,{session:{role:`prime`,kind:`claude`},className:`size-3.5`}),`Prime`,l.kind===`session`&&(0,W.jsx)(_g,{session:l.session})]})),(0,W.jsx)(`div`,{role:`separator`,"aria-label":`Resize panes`,"aria-orientation":`vertical`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(m*100),title:`Drag to resize, or to an edge to shut a Pane. Double-click for half and half.`,tabIndex:0,"data-dragging":i||void 0,className:`cursor-col-resize touch-none bg-border transition-colors hover:bg-primary focus-visible:bg-primary data-dragging:bg-primary`,onPointerDown:e=>{r.current=d,e.currentTarget.setPointerCapture(e.pointerId),a(!0)},onLostPointerCapture:()=>a(!1),onPointerMove:e=>{e.currentTarget.hasPointerCapture(e.pointerId)&&p(e.clientX)},onDoubleClick:()=>e.setRatio(.5),onKeyDown:t=>{let n=t.key===`ArrowLeft`?-.02:t.key===`ArrowRight`?.02:0;n&&(t.preventDefault(),f?f===`left`==n>0&&e.reopen(f):e.setRatio(d+n))}}),c(`right`,u,(0,W.jsx)(Ok,{worker:e.worker,tabs:e.tabs,shownId:u.kind===`session`?u.session.id:void 0,onShowWorker:e.showWorker,onShowTab:t=>e.openOtherSession(o.id,t),onCloseTab:e.closeTab}))]})}function Fk({marker:e,who:t,className:n}){return(0,W.jsx)(`span`,{role:`img`,"aria-label":`${t} ${eh[e]}`,className:U(`grid size-2 shrink-0 rounded-full`,n),children:(0,W.jsx)(nh,{marker:e,className:`size-full`})})}function Ik({view:e,onOpen:t}){return(0,W.jsxs)(`span`,{className:`relative ml-2 inline-flex`,children:[(0,W.jsx)(Uh,{variant:`ghost`,size:`sm`,"aria-label":`Menu`,onClick:t,children:(0,W.jsx)(De,{})}),e.hintElsewhere&&(0,W.jsx)(Fk,{marker:e.hintElsewhere,who:`A session in another workspace`,className:`pointer-events-none absolute top-1 right-1.5 ring-2 ring-background`})]})}function Lk({view:e}){let[t,n]=(0,D.useState)(!1),{workspace:r,session:i}=e;return r?(0,W.jsxs)(rg,{open:t,onOpenChange:n,children:[(0,W.jsxs)(`h1`,{className:`flex min-w-0 items-center gap-1 text-sm`,children:[(0,W.jsx)(ig,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,"aria-label":i?`${r.name} › ${i.name}`:r.name,className:`flex min-w-0 items-center gap-1 rounded-md px-1.5 py-1 outline-none hover:bg-accent focus-visible:ring-[3px] focus-visible:ring-ring/50`,children:[(0,W.jsxs)(`span`,{className:U(`relative flex min-w-0`,e.bellHere&&`pr-2`),children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,title:r.folder,children:r.name}),e.bellHere&&(0,W.jsx)(Fk,{marker:`bell`,who:`Another session here`,className:`absolute top-0 right-0`})]}),i&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-muted-foreground`,children:` › `}),(0,W.jsx)(`span`,{className:`shrink-0 text-foreground`,children:i.name})]}),(0,W.jsx)(ae,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]})}),i&&(0,W.jsx)(_g,{session:i})]}),(0,W.jsxs)(sg,{side:`bottom`,className:`max-h-[80dvh] gap-0 rounded-t-2xl pb-[max(12px,env(safe-area-inset-bottom))]`,children:[(0,W.jsxs)(cg,{className:`pb-2`,children:[(0,W.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto mb-2 h-1 w-10 rounded-full bg-muted-foreground/40`}),(0,W.jsxs)(lg,{className:`flex min-w-0 items-center gap-2 text-sm`,title:r.folder,children:[(0,W.jsx)(sh,{workspace:r}),(0,W.jsx)(`span`,{className:`truncate`,children:r.name})]}),(0,W.jsx)(ug,{className:`sr-only`,children:`Choose a Session to show it.`})]}),(0,W.jsx)(Rk,{view:e,workspace:r,onClose:()=>n(!1)})]})]}):null}function Rk({view:e,workspace:t,onClose:n}){let{primeAndWorker:r,others:i}=dg(t.sessions),a=r=>(0,W.jsx)(zk,{session:r,current:r.id===e.session?.id,onChoose:()=>{e.show(t.id,r.id),n()}},r.id);return(0,W.jsxs)(`ul`,{"aria-label":`Sessions`,className:`grid gap-1 overflow-y-auto px-3`,children:[r.map(a),r.length>0&&i.length>0&&(0,W.jsx)(`li`,{"aria-hidden":`true`,className:`px-2 py-1`,children:(0,W.jsx)(Wh,{})}),i.map(a)]})}function zk({session:e,current:t,onChoose:n}){let r=e.status===`stopped`;return(0,W.jsxs)(`li`,{className:`relative`,children:[(0,W.jsxs)(Uh,{variant:`ghost`,"aria-label":e.name,"aria-current":t?`true`:void 0,className:U(`h-12 w-full justify-start gap-3 pr-9 pl-3 font-normal`,t&&`bg-accent shadow-[inset_3px_0_0_var(--primary)]`,r&&!t&&`text-muted-foreground`),onClick:n,children:[(0,W.jsx)(Ln,{session:e,className:U(`size-4`,r&&`opacity-50`)}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.name}),r&&(0,W.jsx)(tg,{variant:`outline`,className:`text-[10px] font-normal tracking-wide text-muted-foreground uppercase`,children:`stopped`})]}),(0,W.jsx)(_g,{session:e,className:`pointer-events-none absolute top-1/2 right-3 -translate-y-1/2`})]})}function Bk({view:e,workspaces:t}){let{workspace:n,session:r}=e;return n?(0,W.jsx)(`div`,{className:`min-h-0 flex-1`,children:r&&(0,W.jsx)(Mk,{session:r,workspace:n,workspaces:t,focused:!0,takesFocus:!1,starting:e.starting})}):(0,W.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-sm text-muted-foreground`,children:`Create a Workspace to get started.`})}function Vk({workspaces:e,onCreate:t,trigger:n}){let[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(),s=a&&Gg(a),c=a?.newFolders.length??0,[l,u]=(0,D.useState)(``),[d,f]=(0,D.useState)(),p=(0,D.useId)(),m=async()=>{if(s!==void 0)try{await t({folder:s,name:l.trim()||void 0,...c>0&&{createMissingFolders:!0}}),i(!1)}catch(e){f(e instanceof Error?e.message:String(e))}};return(0,W.jsxs)(Y_,{open:r,onOpenChange:e=>{i(e),e&&(u(``),f(void 0))},children:[(0,W.jsx)(X_,{asChild:!0,children:n}),(0,W.jsx)($_,{className:uv,children:(0,W.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col gap-4`,onSubmit:e=>{e.preventDefault(),m()},children:[(0,W.jsxs)(ev,{children:[(0,W.jsx)(nv,{children:`New Workspace`}),(0,W.jsx)(rv,{children:`Pick a project folder on the Host, or make new ones for it.`})]}),(0,W.jsx)(mv,{workspaces:e,onChange:e=>{o(e),f(void 0)}}),(0,W.jsxs)(Dv,{children:[(0,W.jsx)(Ov,{htmlFor:p,children:`Name`}),(0,W.jsx)(lv,{id:p,placeholder:s===void 0?``:Hg(s)||`/`,value:l,onChange:e=>{u(e.target.value),f(void 0)}})]}),d&&(0,W.jsx)(kv,{children:d}),(0,W.jsx)(tv,{children:(0,W.jsx)(Uh,{type:`submit`,disabled:s===void 0,children:c===0?`Create Workspace`:c===1?`Create folder and Workspace`:`Create ${c} folders and Workspace`})})]})})]})}function Hk(){var e=[...arguments];return(0,D.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var Uk=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Wk(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function Gk(e){return`nodeType`in e}function Kk(e){return e?Wk(e)?e:Gk(e)?e.ownerDocument?.defaultView??window:window:window}function qk(e){let{Document:t}=Kk(e);return e instanceof t}function Jk(e){return!Wk(e)&&e instanceof Kk(e).HTMLElement}function Yk(e){return e instanceof Kk(e).SVGElement}function Xk(e){return e?Wk(e)?e.document:Gk(e)?qk(e)?e:Jk(e)||Yk(e)?e.ownerDocument:document:document:document}var Zk=Uk?D.useLayoutEffect:D.useEffect;function Qk(e){let t=(0,D.useRef)(e);return Zk(()=>{t.current=e}),(0,D.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function $k(){let e=(0,D.useRef)(null);return[(0,D.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,D.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function eA(e,t){t===void 0&&(t=[e]);let n=(0,D.useRef)(e);return Zk(()=>{n.current!==e&&(n.current=e)},t),n}function tA(e,t){let n=(0,D.useRef)();return(0,D.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function nA(e){let t=Qk(e),n=(0,D.useRef)(null);return[n,(0,D.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function rA(e){let t=(0,D.useRef)();return(0,D.useEffect)(()=>{t.current=e},[e]),t.current}var iA={};function aA(e,t){return(0,D.useMemo)(()=>{if(t)return t;let n=iA[e]==null?0:iA[e]+1;return iA[e]=n,e+`-`+n},[e,t])}function oA(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var sA=oA(1),cA=oA(-1);function lA(e){return`clientX`in e&&`clientY`in e}function uA(e){if(!e)return!1;let{KeyboardEvent:t}=Kk(e.target);return t&&e instanceof t}function dA(e){if(!e)return!1;let{TouchEvent:t}=Kk(e.target);return t&&e instanceof t}function fA(e){if(dA(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return lA(e)?{x:e.clientX,y:e.clientY}:null}var pA=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[pA.Translate.toString(e),pA.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),mA=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function hA(e){return e.matches(mA)?e:e.querySelector(mA)}var gA={display:`none`};function _A(e){let{id:t,value:n}=e;return D.createElement(`div`,{id:t,style:gA},n)}function vA(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return D.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function yA(){let[e,t]=(0,D.useState)(``);return{announce:(0,D.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var bA=(0,D.createContext)(null);function xA(e){let t=(0,D.useContext)(bA);(0,D.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function SA(){let[e]=(0,D.useState)(()=>new Set),t=(0,D.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,D.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var CA={draggable:`
|
|
71
72
|
To pick up a draggable item, press the space bar.
|
|
72
73
|
While dragging, use the arrow keys to move the item.
|
|
73
74
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
74
|
-
`},CA={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function wA(e){let{announcements:t=CA,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=SA}=e,{announce:a,announcement:o}=vA(),s=iA(`DndLiveRegion`),[c,l]=(0,D.useState)(!1);if((0,D.useEffect)(()=>{l(!0)},[]),bA((0,D.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=D.createElement(D.Fragment,null,D.createElement(gA,{id:r,value:i.draggable}),D.createElement(_A,{id:s,announcement:o}));return n?(0,Un.createPortal)(u,n):u}var TA;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(TA||={});function EA(){}function DA(e,t){return(0,D.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function OA(){var e=[...arguments];return(0,D.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var kA=Object.freeze({x:0,y:0});function AA(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function jA(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function MA(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function NA(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function PA(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var FA=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=PA(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=AA(PA(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(jA)};function IA(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var LA=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=IA(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(MA)};function RA(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function zA(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:kA}function BA(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var VA=BA(1);function HA(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function UA(e,t,n){let r=HA(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var WA={ignoreTransform:!1};function GA(e,t){t===void 0&&(t=WA);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Gk(e).getComputedStyle(e);t&&(n=UA(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function KA(e){return GA(e,{ignoreTransform:!0})}function qA(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function JA(e,t){return t===void 0&&(t=Gk(e).getComputedStyle(e)),t.position===`fixed`}function YA(e,t){t===void 0&&(t=Gk(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}function XA(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(Kk(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!qk(i)||Jk(i)||n.includes(i))return n;let a=Gk(e).getComputedStyle(i);return i!==e&&YA(i,a)&&n.push(i),JA(i,a)?n:r(i.parentNode)}return e?r(e):n}function ZA(e){let[t]=XA(e,1);return t??null}function QA(e){return!Hk||!e?null:Uk(e)?e:Wk(e)?Kk(e)||e===Yk(e).scrollingElement?window:qk(e)?e:null:null}function $A(e){return Uk(e)?e.scrollX:e.scrollLeft}function ej(e){return Uk(e)?e.scrollY:e.scrollTop}function tj(e){return{x:$A(e),y:ej(e)}}var nj;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(nj||={});function rj(e){return!Hk||!e?!1:e===document.scrollingElement}function ij(e){let t={x:0,y:0},n=rj(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var aj={x:.2,y:.2};function oj(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=aj);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=ij(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=nj.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=nj.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=nj.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=nj.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function sj(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function cj(e){return e.reduce((e,t)=>oA(e,tj(t)),kA)}function lj(e){return e.reduce((e,t)=>e+$A(t),0)}function uj(e){return e.reduce((e,t)=>e+ej(t),0)}function dj(e,t){if(t===void 0&&(t=GA),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);ZA(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var fj=[[`x`,[`left`,`right`],lj],[`y`,[`top`,`bottom`],uj]],pj=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=XA(t),r=cj(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of fj)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},mj=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function hj(e){let{EventTarget:t}=Gk(e);return e instanceof t?e:Yk(e)}function gj(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var _j;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(_j||={});function vj(e){e.preventDefault()}function yj(e){e.stopPropagation()}var bj;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(bj||={});var xj={start:[bj.Space,bj.Enter],cancel:[bj.Esc],end:[bj.Space,bj.Enter,bj.Tab]},Sj=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case bj.Right:return{...n,x:n.x+25};case bj.Left:return{...n,x:n.x-25};case bj.Down:return{...n,y:n.y+25};case bj.Up:return{...n,y:n.y-25}}},Cj=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new mj(Yk(t)),this.windowListeners=new mj(Gk(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(_j.Resize,this.handleCancel),this.windowListeners.add(_j.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(_j.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&dj(n),t(kA)}handleKeyDown(e){if(lA(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=xj,coordinateGetter:a=Sj,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:kA;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=sA(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=ij(n),p=sj(n),m={x:Math.min(i===bj.Right?p.right-p.width/2:p.right,Math.max(i===bj.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===bj.Down?p.bottom-p.height/2:p.bottom,Math.max(i===bj.Down?p.top:p.top+p.height/2,u.y))},h=i===bj.Right&&!s||i===bj.Left&&!c,g=i===bj.Down&&!l||i===bj.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===bj.Right&&e<=d.x||i===bj.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}r.x=a?n.scrollLeft-e:i===bj.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===bj.Down&&e<=d.y||i===bj.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}r.y=a?n.scrollTop-e:i===bj.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,oA(sA(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Cj.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=xj,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function wj(e){return!!(e&&`distance`in e)}function Tj(e){return!!(e&&`delay`in e)}var Ej=class{constructor(e,t,n){n===void 0&&(n=hj(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=Yk(i),this.documentListeners=new mj(this.document),this.listeners=new mj(n),this.windowListeners=new mj(Gk(i)),this.initialCoordinates=dA(r)??kA,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(_j.Resize,this.handleCancel),this.windowListeners.add(_j.DragStart,vj),this.windowListeners.add(_j.VisibilityChange,this.handleCancel),this.windowListeners.add(_j.ContextMenu,vj),this.documentListeners.add(_j.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Tj(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(wj(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(_j.Click,yj,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(_j.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=dA(e)??kA,s=sA(n,o);if(!t&&a){if(wj(a)){if(a.tolerance!=null&&gj(s,a.tolerance))return this.handleCancel();if(gj(s,a.distance))return this.handleStart()}if(Tj(a)&&gj(s,a.tolerance))return this.handleCancel();this.handlePending(a,s)}else e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===bj.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Dj={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Oj=class extends Ej{constructor(e){let{event:t}=e,n=Yk(t.target);super(e,Dj,n)}};Oj.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var kj={move:{name:`mousemove`},end:{name:`mouseup`}},Aj;(function(e){e[e.RightClick=2]=`RightClick`})(Aj||={});var jj=class extends Ej{constructor(e){super(e,kj,Yk(e.event.target))}};jj.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==Aj.RightClick&&(r?.({event:n}),!0)}}];var Mj={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Nj=class extends Ej{constructor(e){super(e,Mj)}static setup(){return window.addEventListener(Mj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Mj.move.name,e)};function e(){}}};Nj.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Pj;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Pj||={});var Fj;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Fj||={});function Ij(e){let{acceleration:t,activator:n=Pj.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Fj.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=Rj({delta:d,disabled:!a}),[m,h]=Qk(),g=(0,D.useRef)({x:0,y:0}),_=(0,D.useRef)({x:0,y:0}),v=(0,D.useMemo)(()=>{switch(n){case Pj.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Pj.DraggableRect:return i}},[n,i,c]),y=(0,D.useRef)(null),b=(0,D.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,D.useMemo)(()=>s===Fj.TreeOrder?[...l].reverse():l,[s,l]);(0,D.useEffect)(()=>{if(!a||!l.length||!v)h();else{for(let e of x){if(r?.(e)===!1)continue;let n=l.indexOf(e),i=u[n];if(!i)continue;let{direction:a,speed:s}=oj(e,i,v,t,f);for(let e of[`x`,`y`])p[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){h(),y.current=e,m(b,o),g.current=s,_.current=a;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()}},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var Lj={x:{[nj.Backward]:!1,[nj.Forward]:!1},y:{[nj.Backward]:!1,[nj.Forward]:!1}};function Rj(e){let{delta:t,disabled:n}=e,r=nA(t);return eA(e=>{if(n||!r||!e)return Lj;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[nj.Backward]:e.x[nj.Backward]||i.x===-1,[nj.Forward]:e.x[nj.Forward]||i.x===1},y:{[nj.Backward]:e.y[nj.Backward]||i.y===-1,[nj.Forward]:e.y[nj.Forward]||i.y===1}}},[n,t,r])}function zj(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return eA(e=>t==null?null:r??e??null,[r,t])}function Bj(e,t){return(0,D.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var Vj;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Vj||={});var Hj;(function(e){e.Optimized=`optimized`})(Hj||={});var Uj=new Map;function Wj(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,D.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,D.useRef)(e),d=g(),f=$k(d),p=(0,D.useCallback)(function(e){e===void 0&&(e=[]),f.current||o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,D.useRef)(null),h=eA(t=>{if(d&&!n)return Uj;if(!t||t===Uj||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new pj(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,D.useEffect)(()=>{u.current=e},[e]),(0,D.useEffect)(()=>{d||p()},[n,d]),(0,D.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,D.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case Vj.Always:return!1;case Vj.BeforeDragging:return n;default:return!n}}}function Gj(e,t){return eA(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Kj(e,t){return Gj(e,t)}function qj(e){let{callback:t,disabled:n}=e,r=Zk(t),i=(0,D.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,D.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Jj(e){let{callback:t,disabled:n}=e,r=Zk(t),i=(0,D.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,D.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Yj(e){return new pj(GA(e),e)}function Xj(e,t,n){t===void 0&&(t=Yj);let[r,i]=(0,D.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=qj({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=Jj({callback:a});return Xk(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Zj(e){return zA(e,Gj(e))}var Qj=[];function $j(e){let t=(0,D.useRef)(e),n=eA(n=>e?n&&n!==Qj&&e&&t.current&&e.parentNode===t.current.parentNode?n:XA(e):Qj,[e]);return(0,D.useEffect)(()=>{t.current=e},[e]),n}function eM(e){let[t,n]=(0,D.useState)(null),r=(0,D.useRef)(e),i=(0,D.useCallback)(e=>{let t=QA(e.target);t&&n(e=>e?(e.set(t,tj(t)),new Map(e)):null)},[]);return(0,D.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=QA(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,tj(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{QA(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,D.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>oA(e,t),kA):cj(e):kA,[e,t])}function tM(e,t){t===void 0&&(t=[]);let n=(0,D.useRef)(null);return(0,D.useEffect)(()=>{n.current=null},t),(0,D.useEffect)(()=>{let t=e!==kA;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?sA(e,n.current):kA}function nM(e){(0,D.useEffect)(()=>{if(!Hk)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function rM(e,t){return(0,D.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function iM(e){return(0,D.useMemo)(()=>e?qA(e):null,[e])}var aM=[];function oM(e,t){t===void 0&&(t=GA);let[n]=e,r=iM(n?Gk(n):null),[i,a]=(0,D.useState)(aM);function o(){a(()=>e.length?e.map(e=>rj(e)?r:new pj(t(e),e)):aM)}let s=Jj({callback:o});return Xk(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function sM(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return qk(t)?t:e}function cM(e){let{measure:t}=e,[n,r]=(0,D.useState)(null),i=Jj({callback:(0,D.useCallback)(e=>{for(let{target:n}of e)if(qk(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=tA((0,D.useCallback)(e=>{let n=sM(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,D.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var lM=[{sensor:Oj,options:{}},{sensor:Cj,options:{}}],uM={current:{}},dM={draggable:{measure:KA},droppable:{measure:KA,strategy:Vj.WhileDragging,frequency:Hj.Optimized},dragOverlay:{measure:GA}},fM=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},pM={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new fM,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:EA},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:dM,measureDroppableContainers:EA,windowRect:null,measuringScheduled:!1},mM={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:EA,draggableNodes:new Map,over:null,measureDroppableContainers:EA},hM=(0,D.createContext)(mM),gM=(0,D.createContext)(pM);function _M(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new fM}}}function vM(e,t){switch(t.type){case TA.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case TA.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case TA.DragEnd:case TA.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case TA.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new fM(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case TA.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new fM(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case TA.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new fM(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function yM(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,D.useContext)(hM),a=nA(r),o=nA(n?.id);return(0,D.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!lA(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=mA(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function bM(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function xM(e){return(0,D.useMemo)(()=>({draggable:{...dM.draggable,...e?.draggable},droppable:{...dM.droppable,...e?.droppable},dragOverlay:{...dM.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function SM(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,D.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Xk(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=zA(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=ZA(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var CM=(0,D.createContext)({...kA,scaleX:1,scaleY:1}),wM;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(wM||={});var TM=(0,D.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=lM,collisionDetection:o=LA,measuring:s,modifiers:c,...l}=e,[u,d]=(0,D.useReducer)(vM,void 0,_M),[f,p]=xA(),[m,h]=(0,D.useState)(wM.Uninitialized),g=m===wM.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,D.useRef)({initial:null,translated:null}),C=(0,D.useMemo)(()=>_==null?null:{id:_,data:x?.data??uM,rect:S},[_,x]),w=(0,D.useRef)(null),[T,E]=(0,D.useState)(null),[O,k]=(0,D.useState)(null),A=$k(l,Object.values(l)),j=iA(`DndDescribedBy`,t),M=(0,D.useMemo)(()=>b.getEnabled(),[b]),N=xM(s),{droppableRects:P,measureDroppableContainers:F,measuringScheduled:I}=Wj(M,{dragging:g,dependencies:[y.x,y.y],config:N.droppable}),ee=zj(v,_),te=(0,D.useMemo)(()=>O?dA(O):null,[O]),ne=Ae(),re=Kj(ee,N.draggable.measure);SM({activeNode:_==null?null:v.get(_),config:ne.layoutShiftCompensation,initialRect:re,measure:N.draggable.measure});let L=Xj(ee,N.draggable.measure,re),ie=Xj(ee?ee.parentElement:null),ae=(0,D.useRef)({activatorEvent:null,active:null,activeNode:ee,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=b.getNodeFor(ae.current.over?.id),R=cM({measure:N.dragOverlay.measure}),se=R.nodeRef.current??ee,ce=g?R.rect??L:null,le=!!(R.nodeRef.current&&R.rect),ue=Zj(le?null:L),de=iM(se?Gk(se):null),z=$j(g?oe??ee:null),fe=oM(z),pe=bM(c,{transform:{x:y.x-ue.x,y:y.y-ue.y,scaleX:1,scaleY:1},activatorEvent:O,active:C,activeNodeRect:L,containerNodeRect:ie,draggingNodeRect:ce,over:ae.current.over,overlayNodeRect:R.rect,scrollableAncestors:z,scrollableAncestorRects:fe,windowRect:de}),me=te?oA(te,y):null,he=eM(z),ge=tM(he),_e=tM(he,[L]),ve=oA(pe,ge),ye=ce?VA(ce,pe):null,be=C&&ye?o({active:C,collisionRect:ye,droppableRects:P,droppableContainers:M,pointerCoordinates:me}):null,xe=NA(be,`id`),[Se,Ce]=(0,D.useState)(null),we=RA(le?pe:oA(pe,_e),Se?.rect??null,L),Te=(0,D.useRef)(null),Ee=(0,D.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent,o=new n({active:w.current,activeNode:i,event:a,options:r,context:ae,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=A.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=A.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=A.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,Un.unstable_batchedUpdates)(()=>{r?.(i),h(wM.Initializing),d({type:TA.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Te.current),k(a)})},onMove(e){d({type:TA.DragMove,coordinates:e})},onEnd:s(TA.DragEnd),onCancel:s(TA.DragCancel)});Te.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=ae.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===TA.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=TA.DragCancel)}w.current=null,(0,Un.unstable_batchedUpdates)(()=>{d({type:e}),h(wM.Uninitialized),Ce(null),E(null),k(null),Te.current=null;let t=e===TA.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),De=Bj(a,(0,D.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,Ee(n,t))},[v,Ee]));nM(a),Xk(()=>{L&&m===wM.Initializing&&h(wM.Initialized)},[L,m]),(0,D.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=ae.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ve.x,y:ve.y},over:i};(0,Un.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ve.x,ve.y]),(0,D.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=ae.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(xe),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,Un.unstable_batchedUpdates)(()=>{Ce(s),a?.(c),f({type:`onDragOver`,event:c})})},[xe]),Xk(()=>{ae.current={activatorEvent:O,active:C,activeNode:ee,collisionRect:ye,collisions:be,droppableRects:P,draggableNodes:v,draggingNode:se,draggingNodeRect:ce,droppableContainers:b,over:Se,scrollableAncestors:z,scrollAdjustedTranslate:ve},S.current={initial:ce,translated:ye}},[C,ee,be,ye,v,se,ce,P,b,Se,z,ve]),Ij({...ne,delta:y,draggingRect:ye,pointerCoordinates:me,scrollableAncestors:z,scrollableAncestorRects:fe});let Oe=(0,D.useMemo)(()=>({active:C,activeNode:ee,activeNodeRect:L,activatorEvent:O,collisions:be,containerNodeRect:ie,dragOverlay:R,draggableNodes:v,droppableContainers:b,droppableRects:P,over:Se,measureDroppableContainers:F,scrollableAncestors:z,scrollableAncestorRects:fe,measuringConfiguration:N,measuringScheduled:I,windowRect:de}),[C,ee,L,O,be,ie,R,v,b,P,Se,F,z,fe,N,I,de]),ke=(0,D.useMemo)(()=>({activatorEvent:O,activators:De,active:C,activeNodeRect:L,ariaDescribedById:{draggable:j},dispatch:d,draggableNodes:v,over:Se,measureDroppableContainers:F}),[O,De,C,L,d,j,v,Se,F]);return D.createElement(yA.Provider,{value:p},D.createElement(hM.Provider,{value:ke},D.createElement(gM.Provider,{value:Oe},D.createElement(CM.Provider,{value:we},i)),D.createElement(yM,{disabled:n?.restoreFocus===!1})),D.createElement(wA,{...n,hiddenTextDescribedById:j}));function Ae(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),EM=(0,D.createContext)(null),DM=`button`,OM=`Draggable`;function kM(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=iA(OM),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,D.useContext)(hM),{role:p=DM,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,D.useContext)(g?CM:EM),[v,y]=tA(),[b,x]=tA(),S=rM(o,t),C=$k(n);return Xk(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,D.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===DM?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function AM(){return(0,D.useContext)(gM)}var jM=`Droppable`,MM={timeout:25};function NM(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=iA(jM),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,D.useContext)(hM),u=(0,D.useRef)({disabled:n}),d=(0,D.useRef)(!1),f=(0,D.useRef)(null),p=(0,D.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...MM,...i},_=$k(h??r),v=Jj({callback:(0,D.useCallback)(()=>{d.current?(p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)):d.current=!0},[g]),disabled:m||!o}),[y,b]=tA((0,D.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=$k(t);return(0,D.useEffect)(()=>{v&&y.current&&(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,D.useEffect)(()=>(s({type:TA.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:TA.UnregisterDroppable,key:a,id:r})),[r]),(0,D.useEffect)(()=>{n!==u.current.disabled&&(s({type:TA.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function PM(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function FM(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function IM(e){return e!==null&&e>=0}function LM(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function RM(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var zM=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=PM(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},BM={scaleX:1,scaleY:1},VM=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...BM}:null}let s=HM(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...BM}:r<t&&r>=a?{x:0,y:o.height+s,...BM}:{x:0,y:0,...BM}};function HM(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var UM=`Sortable`,WM=D.createContext({activeIndex:-1,containerId:UM,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:zM,disabled:{draggable:!1,droppable:!1}});function GM(e){let{children:t,id:n,items:r,strategy:i=zM,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=AM(),d=iA(UM,n),f=s.rect!==null,p=(0,D.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,D.useRef)(p),v=!LM(p,_.current),y=g!==-1&&h===-1||v,b=RM(a);Xk(()=>{v&&m&&u(p)},[v,p,m,u]),(0,D.useEffect)(()=>{_.current=p},[p]);let x=(0,D.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:FM(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return D.createElement(WM.Provider,{value:x},t)}var KM=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return PM(n,r,i).indexOf(t)},qM=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},JM={duration:200,easing:`ease`},YM=`transform`,XM=fA.Transition.toString({property:YM,duration:0,easing:`linear`}),ZM={roleDescription:`sortable`};function QM(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,D.useState)(null),s=(0,D.useRef)(n);return Xk(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=GA(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,D.useEffect)(()=>{a&&o(null)},[a]),a}function $M(e){let{animateLayoutChanges:t=qM,attributes:n,disabled:r,data:i,getNewIndex:a=KM,id:o,strategy:s,resizeObserverConfig:c,transition:l=JM}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,D.useContext)(WM),y=eN(r,p),b=u.indexOf(o),x=(0,D.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,D.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=NM({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:O,activatorEvent:k,activeNodeRect:A,attributes:j,setNodeRef:M,listeners:N,isDragging:P,over:F,setActivatorNodeRef:I,transform:ee}=kM({id:o,data:x,attributes:{...ZM,...n},disabled:y.draggable}),te=Vk(E,M),ne=!!O,re=ne&&!m&&IM(f)&&IM(g),L=!_&&P,ie=re?(L&&re?ee:null)??(s??v)({rects:h,activeNodeRect:A,activeIndex:f,overIndex:g,index:b}):null,ae=IM(f)&&IM(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,oe=O?.id,R=(0,D.useRef)({activeId:oe,items:u,newIndex:ae,containerId:d}),se=u!==R.current.items,ce=t({active:O,containerId:d,isDragging:P,isSorting:ne,id:o,index:b,items:u,newIndex:R.current.newIndex,previousItems:R.current.items,previousContainerId:R.current.containerId,transition:l,wasDragging:R.current.activeId!=null}),le=QM({disabled:!ce,index:b,node:w,rect:C});return(0,D.useEffect)(()=>{ne&&R.current.newIndex!==ae&&(R.current.newIndex=ae),d!==R.current.containerId&&(R.current.containerId=d),u!==R.current.items&&(R.current.items=u)},[ne,ae,d,u]),(0,D.useEffect)(()=>{if(oe===R.current.activeId)return;if(oe!=null&&R.current.activeId==null){R.current.activeId=oe;return}let e=setTimeout(()=>{R.current.activeId=oe},50);return()=>clearTimeout(e)},[oe]),{active:O,activeIndex:f,attributes:j,data:x,rect:C,index:b,newIndex:ae,items:u,isOver:T,isSorting:ne,isDragging:P,listeners:N,node:w,overIndex:g,over:F,setNodeRef:te,setActivatorNodeRef:I,setDroppableNodeRef:E,setDraggableNodeRef:M,transform:le??ie,transition:ue()};function ue(){if(le||se&&R.current.newIndex===b)return XM;if(!(L&&!lA(k)||!l)&&(ne||ce))return fA.Transition.toString({...l,property:YM})}}function eN(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}bj.Down,bj.Right,bj.Up,bj.Left;function tN({ids:e,onReorder:t,children:n}){let r=OA(DA(jj,{activationConstraint:{distance:6}}),DA(Nj,{activationConstraint:{delay:200,tolerance:8}}));return(0,W.jsx)(TM,{sensors:r,collisionDetection:FA,onDragEnd:({active:n,over:r})=>{if(!r||n.id===r.id)return;let i=e.indexOf(String(n.id)),a=e.indexOf(String(r.id));i<0||a<0||t(PM(e,i,a))},children:(0,W.jsx)(GM,{items:e,strategy:VM,children:n})})}function nN(e){let{attributes:t,listeners:n,setNodeRef:r,setActivatorNodeRef:i,transform:a,transition:o,isDragging:s}=$M({id:e});return{row:{ref:r,style:{transform:fA.Transform.toString(a),transition:o}},handle:{ref:i,...t,...n},isDragging:s}}function rN({...e}){return(0,W.jsx)(us,{"data-slot":`alert-dialog`,...e})}function iN({...e}){return(0,W.jsx)(ds,{"data-slot":`alert-dialog-portal`,...e})}function aN({className:e,...t}){return(0,W.jsx)(fs,{"data-slot":`alert-dialog-overlay`,className:U(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function oN({className:e,size:t=`default`,...n}){return(0,W.jsxs)(iN,{children:[(0,W.jsx)(aN,{}),(0,W.jsx)(hs,{"data-slot":`alert-dialog-content`,onCloseAutoFocus:ng,"data-size":t,className:U(`group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[size=default]:sm:max-w-lg`,e),...n})]})}function sN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:U(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function cN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:U(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function lN({className:e,...t}){return(0,W.jsx)(gs,{"data-slot":`alert-dialog-title`,className:U(`text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function uN({className:e,...t}){return(0,W.jsx)(_s,{"data-slot":`alert-dialog-description`,className:U(`text-sm text-muted-foreground`,e),...t})}function dN({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,W.jsx)(Uh,{variant:t,size:n,asChild:!0,children:(0,W.jsx)(vs,{"data-slot":`alert-dialog-action`,className:U(e),...r})})}function fN({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,W.jsx)(Uh,{variant:t,size:n,asChild:!0,children:(0,W.jsx)(bs,{"data-slot":`alert-dialog-cancel`,className:U(e),...r})})}function pN({open:e,onOpenChange:t,sessionName:n,onDelete:r}){return(0,W.jsx)(rN,{open:e,onOpenChange:t,children:(0,W.jsxs)(oN,{children:[(0,W.jsxs)(sN,{children:[(0,W.jsxs)(lN,{children:[`Delete `,n,`?`]}),(0,W.jsx)(uN,{children:`This ends its shell and everything running in it. It can't be undone.`})]}),(0,W.jsxs)(cN,{children:[(0,W.jsx)(fN,{children:`Cancel`}),(0,W.jsx)(dN,{variant:`destructive`,onClick:()=>void r(),children:`Delete session`})]})]})})}function mN({workspace:e,onDelete:t,onClose:n}){let[r,i]=(0,D.useState)(),a=e.sessions.length;return(0,W.jsx)(rN,{open:!0,onOpenChange:e=>!e&&n(),children:(0,W.jsxs)(oN,{children:[(0,W.jsxs)(sN,{children:[(0,W.jsxs)(lN,{children:[`Delete `,e.name,`?`]}),(0,W.jsxs)(uN,{children:[a===0?`The Workspace is removed. `:`Its ${a===1?`Session`:`${a} Sessions`} will be ended and everything running in ${a===1?`it`:`them`} stopped. `,`The folder on disk is not touched.`]})]}),r&&(0,W.jsx)(kv,{children:r}),(0,W.jsxs)(cN,{children:[(0,W.jsx)(fN,{children:`Cancel`}),(0,W.jsx)(Uh,{variant:`destructive`,onClick:()=>{t().then(n,e=>i(e instanceof Error?e.message:String(e)))},children:`Delete Workspace`})]})]})})}var hN={model:[`default`,`fable`,`opus`,`sonnet`,`haiku`],effort:[`default`,`low`,`medium`,`high`,`xhigh`,`max`],advisor:[`default`,`off`,`fable`,`opus`,`sonnet`]},gN={model:`default`,effort:`default`,advisor:`default`,focusView:!1};function _N({...e}){return(0,W.jsx)(Nf,{"data-slot":`select`,...e})}function vN({...e}){return(0,W.jsx)(Lf,{"data-slot":`select-value`,...e})}function yN({className:e,size:t=`default`,children:n,...r}){return(0,W.jsxs)(Ff,{"data-slot":`select-trigger`,"data-size":t,className:U(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,W.jsx)(Rf,{asChild:!0,children:(0,W.jsx)(ae,{className:`size-4 opacity-50`})})]})}function bN({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,W.jsx)(Vf,{children:(0,W.jsxs)(Uf,{"data-slot":`select-content`,className:U(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,W.jsx)(SN,{}),(0,W.jsx)(tp,{className:U(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,W.jsx)(CN,{})]})})}function xN({className:e,children:t,...n}){return(0,W.jsxs)(sp,{"data-slot":`select-item`,className:U(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,W.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,W.jsx)(dp,{children:(0,W.jsx)(L,{className:`size-4`})})}),(0,W.jsx)(lp,{children:t})]})}function SN({className:e,...t}){return(0,W.jsx)(pp,{"data-slot":`select-scroll-up-button`,className:U(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,W.jsx)(ce,{className:`size-4`})})}function CN({className:e,...t}){return(0,W.jsx)(hp,{"data-slot":`select-scroll-down-button`,className:U(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,W.jsx)(ae,{className:`size-4`})})}function wN({className:e,size:t=`default`,...n}){return(0,W.jsx)(Vp,{"data-slot":`switch`,"data-size":t,className:U(`peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80`,e),...n,children:(0,W.jsx)(Up,{"data-slot":`switch-thumb`,className:U(`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground`)})})}var TN=[{field:`model`,label:`Model`},{field:`effort`,label:`Effort`},{field:`advisor`,label:`Advisor`}];function EN(e){return e===`xhigh`?`XHigh`:e.charAt(0).toUpperCase()+e.slice(1)}function DN({workspace:e,onLaunch:t,onClose:n}){let[r,i]=(0,D.useState)(``),[a,o]=(0,D.useState)(),[s,c]=(0,D.useState)(),[l,u]=(0,D.useState)(!1),d=(0,D.useId)(),f=`${d}-name`,p=`${d}-focusView`,m=`${d}-nameError`;(0,D.useEffect)(()=>{let e=!0;return Tg.lastLaunchOptions().catch(()=>gN).then(t=>e&&o(t)),()=>{e=!1}},[]);let h=async()=>{if(a){u(!0);try{await t({name:r.trim(),claude:a}),n()}catch(e){c({message:e instanceof Error?e.message:String(e),nameTaken:e instanceof xg&&e.status===409}),u(!1)}}};return(0,W.jsx)(Y_,{open:!0,onOpenChange:e=>!e&&n(),children:(0,W.jsx)($_,{className:`max-h-[calc(100dvh-2rem)] overflow-y-auto`,children:(0,W.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,W.jsxs)(ev,{children:[(0,W.jsx)(nv,{children:`New Claude Session`}),(0,W.jsxs)(rv,{children:[`Runs Claude Code in the folder of `,e.name,`. Default leaves a setting to your own Claude Code configuration.`]})]}),(0,W.jsxs)(Dv,{"data-invalid":s?.nameTaken||void 0,children:[(0,W.jsx)(Ov,{htmlFor:f,children:`Session name`}),(0,W.jsx)(lv,{id:f,"aria-invalid":s?.nameTaken||void 0,"aria-describedby":s?.nameTaken?m:void 0,placeholder:`Optional`,value:r,onChange:e=>{i(e.target.value),c(void 0)},autoFocus:!0}),s?.nameTaken&&(0,W.jsx)(kv,{id:m,children:s.message})]}),(0,W.jsxs)(`fieldset`,{disabled:!a,"aria-busy":!a,className:`grid min-w-0 gap-4 ${a?``:`invisible`}`,children:[TN.map(({field:e,label:t})=>(0,W.jsxs)(Dv,{children:[(0,W.jsx)(Ov,{htmlFor:`${d}-${e}`,children:t}),(0,W.jsxs)(_N,{value:a?.[e]??`default`,onValueChange:t=>a&&o({...a,[e]:t}),children:[(0,W.jsx)(yN,{id:`${d}-${e}`,className:`w-full`,children:(0,W.jsx)(vN,{})}),(0,W.jsx)(bN,{children:hN[e].map(e=>(0,W.jsx)(xN,{value:e,children:EN(e)},e))})]})]},e)),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg border px-3 py-2.5`,children:[(0,W.jsx)(Tv,{htmlFor:p,children:`Focus view`}),(0,W.jsx)(wN,{id:p,checked:a?.focusView??!1,onCheckedChange:e=>a&&o({...a,focusView:e})})]})]}),s&&!s.nameTaken&&(0,W.jsx)(kv,{children:s.message}),(0,W.jsx)(tv,{children:(0,W.jsx)(Uh,{type:`submit`,disabled:l||!a,children:`Launch`})})]})})})}function ON({open:e,onOpenChange:t,currentName:n,onRename:r}){let[i,a]=(0,D.useState)(n),[o,s]=(0,D.useState)(),c=(0,D.useId)(),l=async()=>{try{await r(i.trim()),t(!1)}catch(e){s(e instanceof Error?e.message:String(e))}};return(0,W.jsx)(Y_,{open:e,onOpenChange:e=>{e&&(a(n),s(void 0)),t(e)},children:(0,W.jsx)($_,{children:(0,W.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,W.jsxs)(ev,{children:[(0,W.jsx)(nv,{children:`Rename Session`}),(0,W.jsx)(rv,{children:`Names are unique within their Workspace.`})]}),(0,W.jsxs)(Dv,{children:[(0,W.jsx)(Ov,{htmlFor:c,children:`Session name`}),(0,W.jsx)(lv,{id:c,value:i,onChange:e=>a(e.target.value),onFocus:e=>e.target.select(),autoFocus:!0})]}),o&&(0,W.jsx)(kv,{children:o}),(0,W.jsx)(tv,{children:(0,W.jsx)(Uh,{type:`submit`,disabled:i.trim()===``,children:`Rename`})})]})})})}function kN({workspaces:e,onCreateClaudeSession:t}){let n=Fg(),[r,i]=(0,D.useState)(),[a,o]=(0,D.useState)(),[s,c]=(0,D.useState)();return{newClaude:i,editWorkspace:(e,t)=>o({workspace:e,action:t}),editSession:(e,t)=>c({session:e,action:t}),dialogs:(0,W.jsxs)(W.Fragment,{children:[r&&(0,W.jsx)(DN,{workspace:r,onLaunch:e=>t(r.id,e),onClose:()=>i(void 0)}),a&&a.action!==`delete`&&(0,W.jsx)(Av,{workspace:a.workspace,workspaces:e,edit:a.action,onSave:e=>n.updateWorkspace(a.workspace.id,e),onClose:()=>o(void 0)}),a?.action===`delete`&&(0,W.jsx)(mN,{workspace:a.workspace,onDelete:()=>n.deleteWorkspace(a.workspace.id),onClose:()=>o(void 0)}),s?.action===`rename`&&(0,W.jsx)(ON,{open:!0,onOpenChange:e=>!e&&c(void 0),currentName:s.session.name,onRename:e=>n.renameSession(s.session.id,e)},s.session.id),s?.action===`delete`&&(0,W.jsx)(pN,{open:!0,onOpenChange:e=>!e&&c(void 0),sessionName:s.session.name,onDelete:()=>n.deleteSession(s.session.id)},s.session.id)]})}}function AN({workspaces:e,onReorder:t,openWorkspaceId:n,shown:r,onOpenWorkspace:i,onOpenSession:a}){return(0,W.jsx)(tN,{ids:e.map(e=>e.id),onReorder:t,children:(0,W.jsx)(`ul`,{className:`flex min-h-0 w-full flex-1 flex-col items-center gap-2 overflow-y-auto py-1`,children:e.map(e=>(0,W.jsx)(jN,{workspace:e,isOpen:e.id===n,shown:r,onOpen:()=>i(e.id),onOpenSession:t=>a(e.id,t)},e.id))})})}function jN({workspace:e,isOpen:t,shown:n,onOpen:r,onOpenSession:i}){let{row:a,handle:o,isDragging:s}=nN(e.id),{primeAndWorker:c,others:l}=dg(e.sessions),u=[...c,...l];return(0,W.jsxs)(`li`,{...a,className:U(`flex flex-col items-center gap-1 rounded-lg`,s&&`relative z-20 bg-card shadow-lg`),children:[(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(sh,{workspace:e,size:`md`,marker:t?null:hg(e),className:U(`rounded-lg`,t&&`ring-2 ring-primary ring-offset-2 ring-offset-sidebar`)}),(0,W.jsxs)(vk,{children:[(0,W.jsx)(yk,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,...o,"aria-label":e.name,"aria-current":t?`true`:void 0,onClick:r,className:`absolute inset-0 rounded-lg outline-none hover:bg-foreground/10 focus-visible:ring-[3px] focus-visible:ring-ring/50`})}),(0,W.jsxs)(bk,{side:`right`,children:[(0,W.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,W.jsx)(`div`,{className:`opacity-70`,children:e.folder})]})]})]}),t&&u.length>0&&(0,W.jsx)(`ul`,{className:`flex flex-col items-center gap-0.5 rounded-lg bg-sidebar-accent/40 p-0.5`,children:u.map(e=>(0,W.jsx)(MN,{session:e,isShown:n.has(e.id),onOpen:()=>i(e)},e.id))})]})}function MN({session:e,isShown:t,onOpen:n}){let r=e.status===`stopped`;return(0,W.jsxs)(`li`,{className:U(`relative grid size-7 place-items-center rounded-md`,t?`bg-sidebar-accent shadow-[inset_0_-2px_0_var(--primary)]`:`hover:bg-sidebar-accent/60`),children:[(0,W.jsx)(Ln,{session:e,className:U(`size-4`,r&&`opacity-50`)}),(0,W.jsxs)(vk,{children:[(0,W.jsx)(yk,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,"aria-label":e.name,"aria-current":t?`true`:void 0,onClick:n,className:`absolute inset-0 rounded-md outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`})}),(0,W.jsx)(bk,{side:`right`,children:r?`${e.name} (stopped)`:e.name})]}),r&&(0,W.jsx)(`span`,{className:`sr-only`,children:`stopped`}),(0,W.jsx)(_g,{session:e,className:`pointer-events-none absolute -top-0.5 -right-0.5 scale-75`})]})}var NN=Vh(`relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current`}},defaultVariants:{variant:`default`}});function PN({className:e,variant:t,...n}){return(0,W.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:U(NN({variant:t}),e),...n})}function FN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`alert-description`,className:U(`col-start-2 grid justify-items-start gap-1 text-sm text-muted-foreground [&_p]:leading-relaxed`,e),...t})}function IN({...e}){return(0,W.jsx)(nf,{"data-slot":`dropdown-menu`,...e})}function LN({...e}){return(0,W.jsx)(af,{"data-slot":`dropdown-menu-trigger`,...e})}function RN({className:e,sideOffset:t=4,...n}){return(0,W.jsx)(of,{children:(0,W.jsx)(cf,{"data-slot":`dropdown-menu-content`,onCloseAutoFocus:ng,sideOffset:t,className:U(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...n})})}function zN({className:e,inset:t,variant:n=`default`,...r}){return(0,W.jsx)(lf,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:U(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}var BN=`16rem`,VN=`18rem`,HN=`3.5rem`,UN=D.createContext(null);function WN(){let e=D.useContext(UN);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function GN({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let s=uh(),[c,l]=D.useState(!1),[u,d]=D.useState(e),f=t??u,p=D.useCallback(e=>{let t=typeof e==`function`?e(f):e;n?n(t):d(t)},[n,f]),m=D.useCallback(()=>s?l(e=>!e):p(e=>!e),[s,p,l]),h=f?`expanded`:`collapsed`,g=D.useMemo(()=>({state:h,open:f,setOpen:p,isMobile:s,openMobile:c,setOpenMobile:l,toggleSidebar:m}),[h,f,p,s,c,l,m]);return(0,W.jsx)(UN.Provider,{value:g,children:(0,W.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":BN,"--sidebar-width-icon":HN,...i},className:U(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),...o,children:a})})}function KN({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,...a}){let{isMobile:o,state:s,openMobile:c,setOpenMobile:l}=WN();return n===`none`?(0,W.jsx)(`div`,{"data-slot":`sidebar`,className:U(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),...a,children:i}):o?(0,W.jsx)(rg,{open:c,onOpenChange:l,...a,children:(0,W.jsxs)(sg,{"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:{"--sidebar-width":VN},side:e,children:[(0,W.jsxs)(cg,{className:`sr-only`,children:[(0,W.jsx)(lg,{children:`Workspaces`}),(0,W.jsx)(ug,{children:`Your Workspaces and the Open one's Sessions.`})]}),(0,W.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:i})]})}):(0,W.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":s,"data-collapsible":s===`collapsed`?n:``,"data-variant":t,"data-side":e,"data-slot":`sidebar`,children:[(0,W.jsx)(`div`,{"data-slot":`sidebar-gap`,className:U(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`)}),(0,W.jsx)(`div`,{"data-slot":`sidebar-container`,className:U(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex`,e===`left`?`left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]`:`right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,t===`floating`||t===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,r),...a,children:(0,W.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm`,children:i})})]})}function qN({className:e,...t}){return(0,W.jsx)(`main`,{"data-slot":`sidebar-inset`,className:U(`relative flex w-full flex-1 flex-col bg-background`,`md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,e),...t})}function JN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:U(`flex flex-col gap-2 p-2`,e),...t})}function YN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:U(`flex flex-col gap-2 p-2`,e),...t})}function XN({className:e,...t}){return(0,W.jsx)(Wh,{"data-slot":`sidebar-separator`,"data-sidebar":`separator`,className:U(`mx-2 w-auto bg-sidebar-border`,e),...t})}function ZN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:U(`flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,e),...t})}function QN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:U(`relative flex w-full min-w-0 flex-col p-2`,e),...t})}function $N({className:e,asChild:t=!1,...n}){let r=t?qn:`div`;return(0,W.jsx)(r,{"data-slot":`sidebar-group-label`,"data-sidebar":`group-label`,className:U(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0`,e),...n})}function eP({className:e,...t}){return(0,W.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:U(`flex w-full min-w-0 flex-col gap-1`,e),...t})}function tP({className:e,...t}){return(0,W.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:U(`group/menu-item relative`,e),...t})}var nP=Vh(`peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function rP({asChild:e=!1,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o}){let s=e?qn:`button`,{isMobile:c,state:l}=WN(),u=(0,W.jsx)(s,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":r,"data-active":t,className:U(nP({variant:n,size:r}),a),...o});return i?(typeof i==`string`&&(i={children:i}),(0,W.jsxs)(vk,{children:[(0,W.jsx)(yk,{asChild:!0,children:u}),(0,W.jsx)(bk,{side:`right`,align:`center`,hidden:l!==`collapsed`||c,...i})]})):u}function iP({className:e,...t}){return(0,W.jsx)(`ul`,{"data-slot":`sidebar-menu-sub`,"data-sidebar":`menu-sub`,className:U(`mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5`,`group-data-[collapsible=icon]:hidden`,e),...t})}function aP({className:e,...t}){return(0,W.jsx)(`li`,{"data-slot":`sidebar-menu-sub-item`,"data-sidebar":`menu-sub-item`,className:U(`group/menu-sub-item relative`,e),...t})}function oP({asChild:e=!1,size:t=`md`,isActive:n=!1,className:r,...i}){let a=e?qn:`a`;return(0,W.jsx)(a,{"data-slot":`sidebar-menu-sub-button`,"data-sidebar":`menu-sub-button`,"data-size":t,"data-active":n,className:U(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,`data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground`,t===`sm`&&`text-xs`,t===`md`&&`text-sm`,`group-data-[collapsible=icon]:hidden`,r),...i})}function sP({workspace:e,isOpen:t,mode:n,onOpen:r,onNewShell:i,onNewClaude:a,onAction:o,children:s}){let{row:c,handle:l,isDragging:u}=nN(e.id);return(0,W.jsxs)(tP,{...c,className:U(`rounded-md`,u&&`relative z-20 bg-card shadow-lg`),children:[(0,W.jsx)(`h2`,{className:`text-sm font-normal`,title:e.folder,children:(0,W.jsxs)(rP,{...l,"aria-label":e.name,onClick:r,className:U(n===`drawer`&&`h-10`,t&&`pr-16 font-semibold`),children:[(0,W.jsx)(sh,{workspace:e,marker:t?null:hg(e)}),(0,W.jsx)(`span`,{children:e.name})]})}),t&&(0,W.jsxs)(`div`,{className:U(`absolute right-1 flex items-center`,n===`drawer`?`top-2`:`top-0.5`),children:[(0,W.jsxs)(IN,{children:[(0,W.jsx)(LN,{asChild:!0,children:(0,W.jsx)(xk,{label:`New session in ${e.name}`,children:(0,W.jsx)(Le,{})})}),(0,W.jsxs)(RN,{align:`end`,children:[(0,W.jsxs)(zN,{onSelect:i,children:[(0,W.jsx)(qe,{}),`New shell`]}),(0,W.jsxs)(zN,{onSelect:a,children:[(0,W.jsx)(Ue,{}),`New Claude…`]})]})]}),(0,W.jsxs)(IN,{children:[(0,W.jsx)(LN,{asChild:!0,children:(0,W.jsx)(xk,{label:`Actions for ${e.name}`,children:(0,W.jsx)(pe,{})})}),(0,W.jsxs)(RN,{align:`end`,children:[(0,W.jsxs)(zN,{onSelect:()=>o(`rename`),children:[(0,W.jsx)(Fe,{}),`Rename`]}),(0,W.jsxs)(zN,{onSelect:()=>o(`folder`),children:[(0,W.jsx)(he,{}),`Change folder`]}),(0,W.jsxs)(zN,{variant:`destructive`,onSelect:()=>o(`delete`),children:[(0,W.jsx)(Ze,{}),`Delete`]})]})]})]}),t&&e.missing&&(0,W.jsxs)(PN,{variant:`destructive`,role:`note`,className:`mx-1 mt-1 w-auto px-3 py-2`,children:[(0,W.jsx)($e,{}),(0,W.jsx)(FN,{className:`text-xs`,children:(0,W.jsxs)(`p`,{children:[`Missing: its folder is gone, so Sessions can't start. Running ones carry on.`,` `,(0,W.jsx)(Uh,{variant:`link`,onClick:()=>o(`folder`),className:`h-auto p-0 text-current text-xs underline underline-offset-2`,children:`Change folder`})]})})]}),t&&s]})}function cP({workspace:e,shown:t,mode:n,onOpen:r,onAction:i,onReorder:a}){let{prime:o,worker:s,others:c}=dg(e.sessions),l=e=>({session:e,isShown:t.has(e.id),mode:n,onOpen:()=>r(e),onAction:t=>i(e,t)});return(0,W.jsxs)(iP,{className:`mr-0 pr-0`,children:[o&&(0,W.jsx)(uP,{...l(o)},o.id),s&&(0,W.jsx)(uP,{...l(s)},s.id),c.length>0&&(0,W.jsx)(`li`,{"aria-hidden":`true`,className:`py-1`,children:(0,W.jsx)(Wh,{className:`bg-sidebar-border`})}),(0,W.jsx)(tN,{ids:c.map(e=>e.id),onReorder:a,children:c.map(e=>(0,W.jsx)(lP,{...l(e)},e.id))})]})}function lP(e){return(0,W.jsx)(uP,{...e,drag:nN(e.session.id)})}function uP({session:e,isShown:t,mode:n,onOpen:r,onAction:i,drag:a}){let o=Fg(),s=e.status===`stopped`,c=e.role!==null,l=!c||s;return(0,W.jsxs)(aP,{...a?.row,className:U(`rounded-md`,a?.isDragging&&`relative z-20 bg-card shadow-lg`),children:[(0,W.jsx)(oP,{asChild:!0,isActive:t,className:U(`w-full`,n===`drawer`?`h-9`:`h-7`,l?`pr-12`:`pr-7`,s&&`text-muted-foreground`,`data-[active=true]:shadow-[inset_2px_0_0_var(--primary)]`),children:(0,W.jsxs)(`button`,{type:`button`,...a?.handle,"aria-label":e.name,"aria-current":t?`true`:void 0,onClick:r,children:[(0,W.jsx)(`span`,{role:`img`,"aria-label":e.kind===`claude`?`${e.name} is a Claude Session`:`${e.name} is a shell`,className:U(`flex`,s&&`opacity-50`),children:(0,W.jsx)(Ln,{session:e,className:`size-4`})}),(0,W.jsx)(`span`,{className:`truncate`,children:e.name}),s&&(0,W.jsx)(tg,{variant:`outline`,className:`h-4 px-1.5 text-[10px] font-normal tracking-wide text-muted-foreground uppercase`,children:`stopped`})]})}),(0,W.jsxs)(`span`,{className:`pointer-events-none absolute top-1/2 right-1 flex -translate-y-1/2 items-center gap-1`,children:[(0,W.jsx)(_g,{session:e}),l&&(0,W.jsxs)(IN,{children:[(0,W.jsx)(LN,{asChild:!0,children:(0,W.jsx)(xk,{label:`Actions for ${e.name}`,className:`pointer-events-auto size-6`,children:(0,W.jsx)(pe,{})})}),(0,W.jsxs)(RN,{align:`end`,children:[s&&(0,W.jsxs)(zN,{onSelect:()=>void o.restartSession(e.id),children:[(0,W.jsx)(ze,{}),`Restart`]}),!c&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(zN,{onSelect:()=>i(`rename`),children:[(0,W.jsx)(Fe,{}),`Rename`]}),(0,W.jsxs)(zN,{variant:`destructive`,onSelect:()=>i(`delete`),children:[(0,W.jsx)(Ze,{}),`Delete`]})]})]})]})]})]})}function dP({state:e,shown:t,onOpenSession:n,onOpenWorkspace:r,onCreateWorkspace:i,onCreateSession:a,onCreateClaudeSession:o,error:s}){let c=Fg(),l=e?.workspaces??[],{newClaude:u,editWorkspace:d,editSession:f,dialogs:p}=kN({workspaces:l,onCreateClaudeSession:o}),m=WN(),h=m.isMobile?`drawer`:`sidebar`,g=!m.isMobile&&m.state===`collapsed`,_=e=>(0,W.jsx)(Bk,{workspaces:l,onCreate:i,trigger:e}),v=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(JN,{className:`items-center`,children:(0,W.jsx)(xk,{label:`Expand sidebar`,onClick:()=>m.setOpen(!0),children:(0,W.jsx)(Ne,{})})}),(0,W.jsx)(XN,{className:`mx-auto w-8`}),(0,W.jsx)(ZN,{children:(0,W.jsx)(AN,{workspaces:l,onReorder:c.reorderWorkspaces,openWorkspaceId:e?.openWorkspaceId,shown:t,onOpenWorkspace:r,onOpenSession:n})}),(0,W.jsxs)(YN,{className:`items-center`,children:[_((0,W.jsx)(xk,{label:`New Workspace`,className:`size-8 rounded-lg border border-dashed border-sidebar-border`,children:(0,W.jsx)(Le,{})})),s&&(0,W.jsxs)(vk,{children:[(0,W.jsx)(yk,{asChild:!0,children:(0,W.jsx)(`span`,{role:`alert`,"aria-label":s,className:`flex p-1`,children:(0,W.jsx)($e,{className:`size-4 text-destructive`})})}),(0,W.jsx)(bk,{side:`right`,children:s})]})]})]}),y=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(ZN,{children:(0,W.jsxs)(QN,{children:[(0,W.jsxs)($N,{className:`gap-0.5 pr-0`,children:[(0,W.jsx)(`span`,{className:`flex-1`,children:`Workspaces`}),_((0,W.jsx)(xk,{label:`New Workspace`,children:(0,W.jsx)(Le,{})})),h===`sidebar`&&(0,W.jsx)(xk,{label:`Collapse sidebar`,onClick:()=>m.setOpen(!1),children:(0,W.jsx)(je,{})})]}),(0,W.jsx)(tN,{ids:l.map(e=>e.id),onReorder:c.reorderWorkspaces,children:(0,W.jsx)(eP,{children:l.map(i=>{let o=i.id===e?.openWorkspaceId;return(0,W.jsx)(sP,{workspace:i,isOpen:o,mode:h,onOpen:()=>r(i.id),onNewShell:()=>void a(i.id),onNewClaude:()=>u(i),onAction:e=>d(i,e),children:(0,W.jsx)(cP,{workspace:i,shown:t,mode:h,onOpen:e=>n(i.id,e),onAction:f,onReorder:e=>c.reorderSessions(i.id,e)})},i.id)})})})]})}),s&&(0,W.jsx)(YN,{children:(0,W.jsxs)(PN,{variant:`destructive`,className:`px-3 py-2`,children:[(0,W.jsx)($e,{}),(0,W.jsx)(FN,{className:`text-xs`,children:s})]})})]});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(KN,{collapsible:`icon`,children:(0,W.jsx)(`nav`,{"aria-label":`Workspaces`,className:`flex min-h-0 flex-1 flex-col`,children:g?v:y})}),p]})}var fP=e=>e.preventDefault();function pP({name:e,onPress:t,placement:n=``,children:r}){return(0,W.jsx)(`button`,{type:`button`,"aria-label":e,className:`flex size-9 items-center justify-center rounded-md bg-secondary/60 text-sm text-secondary-foreground backdrop-blur-sm active:bg-primary active:text-primary-foreground pointer-events-auto ${n}`,onMouseDown:fP,onTouchStart:()=>{},onClick:t,children:r})}function mP(){let e=e=>()=>Dh(e),t=Oh();return(0,W.jsxs)(`div`,{role:`group`,"aria-label":`Typing keys`,className:`pointer-events-none absolute top-1 right-1 z-10 grid grid-cols-4 gap-1`,children:[(0,W.jsx)(pP,{name:`Esc`,onPress:e(Eh.esc),children:`⎋`}),(0,W.jsx)(pP,{name:`Tab`,onPress:e(Eh.tab),children:`⇥`}),(0,W.jsx)(pP,{name:`Enter`,onPress:e(Eh.enter),children:`⏎`}),t&&(0,W.jsx)(pP,{name:`Paste`,onPress:()=>void kh(),children:(0,W.jsx)(ue,{className:`size-4`})}),(0,W.jsx)(pP,{name:`Left`,onPress:e(Eh.left),children:`←`}),(0,W.jsx)(pP,{name:`Up`,onPress:e(Eh.up),children:`↑`}),(0,W.jsx)(pP,{name:`Down`,onPress:e(Eh.down),children:`↓`}),(0,W.jsx)(pP,{name:`Right`,onPress:e(Eh.right),children:`→`}),(0,W.jsx)(pP,{name:`Close keyboard`,placement:t?`col-start-4`:`col-start-4 row-start-1`,onPress:Th,children:`⌄`})]})}var hP=`k-bench.phone-sessions`,gP=`k-bench.phone-session`;function _P(){try{let e=JSON.parse(localStorage.getItem(hP)??`{}`);return typeof e!=`object`||!e?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`))}catch{return{}}}function vP(e){try{localStorage.setItem(hP,JSON.stringify(e))}catch{}}function yP(e,{open:t,starting:n}){let[r,i]=(0,D.useState)(_P);(0,D.useLayoutEffect)(()=>vP(r),[r]),(0,D.useEffect)(()=>{try{localStorage.removeItem(gP)}catch{}},[]);let a=pg(e),o=a?.sessions??[],s=a&&r[a.id],c=o.find(e=>e.id===s)??dg(o).prime;return{workspace:a,session:c,starting:n,bellHere:o.some(e=>e.bell&&e.id!==c?.id),hintElsewhere:mg((e?.workspaces??[]).filter(e=>e!==a).flatMap(e=>e.sessions)),show:(e,t)=>i(n=>({...n,[e]:t})),openWorkspace:e=>{i(({[e]:t,...n})=>n),t(e)}}}var bP=100;function xP(){let e=window.visualViewport;return{width:e?.width??window.innerWidth,height:e?.height??window.innerHeight,top:e?.offsetTop??0}}function SP(){return document.activeElement?.closest(`.xterm`)!=null}function CP(e){let[t,n]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{if(!e)return;let t=document.documentElement,r=xP(),i=!1,a=()=>{let e=xP(),a=SP();a?e.width===r.width?e.height>r.height&&(r={...r,height:e.height}):r=i?{...e,height:e.height+bP}:e:r=e;let o=a&&r.height-e.height>=bP;i=o,n(o),o?(t.style.setProperty(`--app-top`,`${e.top}px`),t.style.setProperty(`--app-height`,`${e.height}px`)):(t.style.removeProperty(`--app-top`),t.style.removeProperty(`--app-height`))};a();let o=window.visualViewport;return window.addEventListener(`resize`,a),o?.addEventListener(`resize`,a),o?.addEventListener(`scroll`,a),document.addEventListener(`focusin`,a),document.addEventListener(`focusout`,a),()=>{window.removeEventListener(`resize`,a),o?.removeEventListener(`resize`,a),o?.removeEventListener(`scroll`,a),document.removeEventListener(`focusin`,a),document.removeEventListener(`focusout`,a),t.style.removeProperty(`--app-top`),t.style.removeProperty(`--app-height`),n(!1)}},[e]),t}var wP=`k-bench.sidebar-collapsed`;function TP(){try{return localStorage.getItem(wP)===`true`}catch{return!1}}function EP(e){try{e?localStorage.setItem(wP,`true`):localStorage.removeItem(wP)}catch{}}function DP(){let[e,t]=(0,D.useState)(TP);return[e,e=>{t(e),EP(e)}]}var OP={ratio:.5,shut:null};function kP(e,t){return e<.08?{ratio:t,shut:`left`}:e>.92?{ratio:t,shut:`right`}:{ratio:e,shut:null}}var AP=`k-bench.dividers`;function jP(e){if(typeof e!=`object`||!e)return!1;let{ratio:t,shut:n}=e;return typeof t==`number`&&t>0&&t<1&&(n===null||n===`left`||n===`right`)}function MP(){try{let e=JSON.parse(localStorage.getItem(AP)??`{}`);return typeof e!=`object`||!e?{}:Object.fromEntries(Object.entries(e).filter(([,e])=>jP(e)))}catch{return{}}}function NP(e){try{localStorage.setItem(AP,JSON.stringify(e))}catch{}}var PP=e=>e===`left`?`right`:`left`,FP=`k-bench.layout`,IP={shown:null,tabs:[]};function LP(e){let t=e=>e?{kind:`session`,session:e}:{kind:`empty`},n=e?.sessions??[],{shown:r,tabs:i}=e?.rightPane??IP,{prime:a,worker:o,others:s}=dg(n),c=new Map(s.map(e=>[e.id,e])),l=r===null?void 0:c.get(r);return{left:t(a),right:t(l??o),worker:o,tabs:i.flatMap(e=>c.get(e)??[])}}function RP(e,t){let[n,r]=(0,D.useState)(MP),[i,a]=(0,D.useState)(`left`),[o,s]=(0,D.useState)(0),c=(0,D.useCallback)((e,n)=>{s(e=>e+1),t.openWorkspace(e,n).finally(()=>s(e=>e-1))},[t]),l=pg(e),{left:u,right:d,worker:f,tabs:p}=LP(l),m=(0,D.useRef)(e);m.current=e;let h=zP(e,c);(0,D.useEffect)(()=>NP(n),[n]),(0,D.useEffect)(()=>{try{localStorage.removeItem(FP)}catch{}},[]),(0,D.useEffect)(()=>{e&&bh(new Set(e.workspaces.flatMap(e=>e.sessions.map(e=>e.id))))},[e]);let g=l?`${l.name} — k-bench`:`k-bench`;(0,D.useEffect)(()=>{document.title=g},[g]);let _=l?.id,v=_&&n[_]||OP,y=(0,D.useCallback)((e,t)=>{r(n=>{let r=n[e];return r?.shut===t?{...n,[e]:{ratio:r.ratio,shut:null}}:n})},[]),b=(0,D.useCallback)((e,n)=>{let r=m.current?.workspaces.find(t=>t.id===e)?.rightPane??IP;t.setRightPane(e,n(r))},[t]),x=(0,D.useCallback)((e,t)=>{b(e,({tabs:e})=>({shown:t,tabs:t===null||e.includes(t)?e:[...e,t]})),a(`right`),y(e,`right`)},[b,y]),S=e=>{a(`left`),y(e,`left`)},C=e=>{a(`left`),y(e,`right`),c(e,{showWorker:!0})},w=i===v.shut?PP(i):i,T=w===`left`?u:d,E=new Set;return v.shut!==`left`&&u.kind===`session`&&E.add(u.session.id),v.shut!==`right`&&d.kind===`session`&&E.add(d.session.id),{workspace:l,left:u,right:d,worker:f,tabs:p,ratio:v.ratio,shut:v.shut,focusedTerminal:w,focusedSession:T.kind===`session`?T.session:void 0,starting:!h||o>0,shown:E,openWorkspace:C,open:c,showPrime:()=>{_&&S(_)},showWorker:()=>{_&&x(_,null)},openOtherSession:(e,t)=>x(e,t),closeTab:e=>{_&&b(_,({shown:t,tabs:n})=>({shown:t===e?null:t,tabs:n.filter(t=>t!==e)}))},chooseSession:(e,t)=>{t.role===`worker`?x(e,null):t.role===null?x(e,t.id):S(e)},focusTerminal:a,setRatio:(e,t=v.ratio)=>{_&&r(n=>({...n,[_]:kP(e,t)}))},reopen:e=>{_&&y(_,e)}}}function zP(e,t){let[n,r]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{e&&!n&&(r(!0),e.openWorkspaceId&&t(e.openWorkspaceId))},[e,t,n]),n}function BP(){let[e,t]=DP();return(0,W.jsx)(GN,{open:!e,onOpenChange:e=>t(!e),className:`h-full min-h-0`,children:(0,W.jsx)(VP,{})})}function VP(){let{state:e,actions:t,error:n}=Mg(),r=uh(),i=CP(r),a=RP(e,t),o=yP(e,a),{setOpenMobile:s}=WN(),c=()=>s(!1),l=(e,t)=>{t!==void 0&&(r?o.show(e,t):a.openOtherSession(e,t),c())},u=e=>{r?o.openWorkspace(e):a.openWorkspace(e)},d=o.session?.id;return(0,W.jsxs)(Pg,{value:t,children:[(0,W.jsx)(dP,{state:e,shown:r?new Set(d?[d]:[]):a.shown,onOpenSession:(e,t)=>{r?o.show(e,t.id):a.chooseSession(e,t),c()},onOpenWorkspace:e=>{u(e),c()},onCreateWorkspace:e=>t.createWorkspace(e,u),onCreateSession:async e=>{l(e,await t.createSession(e))},onCreateClaudeSession:async(e,n)=>{l(e,await t.createClaudeSession(e,n))},error:n}),(0,W.jsxs)(qN,{className:U(`min-w-0`,i&&`fixed inset-x-0 top-(--app-top) h-(--app-height)`),children:[!i&&(0,W.jsx)(`header`,{className:`flex h-11 shrink-0 items-center gap-1 border-b px-2`,children:r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Fk,{view:o,onOpen:()=>s(!0)}),(0,W.jsx)(Ik,{view:o})]}):a.workspace&&(0,W.jsx)(ch,{workspace:a.workspace,session:a.focusedSession})}),(0,W.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[e&&(r?(0,W.jsx)(zk,{view:o,workspaces:e.workspaces}):(0,W.jsx)(Nk,{view:a,workspaces:e.workspaces})),i&&d&&(0,W.jsx)(mP,{})]}),r&&!i&&d&&(0,W.jsx)($h,{sessionId:d})]})]})}var HP=document.getElementById(`root`);if(!HP)throw Error(`missing #root`);(0,nt.createRoot)(HP).render((0,W.jsx)(D.StrictMode,{children:(0,W.jsx)(_k,{children:(0,W.jsx)(BP,{})})}));
|
|
75
|
+
`},wA={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function TA(e){let{announcements:t=wA,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=CA}=e,{announce:a,announcement:o}=yA(),s=aA(`DndLiveRegion`),[c,l]=(0,D.useState)(!1);if((0,D.useEffect)(()=>{l(!0)},[]),xA((0,D.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=D.createElement(D.Fragment,null,D.createElement(_A,{id:r,value:i.draggable}),D.createElement(vA,{id:s,announcement:o}));return n?(0,Un.createPortal)(u,n):u}var EA;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(EA||={});function DA(){}function OA(e,t){return(0,D.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function kA(){var e=[...arguments];return(0,D.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var AA=Object.freeze({x:0,y:0});function jA(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function MA(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function NA(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function PA(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function FA(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var IA=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=FA(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=jA(FA(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(MA)};function LA(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var RA=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=LA(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(NA)};function zA(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function BA(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:AA}function VA(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var HA=VA(1);function UA(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function WA(e,t,n){let r=UA(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var GA={ignoreTransform:!1};function KA(e,t){t===void 0&&(t=GA);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=Kk(e).getComputedStyle(e);t&&(n=WA(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function qA(e){return KA(e,{ignoreTransform:!0})}function JA(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function YA(e,t){return t===void 0&&(t=Kk(e).getComputedStyle(e)),t.position===`fixed`}function XA(e,t){t===void 0&&(t=Kk(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}function ZA(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(qk(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!Jk(i)||Yk(i)||n.includes(i))return n;let a=Kk(e).getComputedStyle(i);return i!==e&&XA(i,a)&&n.push(i),YA(i,a)?n:r(i.parentNode)}return e?r(e):n}function QA(e){let[t]=ZA(e,1);return t??null}function $A(e){return!Uk||!e?null:Wk(e)?e:Gk(e)?qk(e)||e===Xk(e).scrollingElement?window:Jk(e)?e:null:null}function ej(e){return Wk(e)?e.scrollX:e.scrollLeft}function tj(e){return Wk(e)?e.scrollY:e.scrollTop}function nj(e){return{x:ej(e),y:tj(e)}}var rj;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(rj||={});function ij(e){return!Uk||!e?!1:e===document.scrollingElement}function aj(e){let t={x:0,y:0},n=ij(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var oj={x:.2,y:.2};function sj(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=oj);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=aj(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=rj.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=rj.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=rj.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=rj.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function cj(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function lj(e){return e.reduce((e,t)=>sA(e,nj(t)),AA)}function uj(e){return e.reduce((e,t)=>e+ej(t),0)}function dj(e){return e.reduce((e,t)=>e+tj(t),0)}function fj(e,t){if(t===void 0&&(t=KA),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);QA(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var pj=[[`x`,[`left`,`right`],uj],[`y`,[`top`,`bottom`],dj]],mj=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=ZA(t),r=lj(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of pj)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},hj=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function gj(e){let{EventTarget:t}=Kk(e);return e instanceof t?e:Xk(e)}function _j(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var vj;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(vj||={});function yj(e){e.preventDefault()}function bj(e){e.stopPropagation()}var xj;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(xj||={});var Sj={start:[xj.Space,xj.Enter],cancel:[xj.Esc],end:[xj.Space,xj.Enter,xj.Tab]},Cj=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case xj.Right:return{...n,x:n.x+25};case xj.Left:return{...n,x:n.x-25};case xj.Down:return{...n,y:n.y+25};case xj.Up:return{...n,y:n.y-25}}},wj=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new hj(Xk(t)),this.windowListeners=new hj(Kk(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(vj.Resize,this.handleCancel),this.windowListeners.add(vj.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(vj.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&fj(n),t(AA)}handleKeyDown(e){if(uA(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Sj,coordinateGetter:a=Cj,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:AA;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=cA(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=aj(n),p=cj(n),m={x:Math.min(i===xj.Right?p.right-p.width/2:p.right,Math.max(i===xj.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===xj.Down?p.bottom-p.height/2:p.bottom,Math.max(i===xj.Down?p.top:p.top+p.height/2,u.y))},h=i===xj.Right&&!s||i===xj.Left&&!c,g=i===xj.Down&&!l||i===xj.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===xj.Right&&e<=d.x||i===xj.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}r.x=a?n.scrollLeft-e:i===xj.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===xj.Down&&e<=d.y||i===xj.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}r.y=a?n.scrollTop-e:i===xj.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,sA(cA(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};wj.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Sj,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Tj(e){return!!(e&&`distance`in e)}function Ej(e){return!!(e&&`delay`in e)}var Dj=class{constructor(e,t,n){n===void 0&&(n=gj(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=Xk(i),this.documentListeners=new hj(this.document),this.listeners=new hj(n),this.windowListeners=new hj(Kk(i)),this.initialCoordinates=fA(r)??AA,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(vj.Resize,this.handleCancel),this.windowListeners.add(vj.DragStart,yj),this.windowListeners.add(vj.VisibilityChange,this.handleCancel),this.windowListeners.add(vj.ContextMenu,yj),this.documentListeners.add(vj.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Ej(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Tj(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(vj.Click,bj,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(vj.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=fA(e)??AA,s=cA(n,o);if(!t&&a){if(Tj(a)){if(a.tolerance!=null&&_j(s,a.tolerance))return this.handleCancel();if(_j(s,a.distance))return this.handleStart()}if(Ej(a)&&_j(s,a.tolerance))return this.handleCancel();this.handlePending(a,s)}else e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===xj.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Oj={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},kj=class extends Dj{constructor(e){let{event:t}=e,n=Xk(t.target);super(e,Oj,n)}};kj.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Aj={move:{name:`mousemove`},end:{name:`mouseup`}},jj;(function(e){e[e.RightClick=2]=`RightClick`})(jj||={});var Mj=class extends Dj{constructor(e){super(e,Aj,Xk(e.event.target))}};Mj.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==jj.RightClick&&(r?.({event:n}),!0)}}];var Nj={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},Pj=class extends Dj{constructor(e){super(e,Nj)}static setup(){return window.addEventListener(Nj.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Nj.move.name,e)};function e(){}}};Pj.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Fj;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(Fj||={});var Ij;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(Ij||={});function Lj(e){let{acceleration:t,activator:n=Fj.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=Ij.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=zj({delta:d,disabled:!a}),[m,h]=$k(),g=(0,D.useRef)({x:0,y:0}),_=(0,D.useRef)({x:0,y:0}),v=(0,D.useMemo)(()=>{switch(n){case Fj.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Fj.DraggableRect:return i}},[n,i,c]),y=(0,D.useRef)(null),b=(0,D.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,D.useMemo)(()=>s===Ij.TreeOrder?[...l].reverse():l,[s,l]);(0,D.useEffect)(()=>{if(!a||!l.length||!v)h();else{for(let e of x){if(r?.(e)===!1)continue;let n=l.indexOf(e),i=u[n];if(!i)continue;let{direction:a,speed:s}=sj(e,i,v,t,f);for(let e of[`x`,`y`])p[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){h(),y.current=e,m(b,o),g.current=s,_.current=a;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()}},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var Rj={x:{[rj.Backward]:!1,[rj.Forward]:!1},y:{[rj.Backward]:!1,[rj.Forward]:!1}};function zj(e){let{delta:t,disabled:n}=e,r=rA(t);return tA(e=>{if(n||!r||!e)return Rj;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[rj.Backward]:e.x[rj.Backward]||i.x===-1,[rj.Forward]:e.x[rj.Forward]||i.x===1},y:{[rj.Backward]:e.y[rj.Backward]||i.y===-1,[rj.Forward]:e.y[rj.Forward]||i.y===1}}},[n,t,r])}function Bj(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return tA(e=>t==null?null:r??e??null,[r,t])}function Vj(e,t){return(0,D.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var Hj;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(Hj||={});var Uj;(function(e){e.Optimized=`optimized`})(Uj||={});var Wj=new Map;function Gj(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,D.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,D.useRef)(e),d=g(),f=eA(d),p=(0,D.useCallback)(function(e){e===void 0&&(e=[]),f.current||o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,D.useRef)(null),h=tA(t=>{if(d&&!n)return Wj;if(!t||t===Wj||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new mj(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,D.useEffect)(()=>{u.current=e},[e]),(0,D.useEffect)(()=>{d||p()},[n,d]),(0,D.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,D.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case Hj.Always:return!1;case Hj.BeforeDragging:return n;default:return!n}}}function Kj(e,t){return tA(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function qj(e,t){return Kj(e,t)}function Jj(e){let{callback:t,disabled:n}=e,r=Qk(t),i=(0,D.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,D.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Yj(e){let{callback:t,disabled:n}=e,r=Qk(t),i=(0,D.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,D.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Xj(e){return new mj(KA(e),e)}function Zj(e,t,n){t===void 0&&(t=Xj);let[r,i]=(0,D.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=Jj({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=Yj({callback:a});return Zk(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function Qj(e){return BA(e,Kj(e))}var $j=[];function eM(e){let t=(0,D.useRef)(e),n=tA(n=>e?n&&n!==$j&&e&&t.current&&e.parentNode===t.current.parentNode?n:ZA(e):$j,[e]);return(0,D.useEffect)(()=>{t.current=e},[e]),n}function tM(e){let[t,n]=(0,D.useState)(null),r=(0,D.useRef)(e),i=(0,D.useCallback)(e=>{let t=$A(e.target);t&&n(e=>e?(e.set(t,nj(t)),new Map(e)):null)},[]);return(0,D.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=$A(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,nj(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{$A(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,D.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>sA(e,t),AA):lj(e):AA,[e,t])}function nM(e,t){t===void 0&&(t=[]);let n=(0,D.useRef)(null);return(0,D.useEffect)(()=>{n.current=null},t),(0,D.useEffect)(()=>{let t=e!==AA;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?cA(e,n.current):AA}function rM(e){(0,D.useEffect)(()=>{if(!Uk)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function iM(e,t){return(0,D.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function aM(e){return(0,D.useMemo)(()=>e?JA(e):null,[e])}var oM=[];function sM(e,t){t===void 0&&(t=KA);let[n]=e,r=aM(n?Kk(n):null),[i,a]=(0,D.useState)(oM);function o(){a(()=>e.length?e.map(e=>ij(e)?r:new mj(t(e),e)):oM)}let s=Yj({callback:o});return Zk(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function cM(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return Jk(t)?t:e}function lM(e){let{measure:t}=e,[n,r]=(0,D.useState)(null),i=Yj({callback:(0,D.useCallback)(e=>{for(let{target:n}of e)if(Jk(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=nA((0,D.useCallback)(e=>{let n=cM(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,D.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var uM=[{sensor:kj,options:{}},{sensor:wj,options:{}}],dM={current:{}},fM={draggable:{measure:qA},droppable:{measure:qA,strategy:Hj.WhileDragging,frequency:Uj.Optimized},dragOverlay:{measure:KA}},pM=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},mM={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new pM,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:DA},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:fM,measureDroppableContainers:DA,windowRect:null,measuringScheduled:!1},hM={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:DA,draggableNodes:new Map,over:null,measureDroppableContainers:DA},gM=(0,D.createContext)(hM),_M=(0,D.createContext)(mM);function vM(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new pM}}}function yM(e,t){switch(t.type){case EA.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case EA.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case EA.DragEnd:case EA.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case EA.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new pM(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case EA.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new pM(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case EA.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new pM(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function bM(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,D.useContext)(gM),a=rA(r),o=rA(n?.id);return(0,D.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!uA(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=hA(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function xM(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function SM(e){return(0,D.useMemo)(()=>({draggable:{...fM.draggable,...e?.draggable},droppable:{...fM.droppable,...e?.droppable},dragOverlay:{...fM.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function CM(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,D.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Zk(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=BA(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=QA(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var wM=(0,D.createContext)({...AA,scaleX:1,scaleY:1}),TM;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(TM||={});var EM=(0,D.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=uM,collisionDetection:o=RA,measuring:s,modifiers:c,...l}=e,[u,d]=(0,D.useReducer)(yM,void 0,vM),[f,p]=SA(),[m,h]=(0,D.useState)(TM.Uninitialized),g=m===TM.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,D.useRef)({initial:null,translated:null}),C=(0,D.useMemo)(()=>_==null?null:{id:_,data:x?.data??dM,rect:S},[_,x]),w=(0,D.useRef)(null),[T,E]=(0,D.useState)(null),[O,k]=(0,D.useState)(null),A=eA(l,Object.values(l)),j=aA(`DndDescribedBy`,t),M=(0,D.useMemo)(()=>b.getEnabled(),[b]),N=SM(s),{droppableRects:P,measureDroppableContainers:F,measuringScheduled:I}=Gj(M,{dragging:g,dependencies:[y.x,y.y],config:N.droppable}),ee=Bj(v,_),te=(0,D.useMemo)(()=>O?fA(O):null,[O]),ne=Ae(),re=qj(ee,N.draggable.measure);CM({activeNode:_==null?null:v.get(_),config:ne.layoutShiftCompensation,initialRect:re,measure:N.draggable.measure});let L=Zj(ee,N.draggable.measure,re),ie=Zj(ee?ee.parentElement:null),ae=(0,D.useRef)({activatorEvent:null,active:null,activeNode:ee,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),oe=b.getNodeFor(ae.current.over?.id),R=lM({measure:N.dragOverlay.measure}),se=R.nodeRef.current??ee,ce=g?R.rect??L:null,le=!!(R.nodeRef.current&&R.rect),ue=Qj(le?null:L),de=aM(se?Kk(se):null),z=eM(g?oe??ee:null),fe=sM(z),pe=xM(c,{transform:{x:y.x-ue.x,y:y.y-ue.y,scaleX:1,scaleY:1},activatorEvent:O,active:C,activeNodeRect:L,containerNodeRect:ie,draggingNodeRect:ce,over:ae.current.over,overlayNodeRect:R.rect,scrollableAncestors:z,scrollableAncestorRects:fe,windowRect:de}),me=te?sA(te,y):null,he=tM(z),ge=nM(he),_e=nM(he,[L]),ve=sA(pe,ge),ye=ce?HA(ce,pe):null,be=C&&ye?o({active:C,collisionRect:ye,droppableRects:P,droppableContainers:M,pointerCoordinates:me}):null,xe=PA(be,`id`),[Se,Ce]=(0,D.useState)(null),we=zA(le?pe:sA(pe,_e),Se?.rect??null,L),Te=(0,D.useRef)(null),Ee=(0,D.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent,o=new n({active:w.current,activeNode:i,event:a,options:r,context:ae,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=A.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=A.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=A.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,Un.unstable_batchedUpdates)(()=>{r?.(i),h(TM.Initializing),d({type:EA.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(Te.current),k(a)})},onMove(e){d({type:EA.DragMove,coordinates:e})},onEnd:s(EA.DragEnd),onCancel:s(EA.DragCancel)});Te.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=ae.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===EA.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=EA.DragCancel)}w.current=null,(0,Un.unstable_batchedUpdates)(()=>{d({type:e}),h(TM.Uninitialized),Ce(null),E(null),k(null),Te.current=null;let t=e===EA.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),De=Vj(a,(0,D.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,Ee(n,t))},[v,Ee]));rM(a),Zk(()=>{L&&m===TM.Initializing&&h(TM.Initialized)},[L,m]),(0,D.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=ae.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:ve.x,y:ve.y},over:i};(0,Un.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[ve.x,ve.y]),(0,D.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=ae.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(xe),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,Un.unstable_batchedUpdates)(()=>{Ce(s),a?.(c),f({type:`onDragOver`,event:c})})},[xe]),Zk(()=>{ae.current={activatorEvent:O,active:C,activeNode:ee,collisionRect:ye,collisions:be,droppableRects:P,draggableNodes:v,draggingNode:se,draggingNodeRect:ce,droppableContainers:b,over:Se,scrollableAncestors:z,scrollAdjustedTranslate:ve},S.current={initial:ce,translated:ye}},[C,ee,be,ye,v,se,ce,P,b,Se,z,ve]),Lj({...ne,delta:y,draggingRect:ye,pointerCoordinates:me,scrollableAncestors:z,scrollableAncestorRects:fe});let Oe=(0,D.useMemo)(()=>({active:C,activeNode:ee,activeNodeRect:L,activatorEvent:O,collisions:be,containerNodeRect:ie,dragOverlay:R,draggableNodes:v,droppableContainers:b,droppableRects:P,over:Se,measureDroppableContainers:F,scrollableAncestors:z,scrollableAncestorRects:fe,measuringConfiguration:N,measuringScheduled:I,windowRect:de}),[C,ee,L,O,be,ie,R,v,b,P,Se,F,z,fe,N,I,de]),ke=(0,D.useMemo)(()=>({activatorEvent:O,activators:De,active:C,activeNodeRect:L,ariaDescribedById:{draggable:j},dispatch:d,draggableNodes:v,over:Se,measureDroppableContainers:F}),[O,De,C,L,d,j,v,Se,F]);return D.createElement(bA.Provider,{value:p},D.createElement(gM.Provider,{value:ke},D.createElement(_M.Provider,{value:Oe},D.createElement(wM.Provider,{value:we},i)),D.createElement(bM,{disabled:n?.restoreFocus===!1})),D.createElement(TA,{...n,hiddenTextDescribedById:j}));function Ae(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),DM=(0,D.createContext)(null),OM=`button`,kM=`Draggable`;function AM(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=aA(kM),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,D.useContext)(gM),{role:p=OM,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,D.useContext)(g?wM:DM),[v,y]=nA(),[b,x]=nA(),S=iM(o,t),C=eA(n);return Zk(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,D.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===OM?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function jM(){return(0,D.useContext)(_M)}var MM=`Droppable`,NM={timeout:25};function PM(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=aA(MM),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,D.useContext)(gM),u=(0,D.useRef)({disabled:n}),d=(0,D.useRef)(!1),f=(0,D.useRef)(null),p=(0,D.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...NM,...i},_=eA(h??r),v=Yj({callback:(0,D.useCallback)(()=>{d.current?(p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)):d.current=!0},[g]),disabled:m||!o}),[y,b]=nA((0,D.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=eA(t);return(0,D.useEffect)(()=>{v&&y.current&&(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,D.useEffect)(()=>(s({type:EA.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:EA.UnregisterDroppable,key:a,id:r})),[r]),(0,D.useEffect)(()=>{n!==u.current.disabled&&(s({type:EA.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function FM(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function IM(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function LM(e){return e!==null&&e>=0}function RM(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function zM(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var BM=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=FM(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},VM={scaleX:1,scaleY:1},HM=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...VM}:null}let s=UM(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...VM}:r<t&&r>=a?{x:0,y:o.height+s,...VM}:{x:0,y:0,...VM}};function UM(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var WM=`Sortable`,GM=D.createContext({activeIndex:-1,containerId:WM,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:BM,disabled:{draggable:!1,droppable:!1}});function KM(e){let{children:t,id:n,items:r,strategy:i=BM,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=jM(),d=aA(WM,n),f=s.rect!==null,p=(0,D.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,D.useRef)(p),v=!RM(p,_.current),y=g!==-1&&h===-1||v,b=zM(a);Zk(()=>{v&&m&&u(p)},[v,p,m,u]),(0,D.useEffect)(()=>{_.current=p},[p]);let x=(0,D.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:IM(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return D.createElement(GM.Provider,{value:x},t)}var qM=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return FM(n,r,i).indexOf(t)},JM=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},YM={duration:200,easing:`ease`},XM=`transform`,ZM=pA.Transition.toString({property:XM,duration:0,easing:`linear`}),QM={roleDescription:`sortable`};function $M(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,D.useState)(null),s=(0,D.useRef)(n);return Zk(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=KA(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,D.useEffect)(()=>{a&&o(null)},[a]),a}function eN(e){let{animateLayoutChanges:t=JM,attributes:n,disabled:r,data:i,getNewIndex:a=qM,id:o,strategy:s,resizeObserverConfig:c,transition:l=YM}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,D.useContext)(GM),y=tN(r,p),b=u.indexOf(o),x=(0,D.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,D.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=PM({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:O,activatorEvent:k,activeNodeRect:A,attributes:j,setNodeRef:M,listeners:N,isDragging:P,over:F,setActivatorNodeRef:I,transform:ee}=AM({id:o,data:x,attributes:{...QM,...n},disabled:y.draggable}),te=Hk(E,M),ne=!!O,re=ne&&!m&&LM(f)&&LM(g),L=!_&&P,ie=re?(L&&re?ee:null)??(s??v)({rects:h,activeNodeRect:A,activeIndex:f,overIndex:g,index:b}):null,ae=LM(f)&&LM(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,oe=O?.id,R=(0,D.useRef)({activeId:oe,items:u,newIndex:ae,containerId:d}),se=u!==R.current.items,ce=t({active:O,containerId:d,isDragging:P,isSorting:ne,id:o,index:b,items:u,newIndex:R.current.newIndex,previousItems:R.current.items,previousContainerId:R.current.containerId,transition:l,wasDragging:R.current.activeId!=null}),le=$M({disabled:!ce,index:b,node:w,rect:C});return(0,D.useEffect)(()=>{ne&&R.current.newIndex!==ae&&(R.current.newIndex=ae),d!==R.current.containerId&&(R.current.containerId=d),u!==R.current.items&&(R.current.items=u)},[ne,ae,d,u]),(0,D.useEffect)(()=>{if(oe===R.current.activeId)return;if(oe!=null&&R.current.activeId==null){R.current.activeId=oe;return}let e=setTimeout(()=>{R.current.activeId=oe},50);return()=>clearTimeout(e)},[oe]),{active:O,activeIndex:f,attributes:j,data:x,rect:C,index:b,newIndex:ae,items:u,isOver:T,isSorting:ne,isDragging:P,listeners:N,node:w,overIndex:g,over:F,setNodeRef:te,setActivatorNodeRef:I,setDroppableNodeRef:E,setDraggableNodeRef:M,transform:le??ie,transition:ue()};function ue(){if(le||se&&R.current.newIndex===b)return ZM;if(!(L&&!uA(k)||!l)&&(ne||ce))return pA.Transition.toString({...l,property:XM})}}function tN(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}xj.Down,xj.Right,xj.Up,xj.Left;function nN({ids:e,onReorder:t,children:n}){let r=kA(OA(Mj,{activationConstraint:{distance:6}}),OA(Pj,{activationConstraint:{delay:200,tolerance:8}}));return(0,W.jsx)(EM,{sensors:r,collisionDetection:IA,onDragEnd:({active:n,over:r})=>{if(!r||n.id===r.id)return;let i=e.indexOf(String(n.id)),a=e.indexOf(String(r.id));i<0||a<0||t(FM(e,i,a))},children:(0,W.jsx)(KM,{items:e,strategy:HM,children:n})})}function rN(e){let{attributes:t,listeners:n,setNodeRef:r,setActivatorNodeRef:i,transform:a,transition:o,isDragging:s}=eN({id:e});return{row:{ref:r,style:{transform:pA.Transform.toString(a),transition:o}},handle:{ref:i,...t,...n},isDragging:s}}function iN({...e}){return(0,W.jsx)(us,{"data-slot":`alert-dialog`,...e})}function aN({...e}){return(0,W.jsx)(ds,{"data-slot":`alert-dialog-portal`,...e})}function oN({className:e,...t}){return(0,W.jsx)(fs,{"data-slot":`alert-dialog-overlay`,className:U(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function sN({className:e,size:t=`default`,...n}){return(0,W.jsxs)(aN,{children:[(0,W.jsx)(oN,{}),(0,W.jsx)(hs,{"data-slot":`alert-dialog-content`,onCloseAutoFocus:ng,"data-size":t,className:U(`group/alert-dialog-content fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 data-[size=sm]:max-w-xs data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[size=default]:sm:max-w-lg`,e),...n})]})}function cN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:U(`grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]`,e),...t})}function lN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:U(`flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end`,e),...t})}function uN({className:e,...t}){return(0,W.jsx)(gs,{"data-slot":`alert-dialog-title`,className:U(`text-lg font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2`,e),...t})}function dN({className:e,...t}){return(0,W.jsx)(_s,{"data-slot":`alert-dialog-description`,className:U(`text-sm text-muted-foreground`,e),...t})}function fN({className:e,variant:t=`default`,size:n=`default`,...r}){return(0,W.jsx)(Uh,{variant:t,size:n,asChild:!0,children:(0,W.jsx)(vs,{"data-slot":`alert-dialog-action`,className:U(e),...r})})}function pN({className:e,variant:t=`outline`,size:n=`default`,...r}){return(0,W.jsx)(Uh,{variant:t,size:n,asChild:!0,children:(0,W.jsx)(bs,{"data-slot":`alert-dialog-cancel`,className:U(e),...r})})}function mN({open:e,onOpenChange:t,sessionName:n,onDelete:r}){return(0,W.jsx)(iN,{open:e,onOpenChange:t,children:(0,W.jsxs)(sN,{children:[(0,W.jsxs)(cN,{children:[(0,W.jsxs)(uN,{children:[`Delete `,n,`?`]}),(0,W.jsx)(dN,{children:`This ends its shell and everything running in it. It can't be undone.`})]}),(0,W.jsxs)(lN,{children:[(0,W.jsx)(pN,{children:`Cancel`}),(0,W.jsx)(fN,{variant:`destructive`,onClick:()=>void r(),children:`Delete session`})]})]})})}function hN({workspace:e,onDelete:t,onClose:n}){let[r,i]=(0,D.useState)(),a=e.sessions.length;return(0,W.jsx)(iN,{open:!0,onOpenChange:e=>!e&&n(),children:(0,W.jsxs)(sN,{children:[(0,W.jsxs)(cN,{children:[(0,W.jsxs)(uN,{children:[`Delete `,e.name,`?`]}),(0,W.jsxs)(dN,{children:[a===0?`The Workspace is removed. `:`Its ${a===1?`Session`:`${a} Sessions`} will be ended and everything running in ${a===1?`it`:`them`} stopped. `,`The folder on disk is not touched.`]})]}),r&&(0,W.jsx)(kv,{children:r}),(0,W.jsxs)(lN,{children:[(0,W.jsx)(pN,{children:`Cancel`}),(0,W.jsx)(Uh,{variant:`destructive`,onClick:()=>{t().then(n,e=>i(e instanceof Error?e.message:String(e)))},children:`Delete Workspace`})]})]})})}var gN={model:[`default`,`fable`,`opus`,`sonnet`,`haiku`],effort:[`default`,`low`,`medium`,`high`,`xhigh`,`max`],advisor:[`default`,`off`,`fable`,`opus`,`sonnet`]},_N={model:`default`,effort:`default`,advisor:`default`,focusView:!1};function vN({...e}){return(0,W.jsx)(Nf,{"data-slot":`select`,...e})}function yN({...e}){return(0,W.jsx)(Lf,{"data-slot":`select-value`,...e})}function bN({className:e,size:t=`default`,children:n,...r}){return(0,W.jsxs)(Ff,{"data-slot":`select-trigger`,"data-size":t,className:U(`flex w-fit items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[placeholder]:text-muted-foreground data-[size=default]:h-9 data-[size=sm]:h-8 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...r,children:[n,(0,W.jsx)(Rf,{asChild:!0,children:(0,W.jsx)(ae,{className:`size-4 opacity-50`})})]})}function xN({className:e,children:t,position:n=`item-aligned`,align:r=`center`,...i}){return(0,W.jsx)(Vf,{children:(0,W.jsxs)(Uf,{"data-slot":`select-content`,className:U(`relative z-50 max-h-(--radix-select-content-available-height) min-w-[8rem] origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,align:r,...i,children:[(0,W.jsx)(CN,{}),(0,W.jsx)(tp,{className:U(`p-1`,n===`popper`&&`h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1`),children:t}),(0,W.jsx)(wN,{})]})})}function SN({className:e,children:t,...n}){return(0,W.jsxs)(sp,{"data-slot":`select-item`,className:U(`relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2`,e),...n,children:[(0,W.jsx)(`span`,{"data-slot":`select-item-indicator`,className:`absolute right-2 flex size-3.5 items-center justify-center`,children:(0,W.jsx)(dp,{children:(0,W.jsx)(L,{className:`size-4`})})}),(0,W.jsx)(lp,{children:t})]})}function CN({className:e,...t}){return(0,W.jsx)(pp,{"data-slot":`select-scroll-up-button`,className:U(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,W.jsx)(ce,{className:`size-4`})})}function wN({className:e,...t}){return(0,W.jsx)(hp,{"data-slot":`select-scroll-down-button`,className:U(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,W.jsx)(ae,{className:`size-4`})})}function TN({className:e,size:t=`default`,...n}){return(0,W.jsx)(Vp,{"data-slot":`switch`,"data-size":t,className:U(`peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input dark:data-[state=unchecked]:bg-input/80`,e),...n,children:(0,W.jsx)(Up,{"data-slot":`switch-thumb`,className:U(`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0 dark:data-[state=checked]:bg-primary-foreground dark:data-[state=unchecked]:bg-foreground`)})})}var EN=[{field:`model`,label:`Model`},{field:`effort`,label:`Effort`},{field:`advisor`,label:`Advisor`}];function DN(e){return e===`xhigh`?`XHigh`:e.charAt(0).toUpperCase()+e.slice(1)}function ON({workspace:e,onLaunch:t,onClose:n}){let[r,i]=(0,D.useState)(``),[a,o]=(0,D.useState)(),[s,c]=(0,D.useState)(),[l,u]=(0,D.useState)(!1),d=(0,D.useId)(),f=`${d}-name`,p=`${d}-focusView`,m=`${d}-nameError`;(0,D.useEffect)(()=>{let e=!0;return Tg.lastLaunchOptions().catch(()=>_N).then(t=>e&&o(t)),()=>{e=!1}},[]);let h=async()=>{if(a){u(!0);try{await t({name:r.trim(),claude:a}),n()}catch(e){c({message:e instanceof Error?e.message:String(e),nameTaken:e instanceof xg&&e.status===409}),u(!1)}}};return(0,W.jsx)(Y_,{open:!0,onOpenChange:e=>!e&&n(),children:(0,W.jsx)($_,{className:`max-h-[calc(100dvh-2rem)] overflow-y-auto`,children:(0,W.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),h()},children:[(0,W.jsxs)(ev,{children:[(0,W.jsx)(nv,{children:`New Claude Session`}),(0,W.jsxs)(rv,{children:[`Runs Claude Code in the folder of `,e.name,`. Default leaves a setting to your own Claude Code configuration.`]})]}),(0,W.jsxs)(Dv,{"data-invalid":s?.nameTaken||void 0,children:[(0,W.jsx)(Ov,{htmlFor:f,children:`Session name`}),(0,W.jsx)(lv,{id:f,"aria-invalid":s?.nameTaken||void 0,"aria-describedby":s?.nameTaken?m:void 0,placeholder:`Optional`,value:r,onChange:e=>{i(e.target.value),c(void 0)},autoFocus:!0}),s?.nameTaken&&(0,W.jsx)(kv,{id:m,children:s.message})]}),(0,W.jsxs)(`fieldset`,{disabled:!a,"aria-busy":!a,className:`grid min-w-0 gap-4 ${a?``:`invisible`}`,children:[EN.map(({field:e,label:t})=>(0,W.jsxs)(Dv,{children:[(0,W.jsx)(Ov,{htmlFor:`${d}-${e}`,children:t}),(0,W.jsxs)(vN,{value:a?.[e]??`default`,onValueChange:t=>a&&o({...a,[e]:t}),children:[(0,W.jsx)(bN,{id:`${d}-${e}`,className:`w-full`,children:(0,W.jsx)(yN,{})}),(0,W.jsx)(xN,{children:gN[e].map(e=>(0,W.jsx)(SN,{value:e,children:DN(e)},e))})]})]},e)),(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-lg border px-3 py-2.5`,children:[(0,W.jsx)(Tv,{htmlFor:p,children:`Focus view`}),(0,W.jsx)(TN,{id:p,checked:a?.focusView??!1,onCheckedChange:e=>a&&o({...a,focusView:e})})]})]}),s&&!s.nameTaken&&(0,W.jsx)(kv,{children:s.message}),(0,W.jsx)(tv,{children:(0,W.jsx)(Uh,{type:`submit`,disabled:l||!a,children:`Launch`})})]})})})}function kN({open:e,onOpenChange:t,currentName:n,onRename:r}){let[i,a]=(0,D.useState)(n),[o,s]=(0,D.useState)(),c=(0,D.useId)(),l=async()=>{try{await r(i.trim()),t(!1)}catch(e){s(e instanceof Error?e.message:String(e))}};return(0,W.jsx)(Y_,{open:e,onOpenChange:e=>{e&&(a(n),s(void 0)),t(e)},children:(0,W.jsx)($_,{children:(0,W.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,W.jsxs)(ev,{children:[(0,W.jsx)(nv,{children:`Rename Session`}),(0,W.jsx)(rv,{children:`Names are unique within their Workspace.`})]}),(0,W.jsxs)(Dv,{children:[(0,W.jsx)(Ov,{htmlFor:c,children:`Session name`}),(0,W.jsx)(lv,{id:c,value:i,onChange:e=>a(e.target.value),onFocus:e=>e.target.select(),autoFocus:!0})]}),o&&(0,W.jsx)(kv,{children:o}),(0,W.jsx)(tv,{children:(0,W.jsx)(Uh,{type:`submit`,disabled:i.trim()===``,children:`Rename`})})]})})})}function AN({workspaces:e,onCreateClaudeSession:t}){let n=Fg(),[r,i]=(0,D.useState)(),[a,o]=(0,D.useState)(),[s,c]=(0,D.useState)();return{newClaude:i,editWorkspace:(e,t)=>o({workspace:e,action:t}),editSession:(e,t)=>c({session:e,action:t}),dialogs:(0,W.jsxs)(W.Fragment,{children:[r&&(0,W.jsx)(ON,{workspace:r,onLaunch:e=>t(r.id,e),onClose:()=>i(void 0)}),a&&a.action!==`delete`&&(0,W.jsx)(Av,{workspace:a.workspace,workspaces:e,edit:a.action,onSave:e=>n.updateWorkspace(a.workspace.id,e),onClose:()=>o(void 0)}),a?.action===`delete`&&(0,W.jsx)(hN,{workspace:a.workspace,onDelete:()=>n.deleteWorkspace(a.workspace.id),onClose:()=>o(void 0)}),s?.action===`rename`&&(0,W.jsx)(kN,{open:!0,onOpenChange:e=>!e&&c(void 0),currentName:s.session.name,onRename:e=>n.renameSession(s.session.id,e)},s.session.id),s?.action===`delete`&&(0,W.jsx)(mN,{open:!0,onOpenChange:e=>!e&&c(void 0),sessionName:s.session.name,onDelete:()=>n.deleteSession(s.session.id)},s.session.id)]})}}function jN({workspaces:e,onReorder:t,openWorkspaceId:n,shown:r,onOpenWorkspace:i,onOpenSession:a}){return(0,W.jsx)(nN,{ids:e.map(e=>e.id),onReorder:t,children:(0,W.jsx)(`ul`,{className:`flex min-h-0 w-full flex-1 flex-col items-center gap-2 overflow-y-auto py-1`,children:e.map(e=>(0,W.jsx)(MN,{workspace:e,isOpen:e.id===n,shown:r,onOpen:()=>i(e.id),onOpenSession:t=>a(e.id,t)},e.id))})})}function MN({workspace:e,isOpen:t,shown:n,onOpen:r,onOpenSession:i}){let{row:a,handle:o,isDragging:s}=rN(e.id),{primeAndWorker:c,others:l}=dg(e.sessions),u=[...c,...l];return(0,W.jsxs)(`li`,{...a,className:U(`flex flex-col items-center gap-1 rounded-lg`,s&&`relative z-20 bg-card shadow-lg`),children:[(0,W.jsxs)(`div`,{className:`relative`,children:[(0,W.jsx)(sh,{workspace:e,size:`md`,marker:t?null:hg(e),className:U(`rounded-lg`,t&&`ring-2 ring-primary ring-offset-2 ring-offset-sidebar`)}),(0,W.jsxs)(yk,{children:[(0,W.jsx)(bk,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,...o,"aria-label":e.name,"aria-current":t?`true`:void 0,onClick:r,className:`absolute inset-0 rounded-lg outline-none hover:bg-foreground/10 focus-visible:ring-[3px] focus-visible:ring-ring/50`})}),(0,W.jsxs)(xk,{side:`right`,children:[(0,W.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,W.jsx)(`div`,{className:`opacity-70`,children:e.folder})]})]})]}),t&&u.length>0&&(0,W.jsx)(`ul`,{className:`flex flex-col items-center gap-0.5 rounded-lg bg-sidebar-accent/40 p-0.5`,children:u.map(e=>(0,W.jsx)(NN,{session:e,isShown:n.has(e.id),onOpen:()=>i(e)},e.id))})]})}function NN({session:e,isShown:t,onOpen:n}){let r=e.status===`stopped`;return(0,W.jsxs)(`li`,{className:U(`relative grid size-7 place-items-center rounded-md`,t?`bg-sidebar-accent shadow-[inset_0_-2px_0_var(--primary)]`:`hover:bg-sidebar-accent/60`),children:[(0,W.jsx)(Ln,{session:e,className:U(`size-4`,r&&`opacity-50`)}),(0,W.jsxs)(yk,{children:[(0,W.jsx)(bk,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,"aria-label":e.name,"aria-current":t?`true`:void 0,onClick:n,className:`absolute inset-0 rounded-md outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`})}),(0,W.jsx)(xk,{side:`right`,children:r?`${e.name} (stopped)`:e.name})]}),r&&(0,W.jsx)(`span`,{className:`sr-only`,children:`stopped`}),(0,W.jsx)(_g,{session:e,className:`pointer-events-none absolute -top-0.5 -right-0.5 scale-75`})]})}var PN=Vh(`relative grid w-full grid-cols-[0_1fr] items-start gap-y-0.5 rounded-lg border px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current`,{variants:{variant:{default:`bg-card text-card-foreground`,destructive:`bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 [&>svg]:text-current`}},defaultVariants:{variant:`default`}});function FN({className:e,variant:t,...n}){return(0,W.jsx)(`div`,{"data-slot":`alert`,role:`alert`,className:U(PN({variant:t}),e),...n})}function IN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`alert-description`,className:U(`col-start-2 grid justify-items-start gap-1 text-sm text-muted-foreground [&_p]:leading-relaxed`,e),...t})}function LN({...e}){return(0,W.jsx)(nf,{"data-slot":`dropdown-menu`,...e})}function RN({...e}){return(0,W.jsx)(af,{"data-slot":`dropdown-menu-trigger`,...e})}function zN({className:e,sideOffset:t=4,...n}){return(0,W.jsx)(of,{children:(0,W.jsx)(cf,{"data-slot":`dropdown-menu-content`,onCloseAutoFocus:ng,sideOffset:t,className:U(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...n})})}function BN({className:e,inset:t,variant:n=`default`,...r}){return(0,W.jsx)(lf,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:U(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}var VN=`16rem`,HN=`18rem`,UN=`3.5rem`,WN=D.createContext(null);function GN(){let e=D.useContext(WN);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}function KN({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o}){let s=uh(),[c,l]=D.useState(!1),[u,d]=D.useState(e),f=t??u,p=D.useCallback(e=>{let t=typeof e==`function`?e(f):e;n?n(t):d(t)},[n,f]),m=D.useCallback(()=>s?l(e=>!e):p(e=>!e),[s,p,l]),h=f?`expanded`:`collapsed`,g=D.useMemo(()=>({state:h,open:f,setOpen:p,isMobile:s,openMobile:c,setOpenMobile:l,toggleSidebar:m}),[h,f,p,s,c,l,m]);return(0,W.jsx)(WN.Provider,{value:g,children:(0,W.jsx)(`div`,{"data-slot":`sidebar-wrapper`,style:{"--sidebar-width":VN,"--sidebar-width-icon":UN,...i},className:U(`group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar`,r),...o,children:a})})}function qN({side:e=`left`,variant:t=`sidebar`,collapsible:n=`offcanvas`,className:r,children:i,...a}){let{isMobile:o,state:s,openMobile:c,setOpenMobile:l}=GN();return n===`none`?(0,W.jsx)(`div`,{"data-slot":`sidebar`,className:U(`flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground`,r),...a,children:i}):o?(0,W.jsx)(rg,{open:c,onOpenChange:l,...a,children:(0,W.jsxs)(sg,{"data-sidebar":`sidebar`,"data-slot":`sidebar`,"data-mobile":`true`,className:`w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden`,style:{"--sidebar-width":HN},side:e,children:[(0,W.jsxs)(cg,{className:`sr-only`,children:[(0,W.jsx)(lg,{children:`Workspaces`}),(0,W.jsx)(ug,{children:`Your Workspaces and the Open one's Sessions.`})]}),(0,W.jsx)(`div`,{className:`flex h-full w-full flex-col`,children:i})]})}):(0,W.jsxs)(`div`,{className:`group peer hidden text-sidebar-foreground md:block`,"data-state":s,"data-collapsible":s===`collapsed`?n:``,"data-variant":t,"data-side":e,"data-slot":`sidebar`,children:[(0,W.jsx)(`div`,{"data-slot":`sidebar-gap`,className:U(`relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear`,`group-data-[collapsible=offcanvas]:w-0`,`group-data-[side=right]:rotate-180`,t===`floating`||t===`inset`?`group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon)`)}),(0,W.jsx)(`div`,{"data-slot":`sidebar-container`,className:U(`fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear md:flex`,e===`left`?`left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]`:`right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]`,t===`floating`||t===`inset`?`p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]`:`group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l`,r),...a,children:(0,W.jsx)(`div`,{"data-sidebar":`sidebar`,"data-slot":`sidebar-inner`,className:`flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm`,children:i})})]})}function JN({className:e,...t}){return(0,W.jsx)(`main`,{"data-slot":`sidebar-inset`,className:U(`relative flex w-full flex-1 flex-col bg-background`,`md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2`,e),...t})}function YN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`sidebar-header`,"data-sidebar":`header`,className:U(`flex flex-col gap-2 p-2`,e),...t})}function XN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`sidebar-footer`,"data-sidebar":`footer`,className:U(`flex flex-col gap-2 p-2`,e),...t})}function ZN({className:e,...t}){return(0,W.jsx)(Wh,{"data-slot":`sidebar-separator`,"data-sidebar":`separator`,className:U(`mx-2 w-auto bg-sidebar-border`,e),...t})}function QN({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`sidebar-content`,"data-sidebar":`content`,className:U(`flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden`,e),...t})}function $N({className:e,...t}){return(0,W.jsx)(`div`,{"data-slot":`sidebar-group`,"data-sidebar":`group`,className:U(`relative flex w-full min-w-0 flex-col p-2`,e),...t})}function eP({className:e,asChild:t=!1,...n}){let r=t?qn:`div`;return(0,W.jsx)(r,{"data-slot":`sidebar-group-label`,"data-sidebar":`group-label`,className:U(`flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0`,`group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0`,e),...n})}function tP({className:e,...t}){return(0,W.jsx)(`ul`,{"data-slot":`sidebar-menu`,"data-sidebar":`menu`,className:U(`flex w-full min-w-0 flex-col gap-1`,e),...t})}function nP({className:e,...t}){return(0,W.jsx)(`li`,{"data-slot":`sidebar-menu-item`,"data-sidebar":`menu-item`,className:U(`group/menu-item relative`,e),...t})}var rP=Vh(`peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0`,{variants:{variant:{default:`hover:bg-sidebar-accent hover:text-sidebar-accent-foreground`,outline:`bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]`},size:{default:`h-8 text-sm`,sm:`h-7 text-xs`,lg:`h-12 text-sm group-data-[collapsible=icon]:p-0!`}},defaultVariants:{variant:`default`,size:`default`}});function iP({asChild:e=!1,isActive:t=!1,variant:n=`default`,size:r=`default`,tooltip:i,className:a,...o}){let s=e?qn:`button`,{isMobile:c,state:l}=GN(),u=(0,W.jsx)(s,{"data-slot":`sidebar-menu-button`,"data-sidebar":`menu-button`,"data-size":r,"data-active":t,className:U(rP({variant:n,size:r}),a),...o});return i?(typeof i==`string`&&(i={children:i}),(0,W.jsxs)(yk,{children:[(0,W.jsx)(bk,{asChild:!0,children:u}),(0,W.jsx)(xk,{side:`right`,align:`center`,hidden:l!==`collapsed`||c,...i})]})):u}function aP({className:e,...t}){return(0,W.jsx)(`ul`,{"data-slot":`sidebar-menu-sub`,"data-sidebar":`menu-sub`,className:U(`mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5`,`group-data-[collapsible=icon]:hidden`,e),...t})}function oP({className:e,...t}){return(0,W.jsx)(`li`,{"data-slot":`sidebar-menu-sub-item`,"data-sidebar":`menu-sub-item`,className:U(`group/menu-sub-item relative`,e),...t})}function sP({asChild:e=!1,size:t=`md`,isActive:n=!1,className:r,...i}){let a=e?qn:`a`;return(0,W.jsx)(a,{"data-slot":`sidebar-menu-sub-button`,"data-sidebar":`menu-sub-button`,"data-size":t,"data-active":n,className:U(`flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground`,`data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground`,t===`sm`&&`text-xs`,t===`md`&&`text-sm`,`group-data-[collapsible=icon]:hidden`,r),...i})}function cP({workspace:e,isOpen:t,mode:n,onOpen:r,onNewShell:i,onNewClaude:a,onAction:o,children:s}){let{row:c,handle:l,isDragging:u}=rN(e.id);return(0,W.jsxs)(nP,{...c,className:U(`rounded-md`,u&&`relative z-20 bg-card shadow-lg`),children:[(0,W.jsx)(`h2`,{className:`text-sm font-normal`,title:e.folder,children:(0,W.jsxs)(iP,{...l,"aria-label":e.name,onClick:r,className:U(n===`drawer`&&`h-10`,t&&`pr-16 font-semibold`),children:[(0,W.jsx)(sh,{workspace:e,marker:t?null:hg(e)}),(0,W.jsx)(`span`,{children:e.name})]})}),t&&(0,W.jsxs)(`div`,{className:U(`absolute right-1 flex items-center`,n===`drawer`?`top-2`:`top-0.5`),children:[(0,W.jsxs)(LN,{children:[(0,W.jsx)(RN,{asChild:!0,children:(0,W.jsx)(Sk,{label:`New session in ${e.name}`,children:(0,W.jsx)(Le,{})})}),(0,W.jsxs)(zN,{align:`end`,children:[(0,W.jsxs)(BN,{onSelect:i,children:[(0,W.jsx)(qe,{}),`New shell`]}),(0,W.jsxs)(BN,{onSelect:a,children:[(0,W.jsx)(Ue,{}),`New Claude…`]})]})]}),(0,W.jsxs)(LN,{children:[(0,W.jsx)(RN,{asChild:!0,children:(0,W.jsx)(Sk,{label:`Actions for ${e.name}`,children:(0,W.jsx)(pe,{})})}),(0,W.jsxs)(zN,{align:`end`,children:[(0,W.jsxs)(BN,{onSelect:()=>o(`rename`),children:[(0,W.jsx)(Fe,{}),`Rename`]}),(0,W.jsxs)(BN,{onSelect:()=>o(`folder`),children:[(0,W.jsx)(he,{}),`Change folder`]}),(0,W.jsxs)(BN,{variant:`destructive`,onSelect:()=>o(`delete`),children:[(0,W.jsx)(Ze,{}),`Delete`]})]})]})]}),t&&e.missing&&(0,W.jsxs)(FN,{variant:`destructive`,role:`note`,className:`mx-1 mt-1 w-auto px-3 py-2`,children:[(0,W.jsx)($e,{}),(0,W.jsx)(IN,{className:`text-xs`,children:(0,W.jsxs)(`p`,{children:[`Missing: its folder is gone, so Sessions can't start. Running ones carry on.`,` `,(0,W.jsx)(Uh,{variant:`link`,onClick:()=>o(`folder`),className:`h-auto p-0 text-current text-xs underline underline-offset-2`,children:`Change folder`})]})})]}),t&&s]})}function lP({workspace:e,shown:t,mode:n,onOpen:r,onAction:i,onReorder:a}){let{prime:o,worker:s,others:c}=dg(e.sessions),l=e=>({session:e,isShown:t.has(e.id),mode:n,onOpen:()=>r(e),onAction:t=>i(e,t)});return(0,W.jsxs)(aP,{className:`mr-0 pr-0`,children:[o&&(0,W.jsx)(dP,{...l(o)},o.id),s&&(0,W.jsx)(dP,{...l(s)},s.id),c.length>0&&(0,W.jsx)(`li`,{"aria-hidden":`true`,className:`py-1`,children:(0,W.jsx)(Wh,{className:`bg-sidebar-border`})}),(0,W.jsx)(nN,{ids:c.map(e=>e.id),onReorder:a,children:c.map(e=>(0,W.jsx)(uP,{...l(e)},e.id))})]})}function uP(e){return(0,W.jsx)(dP,{...e,drag:rN(e.session.id)})}function dP({session:e,isShown:t,mode:n,onOpen:r,onAction:i,drag:a}){let o=Fg(),s=e.status===`stopped`,c=e.role!==null,l=!c||s;return(0,W.jsxs)(oP,{...a?.row,className:U(`rounded-md`,a?.isDragging&&`relative z-20 bg-card shadow-lg`),children:[(0,W.jsx)(sP,{asChild:!0,isActive:t,className:U(`w-full`,n===`drawer`?`h-9`:`h-7`,l?`pr-12`:`pr-7`,s&&`text-muted-foreground`,`data-[active=true]:shadow-[inset_2px_0_0_var(--primary)]`),children:(0,W.jsxs)(`button`,{type:`button`,...a?.handle,"aria-label":e.name,"aria-current":t?`true`:void 0,onClick:r,children:[(0,W.jsx)(`span`,{role:`img`,"aria-label":e.kind===`claude`?`${e.name} is a Claude Session`:`${e.name} is a shell`,className:U(`flex`,s&&`opacity-50`),children:(0,W.jsx)(Ln,{session:e,className:`size-4`})}),(0,W.jsx)(`span`,{className:`truncate`,children:e.name}),s&&(0,W.jsx)(tg,{variant:`outline`,className:`h-4 px-1.5 text-[10px] font-normal tracking-wide text-muted-foreground uppercase`,children:`stopped`})]})}),(0,W.jsxs)(`span`,{className:`pointer-events-none absolute top-1/2 right-1 flex -translate-y-1/2 items-center gap-1`,children:[(0,W.jsx)(_g,{session:e}),l&&(0,W.jsxs)(LN,{children:[(0,W.jsx)(RN,{asChild:!0,children:(0,W.jsx)(Sk,{label:`Actions for ${e.name}`,className:`pointer-events-auto size-6`,children:(0,W.jsx)(pe,{})})}),(0,W.jsxs)(zN,{align:`end`,children:[s&&(0,W.jsxs)(BN,{onSelect:()=>void o.restartSession(e.id),children:[(0,W.jsx)(ze,{}),`Restart`]}),!c&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(BN,{onSelect:()=>i(`rename`),children:[(0,W.jsx)(Fe,{}),`Rename`]}),(0,W.jsxs)(BN,{variant:`destructive`,onSelect:()=>i(`delete`),children:[(0,W.jsx)(Ze,{}),`Delete`]})]})]})]})]})]})}function fP({state:e,shown:t,onOpenSession:n,onOpenWorkspace:r,onCreateWorkspace:i,onCreateSession:a,onCreateClaudeSession:o,error:s}){let c=Fg(),l=e?.workspaces??[],{newClaude:u,editWorkspace:d,editSession:f,dialogs:p}=AN({workspaces:l,onCreateClaudeSession:o}),m=GN(),h=m.isMobile?`drawer`:`sidebar`,g=!m.isMobile&&m.state===`collapsed`,_=e=>(0,W.jsx)(Vk,{workspaces:l,onCreate:i,trigger:e}),v=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(YN,{className:`items-center`,children:(0,W.jsx)(Sk,{label:`Expand sidebar`,onClick:()=>m.setOpen(!0),children:(0,W.jsx)(Ne,{})})}),(0,W.jsx)(ZN,{className:`mx-auto w-8`}),(0,W.jsx)(QN,{children:(0,W.jsx)(jN,{workspaces:l,onReorder:c.reorderWorkspaces,openWorkspaceId:e?.openWorkspaceId,shown:t,onOpenWorkspace:r,onOpenSession:n})}),(0,W.jsxs)(XN,{className:`items-center`,children:[_((0,W.jsx)(Sk,{label:`New Workspace`,className:`size-8 rounded-lg border border-dashed border-sidebar-border`,children:(0,W.jsx)(Le,{})})),s&&(0,W.jsxs)(yk,{children:[(0,W.jsx)(bk,{asChild:!0,children:(0,W.jsx)(`span`,{role:`alert`,"aria-label":s,className:`flex p-1`,children:(0,W.jsx)($e,{className:`size-4 text-destructive`})})}),(0,W.jsx)(xk,{side:`right`,children:s})]})]})]}),y=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(QN,{children:(0,W.jsxs)($N,{children:[(0,W.jsxs)(eP,{className:`gap-0.5 pr-0`,children:[(0,W.jsx)(`span`,{className:`flex-1`,children:`Workspaces`}),_((0,W.jsx)(Sk,{label:`New Workspace`,children:(0,W.jsx)(Le,{})})),h===`sidebar`&&(0,W.jsx)(Sk,{label:`Collapse sidebar`,onClick:()=>m.setOpen(!1),children:(0,W.jsx)(je,{})})]}),(0,W.jsx)(nN,{ids:l.map(e=>e.id),onReorder:c.reorderWorkspaces,children:(0,W.jsx)(tP,{children:l.map(i=>{let o=i.id===e?.openWorkspaceId;return(0,W.jsx)(cP,{workspace:i,isOpen:o,mode:h,onOpen:()=>r(i.id),onNewShell:()=>void a(i.id),onNewClaude:()=>u(i),onAction:e=>d(i,e),children:(0,W.jsx)(lP,{workspace:i,shown:t,mode:h,onOpen:e=>n(i.id,e),onAction:f,onReorder:e=>c.reorderSessions(i.id,e)})},i.id)})})})]})}),s&&(0,W.jsx)(XN,{children:(0,W.jsxs)(FN,{variant:`destructive`,className:`px-3 py-2`,children:[(0,W.jsx)($e,{}),(0,W.jsx)(IN,{className:`text-xs`,children:s})]})})]});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(qN,{collapsible:`icon`,children:(0,W.jsx)(`nav`,{"aria-label":`Workspaces`,className:`flex min-h-0 flex-1 flex-col`,children:g?v:y})}),p]})}var pP=e=>e.preventDefault();function mP({name:e,onPress:t,placement:n=``,children:r}){return(0,W.jsx)(`button`,{type:`button`,"aria-label":e,className:`flex size-9 items-center justify-center rounded-md bg-secondary/60 text-sm text-secondary-foreground backdrop-blur-sm active:bg-primary active:text-primary-foreground pointer-events-auto ${n}`,onMouseDown:pP,onTouchStart:()=>{},onClick:t,children:r})}function hP(){let e=e=>()=>Dh(e);return(0,W.jsxs)(`div`,{role:`group`,"aria-label":`Typing keys`,className:`pointer-events-none absolute top-1 right-1 z-10 grid grid-cols-4 gap-1`,children:[(0,W.jsx)(mP,{name:`Esc`,onPress:e(Eh.esc),children:`⎋`}),(0,W.jsx)(mP,{name:`Tab`,onPress:e(Eh.tab),children:`⇥`}),(0,W.jsx)(mP,{name:`New line`,onPress:e(Eh.newLine),children:`⇧⏎`}),(0,W.jsx)(mP,{name:`Enter`,onPress:e(Eh.enter),children:`⏎`}),(0,W.jsx)(mP,{name:`Left`,onPress:e(Eh.left),children:`←`}),(0,W.jsx)(mP,{name:`Up`,onPress:e(Eh.up),children:`↑`}),(0,W.jsx)(mP,{name:`Down`,onPress:e(Eh.down),children:`↓`}),(0,W.jsx)(mP,{name:`Right`,onPress:e(Eh.right),children:`→`}),Oh()&&(0,W.jsx)(mP,{name:`Paste`,placement:`col-start-3`,onPress:()=>void kh(),children:(0,W.jsx)(ue,{className:`size-4`})}),(0,W.jsx)(mP,{name:`Close keyboard`,placement:`col-start-4`,onPress:Th,children:`⌄`})]})}function gP(e,t){try{let n=JSON.parse(localStorage.getItem(e)??`{}`);return typeof n!=`object`||!n?{}:Object.fromEntries(Object.entries(n).filter(([,e])=>t(e)))}catch{return{}}}function _P(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}var vP=`k-bench.phone-sessions`,yP=`k-bench.phone-session`;function bP(e,{starting:t}){let[n,r]=(0,D.useState)(()=>gP(vP,e=>typeof e==`string`));(0,D.useLayoutEffect)(()=>_P(vP,n),[n]),(0,D.useEffect)(()=>{try{localStorage.removeItem(yP)}catch{}},[]);let i=pg(e),a=i?.sessions??[],o=i&&n[i.id],s=a.find(e=>e.id===o)??dg(a).prime;return{workspace:i,session:s,starting:t,bellHere:a.some(e=>e.bell&&e.id!==s?.id),hintElsewhere:mg((e?.workspaces??[]).filter(e=>e!==i).flatMap(e=>e.sessions)),show:(e,t)=>r(n=>({...n,[e]:t}))}}var xP=100;function SP(){let e=window.visualViewport;return{width:e?.width??window.innerWidth,height:e?.height??window.innerHeight,top:e?.offsetTop??0}}function CP(){return document.activeElement?.closest(`.xterm`)!=null}function wP(e){let[t,n]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{if(!e)return;let t=document.documentElement,r=SP(),i=!1,a=()=>{let e=SP(),a=CP();a?e.width===r.width?e.height>r.height&&(r={...r,height:e.height}):r=i?{...e,height:e.height+xP}:e:r=e;let o=a&&r.height-e.height>=xP;i=o,n(o),o?(t.style.setProperty(`--app-top`,`${e.top}px`),t.style.setProperty(`--app-height`,`${e.height}px`)):(t.style.removeProperty(`--app-top`),t.style.removeProperty(`--app-height`))};a();let o=window.visualViewport;return window.addEventListener(`resize`,a),o?.addEventListener(`resize`,a),o?.addEventListener(`scroll`,a),document.addEventListener(`focusin`,a),document.addEventListener(`focusout`,a),()=>{window.removeEventListener(`resize`,a),o?.removeEventListener(`resize`,a),o?.removeEventListener(`scroll`,a),document.removeEventListener(`focusin`,a),document.removeEventListener(`focusout`,a),t.style.removeProperty(`--app-top`),t.style.removeProperty(`--app-height`),n(!1)}},[e]),t}var TP=`k-bench.sidebar-collapsed`;function EP(){try{return localStorage.getItem(TP)===`true`}catch{return!1}}function DP(e){try{e?localStorage.setItem(TP,`true`):localStorage.removeItem(TP)}catch{}}function OP(){let[e,t]=(0,D.useState)(EP);return[e,e=>{t(e),DP(e)}]}var kP={ratio:.5,shut:null};function AP(e,t){return e<.08?{ratio:t,shut:`left`}:e>.92?{ratio:t,shut:`right`}:{ratio:e,shut:null}}var jP=`k-bench.dividers`,MP=`k-bench.keyboard-panes`;function NP(e){if(typeof e!=`object`||!e)return!1;let{ratio:t,shut:n}=e;return typeof t==`number`&&t>0&&t<1&&(n===null||n===`left`||n===`right`)}var PP=e=>e===`left`||e===`right`,FP=e=>e===`left`?`right`:`left`,IP=`k-bench.layout`,LP={shown:null,tabs:[]};function RP(e){let t=e=>e?{kind:`session`,session:e}:{kind:`empty`},n=e?.sessions??[],{shown:r,tabs:i}=e?.rightPane??LP,{prime:a,worker:o,others:s}=dg(n),c=new Map(s.map(e=>[e.id,e])),l=r===null?void 0:c.get(r);return{left:t(a),right:t(l??o),worker:o,tabs:i.flatMap(e=>c.get(e)??[])}}function zP(e,t){let[n,r]=(0,D.useState)(()=>gP(jP,NP)),[i,a]=(0,D.useState)(()=>gP(MP,PP)),[o,s]=(0,D.useState)(0),c=(0,D.useCallback)(e=>{s(e=>e+1),t.openWorkspace(e).finally(()=>s(e=>e-1))},[t]),l=pg(e),{left:u,right:d,worker:f,tabs:p}=RP(l),m=(0,D.useRef)(e);m.current=e;let h=BP(e,c);(0,D.useEffect)(()=>_P(jP,n),[n]),(0,D.useEffect)(()=>_P(MP,i),[i]),(0,D.useEffect)(()=>{try{localStorage.removeItem(IP)}catch{}},[]),(0,D.useEffect)(()=>{e&&bh(new Set(e.workspaces.flatMap(e=>e.sessions.map(e=>e.id))))},[e]);let g=l?`${l.name} — k-bench`:`k-bench`;(0,D.useEffect)(()=>{document.title=g},[g]);let _=l?.id,v=_&&n[_]||kP,y=_&&i[_]||`left`,b=(0,D.useCallback)((e,t)=>{a(n=>n[e]===t?n:{...n,[e]:t})},[]),x=(0,D.useCallback)((e,t)=>{r(n=>{let r=n[e];return r?.shut===t?{...n,[e]:{ratio:r.ratio,shut:null}}:n})},[]),S=(0,D.useCallback)((e,n)=>{let r=m.current?.workspaces.find(t=>t.id===e)?.rightPane??LP;t.setRightPane(e,n(r))},[t]),C=(0,D.useCallback)((e,t)=>{S(e,({tabs:e})=>({shown:t,tabs:t===null||e.includes(t)?e:[...e,t]})),b(e,`right`),x(e,`right`)},[S,x,b]),w=e=>{b(e,`left`),x(e,`left`)},T=y===v.shut?FP(y):y,E=T===`left`?u:d,O=new Set;return v.shut!==`left`&&u.kind===`session`&&O.add(u.session.id),v.shut!==`right`&&d.kind===`session`&&O.add(d.session.id),{workspace:l,left:u,right:d,worker:f,tabs:p,ratio:v.ratio,shut:v.shut,focusedTerminal:T,focusedSession:E.kind===`session`?E.session:void 0,starting:!h||o>0,shown:O,open:c,showPrime:()=>{_&&w(_)},showWorker:()=>{_&&C(_,null)},openOtherSession:(e,t)=>C(e,t),closeTab:e=>{_&&S(_,({shown:t,tabs:n})=>({shown:t===e?null:t,tabs:n.filter(t=>t!==e)}))},chooseSession:(e,t)=>{t.role===`worker`?C(e,null):t.role===null?C(e,t.id):w(e)},focusTerminal:e=>{_&&b(_,e)},setRatio:(e,t=v.ratio)=>{_&&r(n=>({...n,[_]:AP(e,t)}))},reopen:e=>{_&&x(_,e)}}}function BP(e,t){let[n,r]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{e&&!n&&(r(!0),e.openWorkspaceId&&t(e.openWorkspaceId))},[e,t,n]),n}function VP(){let[e,t]=OP();return(0,W.jsx)(KN,{open:!e,onOpenChange:e=>t(!e),className:`h-full min-h-0`,children:(0,W.jsx)(HP,{})})}function HP(){let{state:e,actions:t,error:n}=Mg(),r=uh(),i=wP(r),a=zP(e,t),o=bP(e,a),{setOpenMobile:s}=GN(),c=()=>s(!1),l=(e,t)=>{t!==void 0&&(r?o.show(e,t):a.openOtherSession(e,t),c())},u=o.session?.id;return(0,W.jsxs)(Pg,{value:t,children:[(0,W.jsx)(fP,{state:e,shown:r?new Set(u?[u]:[]):a.shown,onOpenSession:(e,t)=>{r?o.show(e,t.id):a.chooseSession(e,t),c()},onOpenWorkspace:e=>{a.open(e),c()},onCreateWorkspace:e=>t.createWorkspace(e,a.open),onCreateSession:async e=>{l(e,await t.createSession(e))},onCreateClaudeSession:async(e,n)=>{l(e,await t.createClaudeSession(e,n))},error:n}),(0,W.jsxs)(JN,{className:U(`min-w-0`,i&&`fixed inset-x-0 top-(--app-top) h-(--app-height)`),children:[!i&&(0,W.jsx)(`header`,{className:`flex h-11 shrink-0 items-center gap-1 border-b px-2`,children:r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ik,{view:o,onOpen:()=>s(!0)}),(0,W.jsx)(Lk,{view:o})]}):a.workspace&&(0,W.jsx)(ch,{workspace:a.workspace,session:a.focusedSession})}),(0,W.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col`,children:[e&&(r?(0,W.jsx)(Bk,{view:o,workspaces:e.workspaces}):(0,W.jsx)(Pk,{view:a,workspaces:e.workspaces})),i&&u&&(0,W.jsx)(hP,{})]}),r&&!i&&u&&(0,W.jsx)($h,{sessionId:u})]})]})}var UP=document.getElementById(`root`);if(!UP)throw Error(`missing #root`);(0,nt.createRoot)(UP).render((0,W.jsx)(D.StrictMode,{children:(0,W.jsx)(vk,{children:(0,W.jsx)(VP,{})})}));
|