@gbasin/agentboard-darwin-x64 0.2.43 → 0.2.45

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.
@@ -17,7 +17,7 @@ Error generating stack: `+e.message+`
17
17
  To pick up a draggable item, press the space bar.
18
18
  While dragging, use the arrow keys to move the item.
19
19
  Press space again to drop the item in its new position, or press escape to cancel.
20
- `},Kd={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 qd(e){let{announcements:t=Kd,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Gd}=e,{announce:a,announcement:o}=Vd(),s=Dd(`DndLiveRegion`),[c,l]=(0,x.useState)(!1);if((0,x.useEffect)(()=>{l(!0)},[]),Ud((0,x.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=x.createElement(x.Fragment,null,x.createElement(zd,{id:r,value:i.draggable}),x.createElement(Bd,{id:s,announcement:o}));return n?(0,K.createPortal)(u,n):u}var Jd;(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`})(Jd||={});function Yd(){}function Xd(e,t){return(0,x.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Zd(){var e=[...arguments];return(0,x.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Qd=Object.freeze({x:0,y:0});function $d(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function ef(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function tf(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function nf(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function rf(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 af=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=rf(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=$d(rf(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(ef)};function of(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 sf=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=of(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(tf)};function cf(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function lf(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Qd}function uf(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 df=uf(1);function ff(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]}}else 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 pf(e,t,n){let r=ff(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 mf={ignoreTransform:!1};function hf(e,t){t===void 0&&(t=mf);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=md(e).getComputedStyle(e);t&&(n=pf(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 gf(e){return hf(e,{ignoreTransform:!0})}function _f(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function vf(e,t){return t===void 0&&(t=md(e).getComputedStyle(e)),t.position===`fixed`}function yf(e,t){t===void 0&&(t=md(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):!1})}function bf(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(hd(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!gd(i)||_d(i)||n.includes(i))return n;let a=md(e).getComputedStyle(i);return i!==e&&yf(i,a)&&n.push(i),vf(i,a)?n:r(i.parentNode)}return e?r(e):n}function xf(e){let[t]=bf(e,1);return t??null}function Sf(e){return!dd||!e?null:fd(e)?e:pd(e)?hd(e)||e===vd(e).scrollingElement?window:gd(e)?e:null:null}function Cf(e){return fd(e)?e.scrollX:e.scrollLeft}function wf(e){return fd(e)?e.scrollY:e.scrollTop}function Tf(e){return{x:Cf(e),y:wf(e)}}var Ef;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Ef||={});function Df(e){return!dd||!e?!1:e===document.scrollingElement}function Of(e){let t={x:0,y:0},n=Df(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 kf={x:.2,y:.2};function Af(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=kf);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Of(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=Ef.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Ef.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Ef.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Ef.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function jf(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 Mf(e){return e.reduce((e,t)=>kd(e,Tf(t)),Qd)}function Nf(e){return e.reduce((e,t)=>e+Cf(t),0)}function Pf(e){return e.reduce((e,t)=>e+wf(t),0)}function Ff(e,t){if(t===void 0&&(t=hf),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);xf(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var If=[[`x`,[`left`,`right`],Nf],[`y`,[`top`,`bottom`],Pf]],Lf=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=bf(t),r=Mf(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of If)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})}},Rf=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 zf(e){let{EventTarget:t}=md(e);return e instanceof t?e:vd(e)}function Bf(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:!1}var Vf;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Vf||={});function Hf(e){e.preventDefault()}function Uf(e){e.stopPropagation()}var Wf;(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`})(Wf||={});var Gf={start:[Wf.Space,Wf.Enter],cancel:[Wf.Esc],end:[Wf.Space,Wf.Enter,Wf.Tab]},Kf=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Wf.Right:return{...n,x:n.x+25};case Wf.Left:return{...n,x:n.x-25};case Wf.Down:return{...n,y:n.y+25};case Wf.Up:return{...n,y:n.y-25}}},qf=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 Rf(vd(t)),this.windowListeners=new Rf(md(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Vf.Resize,this.handleCancel),this.windowListeners.add(Vf.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Vf.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Ff(n),t(Qd)}handleKeyDown(e){if(Md(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Gf,coordinateGetter:a=Kf,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}:Qd;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Ad(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}=Of(n),p=jf(n),m={x:Math.min(i===Wf.Right?p.right-p.width/2:p.right,Math.max(i===Wf.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===Wf.Down?p.bottom-p.height/2:p.bottom,Math.max(i===Wf.Down?p.top:p.top+p.height/2,u.y))},h=i===Wf.Right&&!s||i===Wf.Left&&!c,g=i===Wf.Down&&!l||i===Wf.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===Wf.Right&&e<=d.x||i===Wf.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===Wf.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===Wf.Down&&e<=d.y||i===Wf.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===Wf.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,kd(Ad(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()}};qf.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Gf,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 Jf(e){return!!(e&&`distance`in e)}function Yf(e){return!!(e&&`delay`in e)}var Xf=class{constructor(e,t,n){n===void 0&&(n=zf(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=vd(i),this.documentListeners=new Rf(this.document),this.listeners=new Rf(n),this.windowListeners=new Rf(md(i)),this.initialCoordinates=Pd(r)??Qd,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(Vf.Resize,this.handleCancel),this.windowListeners.add(Vf.DragStart,Hf),this.windowListeners.add(Vf.VisibilityChange,this.handleCancel),this.windowListeners.add(Vf.ContextMenu,Hf),this.documentListeners.add(Vf.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Yf(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Jf(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(Vf.Click,Uf,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Vf.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=Pd(e)??Qd,s=Ad(n,o);if(!t&&a){if(Jf(a)){if(a.tolerance!=null&&Bf(s,a.tolerance))return this.handleCancel();if(Bf(s,a.distance))return this.handleStart()}if(Yf(a)&&Bf(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}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===Wf.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Zf={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Qf=class extends Xf{constructor(e){let{event:t}=e,n=vd(t.target);super(e,Zf,n)}};Qf.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 $f={move:{name:`mousemove`},end:{name:`mouseup`}},ep;(function(e){e[e.RightClick=2]=`RightClick`})(ep||={});var tp=class extends Xf{constructor(e){super(e,$f,vd(e.event.target))}};tp.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===ep.RightClick?!1:(r?.({event:n}),!0)}}];var np={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},rp=class extends Xf{constructor(e){super(e,np)}static setup(){return window.addEventListener(np.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(np.move.name,e)};function e(){}}};rp.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 ip;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(ip||={});var ap;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(ap||={});function op(e){let{acceleration:t,activator:n=ip.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=ap.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=cp({delta:d,disabled:!a}),[m,h]=xd(),g=(0,x.useRef)({x:0,y:0}),_=(0,x.useRef)({x:0,y:0}),v=(0,x.useMemo)(()=>{switch(n){case ip.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case ip.DraggableRect:return i}},[n,i,c]),y=(0,x.useRef)(null),b=(0,x.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)},[]),S=(0,x.useMemo)(()=>s===ap.TreeOrder?[...l].reverse():l,[s,l]);(0,x.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of S){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=Af(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;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,S,u,JSON.stringify(f)])}var sp={x:{[Ef.Backward]:!1,[Ef.Forward]:!1},y:{[Ef.Backward]:!1,[Ef.Forward]:!1}};function cp(e){let{delta:t,disabled:n}=e,r=Td(t);return Cd(e=>{if(n||!r||!e)return sp;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Ef.Backward]:e.x[Ef.Backward]||i.x===-1,[Ef.Forward]:e.x[Ef.Forward]||i.x===1},y:{[Ef.Backward]:e.y[Ef.Backward]||i.y===-1,[Ef.Forward]:e.y[Ef.Forward]||i.y===1}}},[n,t,r])}function lp(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Cd(e=>t==null?null:r??e??null,[r,t])}function up(e,t){return(0,x.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 dp;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(dp||={});var fp;(function(e){e.Optimized=`optimized`})(fp||={});var pp=new Map;function mp(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,x.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,x.useRef)(e),d=g(),f=Sd(d),p=(0,x.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,x.useRef)(null),h=Cd(t=>{if(d&&!n)return pp;if(!t||t===pp||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 Lf(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,x.useEffect)(()=>{u.current=e},[e]),(0,x.useEffect)(()=>{d||p()},[n,d]),(0,x.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,x.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 dp.Always:return!1;case dp.BeforeDragging:return n;default:return!n}}}function hp(e,t){return Cd(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function gp(e,t){return hp(e,t)}function _p(e){let{callback:t,disabled:n}=e,r=bd(t),i=(0,x.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,x.useEffect)(()=>()=>i?.disconnect(),[i]),i}function vp(e){let{callback:t,disabled:n}=e,r=bd(t),i=(0,x.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,x.useEffect)(()=>()=>i?.disconnect(),[i]),i}function yp(e){return new Lf(hf(e),e)}function bp(e,t,n){t===void 0&&(t=yp);let[r,i]=(0,x.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=_p({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=vp({callback:a});return yd(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function xp(e){return lf(e,hp(e))}var Sp=[];function Cp(e){let t=(0,x.useRef)(e),n=Cd(n=>e?n&&n!==Sp&&e&&t.current&&e.parentNode===t.current.parentNode?n:bf(e):Sp,[e]);return(0,x.useEffect)(()=>{t.current=e},[e]),n}function wp(e){let[t,n]=(0,x.useState)(null),r=(0,x.useRef)(e),i=(0,x.useCallback)(e=>{let t=Sf(e.target);t&&n(e=>e?(e.set(t,Tf(t)),new Map(e)):null)},[]);return(0,x.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Sf(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Tf(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=>{Sf(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,x.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>kd(e,t),Qd):Mf(e):Qd,[e,t])}function Tp(e,t){t===void 0&&(t=[]);let n=(0,x.useRef)(null);return(0,x.useEffect)(()=>{n.current=null},t),(0,x.useEffect)(()=>{let t=e!==Qd;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Ad(e,n.current):Qd}function Ep(e){(0,x.useEffect)(()=>{if(!dd)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 Dp(e,t){return(0,x.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Op(e){return(0,x.useMemo)(()=>e?_f(e):null,[e])}var kp=[];function Ap(e,t){t===void 0&&(t=hf);let[n]=e,r=Op(n?md(n):null),[i,a]=(0,x.useState)(kp);function o(){a(()=>e.length?e.map(e=>Df(e)?r:new Lf(t(e),e)):kp)}let s=vp({callback:o});return yd(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function jp(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return gd(t)?t:e}function Mp(e){let{measure:t}=e,[n,r]=(0,x.useState)(null),i=vp({callback:(0,x.useCallback)(e=>{for(let{target:n}of e)if(gd(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=wd((0,x.useCallback)(e=>{let n=jp(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,x.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Np=[{sensor:Qf,options:{}},{sensor:qf,options:{}}],Pp={current:{}},Fp={draggable:{measure:gf},droppable:{measure:gf,strategy:dp.WhileDragging,frequency:fp.Optimized},dragOverlay:{measure:hf}},Ip=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}},Lp={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ip,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Yd},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Fp,measureDroppableContainers:Yd,windowRect:null,measuringScheduled:!1},Rp={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Yd,draggableNodes:new Map,over:null,measureDroppableContainers:Yd},zp=(0,x.createContext)(Rp),Bp=(0,x.createContext)(Lp);function Vp(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ip}}}function Hp(e,t){switch(t.type){case Jd.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Jd.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 Jd.DragEnd:case Jd.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Jd.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Ip(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Jd.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 Ip(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Jd.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Ip(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Up(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,x.useContext)(zp),a=Td(r),o=Td(n?.id);return(0,x.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Md(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=Ld(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Wp(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Gp(e){return(0,x.useMemo)(()=>({draggable:{...Fp.draggable,...e?.draggable},droppable:{...Fp.droppable,...e?.droppable},dragOverlay:{...Fp.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Kp(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,x.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;yd(()=>{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=lf(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=xf(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var qp=(0,x.createContext)({...Qd,scaleX:1,scaleY:1}),Jp;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Jp||={});var Yp=(0,x.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Np,collisionDetection:o=sf,measuring:s,modifiers:c,...l}=e,[u,d]=(0,x.useReducer)(Hp,void 0,Vp),[f,p]=Wd(),[m,h]=(0,x.useState)(Jp.Uninitialized),g=m===Jp.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,S=_==null?null:v.get(_),C=(0,x.useRef)({initial:null,translated:null}),w=(0,x.useMemo)(()=>_==null?null:{id:_,data:S?.data??Pp,rect:C},[_,S]),T=(0,x.useRef)(null),[E,D]=(0,x.useState)(null),[O,k]=(0,x.useState)(null),A=Sd(l,Object.values(l)),j=Dd(`DndDescribedBy`,t),M=(0,x.useMemo)(()=>b.getEnabled(),[b]),N=Gp(s),{droppableRects:P,measureDroppableContainers:F,measuringScheduled:I}=mp(M,{dragging:g,dependencies:[y.x,y.y],config:N.droppable}),L=lp(v,_),R=(0,x.useMemo)(()=>O?Pd(O):null,[O]),z=Ce(),B=gp(L,N.draggable.measure);Kp({activeNode:_==null?null:v.get(_),config:z.layoutShiftCompensation,initialRect:B,measure:N.draggable.measure});let V=bp(L,N.draggable.measure,B),H=bp(L?L.parentElement:null),U=(0,x.useRef)({activatorEvent:null,active:null,activeNode:L,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),W=b.getNodeFor(U.current.over?.id),G=Mp({measure:N.dragOverlay.measure}),ee=G.nodeRef.current??L,te=g?G.rect??V:null,q=!!(G.nodeRef.current&&G.rect),ne=xp(q?null:V),re=Op(ee?md(ee):null),ie=Cp(g?W??L:null),ae=Ap(ie),oe=Wp(c,{transform:{x:y.x-ne.x,y:y.y-ne.y,scaleX:1,scaleY:1},activatorEvent:O,active:w,activeNodeRect:V,containerNodeRect:H,draggingNodeRect:te,over:U.current.over,overlayNodeRect:G.rect,scrollableAncestors:ie,scrollableAncestorRects:ae,windowRect:re}),se=R?kd(R,y):null,ce=wp(ie),le=Tp(ce),ue=Tp(ce,[V]),de=kd(oe,le),fe=te?df(te,oe):null,pe=w&&fe?o({active:w,collisionRect:fe,droppableRects:P,droppableContainers:M,pointerCoordinates:se}):null,me=nf(pe,`id`),[he,ge]=(0,x.useState)(null),_e=cf(q?oe:kd(oe,ue),he?.rect??null,V),ve=(0,x.useRef)(null),ye=(0,x.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(T.current==null)return;let i=v.get(T.current);if(!i)return;let a=e.nativeEvent;ve.current=new n({active:T.current,activeNode:i,event:a,options:r,context:U,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=T.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:C}};(0,K.unstable_batchedUpdates)(()=>{r?.(i),h(Jp.Initializing),d({type:Jd.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),D(ve.current),k(a)})},onMove(e){d({type:Jd.DragMove,coordinates:e})},onEnd:o(Jd.DragEnd),onCancel:o(Jd.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=U.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Jd.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Jd.DragCancel)}T.current=null,(0,K.unstable_batchedUpdates)(()=>{d({type:e}),h(Jp.Uninitialized),ge(null),D(null),k(null),ve.current=null;let t=e===Jd.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),be=up(a,(0,x.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(T.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},T.current=r,ye(n,t))},[v,ye]));Ep(a),yd(()=>{V&&m===Jp.Initializing&&h(Jp.Initialized)},[V,m]),(0,x.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=U.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:de.x,y:de.y},over:i};(0,K.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[de.x,de.y]),(0,x.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=U.current;if(!e||T.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(me),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,K.unstable_batchedUpdates)(()=>{ge(s),a?.(c),f({type:`onDragOver`,event:c})})},[me]),yd(()=>{U.current={activatorEvent:O,active:w,activeNode:L,collisionRect:fe,collisions:pe,droppableRects:P,draggableNodes:v,draggingNode:ee,draggingNodeRect:te,droppableContainers:b,over:he,scrollableAncestors:ie,scrollAdjustedTranslate:de},C.current={initial:te,translated:fe}},[w,L,pe,fe,v,ee,te,P,b,he,ie,de]),op({...z,delta:y,draggingRect:fe,pointerCoordinates:se,scrollableAncestors:ie,scrollableAncestorRects:ae});let xe=(0,x.useMemo)(()=>({active:w,activeNode:L,activeNodeRect:V,activatorEvent:O,collisions:pe,containerNodeRect:H,dragOverlay:G,draggableNodes:v,droppableContainers:b,droppableRects:P,over:he,measureDroppableContainers:F,scrollableAncestors:ie,scrollableAncestorRects:ae,measuringConfiguration:N,measuringScheduled:I,windowRect:re}),[w,L,V,O,pe,H,G,v,b,P,he,F,ie,ae,N,I,re]),Se=(0,x.useMemo)(()=>({activatorEvent:O,activators:be,active:w,activeNodeRect:V,ariaDescribedById:{draggable:j},dispatch:d,draggableNodes:v,over:he,measureDroppableContainers:F}),[O,be,w,V,d,j,v,he,F]);return x.createElement(Hd.Provider,{value:p},x.createElement(zp.Provider,{value:Se},x.createElement(Bp.Provider,{value:xe},x.createElement(qp.Provider,{value:_e},i)),x.createElement(Up,{disabled:n?.restoreFocus===!1})),x.createElement(qd,{...n,hiddenTextDescribedById:j}));function Ce(){let e=E?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Xp=(0,x.createContext)(null),Zp=`button`,Qp=`Draggable`;function $p(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Dd(Qp),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,x.useContext)(zp),{role:p=Zp,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,x.useContext)(g?qp:Xp),[v,y]=wd(),[b,S]=wd(),C=Dp(o,t),w=Sd(n);return yd(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:w}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,x.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Zp?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:C,node:v,over:f,setNodeRef:y,setActivatorNodeRef:S,transform:_}}function em(){return(0,x.useContext)(Bp)}var tm=`Droppable`,nm={timeout:25};function rm(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Dd(tm),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,x.useContext)(zp),u=(0,x.useRef)({disabled:n}),d=(0,x.useRef)(!1),f=(0,x.useRef)(null),p=(0,x.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...nm,...i},_=Sd(h??r),v=vp({callback:(0,x.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=wd((0,x.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),S=Sd(t);return(0,x.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,x.useEffect)(()=>(s({type:Jd.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:S}}),()=>s({type:Jd.UnregisterDroppable,key:a,id:r})),[r]),(0,x.useEffect)(()=>{n!==u.current.disabled&&(s({type:Jd.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 im(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function am(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function om(e){return e!==null&&e>=0}function sm(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 cm(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var lm=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=im(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}},um={scaleX:1,scaleY:1},dm=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,...um}:null}let s=fm(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...um}:r<t&&r>=a?{x:0,y:o.height+s,...um}:{x:0,y:0,...um}};function fm(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 pm=`Sortable`,mm=x.createContext({activeIndex:-1,containerId:pm,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:lm,disabled:{draggable:!1,droppable:!1}});function hm(e){let{children:t,id:n,items:r,strategy:i=lm,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=em(),d=Dd(pm,n),f=s.rect!==null,p=(0,x.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,x.useRef)(p),v=!sm(p,_.current),y=g!==-1&&h===-1||v,b=cm(a);yd(()=>{v&&m&&u(p)},[v,p,m,u]),(0,x.useEffect)(()=>{_.current=p},[p]);let S=(0,x.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:am(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return x.createElement(mm.Provider,{value:S},t)}var gm=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return im(n,r,i).indexOf(t)},_m=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},vm={duration:200,easing:`ease`},ym=`transform`,bm=Fd.Transition.toString({property:ym,duration:0,easing:`linear`}),xm={roleDescription:`sortable`};function Sm(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,x.useState)(null),s=(0,x.useRef)(n);return yd(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=hf(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,x.useEffect)(()=>{a&&o(null)},[a]),a}function Cm(e){let{animateLayoutChanges:t=_m,attributes:n,disabled:r,data:i,getNewIndex:a=gm,id:o,strategy:s,resizeObserverConfig:c,transition:l=vm}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,x.useContext)(mm),y=wm(r,p),b=u.indexOf(o),S=(0,x.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),C=(0,x.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:w,node:T,isOver:E,setNodeRef:D}=rm({id:o,data:S,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:O,activatorEvent:k,activeNodeRect:A,attributes:j,setNodeRef:M,listeners:N,isDragging:P,over:F,setActivatorNodeRef:I,transform:L}=$p({id:o,data:S,attributes:{...xm,...n},disabled:y.draggable}),R=ud(D,M),z=!!O,B=z&&!m&&om(f)&&om(g),V=!_&&P,H=B?(V&&B?L:null)??(s??v)({rects:h,activeNodeRect:A,activeIndex:f,overIndex:g,index:b}):null,U=om(f)&&om(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,W=O?.id,G=(0,x.useRef)({activeId:W,items:u,newIndex:U,containerId:d}),ee=u!==G.current.items,K=t({active:O,containerId:d,isDragging:P,isSorting:z,id:o,index:b,items:u,newIndex:G.current.newIndex,previousItems:G.current.items,previousContainerId:G.current.containerId,transition:l,wasDragging:G.current.activeId!=null}),te=Sm({disabled:!K,index:b,node:T,rect:w});return(0,x.useEffect)(()=>{z&&G.current.newIndex!==U&&(G.current.newIndex=U),d!==G.current.containerId&&(G.current.containerId=d),u!==G.current.items&&(G.current.items=u)},[z,U,d,u]),(0,x.useEffect)(()=>{if(W===G.current.activeId)return;if(W!=null&&G.current.activeId==null){G.current.activeId=W;return}let e=setTimeout(()=>{G.current.activeId=W},50);return()=>clearTimeout(e)},[W]),{active:O,activeIndex:f,attributes:j,data:S,rect:w,index:b,newIndex:U,items:u,isOver:E,isSorting:z,isDragging:P,listeners:N,node:T,overIndex:g,over:F,setNodeRef:R,setActivatorNodeRef:I,setDroppableNodeRef:D,setDraggableNodeRef:M,transform:te??H,transition:q()};function q(){if(te||ee&&G.current.newIndex===b)return bm;if(!(V&&!Md(k)||!l)&&(z||K))return Fd.Transition.toString({...l,property:ym})}}function wm(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}Wf.Down,Wf.Right,Wf.Up,Wf.Left;var Tm={permission:0,waiting:1,working:2,unknown:3};function Em(e){let t=e.agentSessionId?.trim();return t&&t.length>0?t:e.id}var Dm={mode:`created`,direction:`desc`};function Om(e,t=Dm){let{mode:n,direction:r,manualOrder:i}=t;if(n===`manual`&&i&&i.length>0){let t=new Map(i.map((e,t)=>[e,t]));return e.toSorted((e,n)=>{let r=Em(e),i=Em(n),a=t.get(r)??t.get(e.id)??1/0,o=t.get(i)??t.get(n.id)??1/0;return a===1/0&&o===1/0?Date.parse(n.createdAt)-Date.parse(e.createdAt):a-o})}return e.toSorted((e,t)=>{if(n===`status`){let n=Tm[e.status]??Tm.unknown,r=Tm[t.status]??Tm.unknown;return n===r?Date.parse(t.lastActivity)-Date.parse(e.lastActivity):n-r}let i=Date.parse(e.createdAt),a=Date.parse(t.createdAt);return r===`desc`?a-i:i-a})}function km(e,t){let n=new Map;for(let t of e){let e=t.projectPath?.trim();if(e){let r=Date.parse(t.lastActivity)||0;r>(n.get(e)||0)&&n.set(e,r)}}for(let e of t){let t=e.projectPath?.trim();if(t){let r=Date.parse(e.lastActivityAt)||0;r>(n.get(t)||0)&&n.set(t,r)}}return Array.from(n.keys()).toSorted((e,t)=>{let r=n.get(e)||0;return(n.get(t)||0)-r})}function Am(e,t){let n=new Map;for(let t of e){let e=t.host?.trim();if(e){let r=Date.parse(t.lastActivity)||0;r>(n.get(e)||0)&&n.set(e,r)}}for(let e of t){let t=e.host?.trim();if(t){let r=Date.parse(e.lastActivityAt)||0;r>(n.get(t)||0)&&n.set(t,r)}}return Array.from(n.keys()).toSorted((e,t)=>{let r=n.get(e)||0;return(n.get(t)||0)-r})}function jm(e){let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Date.now()-t,r=Math.floor(n/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Mm(e){let t=e.trim();if(!t)return null;let n=t.replace(/[\\/]+$/,``);if(!n)return null;let r=n.split(/[\\/]/);return r[r.length-1]||null}function Nm(e){let t=e.map(e=>{let t=e.trim(),n=t.replace(/[\\/]+$/,``);return{path:e,parts:n.split(/[\\/]/).filter(Boolean),fallback:n||t||e}}),n=new Map;for(let e of t)n.set(e.path,1);let r=!0;for(;r;){r=!1;let e=new Map;for(let r of t){if(r.parts.length===0)continue;let t=n.get(r.path)??1,i=r.parts.slice(-t).join(`/`);e.set(i,(e.get(i)??0)+1)}for(let i of t){if(i.parts.length===0)continue;let t=n.get(i.path)??1,a=i.parts.slice(-t).join(`/`);(e.get(a)??0)>1&&t<i.parts.length&&(n.set(i.path,t+1),r=!0)}}let i=new Map,a=new Map;for(let e of t){let t=e.fallback;if(e.parts.length>0){let r=n.get(e.path)??1;t=e.parts.slice(-r).join(`/`)}i.set(e.path,t),a.set(t,(a.get(t)??0)+1)}let o=new Map;for(let e of t){let t=i.get(e.path)??e.fallback;(a.get(t)??0)>1&&(t=e.fallback),o.set(e.path,t)}return o}function Pm(e){let t=e.trim();return!t||t.length<=6?t:`${t.slice(0,3)}…${t.slice(-3)}`}function Fm(e){let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,document.body.appendChild(t),t.focus(),t.select();try{if(!document.execCommand(`copy`))throw 0}catch{navigator.clipboard?.writeText(e).catch(()=>{})}document.body.removeChild(t)}function Im({useSafariLayoutFallback:e,isDragging:t,dndTransform:n,generatedTransform:r}){return e&&!t&&!n||!n?r:!r||r===`none`?n:`${n} ${r}`}var Lm=`agentboard-session`,Rm=N(Lm);function zm(e,t){return e.id===t.id&&e.name===t.name&&e.tmuxWindow===t.tmuxWindow&&e.projectPath===t.projectPath&&e.status===t.status&&e.lastActivity===t.lastActivity&&e.createdAt===t.createdAt&&e.source===t.source&&e.host===t.host&&e.remote===t.remote&&e.command===t.command&&e.agentType===t.agentType&&e.agentSessionId===t.agentSessionId&&e.agentSessionName===t.agentSessionName&&e.logFilePath===t.logFilePath&&e.isPinned===t.isPinned&&e.lastUserMessage===t.lastUserMessage}function Bm(e,t){if(e.length!==t.length)return!1;let n=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=n.get(e.id);if(!t||!zm(t,e))return!1}return!0}function Vm(e){return typeof e==`string`&&e.length>0?e:null}function Hm(e){return Array.isArray(e)?e:[]}var Um=T()(k((e,t)=>({sessions:[],agentSessions:{active:[],hibernating:[],history:[]},agentSessionsEpoch:-1,hostStatuses:[],exitingSessions:new Map,selectedSessionId:null,selectedHibernatingSessionId:null,hasLoaded:!1,connectionStatus:`connecting`,connectionError:null,connectionEpoch:0,remoteAllowControl:!1,remoteAllowAttach:!1,hostLabel:null,setSessions:n=>{let r=t(),i=r.selectedSessionId,a=r.selectedHibernatingSessionId,o=r.sessions,s=r.exitingSessions;if(r.hasLoaded&&Bm(o,n))return;let c=new Set(n.map(e=>e.id)),l=o.filter(e=>!c.has(e.id)&&!s.has(e.id)),u=i;if(i!==null&&!n.some(e=>e.id===i))if(a===null){let{sessionSortMode:e,sessionSortDirection:t}=G.getState();u=Om(n,{mode:e,direction:t})[0]?.id??null}else u=null;if(l.length>0){let t=new Map(s);for(let e of l)t.set(e.id,e);e({sessions:n,hasLoaded:!0,selectedSessionId:u,exitingSessions:t})}else e({sessions:n,hasLoaded:!0,selectedSessionId:u})},setAgentSessions:(t,n,r)=>e(e=>{let i={active:Hm(t),hibernating:Hm(n),history:Hm(r)};return{agentSessions:i,agentSessionsEpoch:e.connectionEpoch,selectedHibernatingSessionId:e.selectedHibernatingSessionId&&!i.hibernating.some(t=>t.sessionId===e.selectedHibernatingSessionId)?null:e.selectedHibernatingSessionId}}),setActiveAgentSessions:t=>e(e=>({agentSessions:{active:Hm(t),hibernating:e.agentSessions.hibernating,history:e.agentSessions.history}})),setHostStatuses:t=>e({hostStatuses:t}),updateSession:t=>e(e=>({sessions:e.sessions.map(e=>e.id===t.id?t:e)})),setSelectedSessionId:t=>e({selectedSessionId:t,...t===null?{}:{selectedHibernatingSessionId:null}}),setSelectedHibernatingSessionId:t=>e({selectedHibernatingSessionId:t,...t===null?{}:{selectedSessionId:null}}),setConnectionStatus:t=>e({connectionStatus:t}),setConnectionError:t=>e({connectionError:t}),setConnectionState:(t,n,r)=>e({connectionStatus:t,connectionError:n,connectionEpoch:r}),setRemoteAllowControl:t=>e({remoteAllowControl:t}),setRemoteAllowAttach:t=>e({remoteAllowAttach:t}),setHostLabel:t=>e({hostLabel:t}),markSessionExiting:n=>{let r=t().sessions.find(e=>e.id===n);if(r){let i=new Map(t().exitingSessions);i.set(n,r),e({exitingSessions:i})}},clearExitingSession:n=>{let r=new Map(t().exitingSessions);r.delete(n),e({exitingSessions:r})}}),{name:Lm,storage:D(()=>Rm),partialize:e=>({selectedSessionId:e.selectedSessionId,selectedHibernatingSessionId:e.selectedHibernatingSessionId}),merge:(e,t)=>{let n=e,r=n?.selectedHibernatingSessionId??n?.selectedSleepingSessionId;return{...t,selectedSessionId:Vm(n?.selectedSessionId),selectedHibernatingSessionId:Vm(r)}}}));function Wm(e,t,n=!1){let[r,i]=(0,x.useState)(!1),a=(0,x.useRef)(e),o=(0,x.useRef)(!1);return(0,x.useEffect)(()=>{let r=a.current;if(n?e>r:e!==r){o.current=!0;let n=setTimeout(()=>{o.current&&=(i(!0),!1)},t);return a.current=e,()=>clearTimeout(n)}a.current=e},[e,t,n]),[r,()=>i(!1)]}function Gm(e,t,n,r){let i=(0,x.useRef)(new Map);(0,x.useEffect)(()=>{let a=new Set(e.map(e=>e.id));for(let e of t.keys())if(a.has(e)){let t=i.current.get(e);t&&(clearTimeout(t),i.current.delete(e)),n(e)}else if(!i.current.has(e)){let t=setTimeout(()=>{i.current.delete(e),n(e)},r+100);i.current.set(e,t)}},[e,t,n,r]),(0,x.useEffect)(()=>()=>{for(let e of i.current.values())clearTimeout(e);i.current.clear()},[])}function Km({className:e}){return(0,J.jsx)(`svg`,{viewBox:`0 0 92.2 92.2`,fill:`currentColor`,className:e,"aria-label":`Anthropic`,children:(0,J.jsx)(`path`,{d:`M66.5,0H52.4l25.7,65h14.1L66.5,0z M25.7,0L0,65h14.4l5.3-13.6h26.9L51.8,65h14.4L40.5,0C40.5,0,25.7,0,25.7,0z M24.3,39.3l8.8-22.8l8.8,22.8H24.3z`,transform:`translate(0, 13.6)`})})}function qm({className:e}){return(0,J.jsx)(`svg`,{viewBox:`-1 -1 26 26`,fill:`currentColor`,className:e,"aria-label":`OpenAI`,children:(0,J.jsx)(`path`,{d:`M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z`})})}function Jm({className:e}){return(0,J.jsx)(`svg`,{viewBox:`0 0 588.42 568.88`,fill:`currentColor`,className:e,"aria-label":`Pi`,children:(0,J.jsx)(`path`,{d:`M 10.499686,177.03840 L 31.174931,178.56990 C 52.615925,154.32116 61.039171,82.595924 187.38789,96.634671 C 182.79339,403.95560 48.021426,436.37234 56.444675,499.41907 C 59.507674,535.15406 87.840417,557.10556 118.47041,558.38181 C 215.21014,555.06356 210.87089,424.63084 240.99038,95.868921 L 365.80760,95.868921 C 359.17110,211.75239 341.04836,327.63586 339.00636,441.22208 C 340.53786,516.77606 386.48285,557.10556 446.97708,557.61606 C 546.52456,560.93431 577.92030,444.79558 577.92030,395.27709 L 556.47931,395.27710 C 554.43731,436.11709 534.78306,465.47083 492.92207,467.25758 C 378.82535,468.78908 441.61683,266.63113 442.38258,97.400421 L 577.92030,98.166171 L 577.15455,11.636437 C 13.807491,8.9075799 85.312284,-2.1366151 10.499686,177.03840 z`})})}var Ym=[[`claude`,Km],[`codex`,qm],[`pi`,Jm]];function Xm({agentType:e,command:t,className:n=``}){let r=(e||t?.split(` `)[0]||``).toLowerCase();for(let[e,t]of Ym)if(r.startsWith(e))return(0,J.jsx)(t,{className:n});return(0,J.jsx)(Le,{className:n})}var Zm=360;function Qm(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}function $m(e){return{"--badge-hue":`${Qm(e)%Zm}`}}function eh({name:e,fullPath:t,className:n=``}){let r=$m(e);return(0,J.jsx)(`span`,{className:`project-badge inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none ${n}`,style:r,title:t,children:e})}var th=(0,x.memo)(function({session:e,showSessionIdPrefix:t,showProjectName:n,showLastUserMessage:r,onResume:i,onPreview:a}){let o=jm(e.lastActivityAt),s=Mm(e.projectPath),c=e.displayName||s||e.sessionId.slice(0,8),l=n&&!!s,u=r&&!!e.lastUserMessage,d=t?Pm(e.sessionId):``,f=(0,x.useRef)(null),[p,m]=(0,x.useState)(null);return(0,x.useEffect)(()=>{if(!p)return;let e=e=>{f.current&&!f.current.contains(e.target)&&m(null)},t=e=>{e.key===`Escape`&&m(null)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[p]),(0,J.jsxs)(`div`,{className:`group relative cursor-pointer px-3 py-2 hover:bg-hover`,role:`button`,tabIndex:0,title:`Click to preview`,onClick:()=>a(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e))},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),m({x:e.clientX,y:e.clientY})},children:[(0,J.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-muted opacity-0 hover:text-primary group-hover:opacity-100`,title:`Wake directly`,onClick:t=>{t.stopPropagation(),i(e.sessionId)},children:`▶`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-2.5 group-hover:pr-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Xm,{agentType:e.agentType,className:`h-3.5 w-3.5 shrink-0 text-muted`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-primary`,children:c}),e.lastResumeError&&(0,J.jsx)(q,{className:`h-3 w-3 shrink-0 text-amber-500`,"aria-label":`Wake failed`,title:`Last wake failed: ${e.lastResumeError}`}),d&&(0,J.jsx)(`span`,{className:`shrink-0 text-[11px] font-mono text-muted`,title:e.sessionId,children:d}),(0,J.jsx)(`span`,{className:`ml-1 w-8 shrink-0 text-right text-xs tabular-nums text-muted`,children:o})]}),(l||u)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pl-[1.375rem]`,children:[l&&(0,J.jsx)(eh,{name:s,fullPath:e.projectPath}),u&&(0,J.jsxs)(`span`,{className:`truncate text-xs italic text-muted`,children:[`"`,e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+`…`:e.lastUserMessage,`"`]})]})]}),p&&(0,J.jsx)(`div`,{ref:f,className:`fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1`,style:{left:p.x,top:p.y},role:`menu`,children:e.logFilePath&&(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),m(null),e.logFilePath&&Fm(e.logFilePath)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:e.logFilePath,children:[(0,J.jsx)(he,{width:14,height:14}),`Copy Log Path`]})})]})});function nh({name:e,className:t=``}){let n=$m(`host:${e}`);return(0,J.jsx)(`span`,{className:`inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium uppercase leading-none tracking-wide ${t}`,style:n,title:e,children:e})}function rh({hosts:e,selectedHosts:t,onSelect:n,statuses:r=[]}){let[i,a]=(0,x.useState)(!1),o=(0,x.useId)(),s=(0,x.useRef)(null),c=(0,x.useMemo)(()=>new Set(t),[t]),l=(0,x.useMemo)(()=>new Map(r.map(e=>[e.host,e])),[r]),u=(0,x.useMemo)(()=>t.length===0?`All Hosts`:t.join(`, `),[t]),d=(0,x.useMemo)(()=>t.length===0?`All Hosts`:t.length===1?t[0]:`${t.length} hosts`,[t]);(0,x.useEffect)(()=>{if(!i||typeof document>`u`||!document.addEventListener||!document.removeEventListener)return;let e=e=>{let t=e.target;t&&s.current?.contains(t)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e,{passive:!0}),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[i]);let f=t=>{let r=new Set(c);r.has(t)?r.delete(t):r.add(t),n(e.filter(e=>r.has(e)))};return(0,J.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":i,"aria-controls":o,"aria-label":`Filter by host`,onClick:()=>a(e=>!e),className:`flex h-6 max-w-[9rem] items-center gap-1.5 rounded border border-border bg-base px-2 text-[11px] text-primary hover:bg-hover focus:border-accent focus:outline-none`,title:u,children:[(0,J.jsx)(je,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`truncate leading-none`,children:d}),(0,J.jsx)(re,{className:`h-3 w-3 shrink-0 text-muted`})]}),i&&(0,J.jsxs)(`div`,{id:o,role:`menu`,className:`absolute left-0 z-20 mt-1 w-48 max-w-[calc(100vw-1.5rem)] rounded border border-border bg-surface p-2 text-xs shadow-lg`,children:[(0,J.jsxs)(`label`,{role:`menuitemcheckbox`,"aria-checked":t.length===0,className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:t.length===0,onChange:()=>n([]),className:`h-3.5 w-3.5 accent-approval`}),(0,J.jsx)(`span`,{children:`All Hosts`})]}),(0,J.jsx)(`div`,{className:`my-2 h-px bg-border`}),e.length===0?(0,J.jsx)(`div`,{className:`px-2 py-1 text-muted`,children:`No hosts`}):(0,J.jsx)(`div`,{className:`max-h-48 overflow-y-auto pr-1`,children:e.map(e=>{let t=l.get(e),n=t?!t.ok:!1;return(0,J.jsxs)(`label`,{role:`menuitemcheckbox`,"aria-checked":c.has(e),className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,title:t?.error?`${e}: ${t.error}`:e,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:c.has(e),onChange:()=>f(e),className:`h-3.5 w-3.5 accent-approval`}),(0,J.jsx)(`span`,{className:`truncate`,children:e}),n&&(0,J.jsx)(`span`,{className:`ml-auto text-[10px] uppercase text-danger`,children:`offline`})]},e)})})]})]})}function ih({projects:e,selectedProjects:t,onSelect:n,hasHiddenPermissions:r}){let[i,a]=(0,x.useState)(!1),o=(0,x.useId)(),s=(0,x.useRef)(null),c=(0,x.useMemo)(()=>Nm(e),[e]),l=(0,x.useMemo)(()=>new Set(t),[t]),u=r&&t.length>0,d=(0,x.useMemo)(()=>t.length===0?`All Projects`:t.map(e=>c.get(e)??Mm(e)??e).join(`, `),[c,t]),f=(0,x.useMemo)(()=>{if(t.length===0)return`All Projects`;if(t.length===1){let e=t[0];return c.get(e)??Mm(e)??e}return`${t.length} projects`},[c,t]);(0,x.useEffect)(()=>{if(!i||typeof document>`u`||!document.addEventListener||!document.removeEventListener)return;let e=e=>{let t=e.target;t&&s.current?.contains(t)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e,{passive:!0}),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[i]);let p=t=>{let r=new Set(l);r.has(t)?r.delete(t):r.add(t),n(e.filter(e=>r.has(e)))};return(0,J.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":i,"aria-controls":o,"aria-label":`Filter by project`,onClick:()=>a(e=>!e),className:`flex h-6 max-w-[11rem] items-center gap-1.5 rounded border border-border bg-base px-2 text-[11px] text-primary hover:bg-hover focus:border-accent focus:outline-none`,title:d,children:[(0,J.jsx)(_e,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`truncate leading-none`,children:f}),(0,J.jsx)(re,{className:`h-3 w-3 shrink-0 text-muted`})]}),i&&(0,J.jsxs)(`div`,{id:o,role:`menu`,className:`absolute left-0 z-20 mt-1 w-60 max-w-[calc(100vw-1.5rem)] rounded border border-border bg-surface p-2 text-xs shadow-lg`,children:[(0,J.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:t.length===0,onChange:()=>n([]),className:`h-3.5 w-3.5 accent-approval`}),(0,J.jsx)(`span`,{children:`All Projects`})]}),(0,J.jsx)(`div`,{className:`my-2 h-px bg-border`}),e.length===0?(0,J.jsx)(`div`,{className:`px-2 py-1 text-muted`,children:`No projects`}):(0,J.jsx)(`div`,{className:`max-h-48 overflow-y-auto pr-1`,children:e.map(e=>{let t=c.get(e)??Mm(e)??e;return(0,J.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,title:e,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:l.has(e),onChange:()=>p(e),className:`h-3.5 w-3.5 accent-approval`}),(0,J.jsx)(`span`,{className:`truncate`,children:t})]},e)})})]}),u&&(0,J.jsx)(`button`,{type:`button`,className:`absolute -right-1 -top-1 h-2 w-2 rounded-full bg-approval pulse-approval ring-2 ring-elevated`,title:`Hidden sessions need attention`,"aria-label":`Clear project filters`,onClick:e=>{e.stopPropagation(),n([])},children:(0,J.jsx)(`span`,{className:`sr-only`,children:`Clear project filters`})})]})}var ah=new Set([`tool_result`,`custom_tool_call_output`]),oh=new Set([`text`,`input_text`,`output_text`]);function sh(e){return!e||typeof e!=`object`?null:e}function ch(e){return typeof e==`string`?e:null}function lh(e){return e===`user`?`user`:e===`assistant`?`assistant`:e===`system`||e===`developer`?`system`:e===`tool`?`tool`:`other`}function uh(e){let t=ch(e.type)??``,n=sh(e.payload),r=ch(n?.type)??``,i=ch(e.source)??ch(n?.source)??``,a=ch(e.agent)??``;return i.toLowerCase()===`pi`||a.toLowerCase()===`pi`?`pi`:t===`response_item`||t===`event_msg`?`codex`:t===`tool_use`||t===`result`||t===`user`||t===`assistant`||t===`system`?`claude`:r===`user_message`||r===`assistant_message`?`codex`:`unknown`}function dh(e){let t=ch(sh(e.payload)?.type);return{family:uh(e),rawType:ch(e.type)??`unknown`,...t?{payloadType:t}:{}}}function fh(e){if(!e)return[];if(typeof e==`string`)return e.trim()?[e]:[];if(Array.isArray(e)){let t=[];for(let n of e){if(typeof n==`string`){n.trim()&&t.push(n);continue}let e=sh(n);if(!e)continue;let r=ch(e.type);if(r&&ah.has(r)||r&&!oh.has(r))continue;let i=ch(e.text);i&&i.trim()&&t.push(i)}return t}let t=sh(e);if(t){let e=ch(t.type);if(e&&ah.has(e))return[];let n=ch(t.text);return n&&n.trim()?[n]:[...fh(t.content),...fh(t.message)]}return[]}function ph(e,t){if(e.type!==`response_item`)return[];let n=sh(e.payload);if(!n||n.type!==`message`)return[];let r=lh(n.role);return fh(n.content).map(e=>({kind:`message`,role:r,text:e,source:t}))}function mh(e,t){if(e.type!==`event_msg`)return[];let n=sh(e.payload);if(!n)return[];let r=ch(n.type),i=null;if(r===`user_message`?i=`user`:r===`assistant_message`?i=`assistant`:r===`system_message`?i=`system`:r===`message`&&(i=lh(n.role)),!i||![`user`,`assistant`,`system`].includes(i))return[];let a=Array.from(new Set([...fh(n.message),...fh(n.content),...fh(n.text)]));return a.length===0?[]:a.map(e=>({kind:`message`,role:i,text:e,source:t}))}function hh(e,t){let n=lh(e.type),r=sh(e.message);if(r){let n=lh(r.role??e.type);return[...fh(r.content),...fh(r.text),...fh(r.message)].map(e=>({kind:`message`,role:n,text:e,source:t}))}return[`user`,`assistant`,`system`].includes(n)?[...fh(e.content),...fh(e.text)].map(e=>({kind:`message`,role:n,text:e,source:t})):[]}function gh(e,t){let n=lh(e.role);return[`user`,`assistant`,`system`].includes(n)?[...fh(e.content),...fh(e.message),...fh(e.text)].map(e=>({kind:`message`,role:n,text:e,source:t})):[]}function _h(e,t){let n=ch(e.type),r=ch(e.event);return n!==`tool_use`&&r!==`tool_use`?[]:[{kind:`tool_call`,role:`assistant`,text:`[Tool: ${ch(e.name)??`tool`}]`,source:t}]}function vh(e,t){if(e.type!==`result`)return[];let n=ch(e.result);return!n||!n.trim()?[]:[{kind:`result`,role:`system`,text:n,source:t}]}function yh(e,t){let n=sh(e.payload),r=[...fh(e.message),...fh(e.content),...fh(e.text),...fh(n?.message),...fh(n?.content)];return r.length===0?[]:r.map(e=>({kind:`unknown`,role:`other`,text:e,source:t}))}function bh(e,t){let n=ch(e.type),r=ch(sh(e.payload)?.type);return n&&ah.has(n)||r&&ah.has(r)?[{kind:`tool_result`,role:`tool`,text:``,source:t}]:[]}function xh(e){let t=sh(e);if(!t)return[];let n=dh(t),r=[...ph(t,n),...mh(t,n),...hh(t,n),..._h(t,n),...vh(t,n),...bh(t,n)];if(r.length>0)return r;let i=gh(t,n);return i.length>0?i:yh(t,n)}function Sh(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);return{parsed:!0,events:xh(e),raw:e}}catch{return{parsed:!1,events:[{kind:`unknown`,role:`other`,text:t,source:{family:`unknown`,rawType:`raw_text`}}],raw:e}}}var Ch=1e4;function wh(e){return e===`user`?`user`:e===`assistant`?`assistant`:e===`system`?`system`:`other`}function Th(e){let t=Sh(e);if(!t)return[];let n=t.events.map(t=>({type:wh(t.role),content:t.text.trim(),raw:e})).filter(e=>e.content.length>0);return n.length>0?n:!t.parsed&&e.trim()?[{type:`other`,content:e.trim(),raw:e}]:[]}function Eh({session:e,className:t=``,onStateChange:n}){let[r,i]=(0,x.useState)(!0),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(!1),d=(0,x.useRef)(null);(0,x.useEffect)(()=>{let t=!1,n=new AbortController,r=setTimeout(()=>n.abort(),Ch);return(async()=>{i(!0),o(null),c(null);try{let r=await fetch(`/api/session-preview/${e.sessionId}`,{signal:n.signal});if(!r.ok){let e=`Failed to load preview (HTTP ${r.status})`;try{let t=await r.json();t?.error&&(e=t.error)}catch{}throw Error(e)}let i=await r.json();t||c(i)}catch(e){if(t)return;n.signal.aborted?o(`Preview timed out`):o(e instanceof Error?e.message:`Failed to load preview`)}finally{t||i(!1)}})(),()=>{t=!0,clearTimeout(r),n.abort()}},[e.sessionId]),(0,x.useEffect)(()=>{n?.({loading:r,error:a})},[a,r,n]),(0,x.useEffect)(()=>{d.current&&s&&(d.current.scrollTop=d.current.scrollHeight)},[s,l]);let f=s?.lines.flatMap(Th).slice(-30)??[];return(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-elevated ${t}`.trim(),children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-primary`,children:`Recent Preview`}),(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Derived from the saved session log.`})]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`btn text-xs ${l?`btn-primary`:``}`,children:l?`Parsed`:`Raw`})]}),(0,J.jsxs)(`div`,{ref:d,className:`flex-1 overflow-y-auto p-4 font-mono text-xs`,children:[r&&(0,J.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted`,children:`Loading preview...`}),a&&(0,J.jsx)(`div`,{className:`flex items-center justify-center py-8 text-danger`,children:a}),s&&!l&&(0,J.jsx)(`div`,{className:`space-y-2`,children:f.length===0?(0,J.jsx)(`div`,{className:`py-8 text-center text-muted`,children:`No readable content found. Try raw view.`}):f.map((e,t)=>(0,J.jsx)(`div`,{className:`rounded px-2 py-1 ${e.type===`user`?`bg-blue-500/10 text-blue-400`:e.type===`assistant`?`bg-emerald-500/10 text-emerald-400`:e.type===`system`?`bg-yellow-500/10 text-yellow-400`:`text-muted`}`,children:(0,J.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:e.content.length>500?`${e.content.slice(0,500)}...`:e.content})},t))}),s&&l&&(0,J.jsx)(`div`,{className:`space-y-1`,children:s.lines.slice(-50).map((e,t)=>(0,J.jsx)(`div`,{className:`whitespace-pre-wrap break-all text-muted`,children:e||` `},t))})]})]})}function Dh({session:e,onClose:t,onResume:n}){let r=(0,x.useRef)(null),[i,a]=(0,x.useState)({loading:!0,error:null}),o=(0,x.useCallback)(()=>{i.loading||n(e.sessionId)},[i.loading,n,e.sessionId]);(0,x.useEffect)(()=>{let e=e=>{e.key===`Escape`?(e.stopPropagation(),t()):e.key===`Enter`&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,t]),(0,x.useEffect)(()=>{r.current?.focus()},[]);let s=e.displayName||Mm(e.projectPath)||e.sessionId.slice(0,8),c=jm(e.lastActivityAt);return(0,J.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`preview-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,J.jsxs)(`div`,{ref:r,tabIndex:-1,className:`flex max-h-[80vh] w-full max-w-2xl flex-col border border-border bg-elevated`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-4 py-3`,children:[(0,J.jsx)(Xm,{agentType:e.agentType,className:`h-5 w-5 shrink-0 text-muted`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h2`,{id:`preview-title`,className:`truncate text-sm font-semibold text-primary`,children:s}),(0,J.jsxs)(`p`,{className:`truncate text-xs text-muted`,title:e.projectPath,children:[Mm(e.projectPath),` · `,c]})]})]}),(0,J.jsx)(Eh,{session:e,className:`m-4 mt-0 flex-1 border-0 bg-transparent`,onStateChange:a}),(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border px-4 py-3`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:o,className:`btn btn-primary`,disabled:i.loading,children:`Wake`})]})]})})}function Oh({session:e,isSelected:t,showSessionIdPrefix:n,showProjectName:r,showLastUserMessage:i,onSelect:a,onWake:o,onRename:s,onMoveToHistory:c}){let l=jm(e.lastActivityAt),u=Mm(e.projectPath),d=e.displayName||u||e.sessionId.slice(0,8),f=r&&!!u,p=i&&!!e.lastUserMessage,m=n?Pm(e.sessionId):``,h=(0,x.useRef)(null),g=(0,x.useRef)(null),[_,v]=(0,x.useState)(null),[y,b]=(0,x.useState)(!1),[S,C]=(0,x.useState)(d);(0,x.useEffect)(()=>{C(d)},[d]),(0,x.useEffect)(()=>{y&&g.current&&(g.current.focus(),g.current.select())},[y]);let w=()=>{let t=S.trim();t&&t!==d&&s?.(e.sessionId,t),b(!1)};return(0,x.useEffect)(()=>{if(!_)return;let e=e=>{h.current&&!h.current.contains(e.target)&&v(null)},t=e=>{e.key===`Escape`&&v(null)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[_]),(0,J.jsxs)(`div`,{className:`group relative cursor-pointer px-3 py-2 hover:bg-hover ${t?`bg-hover`:``}`,role:`button`,tabIndex:0,"data-testid":`hibernating-session-card`,onClick:()=>a(e.sessionId),onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),v({x:e.clientX,y:e.clientY})},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.sessionId))},children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-2.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Xm,{agentType:e.agentType,className:`h-3.5 w-3.5 shrink-0 text-muted`}),y?(0,J.jsx)(`input`,{ref:g,type:`text`,value:S,onChange:e=>C(e.target.value),onBlur:w,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),w()):e.key===`Escape`&&(e.preventDefault(),C(d),b(!1))},onClick:e=>e.stopPropagation(),className:`min-w-0 flex-1 rounded border border-border bg-surface px-1.5 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-primary`,children:d}),(0,J.jsx)(Ce,{className:`h-3 w-3 shrink-0 text-muted`,"aria-label":`Hibernating`,title:`Hibernating`}),e.lastResumeError&&(0,J.jsx)(q,{className:`h-3 w-3 shrink-0 text-amber-500`,"aria-label":`Wake failed`,title:`Last wake failed: ${e.lastResumeError}`}),m&&(0,J.jsx)(`span`,{className:`shrink-0 text-[11px] font-mono text-muted`,title:e.sessionId,children:m}),(0,J.jsx)(`span`,{className:`ml-1 w-8 shrink-0 text-right text-xs tabular-nums text-muted`,children:l})]}),(f||p)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pl-[1.375rem]`,children:[f&&(0,J.jsx)(eh,{name:u,fullPath:e.projectPath}),p&&(0,J.jsxs)(`span`,{className:`line-clamp-2 text-xs italic text-muted`,children:[`"`,e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+`...`:e.lastUserMessage,`"`]})]})]}),_&&(0,J.jsxs)(`div`,{ref:h,className:`fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1`,style:{left:_.x,top:_.y},role:`menu`,children:[o&&(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),o(e.sessionId)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,J.jsx)(De,{width:14,height:14}),`Wake`]}),s&&(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),v(null),b(!0)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,J.jsx)(pe,{width:14,height:14}),`Rename`]}),e.logFilePath&&(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),Fm(e.logFilePath)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:e.logFilePath,children:[(0,J.jsx)(he,{width:14,height:14}),`Copy Log Path`]}),c&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),c(e.sessionId)},className:`w-full px-3 py-2 text-left text-sm text-danger hover:bg-danger/10 flex items-center gap-2`,role:`menuitem`,children:[(0,J.jsx)(ze,{width:14,height:14}),`Move to History`]})]})]})]})}var kh={working:`bg-green-500/20 text-green-600`,waiting:`bg-zinc-500/20 text-zinc-400`,permission:`bg-amber-500/20 text-amber-600`,unknown:`bg-zinc-500/20 text-zinc-400`};function Ah(){let[,e]=(0,x.useState)(0);(0,x.useEffect)(()=>{let t=setInterval(()=>e(e=>e+1),3e4);return()=>clearInterval(t)},[])}function jh({sessions:e,hibernatingSessions:t=[],historySessions:n=[],selectedSessionId:r,selectedHibernatingSessionId:i=null,loading:a,error:o,onSelect:s,onSelectHibernating:c,onRename:l,onResume:u,onHibernate:d,onKill:f,onDuplicate:p,onMoveToHistory:m,onNewSession:h}){Ah();let g=(0,x.useMemo)(()=>typeof navigator>`u`?!1:/^((?!chrome|android).)*safari/i.test(navigator.userAgent),[]),[_,v]=(0,x.useState)(null),y=G(e=>e.historySessionsExpanded),b=G(e=>e.setHistorySessionsExpanded),S=G(e=>e.hibernatingSessionsExpanded),C=G(e=>e.setHibernatingSessionsExpanded),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(20),O=ld(),k=g&&!O,A=(0,x.useMemo)(()=>[...t,...n],[t,n]);(0,x.useEffect)(()=>{y||D(20)},[y]);let[j,M]=Wm(e.length,200),[N,P]=Wm(n.length,200,!0),F=(0,x.useRef)(new Set(e.map(e=>e.id))),I=(0,x.useRef)(new Set([...t,...n].map(e=>e.sessionId))),[L,R]=(0,x.useState)(new Set);(0,x.useEffect)(()=>{let r=new Set(e.map(e=>e.id)),i=new Set([...t,...n].map(e=>e.sessionId)),a=new Set;for(let e of r)F.current.has(e)||a.add(e);for(let t of e){let e=t.agentSessionId?.trim();e&&I.current.has(e)&&!i.has(e)&&a.add(t.id)}F.current=r,I.current=i,a.size>0&&R(a)},[e,t,n]),(0,x.useEffect)(()=>{if(L.size===0)return;let e=setTimeout(()=>R(new Set),500);return()=>clearTimeout(e)},[L]);let z=Ge(Ue(G(e=>e.shortcutModifier))),B=G(e=>e.sessionSortMode),V=G(e=>e.setSessionSortMode),H=G(e=>e.sessionSortDirection),U=G(e=>e.manualSessionOrder),W=G(e=>e.setManualSessionOrder),ee=G(e=>e.showProjectName),K=G(e=>e.showLastUserMessage),te=G(e=>e.showSessionIdPrefix),q=G(e=>e.projectFilters),ne=G(e=>e.setProjectFilters),ie=G(e=>e.hostFilters),oe=G(e=>e.setHostFilters),se=Um(e=>e.exitingSessions),ce=Um(e=>e.clearExitingSession),le=Um(e=>e.hostStatuses),ue=Um(e=>e.remoteAllowControl);Gm(e,se,ce,200),(0,x.useEffect)(()=>{if(U.length===0)return;let t=new Set;for(let n of e)t.add(Em(n)),t.add(n.id);for(let e of A)t.add(e.sessionId);let n=U.filter(e=>t.has(e));n.length!==U.length&&W(n)},[e,A,U,W]);let de=(0,x.useMemo)(()=>Om(e,{mode:B,direction:H,manualOrder:U}),[e,B,H,U]),fe=(0,x.useMemo)(()=>km(e,A),[e,A]),pe=(0,x.useMemo)(()=>{let t=Am(e,A),n=le.map(e=>e.host),r=new Set,i=[];for(let e of n)!e||r.has(e)||(r.add(e),i.push(e));for(let e of t)!e||r.has(e)||(r.add(e),i.push(e));return i},[e,A,le]),me=(0,x.useMemo)(()=>pe.length>1,[pe]),he=(0,x.useMemo)(()=>{let e=de;return q.length>0&&(e=e.filter(e=>q.includes(e.projectPath))),ie.length>0&&(e=e.filter(e=>ie.includes(e.host??``))),e},[de,q,ie]),ge=(0,x.useMemo)(()=>`${q.length===0?`all-projects`:q.join(`|`)}::${ie.length===0?`all-hosts`:ie.join(`|`)}`,[q,ie]),_e=(0,x.useRef)(new Set(he.map(e=>e.id))),[ve,ye]=(0,x.useState)(new Set);(0,x.useEffect)(()=>{let e=new Set(he.map(e=>e.id)),t=new Set;for(let n of e)_e.current.has(n)||L.has(n)||t.add(n);_e.current=e,t.size>0&&ye(t)},[he,L]),(0,x.useEffect)(()=>{if(ve.size===0)return;let e=setTimeout(()=>ye(new Set),500);return()=>clearTimeout(e)},[ve]);let be=(0,x.useMemo)(()=>{let e=t;return q.length>0&&(e=e.filter(e=>q.includes(e.projectPath))),ie.length>0&&(e=e.filter(e=>ie.includes(e.host??``))),e},[t,q,ie]),xe=(0,x.useMemo)(()=>{let e=n;return q.length>0&&(e=e.filter(e=>q.includes(e.projectPath))),ie.length>0&&(e=e.filter(e=>ie.includes(e.host??``))),e},[n,q,ie]),Se=(0,x.useMemo)(()=>{if(q.length===0)return 0;let t=new Set(q);return e.filter(e=>!t.has(e.projectPath)&&e.status===`permission`).length},[e,q]);(0,x.useEffect)(()=>{if(q.length===0||fe.length===0)return;let e=new Set(fe),t=q.filter(t=>e.has(t));t.length!==q.length&&ne(t)},[q,fe,ne]),(0,x.useEffect)(()=>{if(ie.length===0||pe.length===0)return;let e=new Set(pe),t=ie.filter(t=>e.has(t));t.length!==ie.length&&oe(t)},[ie,pe,oe]);let Ce=Zd(Xd(Qf,{activationConstraint:{distance:8}})),[we,Te]=(0,x.useState)(null),[Ee,De]=(0,x.useState)(null),[Oe,Ae]=(0,x.useState)(!1),je=(0,x.useCallback)(e=>{Te(e.active.id),Ae(!0)},[]),Me=(0,x.useCallback)(e=>{De(e.over?.id)},[]),Ne=(0,x.useCallback)(e=>{let{active:t,over:n}=e;if(Te(null),De(null),!n||t.id===n.id){setTimeout(()=>Ae(!1),100);return}let r=he.findIndex(e=>e.id===t.id),i=he.findIndex(e=>e.id===n.id);if(r===-1||i===-1){setTimeout(()=>Ae(!1),100);return}let a=he.map(e=>Em(e)),[o]=a.splice(r,1);a.splice(i,0,o);let s=de.map(e=>Em(e)),c=new Set(a),l=0,u=s.map(e=>{if(!c.has(e))return e;let t=a[l];return l+=1,t});B!==`manual`&&V(`manual`),W(u),setTimeout(()=>Ae(!1),100)},[he,de,B,V,W]),Pe=(0,x.useCallback)(()=>{Te(null),De(null),setTimeout(()=>Ae(!1),100)},[]);(0,x.useEffect)(()=>{if(!we&&!Ee)return;let e=new Set(he.map(e=>e.id)),t=!1;we&&!e.has(we)&&(Te(null),t=!0),Ee&&!e.has(Ee)&&(De(null),t=!0),t&&Ae(!1)},[he,we,Ee]);let Fe=(e,t)=>{l(e,t),v(null)};return(0,J.jsxs)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-r border-border bg-elevated`,children:[o&&(0,J.jsx)(`div`,{className:`shrink-0 border-b border-danger/30 bg-danger/10 px-3 py-2 text-xs text-danger`,children:o}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,J.jsxs)(`div`,{className:`sticky top-0 z-10 flex h-10 items-center justify-start gap-2 border-b border-border bg-elevated px-3`,children:[me&&(0,J.jsx)(rh,{hosts:pe,selectedHosts:ie,onSelect:oe,statuses:le}),(0,J.jsx)(ih,{projects:fe,selectedProjects:q,onSelect:ne,hasHiddenPermissions:Se>0})]}),a?(0,J.jsx)(`div`,{className:`space-y-1 p-2`,children:[0,1,2].map(e=>(0,J.jsx)(`div`,{className:`h-14 animate-pulse rounded bg-surface`},e))}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 text-xs font-medium uppercase tracking-wider text-muted`,children:[(0,J.jsx)(`span`,{children:`Active`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[he.length===0&&h&&(0,J.jsxs)(`button`,{type:`button`,onClick:h,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium normal-case tracking-normal text-accent hover:bg-hover`,title:`Start a new session`,children:[(0,J.jsx)(ke,{className:`h-3.5 w-3.5`}),`New session`]}),(0,J.jsx)(cd.span,{className:`w-8 text-right text-xs`,animate:j&&!O?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:M,children:he.length})]})]}),he.length>0&&(0,J.jsx)(Yp,{sensors:Ce,collisionDetection:af,onDragStart:je,onDragOver:Me,onDragEnd:Ne,onDragCancel:Pe,children:(0,J.jsx)(hm,{items:he.map(e=>e.id),strategy:dm,children:(0,J.jsx)(`div`,{children:(0,J.jsx)(Ya,{initial:!1,mode:k?`sync`:`popLayout`,children:he.map((e,t)=>{let n=L.has(e.id),i=ve.has(e.id),a=e.remote===!0,o=e.source===`managed`,c=!a||ue&&o,l=!!(d&&!a&&o&&e.agentSessionId?.trim()),u=we?he.findIndex(e=>e.id===we):-1,m=Ee===e.id&&we!==e.id?u>t?`above`:`below`:null;return(0,J.jsx)(Mh,{session:e,isNew:n||i,exitDuration:200,prefersReducedMotion:O,useSafariLayoutFallback:k,layoutAnimationsDisabled:Oe,isSelected:e.id===r,isEditing:e.id===_,showSessionIdPrefix:te,showProjectName:ee,showLastUserMessage:K,showHostInfo:me,dropIndicator:m,onSelect:()=>s(e.id),onStartEdit:c?()=>v(e.id):void 0,onCancelEdit:()=>v(null),onRename:t=>Fe(e.id,t),onHibernate:l?()=>d?.(e.agentSessionId.trim()):void 0,onKill:f&&c?()=>f(e.id):void 0,onDuplicate:p&&c?()=>p(e.id):void 0},e.id)})})},ge)})}),be.length>0&&(0,J.jsxs)(`div`,{className:`border-t border-border`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>C(!S),className:`flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-muted hover:text-primary`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[S?(0,J.jsx)(re,{className:`h-4 w-4`}):(0,J.jsx)(ae,{className:`h-4 w-4`}),`Hibernating`]}),(0,J.jsx)(`span`,{className:`w-8 text-right text-xs text-muted`,children:be.length})]}),S&&(0,J.jsx)(`div`,{className:`py-1`,children:be.map(e=>(0,J.jsx)(Oh,{session:e,isSelected:i===e.sessionId,showSessionIdPrefix:te,showProjectName:ee,showLastUserMessage:K,onSelect:e=>c?.(e),onWake:e=>u?.(e),onRename:(e,t)=>Fe(e,t),onMoveToHistory:m},e.sessionId))})]})]}),xe.length>0&&(0,J.jsxs)(`div`,{className:`border-t border-border`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>b(!y),className:`flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-muted hover:text-primary`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[y?(0,J.jsx)(re,{className:`h-4 w-4`}):(0,J.jsx)(ae,{className:`h-4 w-4`}),`History`]}),(0,J.jsx)(cd.span,{className:`w-8 text-right text-xs`,animate:N&&!O?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:P,children:xe.length})]}),y&&(0,J.jsxs)(`div`,{className:`py-1`,children:[xe.slice(0,E).map(e=>(0,J.jsx)(th,{session:e,showSessionIdPrefix:te,showProjectName:ee,showLastUserMessage:K,onResume:e=>u?.(e),onPreview:T},e.sessionId)),xe.length>E&&(0,J.jsxs)(`button`,{type:`button`,onClick:()=>D(e=>e+20),className:`w-full px-3 py-2 text-center text-xs text-muted hover:text-primary hover:bg-hover`,children:[`Show more (`,xe.length-E,` remaining)`]})]})]})]}),(0,J.jsx)(`div`,{className:`hidden shrink-0 border-t border-border px-3 py-2 md:block`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-[10px] text-muted`,children:[(0,J.jsxs)(`span`,{children:[z,`[ ] nav`]}),(0,J.jsxs)(`span`,{children:[z,`N new`]}),(0,J.jsxs)(`span`,{children:[z,`X kill`]})]})}),w&&(0,J.jsx)(Dh,{session:w,onClose:()=>T(null),onResume:e=>{T(null),u?.(e)}})]})}var Mh=(0,x.forwardRef)(function({session:e,isNew:t,exitDuration:n,prefersReducedMotion:r,useSafariLayoutFallback:i,layoutAnimationsDisabled:a,isSelected:o,isEditing:s,showSessionIdPrefix:c,showProjectName:l,showLastUserMessage:u,showHostInfo:d,dropIndicator:f,onSelect:p,onStartEdit:m,onCancelEdit:h,onRename:g,onHibernate:_,onKill:v,onDuplicate:y},b){let{attributes:S,listeners:C,setNodeRef:w,transform:T,transition:E,isDragging:D}=Cm({id:e.id,animateLayoutChanges:({isSorting:e,wasDragging:t})=>e||t}),O=Fd.Transform.toString(T),k={...r&&O?{transform:O,transition:E}:{},zIndex:D?10:void 0,opacity:D?.9:void 0},A=(0,x.useCallback)(e=>{w(e),typeof b==`function`?b(e):b&&(b.current=e)},[w,b]);return(0,J.jsxs)(cd.div,{ref:A,style:{...k,overflow:`hidden`},className:`relative`,layout:!r&&!D&&!a&&!t?!i:!1,transformTemplate:(e,t)=>Im({useSafariLayoutFallback:i,isDragging:D,dndTransform:O,generatedTransform:t}),initial:r||!t?!1:i?{opacity:0}:{opacity:0,scale:.97},animate:r?{opacity:1}:t?i?{opacity:1}:{opacity:1,scale:[1.02,.99,1]}:{opacity:1,scale:1},exit:r?{opacity:0}:i?{opacity:0,height:0}:{opacity:0,height:0,scale:.97},transition:r?{duration:0}:i?{opacity:{duration:n/1e3},height:{duration:n/1e3,ease:`easeOut`}}:{layout:{type:`spring`,stiffness:500,damping:35},opacity:{duration:n/1e3},scale:{duration:n/1e3,ease:[.34,1.56,.64,1]},height:{duration:n/1e3,ease:`easeOut`}},...S,...C,children:[f===`above`&&(0,J.jsx)(`div`,{className:`absolute -top-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent`}),(0,J.jsx)(Nh,{session:e,isSelected:o,isEditing:s,showSessionIdPrefix:c,showProjectName:l,showLastUserMessage:u,showHostInfo:d,isDragging:D,onSelect:p,onStartEdit:m,onCancelEdit:h,onRename:g,onHibernate:_,onKill:v,onDuplicate:y}),f===`below`&&(0,J.jsx)(`div`,{className:`absolute -bottom-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent`})]})});Mh.displayName=`SortableSessionItem`;function Nh({session:e,isSelected:t,isEditing:n,showSessionIdPrefix:r,showProjectName:i,showLastUserMessage:a,showHostInfo:o,isDragging:s=!1,onSelect:c,onStartEdit:l,onCancelEdit:u,onRename:d,onHibernate:f,onKill:p,onDuplicate:m}){let h=jm(e.lastActivity),g=(0,x.useRef)(null),_=(0,x.useRef)(null),v=e.agentSessionName?.trim()||e.name?.trim()||e.id,[y,b]=(0,x.useState)(v),S=(0,x.useRef)(null),[C,w]=(0,x.useState)(null),T=Mm(e.projectPath),E=e.host?.trim(),D=e.status===`permission`,O=e.agentSessionId?.trim(),k=r&&O?Pm(O):``,A=i&&!!T,j=o&&!!E,M=a&&!!e.lastUserMessage,N=(0,x.useRef)(e.status),[P,F]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let t=N.current,n=e.status;t===`working`&&n===`waiting`?F(!0):N.current=n},[e.status]);let I=()=>{F(!1),N.current=e.status};(0,x.useEffect)(()=>{n&&g.current&&(g.current.focus(),g.current.select())},[n]),(0,x.useEffect)(()=>{b(v)},[v]);let L=()=>{let e=y.trim();e&&e!==v?d(e):u()},R=e=>{e.key===`Enter`?(e.preventDefault(),L()):e.key===`Escape`&&(e.preventDefault(),b(v),u())},z=(0,x.useRef)(null),B=e=>{if(s)return;let t=e.touches[0];z.current={x:t.clientX,y:t.clientY},S.current=setTimeout(()=>{z.current&&w(z.current)},500)},V=()=>{S.current&&=(clearTimeout(S.current),null)};return(0,x.useEffect)(()=>{if(!C)return;let e=e=>{_.current&&!_.current.contains(e.target)&&w(null)},t=e=>{e.key===`Escape`&&w(null)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[C]),(0,J.jsxs)(`div`,{className:`session-row group cursor-pointer select-none px-3 py-2 ${t?`selected`:``} ${s?`cursor-grabbing shadow-lg ring-1 ring-accent/30 bg-elevated`:`cursor-grab`}`,role:`button`,tabIndex:0,"data-testid":`session-card`,"data-session-id":e.id,onClick:s?void 0:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&c()},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),w({x:e.clientX,y:e.clientY})},onTouchStart:B,onTouchEnd:V,onTouchCancel:V,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-0.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Xm,{agentType:e.agentType,command:e.command,className:`h-3.5 w-3.5 shrink-0 text-muted`}),n?(0,J.jsx)(`input`,{ref:g,type:`text`,value:y,onChange:e=>b(e.target.value),onBlur:L,onKeyDown:R,onClick:e=>e.stopPropagation(),className:`min-w-0 flex-1 rounded border border-border bg-surface px-1.5 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-primary`,children:v}),k&&(0,J.jsx)(`span`,{className:`shrink-0 text-[11px] font-mono text-muted`,title:O,children:k}),D?(0,J.jsx)(`span`,{className:`ml-1 flex shrink-0 items-center justify-center rounded-full px-1.5 py-0.5 ${kh[e.status]} pulse-approval`,onAnimationEnd:I,children:(0,J.jsx)(ye,{className:`h-3 w-3`,"aria-label":`Needs input`})}):(0,J.jsx)(`span`,{className:`ml-1 shrink-0 rounded-full px-1.5 py-0.5 text-right text-xs tabular-nums ${kh[e.status]}${P?` pulse-complete`:``}`,onAnimationEnd:I,children:h})]}),(A||j||M)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pl-[1.375rem]`,children:[j&&(0,J.jsx)(nh,{name:E}),A&&(0,J.jsx)(eh,{name:T,fullPath:e.projectPath}),M&&(0,J.jsxs)(`span`,{className:`line-clamp-2 text-xs italic text-muted`,children:[`"`,e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+`…`:e.lastUserMessage,`"`]})]})]}),C&&(0,J.jsxs)(`div`,{ref:_,className:`fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1`,style:{left:C.x,top:C.y},role:`menu`,children:[l&&(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),l()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,J.jsx)(pe,{width:14,height:14}),`Rename`]}),m&&(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),m()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:`Create a copy in a new tmux window`,children:[(0,J.jsx)(se,{width:14,height:14}),`Duplicate`]}),f&&(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),f()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:`Close the live window and keep this session ready to wake`,children:[(0,J.jsx)(Ce,{width:14,height:14}),`Hibernate`]}),e.logFilePath&&(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),w(null),e.logFilePath&&Fm(e.logFilePath)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:e.logFilePath,children:[(0,J.jsx)(he,{width:14,height:14}),`Copy Log Path`]}),p&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),p()},className:`w-full px-3 py-2 text-left text-sm text-danger hover:bg-danger/10 flex items-center gap-2`,role:`menuitem`,children:[(0,J.jsx)(ze,{width:14,height:14}),`Kill Session`]})]})]})]})}var Ph={debug:0,info:1,warn:2,error:3},Fh=`info`;function Ih(e){let t=e.toLowerCase();t in Ph&&(Fh=t)}function Z(e,t,n=`debug`){if(!(Ph[n]<Ph[Fh]))try{fetch(`/api/client-log`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({event:e,data:t,level:n})}).catch(()=>{})}catch{}}var Lh=s(((e,t)=>{(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r();else if(typeof define==`function`&&define.amd)define([],r);else{var i=r();for(var a in i)(typeof e==`object`?e:n)[a]=i[a]}})(globalThis,(()=>(()=>{var e={4567:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.AccessibilityManager=void 0;let a=n(9042),o=n(9924),s=n(844),c=n(4725),l=n(2585),u=n(3656),d=t.AccessibilityManager=class extends s.Disposable{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=``,this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=this._coreBrowserService.mainDocument.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._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new o.TimeBasedDebouncer(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(`
20
+ `},Kd={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 qd(e){let{announcements:t=Kd,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Gd}=e,{announce:a,announcement:o}=Vd(),s=Dd(`DndLiveRegion`),[c,l]=(0,x.useState)(!1);if((0,x.useEffect)(()=>{l(!0)},[]),Ud((0,x.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=x.createElement(x.Fragment,null,x.createElement(zd,{id:r,value:i.draggable}),x.createElement(Bd,{id:s,announcement:o}));return n?(0,K.createPortal)(u,n):u}var Jd;(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`})(Jd||={});function Yd(){}function Xd(e,t){return(0,x.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Zd(){var e=[...arguments];return(0,x.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var Qd=Object.freeze({x:0,y:0});function $d(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function ef(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function tf(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function nf(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function rf(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 af=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=rf(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=$d(rf(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(ef)};function of(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 sf=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=of(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(tf)};function cf(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function lf(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Qd}function uf(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 df=uf(1);function ff(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]}}else 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 pf(e,t,n){let r=ff(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 mf={ignoreTransform:!1};function hf(e,t){t===void 0&&(t=mf);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=md(e).getComputedStyle(e);t&&(n=pf(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 gf(e){return hf(e,{ignoreTransform:!0})}function _f(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function vf(e,t){return t===void 0&&(t=md(e).getComputedStyle(e)),t.position===`fixed`}function yf(e,t){t===void 0&&(t=md(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):!1})}function bf(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(hd(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!gd(i)||_d(i)||n.includes(i))return n;let a=md(e).getComputedStyle(i);return i!==e&&yf(i,a)&&n.push(i),vf(i,a)?n:r(i.parentNode)}return e?r(e):n}function xf(e){let[t]=bf(e,1);return t??null}function Sf(e){return!dd||!e?null:fd(e)?e:pd(e)?hd(e)||e===vd(e).scrollingElement?window:gd(e)?e:null:null}function Cf(e){return fd(e)?e.scrollX:e.scrollLeft}function wf(e){return fd(e)?e.scrollY:e.scrollTop}function Tf(e){return{x:Cf(e),y:wf(e)}}var Ef;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Ef||={});function Df(e){return!dd||!e?!1:e===document.scrollingElement}function Of(e){let t={x:0,y:0},n=Df(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 kf={x:.2,y:.2};function Af(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=kf);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Of(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=Ef.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Ef.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Ef.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Ef.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function jf(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 Mf(e){return e.reduce((e,t)=>kd(e,Tf(t)),Qd)}function Nf(e){return e.reduce((e,t)=>e+Cf(t),0)}function Pf(e){return e.reduce((e,t)=>e+wf(t),0)}function Ff(e,t){if(t===void 0&&(t=hf),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);xf(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var If=[[`x`,[`left`,`right`],Nf],[`y`,[`top`,`bottom`],Pf]],Lf=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=bf(t),r=Mf(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of If)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})}},Rf=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 zf(e){let{EventTarget:t}=md(e);return e instanceof t?e:vd(e)}function Bf(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:!1}var Vf;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Vf||={});function Hf(e){e.preventDefault()}function Uf(e){e.stopPropagation()}var Wf;(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`})(Wf||={});var Gf={start:[Wf.Space,Wf.Enter],cancel:[Wf.Esc],end:[Wf.Space,Wf.Enter,Wf.Tab]},Kf=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Wf.Right:return{...n,x:n.x+25};case Wf.Left:return{...n,x:n.x-25};case Wf.Down:return{...n,y:n.y+25};case Wf.Up:return{...n,y:n.y-25}}},qf=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 Rf(vd(t)),this.windowListeners=new Rf(md(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Vf.Resize,this.handleCancel),this.windowListeners.add(Vf.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Vf.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Ff(n),t(Qd)}handleKeyDown(e){if(Md(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Gf,coordinateGetter:a=Kf,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}:Qd;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Ad(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}=Of(n),p=jf(n),m={x:Math.min(i===Wf.Right?p.right-p.width/2:p.right,Math.max(i===Wf.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===Wf.Down?p.bottom-p.height/2:p.bottom,Math.max(i===Wf.Down?p.top:p.top+p.height/2,u.y))},h=i===Wf.Right&&!s||i===Wf.Left&&!c,g=i===Wf.Down&&!l||i===Wf.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===Wf.Right&&e<=d.x||i===Wf.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===Wf.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===Wf.Down&&e<=d.y||i===Wf.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===Wf.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,kd(Ad(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()}};qf.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Gf,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 Jf(e){return!!(e&&`distance`in e)}function Yf(e){return!!(e&&`delay`in e)}var Xf=class{constructor(e,t,n){n===void 0&&(n=zf(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=vd(i),this.documentListeners=new Rf(this.document),this.listeners=new Rf(n),this.windowListeners=new Rf(md(i)),this.initialCoordinates=Pd(r)??Qd,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(Vf.Resize,this.handleCancel),this.windowListeners.add(Vf.DragStart,Hf),this.windowListeners.add(Vf.VisibilityChange,this.handleCancel),this.windowListeners.add(Vf.ContextMenu,Hf),this.documentListeners.add(Vf.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Yf(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Jf(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(Vf.Click,Uf,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Vf.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=Pd(e)??Qd,s=Ad(n,o);if(!t&&a){if(Jf(a)){if(a.tolerance!=null&&Bf(s,a.tolerance))return this.handleCancel();if(Bf(s,a.distance))return this.handleStart()}if(Yf(a)&&Bf(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}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===Wf.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Zf={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Qf=class extends Xf{constructor(e){let{event:t}=e,n=vd(t.target);super(e,Zf,n)}};Qf.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 $f={move:{name:`mousemove`},end:{name:`mouseup`}},ep;(function(e){e[e.RightClick=2]=`RightClick`})(ep||={});var tp=class extends Xf{constructor(e){super(e,$f,vd(e.event.target))}};tp.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===ep.RightClick?!1:(r?.({event:n}),!0)}}];var np={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},rp=class extends Xf{constructor(e){super(e,np)}static setup(){return window.addEventListener(np.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(np.move.name,e)};function e(){}}};rp.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 ip;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(ip||={});var ap;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(ap||={});function op(e){let{acceleration:t,activator:n=ip.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=ap.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=cp({delta:d,disabled:!a}),[m,h]=xd(),g=(0,x.useRef)({x:0,y:0}),_=(0,x.useRef)({x:0,y:0}),v=(0,x.useMemo)(()=>{switch(n){case ip.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case ip.DraggableRect:return i}},[n,i,c]),y=(0,x.useRef)(null),b=(0,x.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)},[]),S=(0,x.useMemo)(()=>s===ap.TreeOrder?[...l].reverse():l,[s,l]);(0,x.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of S){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=Af(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;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,S,u,JSON.stringify(f)])}var sp={x:{[Ef.Backward]:!1,[Ef.Forward]:!1},y:{[Ef.Backward]:!1,[Ef.Forward]:!1}};function cp(e){let{delta:t,disabled:n}=e,r=Td(t);return Cd(e=>{if(n||!r||!e)return sp;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Ef.Backward]:e.x[Ef.Backward]||i.x===-1,[Ef.Forward]:e.x[Ef.Forward]||i.x===1},y:{[Ef.Backward]:e.y[Ef.Backward]||i.y===-1,[Ef.Forward]:e.y[Ef.Forward]||i.y===1}}},[n,t,r])}function lp(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Cd(e=>t==null?null:r??e??null,[r,t])}function up(e,t){return(0,x.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 dp;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(dp||={});var fp;(function(e){e.Optimized=`optimized`})(fp||={});var pp=new Map;function mp(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,x.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,x.useRef)(e),d=g(),f=Sd(d),p=(0,x.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,x.useRef)(null),h=Cd(t=>{if(d&&!n)return pp;if(!t||t===pp||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 Lf(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,x.useEffect)(()=>{u.current=e},[e]),(0,x.useEffect)(()=>{d||p()},[n,d]),(0,x.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,x.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 dp.Always:return!1;case dp.BeforeDragging:return n;default:return!n}}}function hp(e,t){return Cd(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function gp(e,t){return hp(e,t)}function _p(e){let{callback:t,disabled:n}=e,r=bd(t),i=(0,x.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,x.useEffect)(()=>()=>i?.disconnect(),[i]),i}function vp(e){let{callback:t,disabled:n}=e,r=bd(t),i=(0,x.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,x.useEffect)(()=>()=>i?.disconnect(),[i]),i}function yp(e){return new Lf(hf(e),e)}function bp(e,t,n){t===void 0&&(t=yp);let[r,i]=(0,x.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=_p({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=vp({callback:a});return yd(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function xp(e){return lf(e,hp(e))}var Sp=[];function Cp(e){let t=(0,x.useRef)(e),n=Cd(n=>e?n&&n!==Sp&&e&&t.current&&e.parentNode===t.current.parentNode?n:bf(e):Sp,[e]);return(0,x.useEffect)(()=>{t.current=e},[e]),n}function wp(e){let[t,n]=(0,x.useState)(null),r=(0,x.useRef)(e),i=(0,x.useCallback)(e=>{let t=Sf(e.target);t&&n(e=>e?(e.set(t,Tf(t)),new Map(e)):null)},[]);return(0,x.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Sf(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Tf(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=>{Sf(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,x.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>kd(e,t),Qd):Mf(e):Qd,[e,t])}function Tp(e,t){t===void 0&&(t=[]);let n=(0,x.useRef)(null);return(0,x.useEffect)(()=>{n.current=null},t),(0,x.useEffect)(()=>{let t=e!==Qd;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Ad(e,n.current):Qd}function Ep(e){(0,x.useEffect)(()=>{if(!dd)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 Dp(e,t){return(0,x.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Op(e){return(0,x.useMemo)(()=>e?_f(e):null,[e])}var kp=[];function Ap(e,t){t===void 0&&(t=hf);let[n]=e,r=Op(n?md(n):null),[i,a]=(0,x.useState)(kp);function o(){a(()=>e.length?e.map(e=>Df(e)?r:new Lf(t(e),e)):kp)}let s=vp({callback:o});return yd(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function jp(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return gd(t)?t:e}function Mp(e){let{measure:t}=e,[n,r]=(0,x.useState)(null),i=vp({callback:(0,x.useCallback)(e=>{for(let{target:n}of e)if(gd(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=wd((0,x.useCallback)(e=>{let n=jp(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,x.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Np=[{sensor:Qf,options:{}},{sensor:qf,options:{}}],Pp={current:{}},Fp={draggable:{measure:gf},droppable:{measure:gf,strategy:dp.WhileDragging,frequency:fp.Optimized},dragOverlay:{measure:hf}},Ip=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}},Lp={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Ip,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Yd},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Fp,measureDroppableContainers:Yd,windowRect:null,measuringScheduled:!1},Rp={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Yd,draggableNodes:new Map,over:null,measureDroppableContainers:Yd},zp=(0,x.createContext)(Rp),Bp=(0,x.createContext)(Lp);function Vp(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Ip}}}function Hp(e,t){switch(t.type){case Jd.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Jd.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 Jd.DragEnd:case Jd.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Jd.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Ip(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Jd.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 Ip(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Jd.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Ip(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Up(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,x.useContext)(zp),a=Td(r),o=Td(n?.id);return(0,x.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Md(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=Ld(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Wp(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Gp(e){return(0,x.useMemo)(()=>({draggable:{...Fp.draggable,...e?.draggable},droppable:{...Fp.droppable,...e?.droppable},dragOverlay:{...Fp.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Kp(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,x.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;yd(()=>{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=lf(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=xf(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var qp=(0,x.createContext)({...Qd,scaleX:1,scaleY:1}),Jp;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Jp||={});var Yp=(0,x.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Np,collisionDetection:o=sf,measuring:s,modifiers:c,...l}=e,[u,d]=(0,x.useReducer)(Hp,void 0,Vp),[f,p]=Wd(),[m,h]=(0,x.useState)(Jp.Uninitialized),g=m===Jp.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,S=_==null?null:v.get(_),C=(0,x.useRef)({initial:null,translated:null}),w=(0,x.useMemo)(()=>_==null?null:{id:_,data:S?.data??Pp,rect:C},[_,S]),T=(0,x.useRef)(null),[E,D]=(0,x.useState)(null),[O,k]=(0,x.useState)(null),A=Sd(l,Object.values(l)),j=Dd(`DndDescribedBy`,t),M=(0,x.useMemo)(()=>b.getEnabled(),[b]),N=Gp(s),{droppableRects:P,measureDroppableContainers:F,measuringScheduled:I}=mp(M,{dragging:g,dependencies:[y.x,y.y],config:N.droppable}),L=lp(v,_),R=(0,x.useMemo)(()=>O?Pd(O):null,[O]),z=Ce(),B=gp(L,N.draggable.measure);Kp({activeNode:_==null?null:v.get(_),config:z.layoutShiftCompensation,initialRect:B,measure:N.draggable.measure});let V=bp(L,N.draggable.measure,B),H=bp(L?L.parentElement:null),U=(0,x.useRef)({activatorEvent:null,active:null,activeNode:L,collisionRect:null,collisions:null,droppableRects:P,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),W=b.getNodeFor(U.current.over?.id),G=Mp({measure:N.dragOverlay.measure}),ee=G.nodeRef.current??L,te=g?G.rect??V:null,q=!!(G.nodeRef.current&&G.rect),ne=xp(q?null:V),re=Op(ee?md(ee):null),ie=Cp(g?W??L:null),ae=Ap(ie),oe=Wp(c,{transform:{x:y.x-ne.x,y:y.y-ne.y,scaleX:1,scaleY:1},activatorEvent:O,active:w,activeNodeRect:V,containerNodeRect:H,draggingNodeRect:te,over:U.current.over,overlayNodeRect:G.rect,scrollableAncestors:ie,scrollableAncestorRects:ae,windowRect:re}),se=R?kd(R,y):null,ce=wp(ie),le=Tp(ce),ue=Tp(ce,[V]),de=kd(oe,le),fe=te?df(te,oe):null,pe=w&&fe?o({active:w,collisionRect:fe,droppableRects:P,droppableContainers:M,pointerCoordinates:se}):null,me=nf(pe,`id`),[he,ge]=(0,x.useState)(null),_e=cf(q?oe:kd(oe,ue),he?.rect??null,V),ve=(0,x.useRef)(null),ye=(0,x.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(T.current==null)return;let i=v.get(T.current);if(!i)return;let a=e.nativeEvent;ve.current=new n({active:T.current,activeNode:i,event:a,options:r,context:U,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=T.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:C}};(0,K.unstable_batchedUpdates)(()=>{r?.(i),h(Jp.Initializing),d({type:Jd.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),D(ve.current),k(a)})},onMove(e){d({type:Jd.DragMove,coordinates:e})},onEnd:o(Jd.DragEnd),onCancel:o(Jd.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=U.current,o=null;if(t&&i){let{cancelDrop:s}=A.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Jd.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Jd.DragCancel)}T.current=null,(0,K.unstable_batchedUpdates)(()=>{d({type:e}),h(Jp.Uninitialized),ge(null),D(null),k(null),ve.current=null;let t=e===Jd.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=A.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),be=up(a,(0,x.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(T.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},T.current=r,ye(n,t))},[v,ye]));Ep(a),yd(()=>{V&&m===Jp.Initializing&&h(Jp.Initialized)},[V,m]),(0,x.useEffect)(()=>{let{onDragMove:e}=A.current,{active:t,activatorEvent:n,collisions:r,over:i}=U.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:de.x,y:de.y},over:i};(0,K.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[de.x,de.y]),(0,x.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=U.current;if(!e||T.current==null||!t||!i)return;let{onDragOver:a}=A.current,o=r.get(me),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,K.unstable_batchedUpdates)(()=>{ge(s),a?.(c),f({type:`onDragOver`,event:c})})},[me]),yd(()=>{U.current={activatorEvent:O,active:w,activeNode:L,collisionRect:fe,collisions:pe,droppableRects:P,draggableNodes:v,draggingNode:ee,draggingNodeRect:te,droppableContainers:b,over:he,scrollableAncestors:ie,scrollAdjustedTranslate:de},C.current={initial:te,translated:fe}},[w,L,pe,fe,v,ee,te,P,b,he,ie,de]),op({...z,delta:y,draggingRect:fe,pointerCoordinates:se,scrollableAncestors:ie,scrollableAncestorRects:ae});let xe=(0,x.useMemo)(()=>({active:w,activeNode:L,activeNodeRect:V,activatorEvent:O,collisions:pe,containerNodeRect:H,dragOverlay:G,draggableNodes:v,droppableContainers:b,droppableRects:P,over:he,measureDroppableContainers:F,scrollableAncestors:ie,scrollableAncestorRects:ae,measuringConfiguration:N,measuringScheduled:I,windowRect:re}),[w,L,V,O,pe,H,G,v,b,P,he,F,ie,ae,N,I,re]),Se=(0,x.useMemo)(()=>({activatorEvent:O,activators:be,active:w,activeNodeRect:V,ariaDescribedById:{draggable:j},dispatch:d,draggableNodes:v,over:he,measureDroppableContainers:F}),[O,be,w,V,d,j,v,he,F]);return x.createElement(Hd.Provider,{value:p},x.createElement(zp.Provider,{value:Se},x.createElement(Bp.Provider,{value:xe},x.createElement(qp.Provider,{value:_e},i)),x.createElement(Up,{disabled:n?.restoreFocus===!1})),x.createElement(qd,{...n,hiddenTextDescribedById:j}));function Ce(){let e=E?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Xp=(0,x.createContext)(null),Zp=`button`,Qp=`Draggable`;function $p(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Dd(Qp),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,x.useContext)(zp),{role:p=Zp,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,x.useContext)(g?qp:Xp),[v,y]=wd(),[b,S]=wd(),C=Dp(o,t),w=Sd(n);return yd(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:w}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,x.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Zp?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:C,node:v,over:f,setNodeRef:y,setActivatorNodeRef:S,transform:_}}function em(){return(0,x.useContext)(Bp)}var tm=`Droppable`,nm={timeout:25};function rm(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Dd(tm),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,x.useContext)(zp),u=(0,x.useRef)({disabled:n}),d=(0,x.useRef)(!1),f=(0,x.useRef)(null),p=(0,x.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...nm,...i},_=Sd(h??r),v=vp({callback:(0,x.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=wd((0,x.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),S=Sd(t);return(0,x.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,x.useEffect)(()=>(s({type:Jd.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:S}}),()=>s({type:Jd.UnregisterDroppable,key:a,id:r})),[r]),(0,x.useEffect)(()=>{n!==u.current.disabled&&(s({type:Jd.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 im(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function am(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function om(e){return e!==null&&e>=0}function sm(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 cm(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var lm=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=im(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}},um={scaleX:1,scaleY:1},dm=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,...um}:null}let s=fm(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...um}:r<t&&r>=a?{x:0,y:o.height+s,...um}:{x:0,y:0,...um}};function fm(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 pm=`Sortable`,mm=x.createContext({activeIndex:-1,containerId:pm,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:lm,disabled:{draggable:!1,droppable:!1}});function hm(e){let{children:t,id:n,items:r,strategy:i=lm,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=em(),d=Dd(pm,n),f=s.rect!==null,p=(0,x.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,x.useRef)(p),v=!sm(p,_.current),y=g!==-1&&h===-1||v,b=cm(a);yd(()=>{v&&m&&u(p)},[v,p,m,u]),(0,x.useEffect)(()=>{_.current=p},[p]);let S=(0,x.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:am(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return x.createElement(mm.Provider,{value:S},t)}var gm=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return im(n,r,i).indexOf(t)},_m=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},vm={duration:200,easing:`ease`},ym=`transform`,bm=Fd.Transition.toString({property:ym,duration:0,easing:`linear`}),xm={roleDescription:`sortable`};function Sm(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,x.useState)(null),s=(0,x.useRef)(n);return yd(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=hf(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,x.useEffect)(()=>{a&&o(null)},[a]),a}function Cm(e){let{animateLayoutChanges:t=_m,attributes:n,disabled:r,data:i,getNewIndex:a=gm,id:o,strategy:s,resizeObserverConfig:c,transition:l=vm}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,x.useContext)(mm),y=wm(r,p),b=u.indexOf(o),S=(0,x.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),C=(0,x.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:w,node:T,isOver:E,setNodeRef:D}=rm({id:o,data:S,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:O,activatorEvent:k,activeNodeRect:A,attributes:j,setNodeRef:M,listeners:N,isDragging:P,over:F,setActivatorNodeRef:I,transform:L}=$p({id:o,data:S,attributes:{...xm,...n},disabled:y.draggable}),R=ud(D,M),z=!!O,B=z&&!m&&om(f)&&om(g),V=!_&&P,H=B?(V&&B?L:null)??(s??v)({rects:h,activeNodeRect:A,activeIndex:f,overIndex:g,index:b}):null,U=om(f)&&om(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,W=O?.id,G=(0,x.useRef)({activeId:W,items:u,newIndex:U,containerId:d}),ee=u!==G.current.items,K=t({active:O,containerId:d,isDragging:P,isSorting:z,id:o,index:b,items:u,newIndex:G.current.newIndex,previousItems:G.current.items,previousContainerId:G.current.containerId,transition:l,wasDragging:G.current.activeId!=null}),te=Sm({disabled:!K,index:b,node:T,rect:w});return(0,x.useEffect)(()=>{z&&G.current.newIndex!==U&&(G.current.newIndex=U),d!==G.current.containerId&&(G.current.containerId=d),u!==G.current.items&&(G.current.items=u)},[z,U,d,u]),(0,x.useEffect)(()=>{if(W===G.current.activeId)return;if(W!=null&&G.current.activeId==null){G.current.activeId=W;return}let e=setTimeout(()=>{G.current.activeId=W},50);return()=>clearTimeout(e)},[W]),{active:O,activeIndex:f,attributes:j,data:S,rect:w,index:b,newIndex:U,items:u,isOver:E,isSorting:z,isDragging:P,listeners:N,node:T,overIndex:g,over:F,setNodeRef:R,setActivatorNodeRef:I,setDroppableNodeRef:D,setDraggableNodeRef:M,transform:te??H,transition:q()};function q(){if(te||ee&&G.current.newIndex===b)return bm;if(!(V&&!Md(k)||!l)&&(z||K))return Fd.Transition.toString({...l,property:ym})}}function wm(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}Wf.Down,Wf.Right,Wf.Up,Wf.Left;var Tm={permission:0,waiting:1,working:2,unknown:3};function Em(e){let t=e.agentSessionId?.trim();return t&&t.length>0?t:e.id}var Dm={mode:`created`,direction:`desc`};function Om(e,t=Dm){let{mode:n,direction:r,manualOrder:i}=t;if(n===`manual`&&i&&i.length>0){let t=new Map(i.map((e,t)=>[e,t]));return e.toSorted((e,n)=>{let r=Em(e),i=Em(n),a=t.get(r)??t.get(e.id)??1/0,o=t.get(i)??t.get(n.id)??1/0;return a===1/0&&o===1/0?Date.parse(n.createdAt)-Date.parse(e.createdAt):a-o})}return e.toSorted((e,t)=>{if(n===`status`){let n=Tm[e.status]??Tm.unknown,r=Tm[t.status]??Tm.unknown;return n===r?Date.parse(t.lastActivity)-Date.parse(e.lastActivity):n-r}let i=Date.parse(e.createdAt),a=Date.parse(t.createdAt);return r===`desc`?a-i:i-a})}function km(e,t){let n=new Map;for(let t of e){let e=t.projectPath?.trim();if(e){let r=Date.parse(t.lastActivity)||0;r>(n.get(e)||0)&&n.set(e,r)}}for(let e of t){let t=e.projectPath?.trim();if(t){let r=Date.parse(e.lastActivityAt)||0;r>(n.get(t)||0)&&n.set(t,r)}}return Array.from(n.keys()).toSorted((e,t)=>{let r=n.get(e)||0;return(n.get(t)||0)-r})}function Am(e,t){let n=new Map;for(let t of e){let e=t.host?.trim();if(e){let r=Date.parse(t.lastActivity)||0;r>(n.get(e)||0)&&n.set(e,r)}}for(let e of t){let t=e.host?.trim();if(t){let r=Date.parse(e.lastActivityAt)||0;r>(n.get(t)||0)&&n.set(t,r)}}return Array.from(n.keys()).toSorted((e,t)=>{let r=n.get(e)||0;return(n.get(t)||0)-r})}function jm(e){let t=Date.parse(e);if(Number.isNaN(t))return``;let n=Date.now()-t,r=Math.floor(n/6e4);if(r<1)return`now`;if(r<60)return`${r}m`;let i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function Mm(e){let t=e.trim();if(!t)return null;let n=t.replace(/[\\/]+$/,``);if(!n)return null;let r=n.split(/[\\/]/);return r[r.length-1]||null}function Nm(e){let t=e.map(e=>{let t=e.trim(),n=t.replace(/[\\/]+$/,``);return{path:e,parts:n.split(/[\\/]/).filter(Boolean),fallback:n||t||e}}),n=new Map;for(let e of t)n.set(e.path,1);let r=!0;for(;r;){r=!1;let e=new Map;for(let r of t){if(r.parts.length===0)continue;let t=n.get(r.path)??1,i=r.parts.slice(-t).join(`/`);e.set(i,(e.get(i)??0)+1)}for(let i of t){if(i.parts.length===0)continue;let t=n.get(i.path)??1,a=i.parts.slice(-t).join(`/`);(e.get(a)??0)>1&&t<i.parts.length&&(n.set(i.path,t+1),r=!0)}}let i=new Map,a=new Map;for(let e of t){let t=e.fallback;if(e.parts.length>0){let r=n.get(e.path)??1;t=e.parts.slice(-r).join(`/`)}i.set(e.path,t),a.set(t,(a.get(t)??0)+1)}let o=new Map;for(let e of t){let t=i.get(e.path)??e.fallback;(a.get(t)??0)>1&&(t=e.fallback),o.set(e.path,t)}return o}function Pm(e){let t=e.trim();return!t||t.length<=6?t:`${t.slice(0,3)}…${t.slice(-3)}`}function Fm(e){let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-9999px`,document.body.appendChild(t),t.focus(),t.select();try{if(!document.execCommand(`copy`))throw 0}catch{navigator.clipboard?.writeText(e).catch(()=>{})}document.body.removeChild(t)}function Im({useSafariLayoutFallback:e,isDragging:t,dndTransform:n,generatedTransform:r}){return e&&!t&&!n||!n?r:!r||r===`none`?n:`${n} ${r}`}var Lm=`agentboard-session`,Rm=N(Lm);function zm(e,t){return e.id===t.id&&e.name===t.name&&e.tmuxWindow===t.tmuxWindow&&e.projectPath===t.projectPath&&e.status===t.status&&e.lastActivity===t.lastActivity&&e.createdAt===t.createdAt&&e.source===t.source&&e.host===t.host&&e.remote===t.remote&&e.command===t.command&&e.agentType===t.agentType&&e.agentSessionId===t.agentSessionId&&e.agentSessionName===t.agentSessionName&&e.logFilePath===t.logFilePath&&e.isPinned===t.isPinned&&e.lastUserMessage===t.lastUserMessage}function Bm(e,t){if(e.length!==t.length)return!1;let n=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=n.get(e.id);if(!t||!zm(t,e))return!1}return!0}function Vm(e){return typeof e==`string`&&e.length>0?e:null}function Hm(e){return Array.isArray(e)?e:[]}var Um=T()(k((e,t)=>({sessions:[],agentSessions:{active:[],hibernating:[],history:[]},agentSessionsEpoch:-1,hostStatuses:[],exitingSessions:new Map,selectedSessionId:null,selectedHibernatingSessionId:null,hasLoaded:!1,connectionStatus:`connecting`,connectionError:null,connectionEpoch:0,remoteAllowControl:!1,remoteAllowAttach:!1,hostLabel:null,setSessions:n=>{let r=t(),i=r.selectedSessionId,a=r.selectedHibernatingSessionId,o=r.sessions,s=r.exitingSessions;if(r.hasLoaded&&Bm(o,n))return;let c=new Set(n.map(e=>e.id)),l=o.filter(e=>!c.has(e.id)&&!s.has(e.id)),u=i;if(i!==null&&!n.some(e=>e.id===i))if(a===null){let{sessionSortMode:e,sessionSortDirection:t}=G.getState();u=Om(n,{mode:e,direction:t})[0]?.id??null}else u=null;if(l.length>0){let t=new Map(s);for(let e of l)t.set(e.id,e);e({sessions:n,hasLoaded:!0,selectedSessionId:u,exitingSessions:t})}else e({sessions:n,hasLoaded:!0,selectedSessionId:u})},setAgentSessions:(t,n,r)=>e(e=>{let i={active:Hm(t),hibernating:Hm(n),history:Hm(r)};return{agentSessions:i,agentSessionsEpoch:e.connectionEpoch,selectedHibernatingSessionId:e.selectedHibernatingSessionId&&!i.hibernating.some(t=>t.sessionId===e.selectedHibernatingSessionId)?null:e.selectedHibernatingSessionId}}),setActiveAgentSessions:t=>e(e=>({agentSessions:{active:Hm(t),hibernating:e.agentSessions.hibernating,history:e.agentSessions.history}})),setHostStatuses:t=>e({hostStatuses:t}),updateSession:t=>e(e=>({sessions:e.sessions.map(e=>e.id===t.id?t:e)})),setSelectedSessionId:t=>e({selectedSessionId:t,...t===null?{}:{selectedHibernatingSessionId:null}}),setSelectedHibernatingSessionId:t=>e({selectedHibernatingSessionId:t,...t===null?{}:{selectedSessionId:null}}),setConnectionStatus:t=>e({connectionStatus:t}),setConnectionError:t=>e({connectionError:t}),setConnectionState:(t,n,r)=>e({connectionStatus:t,connectionError:n,connectionEpoch:r}),setRemoteAllowControl:t=>e({remoteAllowControl:t}),setRemoteAllowAttach:t=>e({remoteAllowAttach:t}),setHostLabel:t=>e({hostLabel:t}),markSessionExiting:n=>{let r=t().sessions.find(e=>e.id===n);if(r){let i=new Map(t().exitingSessions);i.set(n,r),e({exitingSessions:i})}},clearExitingSession:n=>{let r=new Map(t().exitingSessions);r.delete(n),e({exitingSessions:r})}}),{name:Lm,storage:D(()=>Rm),partialize:e=>({selectedSessionId:e.selectedSessionId,selectedHibernatingSessionId:e.selectedHibernatingSessionId}),merge:(e,t)=>{let n=e,r=n?.selectedHibernatingSessionId??n?.selectedSleepingSessionId;return{...t,selectedSessionId:Vm(n?.selectedSessionId),selectedHibernatingSessionId:Vm(r)}}}));function Wm(e,t,n=!1){let[r,i]=(0,x.useState)(!1),a=(0,x.useRef)(e),o=(0,x.useRef)(!1);return(0,x.useEffect)(()=>{let r=a.current;if(n?e>r:e!==r){o.current=!0;let n=setTimeout(()=>{o.current&&=(i(!0),!1)},t);return a.current=e,()=>clearTimeout(n)}a.current=e},[e,t,n]),[r,()=>i(!1)]}function Gm(e,t,n,r){let i=(0,x.useRef)(new Map);(0,x.useEffect)(()=>{let a=new Set(e.map(e=>e.id));for(let e of t.keys())if(a.has(e)){let t=i.current.get(e);t&&(clearTimeout(t),i.current.delete(e)),n(e)}else if(!i.current.has(e)){let t=setTimeout(()=>{i.current.delete(e),n(e)},r+100);i.current.set(e,t)}},[e,t,n,r]),(0,x.useEffect)(()=>()=>{for(let e of i.current.values())clearTimeout(e);i.current.clear()},[])}function Km({className:e}){return(0,J.jsx)(`svg`,{viewBox:`0 0 92.2 92.2`,fill:`currentColor`,className:e,"aria-label":`Anthropic`,children:(0,J.jsx)(`path`,{d:`M66.5,0H52.4l25.7,65h14.1L66.5,0z M25.7,0L0,65h14.4l5.3-13.6h26.9L51.8,65h14.4L40.5,0C40.5,0,25.7,0,25.7,0z M24.3,39.3l8.8-22.8l8.8,22.8H24.3z`,transform:`translate(0, 13.6)`})})}function qm({className:e}){return(0,J.jsx)(`svg`,{viewBox:`-1 -1 26 26`,fill:`currentColor`,className:e,"aria-label":`OpenAI`,children:(0,J.jsx)(`path`,{d:`M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z`})})}function Jm({className:e}){return(0,J.jsx)(`svg`,{viewBox:`0 0 588.42 568.88`,fill:`currentColor`,className:e,"aria-label":`Pi`,children:(0,J.jsx)(`path`,{d:`M 10.499686,177.03840 L 31.174931,178.56990 C 52.615925,154.32116 61.039171,82.595924 187.38789,96.634671 C 182.79339,403.95560 48.021426,436.37234 56.444675,499.41907 C 59.507674,535.15406 87.840417,557.10556 118.47041,558.38181 C 215.21014,555.06356 210.87089,424.63084 240.99038,95.868921 L 365.80760,95.868921 C 359.17110,211.75239 341.04836,327.63586 339.00636,441.22208 C 340.53786,516.77606 386.48285,557.10556 446.97708,557.61606 C 546.52456,560.93431 577.92030,444.79558 577.92030,395.27709 L 556.47931,395.27710 C 554.43731,436.11709 534.78306,465.47083 492.92207,467.25758 C 378.82535,468.78908 441.61683,266.63113 442.38258,97.400421 L 577.92030,98.166171 L 577.15455,11.636437 C 13.807491,8.9075799 85.312284,-2.1366151 10.499686,177.03840 z`})})}var Ym=[[`claude`,Km],[`codex`,qm],[`pi`,Jm]];function Xm({agentType:e,command:t,className:n=``}){let r=(e||t?.split(` `)[0]||``).toLowerCase();for(let[e,t]of Ym)if(r.startsWith(e))return(0,J.jsx)(t,{className:n});return(0,J.jsx)(Le,{className:n})}var Zm=360;function Qm(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}function $m(e){return{"--badge-hue":`${Qm(e)%Zm}`}}function eh({name:e,fullPath:t,className:n=``}){let r=$m(e);return(0,J.jsx)(`span`,{className:`project-badge inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none ${n}`,style:r,title:t,children:e})}var th=(0,x.memo)(function({session:e,showSessionIdPrefix:t,showProjectName:n,showLastUserMessage:r,onResume:i,onPreview:a}){let o=jm(e.lastActivityAt),s=Mm(e.projectPath),c=e.displayName||s||e.sessionId.slice(0,8),l=n&&!!s,u=r&&!!e.lastUserMessage,d=t?Pm(e.sessionId):``,f=(0,x.useRef)(null),[p,m]=(0,x.useState)(null);return(0,x.useEffect)(()=>{if(!p)return;let e=e=>{f.current&&!f.current.contains(e.target)&&m(null)},t=e=>{e.key===`Escape`&&m(null)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[p]),(0,J.jsxs)(`div`,{className:`group relative cursor-pointer px-3 py-2 hover:bg-hover`,role:`button`,tabIndex:0,title:`Click to preview`,onClick:()=>a(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e))},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),m({x:e.clientX,y:e.clientY})},children:[(0,J.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-muted opacity-0 hover:text-primary group-hover:opacity-100`,title:`Wake directly`,onClick:t=>{t.stopPropagation(),i(e.sessionId)},children:`▶`}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-2.5 group-hover:pr-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Xm,{agentType:e.agentType,className:`h-3.5 w-3.5 shrink-0 text-muted`}),(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-primary`,children:c}),e.lastResumeError&&(0,J.jsx)(q,{className:`h-3 w-3 shrink-0 text-amber-500`,"aria-label":`Wake failed`,title:`Last wake failed: ${e.lastResumeError}`}),d&&(0,J.jsx)(`span`,{className:`shrink-0 text-[11px] font-mono text-muted`,title:e.sessionId,children:d}),(0,J.jsx)(`span`,{className:`ml-1 w-8 shrink-0 text-right text-xs tabular-nums text-muted`,children:o})]}),(l||u)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pl-[1.375rem]`,children:[l&&(0,J.jsx)(eh,{name:s,fullPath:e.projectPath}),u&&(0,J.jsxs)(`span`,{className:`truncate text-xs italic text-muted`,children:[`"`,e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+`…`:e.lastUserMessage,`"`]})]})]}),p&&(0,J.jsx)(`div`,{ref:f,className:`fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1`,style:{left:p.x,top:p.y},role:`menu`,children:e.logFilePath&&(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),m(null),e.logFilePath&&Fm(e.logFilePath)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:e.logFilePath,children:[(0,J.jsx)(he,{width:14,height:14}),`Copy Log Path`]})})]})});function nh({name:e,className:t=``}){let n=$m(`host:${e}`);return(0,J.jsx)(`span`,{className:`inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium uppercase leading-none tracking-wide ${t}`,style:n,title:e,children:e})}function rh({hosts:e,selectedHosts:t,onSelect:n,statuses:r=[]}){let[i,a]=(0,x.useState)(!1),o=(0,x.useId)(),s=(0,x.useRef)(null),c=(0,x.useMemo)(()=>new Set(t),[t]),l=(0,x.useMemo)(()=>new Map(r.map(e=>[e.host,e])),[r]),u=(0,x.useMemo)(()=>t.length===0?`All Hosts`:t.join(`, `),[t]),d=(0,x.useMemo)(()=>t.length===0?`All Hosts`:t.length===1?t[0]:`${t.length} hosts`,[t]);(0,x.useEffect)(()=>{if(!i||typeof document>`u`||!document.addEventListener||!document.removeEventListener)return;let e=e=>{let t=e.target;t&&s.current?.contains(t)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e,{passive:!0}),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[i]);let f=t=>{let r=new Set(c);r.has(t)?r.delete(t):r.add(t),n(e.filter(e=>r.has(e)))};return(0,J.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":i,"aria-controls":o,"aria-label":`Filter by host`,onClick:()=>a(e=>!e),className:`flex h-6 max-w-[9rem] items-center gap-1.5 rounded border border-border bg-base px-2 text-[11px] text-primary hover:bg-hover focus:border-accent focus:outline-none`,title:u,children:[(0,J.jsx)(je,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`truncate leading-none`,children:d}),(0,J.jsx)(re,{className:`h-3 w-3 shrink-0 text-muted`})]}),i&&(0,J.jsxs)(`div`,{id:o,role:`menu`,className:`absolute left-0 z-20 mt-1 w-48 max-w-[calc(100vw-1.5rem)] rounded border border-border bg-surface p-2 text-xs shadow-lg`,children:[(0,J.jsxs)(`label`,{role:`menuitemcheckbox`,"aria-checked":t.length===0,className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:t.length===0,onChange:()=>n([]),className:`h-3.5 w-3.5 accent-approval`}),(0,J.jsx)(`span`,{children:`All Hosts`})]}),(0,J.jsx)(`div`,{className:`my-2 h-px bg-border`}),e.length===0?(0,J.jsx)(`div`,{className:`px-2 py-1 text-muted`,children:`No hosts`}):(0,J.jsx)(`div`,{className:`max-h-48 overflow-y-auto pr-1`,children:e.map(e=>{let t=l.get(e),n=t?!t.ok:!1;return(0,J.jsxs)(`label`,{role:`menuitemcheckbox`,"aria-checked":c.has(e),className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,title:t?.error?`${e}: ${t.error}`:e,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:c.has(e),onChange:()=>f(e),className:`h-3.5 w-3.5 accent-approval`}),(0,J.jsx)(`span`,{className:`truncate`,children:e}),n&&(0,J.jsx)(`span`,{className:`ml-auto text-[10px] uppercase text-danger`,children:`offline`})]},e)})})]})]})}function ih({projects:e,selectedProjects:t,onSelect:n,hasHiddenPermissions:r}){let[i,a]=(0,x.useState)(!1),o=(0,x.useId)(),s=(0,x.useRef)(null),c=(0,x.useMemo)(()=>Nm(e),[e]),l=(0,x.useMemo)(()=>new Set(t),[t]),u=r&&t.length>0,d=(0,x.useMemo)(()=>t.length===0?`All Projects`:t.map(e=>c.get(e)??Mm(e)??e).join(`, `),[c,t]),f=(0,x.useMemo)(()=>{if(t.length===0)return`All Projects`;if(t.length===1){let e=t[0];return c.get(e)??Mm(e)??e}return`${t.length} projects`},[c,t]);(0,x.useEffect)(()=>{if(!i||typeof document>`u`||!document.addEventListener||!document.removeEventListener)return;let e=e=>{let t=e.target;t&&s.current?.contains(t)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e,{passive:!0}),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[i]);let p=t=>{let r=new Set(l);r.has(t)?r.delete(t):r.add(t),n(e.filter(e=>r.has(e)))};return(0,J.jsxs)(`div`,{ref:s,className:`relative`,children:[(0,J.jsxs)(`button`,{type:`button`,"aria-haspopup":`menu`,"aria-expanded":i,"aria-controls":o,"aria-label":`Filter by project`,onClick:()=>a(e=>!e),className:`flex h-6 max-w-[11rem] items-center gap-1.5 rounded border border-border bg-base px-2 text-[11px] text-primary hover:bg-hover focus:border-accent focus:outline-none`,title:d,children:[(0,J.jsx)(_e,{className:`h-3.5 w-3.5 shrink-0`}),(0,J.jsx)(`span`,{className:`truncate leading-none`,children:f}),(0,J.jsx)(re,{className:`h-3 w-3 shrink-0 text-muted`})]}),i&&(0,J.jsxs)(`div`,{id:o,role:`menu`,className:`absolute left-0 z-20 mt-1 w-60 max-w-[calc(100vw-1.5rem)] rounded border border-border bg-surface p-2 text-xs shadow-lg`,children:[(0,J.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:t.length===0,onChange:()=>n([]),className:`h-3.5 w-3.5 accent-approval`}),(0,J.jsx)(`span`,{children:`All Projects`})]}),(0,J.jsx)(`div`,{className:`my-2 h-px bg-border`}),e.length===0?(0,J.jsx)(`div`,{className:`px-2 py-1 text-muted`,children:`No projects`}):(0,J.jsx)(`div`,{className:`max-h-48 overflow-y-auto pr-1`,children:e.map(e=>{let t=c.get(e)??Mm(e)??e;return(0,J.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover`,title:e,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:l.has(e),onChange:()=>p(e),className:`h-3.5 w-3.5 accent-approval`}),(0,J.jsx)(`span`,{className:`truncate`,children:t})]},e)})})]}),u&&(0,J.jsx)(`button`,{type:`button`,className:`absolute -right-1 -top-1 h-2 w-2 rounded-full bg-approval pulse-approval ring-2 ring-elevated`,title:`Hidden sessions need attention`,"aria-label":`Clear project filters`,onClick:e=>{e.stopPropagation(),n([])},children:(0,J.jsx)(`span`,{className:`sr-only`,children:`Clear project filters`})})]})}var ah=new Set([`tool_result`,`custom_tool_call_output`]),oh=new Set([`text`,`input_text`,`output_text`]);function sh(e){return!e||typeof e!=`object`?null:e}function ch(e){return typeof e==`string`?e:null}function lh(e){return e===`user`?`user`:e===`assistant`?`assistant`:e===`system`||e===`developer`?`system`:e===`tool`?`tool`:`other`}function uh(e){let t=ch(e.type)??``,n=sh(e.payload),r=ch(n?.type)??``,i=ch(e.source)??ch(n?.source)??``,a=ch(e.agent)??``;return i.toLowerCase()===`pi`||a.toLowerCase()===`pi`?`pi`:t===`response_item`||t===`event_msg`?`codex`:t===`tool_use`||t===`result`||t===`user`||t===`assistant`||t===`system`?`claude`:r===`user_message`||r===`assistant_message`?`codex`:`unknown`}function dh(e){let t=ch(sh(e.payload)?.type);return{family:uh(e),rawType:ch(e.type)??`unknown`,...t?{payloadType:t}:{}}}function fh(e){if(!e)return[];if(typeof e==`string`)return e.trim()?[e]:[];if(Array.isArray(e)){let t=[];for(let n of e){if(typeof n==`string`){n.trim()&&t.push(n);continue}let e=sh(n);if(!e)continue;let r=ch(e.type);if(r&&ah.has(r)||r&&!oh.has(r))continue;let i=ch(e.text);i&&i.trim()&&t.push(i)}return t}let t=sh(e);if(t){let e=ch(t.type);if(e&&ah.has(e))return[];let n=ch(t.text);return n&&n.trim()?[n]:[...fh(t.content),...fh(t.message)]}return[]}function ph(e,t){if(e.type!==`response_item`)return[];let n=sh(e.payload);if(!n||n.type!==`message`)return[];let r=lh(n.role);return fh(n.content).map(e=>({kind:`message`,role:r,text:e,source:t}))}function mh(e,t){if(e.type!==`event_msg`)return[];let n=sh(e.payload);if(!n)return[];let r=ch(n.type),i=null;if(r===`user_message`?i=`user`:r===`assistant_message`?i=`assistant`:r===`system_message`?i=`system`:r===`message`&&(i=lh(n.role)),!i||![`user`,`assistant`,`system`].includes(i))return[];let a=Array.from(new Set([...fh(n.message),...fh(n.content),...fh(n.text)]));return a.length===0?[]:a.map(e=>({kind:`message`,role:i,text:e,source:t}))}function hh(e,t){let n=lh(e.type),r=sh(e.message);if(r){let n=lh(r.role??e.type);return[...fh(r.content),...fh(r.text),...fh(r.message)].map(e=>({kind:`message`,role:n,text:e,source:t}))}return[`user`,`assistant`,`system`].includes(n)?[...fh(e.content),...fh(e.text)].map(e=>({kind:`message`,role:n,text:e,source:t})):[]}function gh(e,t){let n=lh(e.role);return[`user`,`assistant`,`system`].includes(n)?[...fh(e.content),...fh(e.message),...fh(e.text)].map(e=>({kind:`message`,role:n,text:e,source:t})):[]}function _h(e,t){let n=ch(e.type),r=ch(e.event);return n!==`tool_use`&&r!==`tool_use`?[]:[{kind:`tool_call`,role:`assistant`,text:`[Tool: ${ch(e.name)??`tool`}]`,source:t}]}function vh(e,t){if(e.type!==`result`)return[];let n=ch(e.result);return!n||!n.trim()?[]:[{kind:`result`,role:`system`,text:n,source:t}]}function yh(e,t){let n=sh(e.payload),r=[...fh(e.message),...fh(e.content),...fh(e.text),...fh(n?.message),...fh(n?.content)];return r.length===0?[]:r.map(e=>({kind:`unknown`,role:`other`,text:e,source:t}))}function bh(e,t){let n=ch(e.type),r=ch(sh(e.payload)?.type);return n&&ah.has(n)||r&&ah.has(r)?[{kind:`tool_result`,role:`tool`,text:``,source:t}]:[]}function xh(e){let t=sh(e);if(!t||t.isMeta===!0)return[];let n=dh(t),r=[...ph(t,n),...mh(t,n),...hh(t,n),..._h(t,n),...vh(t,n),...bh(t,n)];if(r.length>0)return r;let i=gh(t,n);return i.length>0?i:yh(t,n)}function Sh(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);return{parsed:!0,events:xh(e),raw:e}}catch{return{parsed:!1,events:[{kind:`unknown`,role:`other`,text:t,source:{family:`unknown`,rawType:`raw_text`}}],raw:e}}}var Ch=1e4;function wh(e){return e===`user`?`user`:e===`assistant`?`assistant`:e===`system`?`system`:`other`}function Th(e){let t=Sh(e);if(!t)return[];let n=t.events.map(t=>({type:wh(t.role),content:t.text.trim(),raw:e})).filter(e=>e.content.length>0);return n.length>0?n:!t.parsed&&e.trim()?[{type:`other`,content:e.trim(),raw:e}]:[]}function Eh({session:e,className:t=``,onStateChange:n}){let[r,i]=(0,x.useState)(!0),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(!1),d=(0,x.useRef)(null);(0,x.useEffect)(()=>{let t=!1,n=new AbortController,r=setTimeout(()=>n.abort(),Ch);return(async()=>{i(!0),o(null),c(null);try{let r=await fetch(`/api/session-preview/${e.sessionId}`,{signal:n.signal});if(!r.ok){let e=`Failed to load preview (HTTP ${r.status})`;try{let t=await r.json();t?.error&&(e=t.error)}catch{}throw Error(e)}let i=await r.json();t||c(i)}catch(e){if(t)return;n.signal.aborted?o(`Preview timed out`):o(e instanceof Error?e.message:`Failed to load preview`)}finally{t||i(!1)}})(),()=>{t=!0,clearTimeout(r),n.abort()}},[e.sessionId]),(0,x.useEffect)(()=>{n?.({loading:r,error:a})},[a,r,n]),(0,x.useEffect)(()=>{d.current&&s&&(d.current.scrollTop=d.current.scrollHeight)},[s,l]);let f=s?.lines.flatMap(Th).slice(-30)??[];return(0,J.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-elevated ${t}`.trim(),children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between border-b border-border px-4 py-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold text-primary`,children:`Recent Preview`}),(0,J.jsx)(`p`,{className:`text-xs text-muted`,children:`Derived from the saved session log.`})]}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`btn text-xs ${l?`btn-primary`:``}`,children:l?`Parsed`:`Raw`})]}),(0,J.jsxs)(`div`,{ref:d,className:`flex-1 overflow-y-auto p-4 font-mono text-xs`,children:[r&&(0,J.jsx)(`div`,{className:`flex items-center justify-center py-8 text-muted`,children:`Loading preview...`}),a&&(0,J.jsx)(`div`,{className:`flex items-center justify-center py-8 text-danger`,children:a}),s&&!l&&(0,J.jsx)(`div`,{className:`space-y-2`,children:f.length===0?(0,J.jsx)(`div`,{className:`py-8 text-center text-muted`,children:`No readable content found. Try raw view.`}):f.map((e,t)=>(0,J.jsx)(`div`,{className:`rounded px-2 py-1 ${e.type===`user`?`bg-blue-500/10 text-blue-400`:e.type===`assistant`?`bg-emerald-500/10 text-emerald-400`:e.type===`system`?`bg-yellow-500/10 text-yellow-400`:`text-muted`}`,children:(0,J.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:e.content.length>500?`${e.content.slice(0,500)}...`:e.content})},t))}),s&&l&&(0,J.jsx)(`div`,{className:`space-y-1`,children:s.lines.slice(-50).map((e,t)=>(0,J.jsx)(`div`,{className:`whitespace-pre-wrap break-all text-muted`,children:e||` `},t))})]})]})}function Dh({session:e,onClose:t,onResume:n}){let r=(0,x.useRef)(null),[i,a]=(0,x.useState)({loading:!0,error:null}),o=(0,x.useCallback)(()=>{i.loading||n(e.sessionId)},[i.loading,n,e.sessionId]);(0,x.useEffect)(()=>{let e=e=>{e.key===`Escape`?(e.stopPropagation(),t()):e.key===`Enter`&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,t]),(0,x.useEffect)(()=>{r.current?.focus()},[]);let s=e.displayName||Mm(e.projectPath)||e.sessionId.slice(0,8),c=jm(e.lastActivityAt);return(0,J.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`preview-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,J.jsxs)(`div`,{ref:r,tabIndex:-1,className:`flex max-h-[80vh] w-full max-w-2xl flex-col border border-border bg-elevated`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border px-4 py-3`,children:[(0,J.jsx)(Xm,{agentType:e.agentType,className:`h-5 w-5 shrink-0 text-muted`}),(0,J.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,J.jsx)(`h2`,{id:`preview-title`,className:`truncate text-sm font-semibold text-primary`,children:s}),(0,J.jsxs)(`p`,{className:`truncate text-xs text-muted`,title:e.projectPath,children:[Mm(e.projectPath),` · `,c]})]})]}),(0,J.jsx)(Eh,{session:e,className:`m-4 mt-0 flex-1 border-0 bg-transparent`,onStateChange:a}),(0,J.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border px-4 py-3`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:o,className:`btn btn-primary`,disabled:i.loading,children:`Wake`})]})]})})}function Oh({session:e,isSelected:t,showSessionIdPrefix:n,showProjectName:r,showLastUserMessage:i,onSelect:a,onWake:o,onRename:s,onMoveToHistory:c}){let l=jm(e.lastActivityAt),u=Mm(e.projectPath),d=e.displayName||u||e.sessionId.slice(0,8),f=r&&!!u,p=i&&!!e.lastUserMessage,m=n?Pm(e.sessionId):``,h=(0,x.useRef)(null),g=(0,x.useRef)(null),[_,v]=(0,x.useState)(null),[y,b]=(0,x.useState)(!1),[S,C]=(0,x.useState)(d);(0,x.useEffect)(()=>{C(d)},[d]),(0,x.useEffect)(()=>{y&&g.current&&(g.current.focus(),g.current.select())},[y]);let w=()=>{let t=S.trim();t&&t!==d&&s?.(e.sessionId,t),b(!1)};return(0,x.useEffect)(()=>{if(!_)return;let e=e=>{h.current&&!h.current.contains(e.target)&&v(null)},t=e=>{e.key===`Escape`&&v(null)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[_]),(0,J.jsxs)(`div`,{className:`group relative cursor-pointer px-3 py-2 hover:bg-hover ${t?`bg-hover`:``}`,role:`button`,tabIndex:0,"data-testid":`hibernating-session-card`,onClick:()=>a(e.sessionId),onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),v({x:e.clientX,y:e.clientY})},onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),a(e.sessionId))},children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-2.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Xm,{agentType:e.agentType,className:`h-3.5 w-3.5 shrink-0 text-muted`}),y?(0,J.jsx)(`input`,{ref:g,type:`text`,value:S,onChange:e=>C(e.target.value),onBlur:w,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),w()):e.key===`Escape`&&(e.preventDefault(),C(d),b(!1))},onClick:e=>e.stopPropagation(),className:`min-w-0 flex-1 rounded border border-border bg-surface px-1.5 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-primary`,children:d}),(0,J.jsx)(Ce,{className:`h-3 w-3 shrink-0 text-muted`,"aria-label":`Hibernating`,title:`Hibernating`}),e.lastResumeError&&(0,J.jsx)(q,{className:`h-3 w-3 shrink-0 text-amber-500`,"aria-label":`Wake failed`,title:`Last wake failed: ${e.lastResumeError}`}),m&&(0,J.jsx)(`span`,{className:`shrink-0 text-[11px] font-mono text-muted`,title:e.sessionId,children:m}),(0,J.jsx)(`span`,{className:`ml-1 w-8 shrink-0 text-right text-xs tabular-nums text-muted`,children:l})]}),(f||p)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pl-[1.375rem]`,children:[f&&(0,J.jsx)(eh,{name:u,fullPath:e.projectPath}),p&&(0,J.jsxs)(`span`,{className:`line-clamp-2 text-xs italic text-muted`,children:[`"`,e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+`...`:e.lastUserMessage,`"`]})]})]}),_&&(0,J.jsxs)(`div`,{ref:h,className:`fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1`,style:{left:_.x,top:_.y},role:`menu`,children:[o&&(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),o(e.sessionId)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,J.jsx)(De,{width:14,height:14}),`Wake`]}),s&&(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),v(null),b(!0)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,J.jsx)(pe,{width:14,height:14}),`Rename`]}),e.logFilePath&&(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),Fm(e.logFilePath)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:e.logFilePath,children:[(0,J.jsx)(he,{width:14,height:14}),`Copy Log Path`]}),c&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),v(null),c(e.sessionId)},className:`w-full px-3 py-2 text-left text-sm text-danger hover:bg-danger/10 flex items-center gap-2`,role:`menuitem`,children:[(0,J.jsx)(ze,{width:14,height:14}),`Move to History`]})]})]})]})}var kh={working:`bg-green-500/20 text-green-600`,waiting:`bg-zinc-500/20 text-zinc-400`,permission:`bg-amber-500/20 text-amber-600`,unknown:`bg-zinc-500/20 text-zinc-400`};function Ah(){let[,e]=(0,x.useState)(0);(0,x.useEffect)(()=>{let t=setInterval(()=>e(e=>e+1),3e4);return()=>clearInterval(t)},[])}function jh({sessions:e,hibernatingSessions:t=[],historySessions:n=[],selectedSessionId:r,selectedHibernatingSessionId:i=null,loading:a,error:o,onSelect:s,onSelectHibernating:c,onRename:l,onResume:u,onHibernate:d,onKill:f,onDuplicate:p,onMoveToHistory:m,onNewSession:h}){Ah();let g=(0,x.useMemo)(()=>typeof navigator>`u`?!1:/^((?!chrome|android).)*safari/i.test(navigator.userAgent),[]),[_,v]=(0,x.useState)(null),y=G(e=>e.historySessionsExpanded),b=G(e=>e.setHistorySessionsExpanded),S=G(e=>e.hibernatingSessionsExpanded),C=G(e=>e.setHibernatingSessionsExpanded),[w,T]=(0,x.useState)(null),[E,D]=(0,x.useState)(20),O=ld(),k=g&&!O,A=(0,x.useMemo)(()=>[...t,...n],[t,n]);(0,x.useEffect)(()=>{y||D(20)},[y]);let[j,M]=Wm(e.length,200),[N,P]=Wm(n.length,200,!0),F=(0,x.useRef)(new Set(e.map(e=>e.id))),I=(0,x.useRef)(new Set([...t,...n].map(e=>e.sessionId))),[L,R]=(0,x.useState)(new Set);(0,x.useEffect)(()=>{let r=new Set(e.map(e=>e.id)),i=new Set([...t,...n].map(e=>e.sessionId)),a=new Set;for(let e of r)F.current.has(e)||a.add(e);for(let t of e){let e=t.agentSessionId?.trim();e&&I.current.has(e)&&!i.has(e)&&a.add(t.id)}F.current=r,I.current=i,a.size>0&&R(a)},[e,t,n]),(0,x.useEffect)(()=>{if(L.size===0)return;let e=setTimeout(()=>R(new Set),500);return()=>clearTimeout(e)},[L]);let z=Ge(Ue(G(e=>e.shortcutModifier))),B=G(e=>e.sessionSortMode),V=G(e=>e.setSessionSortMode),H=G(e=>e.sessionSortDirection),U=G(e=>e.manualSessionOrder),W=G(e=>e.setManualSessionOrder),ee=G(e=>e.showProjectName),K=G(e=>e.showLastUserMessage),te=G(e=>e.showSessionIdPrefix),q=G(e=>e.projectFilters),ne=G(e=>e.setProjectFilters),ie=G(e=>e.hostFilters),oe=G(e=>e.setHostFilters),se=Um(e=>e.exitingSessions),ce=Um(e=>e.clearExitingSession),le=Um(e=>e.hostStatuses),ue=Um(e=>e.remoteAllowControl);Gm(e,se,ce,200),(0,x.useEffect)(()=>{if(U.length===0)return;let t=new Set;for(let n of e)t.add(Em(n)),t.add(n.id);for(let e of A)t.add(e.sessionId);let n=U.filter(e=>t.has(e));n.length!==U.length&&W(n)},[e,A,U,W]);let de=(0,x.useMemo)(()=>Om(e,{mode:B,direction:H,manualOrder:U}),[e,B,H,U]),fe=(0,x.useMemo)(()=>km(e,A),[e,A]),pe=(0,x.useMemo)(()=>{let t=Am(e,A),n=le.map(e=>e.host),r=new Set,i=[];for(let e of n)!e||r.has(e)||(r.add(e),i.push(e));for(let e of t)!e||r.has(e)||(r.add(e),i.push(e));return i},[e,A,le]),me=(0,x.useMemo)(()=>pe.length>1,[pe]),he=(0,x.useMemo)(()=>{let e=de;return q.length>0&&(e=e.filter(e=>q.includes(e.projectPath))),ie.length>0&&(e=e.filter(e=>ie.includes(e.host??``))),e},[de,q,ie]),ge=(0,x.useMemo)(()=>`${q.length===0?`all-projects`:q.join(`|`)}::${ie.length===0?`all-hosts`:ie.join(`|`)}`,[q,ie]),_e=(0,x.useRef)(new Set(he.map(e=>e.id))),[ve,ye]=(0,x.useState)(new Set);(0,x.useEffect)(()=>{let e=new Set(he.map(e=>e.id)),t=new Set;for(let n of e)_e.current.has(n)||L.has(n)||t.add(n);_e.current=e,t.size>0&&ye(t)},[he,L]),(0,x.useEffect)(()=>{if(ve.size===0)return;let e=setTimeout(()=>ye(new Set),500);return()=>clearTimeout(e)},[ve]);let be=(0,x.useMemo)(()=>{let e=t;return q.length>0&&(e=e.filter(e=>q.includes(e.projectPath))),ie.length>0&&(e=e.filter(e=>ie.includes(e.host??``))),e},[t,q,ie]),xe=(0,x.useMemo)(()=>{let e=n;return q.length>0&&(e=e.filter(e=>q.includes(e.projectPath))),ie.length>0&&(e=e.filter(e=>ie.includes(e.host??``))),e},[n,q,ie]),Se=(0,x.useMemo)(()=>{if(q.length===0)return 0;let t=new Set(q);return e.filter(e=>!t.has(e.projectPath)&&e.status===`permission`).length},[e,q]);(0,x.useEffect)(()=>{if(q.length===0||fe.length===0)return;let e=new Set(fe),t=q.filter(t=>e.has(t));t.length!==q.length&&ne(t)},[q,fe,ne]),(0,x.useEffect)(()=>{if(ie.length===0||pe.length===0)return;let e=new Set(pe),t=ie.filter(t=>e.has(t));t.length!==ie.length&&oe(t)},[ie,pe,oe]);let Ce=Zd(Xd(Qf,{activationConstraint:{distance:8}})),[we,Te]=(0,x.useState)(null),[Ee,De]=(0,x.useState)(null),[Oe,Ae]=(0,x.useState)(!1),je=(0,x.useCallback)(e=>{Te(e.active.id),Ae(!0)},[]),Me=(0,x.useCallback)(e=>{De(e.over?.id)},[]),Ne=(0,x.useCallback)(e=>{let{active:t,over:n}=e;if(Te(null),De(null),!n||t.id===n.id){setTimeout(()=>Ae(!1),100);return}let r=he.findIndex(e=>e.id===t.id),i=he.findIndex(e=>e.id===n.id);if(r===-1||i===-1){setTimeout(()=>Ae(!1),100);return}let a=he.map(e=>Em(e)),[o]=a.splice(r,1);a.splice(i,0,o);let s=de.map(e=>Em(e)),c=new Set(a),l=0,u=s.map(e=>{if(!c.has(e))return e;let t=a[l];return l+=1,t});B!==`manual`&&V(`manual`),W(u),setTimeout(()=>Ae(!1),100)},[he,de,B,V,W]),Pe=(0,x.useCallback)(()=>{Te(null),De(null),setTimeout(()=>Ae(!1),100)},[]);(0,x.useEffect)(()=>{if(!we&&!Ee)return;let e=new Set(he.map(e=>e.id)),t=!1;we&&!e.has(we)&&(Te(null),t=!0),Ee&&!e.has(Ee)&&(De(null),t=!0),t&&Ae(!1)},[he,we,Ee]);let Fe=(e,t)=>{l(e,t),v(null)};return(0,J.jsxs)(`aside`,{className:`flex min-h-0 flex-1 flex-col border-r border-border bg-elevated`,children:[o&&(0,J.jsx)(`div`,{className:`shrink-0 border-b border-danger/30 bg-danger/10 px-3 py-2 text-xs text-danger`,children:o}),(0,J.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,J.jsxs)(`div`,{className:`sticky top-0 z-10 flex h-10 items-center justify-start gap-2 border-b border-border bg-elevated px-3`,children:[me&&(0,J.jsx)(rh,{hosts:pe,selectedHosts:ie,onSelect:oe,statuses:le}),(0,J.jsx)(ih,{projects:fe,selectedProjects:q,onSelect:ne,hasHiddenPermissions:Se>0})]}),a?(0,J.jsx)(`div`,{className:`space-y-1 p-2`,children:[0,1,2].map(e=>(0,J.jsx)(`div`,{className:`h-14 animate-pulse rounded bg-surface`},e))}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 text-xs font-medium uppercase tracking-wider text-muted`,children:[(0,J.jsx)(`span`,{children:`Active`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[he.length===0&&h&&(0,J.jsxs)(`button`,{type:`button`,onClick:h,className:`flex items-center gap-1 rounded px-1.5 py-0.5 text-[11px] font-medium normal-case tracking-normal text-accent hover:bg-hover`,title:`Start a new session`,children:[(0,J.jsx)(ke,{className:`h-3.5 w-3.5`}),`New session`]}),(0,J.jsx)(cd.span,{className:`w-8 text-right text-xs`,animate:j&&!O?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:M,children:he.length})]})]}),he.length>0&&(0,J.jsx)(Yp,{sensors:Ce,collisionDetection:af,onDragStart:je,onDragOver:Me,onDragEnd:Ne,onDragCancel:Pe,children:(0,J.jsx)(hm,{items:he.map(e=>e.id),strategy:dm,children:(0,J.jsx)(`div`,{children:(0,J.jsx)(Ya,{initial:!1,mode:k?`sync`:`popLayout`,children:he.map((e,t)=>{let n=L.has(e.id),i=ve.has(e.id),a=e.remote===!0,o=e.source===`managed`,c=!a||ue&&o,l=!!(d&&!a&&o&&e.agentSessionId?.trim()),u=we?he.findIndex(e=>e.id===we):-1,m=Ee===e.id&&we!==e.id?u>t?`above`:`below`:null;return(0,J.jsx)(Mh,{session:e,isNew:n||i,exitDuration:200,prefersReducedMotion:O,useSafariLayoutFallback:k,layoutAnimationsDisabled:Oe,isSelected:e.id===r,isEditing:e.id===_,showSessionIdPrefix:te,showProjectName:ee,showLastUserMessage:K,showHostInfo:me,dropIndicator:m,onSelect:()=>s(e.id),onStartEdit:c?()=>v(e.id):void 0,onCancelEdit:()=>v(null),onRename:t=>Fe(e.id,t),onHibernate:l?()=>d?.(e.agentSessionId.trim()):void 0,onKill:f&&c?()=>f(e.id,`session_list_context_menu`):void 0,onDuplicate:p&&c?()=>p(e.id):void 0},e.id)})})},ge)})}),be.length>0&&(0,J.jsxs)(`div`,{className:`border-t border-border`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>C(!S),className:`flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-muted hover:text-primary`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[S?(0,J.jsx)(re,{className:`h-4 w-4`}):(0,J.jsx)(ae,{className:`h-4 w-4`}),`Hibernating`]}),(0,J.jsx)(`span`,{className:`w-8 text-right text-xs text-muted`,children:be.length})]}),S&&(0,J.jsx)(`div`,{className:`py-1`,children:be.map(e=>(0,J.jsx)(Oh,{session:e,isSelected:i===e.sessionId,showSessionIdPrefix:te,showProjectName:ee,showLastUserMessage:K,onSelect:e=>c?.(e),onWake:e=>u?.(e),onRename:(e,t)=>Fe(e,t),onMoveToHistory:m},e.sessionId))})]})]}),xe.length>0&&(0,J.jsxs)(`div`,{className:`border-t border-border`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>b(!y),className:`flex w-full items-center justify-between px-3 py-2 text-left text-xs font-medium uppercase tracking-wider text-muted hover:text-primary`,children:[(0,J.jsxs)(`span`,{className:`flex items-center gap-2`,children:[y?(0,J.jsx)(re,{className:`h-4 w-4`}):(0,J.jsx)(ae,{className:`h-4 w-4`}),`History`]}),(0,J.jsx)(cd.span,{className:`w-8 text-right text-xs`,animate:N&&!O?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:P,children:xe.length})]}),y&&(0,J.jsxs)(`div`,{className:`py-1`,children:[xe.slice(0,E).map(e=>(0,J.jsx)(th,{session:e,showSessionIdPrefix:te,showProjectName:ee,showLastUserMessage:K,onResume:e=>u?.(e),onPreview:T},e.sessionId)),xe.length>E&&(0,J.jsxs)(`button`,{type:`button`,onClick:()=>D(e=>e+20),className:`w-full px-3 py-2 text-center text-xs text-muted hover:text-primary hover:bg-hover`,children:[`Show more (`,xe.length-E,` remaining)`]})]})]})]}),(0,J.jsx)(`div`,{className:`hidden shrink-0 border-t border-border px-3 py-2 md:block`,children:(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-0.5 text-[10px] text-muted`,children:[(0,J.jsxs)(`span`,{children:[z,`[ ] nav`]}),(0,J.jsxs)(`span`,{children:[z,`N new`]}),(0,J.jsxs)(`span`,{children:[z,`X kill`]})]})}),w&&(0,J.jsx)(Dh,{session:w,onClose:()=>T(null),onResume:e=>{T(null),u?.(e)}})]})}var Mh=(0,x.forwardRef)(function({session:e,isNew:t,exitDuration:n,prefersReducedMotion:r,useSafariLayoutFallback:i,layoutAnimationsDisabled:a,isSelected:o,isEditing:s,showSessionIdPrefix:c,showProjectName:l,showLastUserMessage:u,showHostInfo:d,dropIndicator:f,onSelect:p,onStartEdit:m,onCancelEdit:h,onRename:g,onHibernate:_,onKill:v,onDuplicate:y},b){let{attributes:S,listeners:C,setNodeRef:w,transform:T,transition:E,isDragging:D}=Cm({id:e.id,animateLayoutChanges:({isSorting:e,wasDragging:t})=>e||t}),O=Fd.Transform.toString(T),k={...r&&O?{transform:O,transition:E}:{},zIndex:D?10:void 0,opacity:D?.9:void 0},A=(0,x.useCallback)(e=>{w(e),typeof b==`function`?b(e):b&&(b.current=e)},[w,b]);return(0,J.jsxs)(cd.div,{ref:A,style:{...k,overflow:`hidden`},className:`relative`,layout:!r&&!D&&!a&&!t?!i:!1,transformTemplate:(e,t)=>Im({useSafariLayoutFallback:i,isDragging:D,dndTransform:O,generatedTransform:t}),initial:r||!t?!1:i?{opacity:0}:{opacity:0,scale:.97},animate:r?{opacity:1}:t?i?{opacity:1}:{opacity:1,scale:[1.02,.99,1]}:{opacity:1,scale:1},exit:r?{opacity:0}:i?{opacity:0,height:0}:{opacity:0,height:0,scale:.97},transition:r?{duration:0}:i?{opacity:{duration:n/1e3},height:{duration:n/1e3,ease:`easeOut`}}:{layout:{type:`spring`,stiffness:500,damping:35},opacity:{duration:n/1e3},scale:{duration:n/1e3,ease:[.34,1.56,.64,1]},height:{duration:n/1e3,ease:`easeOut`}},...S,...C,children:[f===`above`&&(0,J.jsx)(`div`,{className:`absolute -top-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent`}),(0,J.jsx)(Nh,{session:e,isSelected:o,isEditing:s,showSessionIdPrefix:c,showProjectName:l,showLastUserMessage:u,showHostInfo:d,isDragging:D,onSelect:p,onStartEdit:m,onCancelEdit:h,onRename:g,onHibernate:_,onKill:v,onDuplicate:y}),f===`below`&&(0,J.jsx)(`div`,{className:`absolute -bottom-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent`})]})});Mh.displayName=`SortableSessionItem`;function Nh({session:e,isSelected:t,isEditing:n,showSessionIdPrefix:r,showProjectName:i,showLastUserMessage:a,showHostInfo:o,isDragging:s=!1,onSelect:c,onStartEdit:l,onCancelEdit:u,onRename:d,onHibernate:f,onKill:p,onDuplicate:m}){let h=jm(e.lastActivity),g=(0,x.useRef)(null),_=(0,x.useRef)(null),v=e.agentSessionName?.trim()||e.name?.trim()||e.id,[y,b]=(0,x.useState)(v),S=(0,x.useRef)(null),[C,w]=(0,x.useState)(null),T=Mm(e.projectPath),E=e.host?.trim(),D=e.status===`permission`,O=e.agentSessionId?.trim(),k=r&&O?Pm(O):``,A=i&&!!T,j=o&&!!E,M=a&&!!e.lastUserMessage,N=(0,x.useRef)(e.status),[P,F]=(0,x.useState)(!1);(0,x.useEffect)(()=>{let t=N.current,n=e.status;t===`working`&&n===`waiting`?F(!0):N.current=n},[e.status]);let I=()=>{F(!1),N.current=e.status};(0,x.useEffect)(()=>{n&&g.current&&(g.current.focus(),g.current.select())},[n]),(0,x.useEffect)(()=>{b(v)},[v]);let L=()=>{let e=y.trim();e&&e!==v?d(e):u()},R=e=>{e.key===`Enter`?(e.preventDefault(),L()):e.key===`Escape`&&(e.preventDefault(),b(v),u())},z=(0,x.useRef)(null),B=e=>{if(s)return;let t=e.touches[0];z.current={x:t.clientX,y:t.clientY},S.current=setTimeout(()=>{z.current&&w(z.current)},500)},V=()=>{S.current&&=(clearTimeout(S.current),null)};return(0,x.useEffect)(()=>{if(!C)return;let e=e=>{_.current&&!_.current.contains(e.target)&&w(null)},t=e=>{e.key===`Escape`&&w(null)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[C]),(0,J.jsxs)(`div`,{className:`session-row group cursor-pointer select-none px-3 py-2 ${t?`selected`:``} ${s?`cursor-grabbing shadow-lg ring-1 ring-accent/30 bg-elevated`:`cursor-grab`}`,role:`button`,tabIndex:0,"data-testid":`session-card`,"data-session-id":e.id,onClick:s?void 0:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&c()},onContextMenu:e=>{e.preventDefault(),e.stopPropagation(),w({x:e.clientX,y:e.clientY})},onTouchStart:B,onTouchEnd:V,onTouchCancel:V,children:[(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5 pl-0.5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(Xm,{agentType:e.agentType,command:e.command,className:`h-3.5 w-3.5 shrink-0 text-muted`}),n?(0,J.jsx)(`input`,{ref:g,type:`text`,value:y,onChange:e=>b(e.target.value),onBlur:L,onKeyDown:R,onClick:e=>e.stopPropagation(),className:`min-w-0 flex-1 rounded border border-border bg-surface px-1.5 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,J.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-primary`,children:v}),k&&(0,J.jsx)(`span`,{className:`shrink-0 text-[11px] font-mono text-muted`,title:O,children:k}),D?(0,J.jsx)(`span`,{className:`ml-1 flex shrink-0 items-center justify-center rounded-full px-1.5 py-0.5 ${kh[e.status]} pulse-approval`,onAnimationEnd:I,children:(0,J.jsx)(ye,{className:`h-3 w-3`,"aria-label":`Needs input`})}):(0,J.jsx)(`span`,{className:`ml-1 shrink-0 rounded-full px-1.5 py-0.5 text-right text-xs tabular-nums ${kh[e.status]}${P?` pulse-complete`:``}`,onAnimationEnd:I,children:h})]}),(A||j||M)&&(0,J.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pl-[1.375rem]`,children:[j&&(0,J.jsx)(nh,{name:E}),A&&(0,J.jsx)(eh,{name:T,fullPath:e.projectPath}),M&&(0,J.jsxs)(`span`,{className:`line-clamp-2 text-xs italic text-muted`,children:[`"`,e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+`…`:e.lastUserMessage,`"`]})]})]}),C&&(0,J.jsxs)(`div`,{ref:_,className:`fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1`,style:{left:C.x,top:C.y},role:`menu`,children:[l&&(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),l()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,children:[(0,J.jsx)(pe,{width:14,height:14}),`Rename`]}),m&&(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),m()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:`Create a copy in a new tmux window`,children:[(0,J.jsx)(se,{width:14,height:14}),`Duplicate`]}),f&&(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),f()},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:`Close the live window and keep this session ready to wake`,children:[(0,J.jsx)(Ce,{width:14,height:14}),`Hibernate`]}),e.logFilePath&&(0,J.jsxs)(`button`,{onClick:t=>{t.stopPropagation(),w(null),e.logFilePath&&Fm(e.logFilePath)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,role:`menuitem`,title:e.logFilePath,children:[(0,J.jsx)(he,{width:14,height:14}),`Copy Log Path`]}),p&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`my-1 border-t border-border`}),(0,J.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),w(null),p()},className:`w-full px-3 py-2 text-left text-sm text-danger hover:bg-danger/10 flex items-center gap-2`,role:`menuitem`,children:[(0,J.jsx)(ze,{width:14,height:14}),`Kill Session`]})]})]})]})}var Ph={debug:0,info:1,warn:2,error:3},Fh=`info`;function Ih(e){let t=e.toLowerCase();t in Ph&&(Fh=t)}function Z(e,t,n=`debug`){if(!(Ph[n]<Ph[Fh]))try{fetch(`/api/client-log`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({event:e,data:t,level:n})}).catch(()=>{})}catch{}}var Lh=s(((e,t)=>{(function(n,r){if(typeof e==`object`&&typeof t==`object`)t.exports=r();else if(typeof define==`function`&&define.amd)define([],r);else{var i=r();for(var a in i)(typeof e==`object`?e:n)[a]=i[a]}})(globalThis,(()=>(()=>{var e={4567:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.AccessibilityManager=void 0;let a=n(9042),o=n(9924),s=n(844),c=n(4725),l=n(2585),u=n(3656),d=t.AccessibilityManager=class extends s.Disposable{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=``,this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=this._coreBrowserService.mainDocument.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._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new o.TimeBasedDebouncer(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(`
21
21
  `)))),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((0,u.addDisposableDomListener)(document,`selectionchange`,(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,s.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(` `)}_handleChar(e){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
22
22
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=a.tooMuchOutput)))}_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.innerText=`\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._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=document.getSelection();if(!e)return;if(e.isCollapsed)return void(this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection());if(!e.anchorNode||!e.focusNode)return void console.error(`anchorNode and/or focusNode are null`);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){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}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])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}};t.AccessibilityManager=d=r([i(1,l.IInstantiationService),i(2,c.ICoreBrowserService),i(3,c.IRenderService)],d)},3614:(e,t)=>{function n(e){return e.replace(/\r?\n/g,`\r`)}function r(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function i(e,t,i,a){e=r(e=n(e),i.decPrivateModes.bracketedPasteMode&&!0!==a.rawOptions.ignoreBracketedPasteMode),i.triggerDataEvent(e,!0),t.value=``}function a(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}Object.defineProperty(t,`__esModule`,{value:!0}),t.rightClickHandler=t.moveTextAreaUnderMouseCursor=t.paste=t.handlePasteEvent=t.copyHandler=t.bracketTextForPaste=t.prepareTextForTerminal=void 0,t.prepareTextForTerminal=n,t.bracketTextForPaste=r,t.copyHandler=function(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()},t.handlePasteEvent=function(e,t,n,r){e.stopPropagation(),e.clipboardData&&i(e.clipboardData.getData(`text/plain`),t,n,r)},t.paste=i,t.moveTextAreaUnderMouseCursor=a,t.rightClickHandler=function(e,t,n,r,i){a(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}},7239:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.ColorContrastCache=void 0;let r=n(1505);t.ColorContrastCache=class{constructor(){this._color=new r.TwoKeyMap,this._css=new r.TwoKeyMap}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()}}},3656:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.addDisposableDomListener=void 0,t.addDisposableDomListener=function(e,t,n,r){e.addEventListener(t,n,r);let i=!1;return{dispose:()=>{i||(i=!0,e.removeEventListener(t,n,r))}}}},3551:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.Linkifier=void 0;let a=n(3656),o=n(8460),s=n(844),c=n(2585),l=n(4725),u=t.Linkifier=class extends s.Disposable{get currentLink(){return this._currentLink}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 o.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new o.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,s.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,s.toDisposable)((()=>{this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,a.addDisposableDomListener)(this._element,`mouseleave`,(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,a.addDisposableDomListener)(this._element,`mousemove`,this._handleMouseMove.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,`mousedown`,this._handleMouseDown.bind(this))),this.register((0,a.addDisposableDomListener)(this._element,`mouseup`,this._handleMouseUp.bind(this)))}_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){if(this._activeLine!==e.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(e,!1),void(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===this._currentLink&&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,(0,s.disposeArray)(this._linkCacheDisposables))}_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}}};t.Linkifier=u=r([i(1,l.IMouseService),i(2,l.IRenderService),i(3,c.IBufferService),i(4,l.ILinkProviderService)],u)},9042:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.tooMuchOutput=t.promptLabel=void 0,t.promptLabel=`Terminal input`,t.tooMuchOutput=`Too much output to announce, navigate to rows manually to read`},3730:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.OscLinkProvider=void 0;let a=n(511),o=n(2585),s=t.OscLinkProvider=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n)return void t(void 0);let r=[],i=this._optionsService.rawOptions.linkHandler,o=new a.CellData,s=n.getTrimmedLength(),l=-1,u=-1,d=!1;for(let t=0;t<s;t++)if(u!==-1||n.hasContent(t)){if(n.loadCell(t,o),o.hasExtendedAttrs()&&o.extended.urlId){if(u===-1){u=t,l=o.extended.urlId;continue}d=o.extended.urlId!==l}else u!==-1&&(d=!0);if(d||u!==-1&&t===s-1){let n=this._oscLinkService.getLinkData(l)?.uri;if(n){let a={start:{x:u+1,y:e},end:{x:t+(d||t!==s-1?0:1),y:e}},o=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(o=!0)}catch{o=!0}o||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):c(0,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}d=!1,o.hasExtendedAttrs()&&o.extended.urlId?(u=t,l=o.extended.urlId):(u=-1,l=-1)}}t(r)}};function c(e,t){if(confirm(`Do you want to navigate to ${t}?\n\nWARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}t.OscLinkProvider=s=r([i(0,o.IBufferService),i(1,o.IOptionsService),i(2,o.IOscLinkService)],s)},6193:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.RenderDebouncer=void 0,t.RenderDebouncer=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())),this._animationFrame}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),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();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),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}}},3236:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.Terminal=void 0;let r=n(3614),i=n(3656),a=n(3551),o=n(9042),s=n(3730),c=n(1680),l=n(3107),u=n(5744),d=n(2950),f=n(1296),p=n(428),m=n(4269),h=n(5114),g=n(8934),_=n(3230),v=n(9312),y=n(4725),b=n(6731),x=n(8055),S=n(8969),C=n(8460),w=n(844),T=n(6114),E=n(8437),D=n(2584),O=n(7399),k=n(5941),A=n(9074),j=n(2585),M=n(5435),N=n(4567),P=n(779);class F extends S.CoreTerminal{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}constructor(e={}){super(e),this.browser=T,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new w.MutableDisposable),this._onCursorMove=this.register(new C.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new C.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new C.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new C.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new C.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new C.EventEmitter),this._onBlur=this.register(new C.EventEmitter),this._onA11yCharEmitter=this.register(new C.EventEmitter),this._onA11yTabEmitter=this.register(new C.EventEmitter),this._onWillOpen=this.register(new C.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(A.DecorationService),this._instantiationService.setService(j.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(P.LinkProviderService),this._instantiationService.setService(y.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(s.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((e,t)=>this.refresh(e,t)))),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((0,C.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,C.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,C.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((e=>this._afterResize(e.cols,e.rows)))),this.register((0,w.toDisposable)((()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)})))}_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=x.color.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${D.C0.ESC}]${n};${(0,k.toRgbString)(r)}${D.C1_ESCAPED.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors((e=>e.ansi[t.index]=x.channels.toColor(...t.color)));else{let n=e;this._themeService.modifyColors((e=>e[n]=x.channels.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(N.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(D.C0.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(D.C0.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((0,i.addDisposableDomListener)(this.element,`copy`,(e=>{this.hasSelection()&&(0,r.copyHandler)(e,this._selectionService)})));let e=e=>(0,r.handlePasteEvent)(e,this.textarea,this.coreService,this.optionsService);this.register((0,i.addDisposableDomListener)(this.textarea,`paste`,e)),this.register((0,i.addDisposableDomListener)(this.element,`paste`,e)),T.isFirefox?this.register((0,i.addDisposableDomListener)(this.element,`mousedown`,(e=>{e.button===2&&(0,r.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,i.addDisposableDomListener)(this.element,`contextmenu`,(e=>{(0,r.rightClickHandler)(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),T.isLinux&&this.register((0,i.addDisposableDomListener)(this.element,`auxclick`,(e=>{e.button===1&&(0,r.moveTextAreaUnderMouseCursor)(e,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,i.addDisposableDomListener)(this.textarea,`keyup`,(e=>this._keyUp(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`keydown`,(e=>this._keyDown(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`keypress`,(e=>this._keyPress(e)),!0)),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionstart`,(()=>this._compositionHelper.compositionstart()))),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionupdate`,(e=>this._compositionHelper.compositionupdate(e)))),this.register((0,i.addDisposableDomListener)(this.textarea,`compositionend`,(()=>this._compositionHelper.compositionend()))),this.register((0,i.addDisposableDomListener)(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)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));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._viewportScrollArea=this._document.createElement(`div`),this._viewportScrollArea.classList.add(`xterm-scroll-area`),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this.register((0,i.addDisposableDomListener)(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),this.textarea=this._document.createElement(`textarea`),this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,o.promptLabel),T.isChromeOS||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._coreBrowserService=this.register(this._instantiationService.createInstance(h.CoreBrowserService,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(y.ICoreBrowserService,this._coreBrowserService),this.register((0,i.addDisposableDomListener)(this.textarea,`focus`,(e=>this._handleTextAreaFocus(e)))),this.register((0,i.addDisposableDomListener)(this.textarea,`blur`,(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(p.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(y.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(b.ThemeService),this._instantiationService.setService(y.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(m.CharacterJoinerService),this._instantiationService.setService(y.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(_.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(y.IRenderService,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(d.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(g.MouseService),this._instantiationService.setService(y.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(a.Linkifier,this.screenElement)),this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(c.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((e=>this.scrollLines(e.amount,e.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),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.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(v.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(y.ISelectionService,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(this._onScroll.event((e=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,i.addDisposableDomListener)(this._viewportElement,`scroll`,(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(l.BufferDecorationRenderer,this.screenElement)),this.register((0,i.addDisposableDomListener)(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(N.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,(e=>this._handleScreenReaderModeOptionChange(e)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(u.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRulerWidth`,(e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(u.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(f.DomRenderer,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=1&t.buttons?0:4&t.buttons?1:2&t.buttons?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&&!1===e._customWheelEventHandler(t)||e.viewport.getLinesScrolled(t)===0)return!1;i=t.deltaY<0?0:1,r=4;break;default:return!1}return!(i===void 0||r===void 0||r>4)&&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},a={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()),8&e?r.mousemove||=(t.addEventListener(`mousemove`,a.mousemove),a.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),16&e?r.wheel||=(t.addEventListener(`wheel`,a.wheel,{passive:!1}),a.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),2&e?r.mouseup||=a.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),4&e?r.mousedrag||=a.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,i.addDisposableDomListener)(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((0,i.addDisposableDomListener)(t,`wheel`,(e=>{if(!r.wheel){if(this._customWheelEventHandler&&!1===this._customWheelEventHandler(e))return!1;if(!this.buffer.hasScrollback){let t=this.viewport.getLinesScrolled(e);if(t===0)return;let n=D.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(e.deltaY<0?`A`:`B`),r=``;for(let e=0;e<Math.abs(t);e++)r+=n;return this.coreService.triggerDataEvent(r,!0),this.cancel(e,!0)}return this.viewport.handleWheel(e)?this.cancel(e):void 0}}),{passive:!1})),this.register((0,i.addDisposableDomListener)(t,`touchstart`,(e=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(e),this.cancel(e)}),{passive:!0})),this.register((0,i.addDisposableDomListener)(t,`touchmove`,(e=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(e)?void 0:this.cancel(e)}),{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,n=0){n===1?(super.scrollLines(e,t,n),this.refresh(0,this.rows-1)):this.viewport?.scrollLines(e)}paste(e){(0,r.paste)(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}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&&!1===this._customKeyEventHandler(e))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(),!1;t||e.key!==`Dead`&&e.key!==`AltGraph`||(this._unprocessedDeadKey=!0);let n=(0,O.evaluateKeyboardEvent)(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)}return 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)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(n.key!==D.C0.ETX&&n.key!==D.C0.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?this.cancel(e,!0):void(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&&!1===this._customKeyEventHandler(e)||(function(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&!1===this._customKeyEventHandler(e))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)return!1;t=e.which}return!(!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)||(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?super.resize(e,t):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(e,t){this._charSizeService?.measure(),this.viewport?.syncScrollArea(!0)}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(E.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),this.viewport?.reset(),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.viewport?.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){this._renderService?.clearTextureAtlas()}_reportFocus(){this.element?.classList.contains(`focus`)?this.coreService.triggerDataEvent(D.C0.ESC+`[I`):this.coreService.triggerDataEvent(D.C0.ESC+`[O`)}_reportWindowsOptions(e){if(this._renderService)switch(e){case M.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:let e=this._renderService.dimensions.css.canvas.width.toFixed(0),t=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${D.C0.ESC}[4;${t};${e}t`);break;case M.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:let n=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${D.C0.ESC}[6;${r};${n}t`)}}cancel(e,t){if(this.options.cancelEvents||t)return e.preventDefault(),e.stopPropagation(),!1}}t.Terminal=F},9924:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.TimeBasedDebouncer=void 0,t.TimeBasedDebouncer=class{constructor(e,t=1e3){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=Date.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=Date.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)}}},1680:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.Viewport=void 0;let a=n(3656),o=n(4725),s=n(8460),c=n(844),l=n(2585),u=t.Viewport=class extends c.Disposable{constructor(e,t,n,r,i,o,c,l){super(),this._viewportElement=e,this._scrollArea=t,this._bufferService=n,this._optionsService=r,this._charSizeService=i,this._renderService=o,this._coreBrowserService=c,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new s.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,a.addDisposableDomListener)(this._viewportElement,`scroll`,this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((e=>this._activeBuffer=e.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((e=>this._renderDimensions=e))),this._handleThemeChange(l.colors),this.register(l.onChangeColors((e=>this._handleThemeChange(e)))),this.register(this._optionsService.onSpecificOptionChange(`scrollback`,(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(e){this._viewportElement.style.backgroundColor=e.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(e){if(e)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;let e=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==e&&(this._lastRecordedBufferHeight=e,this._scrollArea.style.height=this._lastRecordedBufferHeight+`px`)}let e=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==e&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=e),this._refreshAnimationFrame=null}syncScrollArea(e=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(e);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(e)}_handleScroll(e){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});let t=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:t,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;let e=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(e*(this._smoothScrollState.target-this._smoothScrollState.origin)),e<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(e,t){let n=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(t<0&&this._viewportElement.scrollTop!==0||t>0&&n<this._lastRecordedBufferHeight)||(e.cancelable&&e.preventDefault(),!1)}handleWheel(e){let t=this._getPixelsScrolled(e);return t!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+t:this._smoothScrollState.target+=t,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))}scrollLines(e){if(e!==0)if(this._optionsService.rawOptions.smoothScrollDuration){let t=e*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+t,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:e,suppressScrollEvent:!1})}_getPixelsScrolled(e){if(e.deltaY===0||e.shiftKey)return 0;let t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_LINE?t*=this._currentRowHeight:e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._currentRowHeight*this._bufferService.rows),t}getBufferElements(e,t){let n,r=``,i=[],a=t??this._bufferService.buffer.lines.length,o=this._bufferService.buffer.lines;for(let t=e;t<a;t++){let e=o.get(t);if(!e)continue;let a=o.get(t+1)?.isWrapped;if(r+=e.translateToString(!a),!a||t===o.length-1){let e=document.createElement(`div`);e.textContent=r,i.push(e),r.length>0&&(n=e),r=``}}return{bufferElements:i,cursorElement:n}}getLinesScrolled(e){if(e.deltaY===0||e.shiftKey)return 0;let t=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(t/=this._currentRowHeight+0,this._wheelPartialScroll+=t,t=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(t*=this._bufferService.rows),t}_applyScrollModifier(e,t){let n=this._optionsService.rawOptions.fastScrollModifier;return n===`alt`&&t.altKey||n===`ctrl`&&t.ctrlKey||n===`shift`&&t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(e){this._lastTouchY=e.touches[0].pageY}handleTouchMove(e){let t=this._lastTouchY-e.touches[0].pageY;return this._lastTouchY=e.touches[0].pageY,t!==0&&(this._viewportElement.scrollTop+=t,this._bubbleScroll(e,t))}};t.Viewport=u=r([i(2,l.IBufferService),i(3,l.IOptionsService),i(4,o.ICharSizeService),i(5,o.IRenderService),i(6,o.ICoreBrowserService),i(7,o.IThemeService)],u)},3107:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.BufferDecorationRenderer=void 0;let a=n(4725),o=n(844),s=n(2585),c=t.BufferDecorationRenderer=class extends o.Disposable{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((e=>this._removeDecoration(e)))),this.register((0,o.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=(e.options.height||1)*this._renderService.dimensions.css.cell.height+`px`,t.style.top=(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+`px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose((()=>{this._decorationElements.delete(e),n.remove()}))),n.style.top=t*this._renderService.dimensions.css.cell.height+`px`,n.style.display=this._altBufferIsActive?`none`:`block`,e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?n*this._renderService.dimensions.css.cell.width+`px`:``:t.style.left=n?n*this._renderService.dimensions.css.cell.width+`px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};t.BufferDecorationRenderer=c=r([i(1,s.IBufferService),i(2,a.ICoreBrowserService),i(3,s.IDecorationService),i(4,a.IRenderService)],c)},5871:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.ColorZoneStore=void 0,t.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position))return void this._addLineToZone(t,e.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}}},5744:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.OverviewRulerRenderer=void 0;let a=n(5871),o=n(4725),s=n(844),c=n(2585),l={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0},f=t.OverviewRulerRenderer=class extends s.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(e,t,n,r,i,o,c){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=o,this._coreBrowserService=c,this._colorZoneStore=new a.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement);let l=this._canvas.getContext(`2d`);if(!l)throw Error(`Ctx cannot be null`);this._ctx=l,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,s.toDisposable)((()=>{this._canvas?.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange(`overviewRulerWidth`,(()=>this._queueRefresh(!0)))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){let e=Math.floor(this._canvas.width/3),t=Math.ceil(this._canvas.width/3);u.full=this._canvas.width,u.left=e,u.center=t,u.right=e,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=u.left,d.right=u.left+u.center}_refreshDrawHeightConstants(){l.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);l.left=t,l.center=t,l.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1;let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(d[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-l[e.position||`full`]/2),u[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+l[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};t.OverviewRulerRenderer=f=r([i(2,c.IBufferService),i(3,c.IDecorationService),i(4,o.IRenderService),i(5,c.IOptionsService),i(6,o.ICoreBrowserService)],f)},2950:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.CompositionHelper=void 0;let a=n(4725),o=n(2585),s=n(2584),c=t.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let t;this._isSendingComposition=!1,e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,e.end):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}}),0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout((()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.length<e.length?this._coreService.triggerDataEvent(`${s.C0.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}}),0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let e=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),t=this._renderService.dimensions.css.cell.height,n=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=e*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+`px`,this._compositionView.style.top=n+`px`,this._compositionView.style.height=t+`px`,this._compositionView.style.lineHeight=t+`px`,this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+`px`;let i=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+`px`,this._textarea.style.top=n+`px`,this._textarea.style.width=Math.max(i.width,1)+`px`,this._textarea.style.height=Math.max(i.height,1)+`px`,this._textarea.style.lineHeight=i.height+`px`}e||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};t.CompositionHelper=c=r([i(2,o.IBufferService),i(3,o.IOptionsService),i(4,o.ICoreService),i(5,a.IRenderService)],c)},9806:(e,t)=>{function n(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}Object.defineProperty(t,`__esModule`,{value:!0}),t.getCoords=t.getCoordsRelativeToElement=void 0,t.getCoordsRelativeToElement=n,t.getCoords=function(e,t,r,i,a,o,s,c,l){if(!o)return;let u=n(e,t,r);return u?(u[0]=Math.ceil((u[0]+(l?s/2:0))/s),u[1]=Math.ceil(u[1]/c),u[0]=Math.min(Math.max(u[0],1),i+ +!!l),u[1]=Math.min(Math.max(u[1],1),a),u):void 0}},9504:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.moveToCellSequence=void 0;let r=n(2584);function i(e,t,n,r){let i=e-a(e,n),s=t-a(t,n);return l(Math.abs(i-s)-function(e,t,n){let r=0,i=e-a(e,n),s=t-a(t,n);for(let a=0;a<Math.abs(i-s);a++){let s=o(e,t)===`A`?-1:1;n.buffer.lines.get(i+s*a)?.isWrapped&&r++}return r}(e,t,n),c(o(e,t),r))}function a(e,t){let n=0,r=t.buffer.lines.get(e),i=r?.isWrapped;for(;i&&e>=0&&e<t.rows;)n++,r=t.buffer.lines.get(--e),i=r?.isWrapped;return n}function o(e,t){return e>t?`A`:`B`}function s(e,t,n,r,i,a){let o=e,s=t,c=``;for(;o!==n||s!==r;)o+=i?1:-1,i&&o>a.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function c(e,t){let n=t?`O`:`[`;return r.C0.ESC+n+e}function l(e,t){e=Math.floor(e);let n=``;for(let r=0;r<e;r++)n+=t;return n}t.moveToCellSequence=function(e,t,n,r){let o=n.buffer.x,u=n.buffer.y;if(!n.buffer.hasScrollback)return function(e,t,n,r,o,u){return i(t,r,o,u).length===0?``:l(s(e,t,e,t-a(t,o),!1,o).length,c(`D`,u))}(o,u,0,t,n,r)+i(u,t,n,r)+function(e,t,n,r,o,u){let d;d=i(t,r,o,u).length>0?r-a(r,o):t;let f=r,p=function(e,t,n,r,o,s){let c;return c=i(n,r,o,s).length>0?r-a(r,o):t,e<n&&c<=r||e>=n&&c<r?`C`:`D`}(e,t,n,r,o,u);return l(s(e,d,n,f,p===`C`,o).length,c(p,u))}(o,u,e,t,n,r);let d;if(u===t)return d=o>e?`D`:`C`,l(Math.abs(o-e),c(d,r));d=u>t?`D`:`C`;let f=Math.abs(u-t);return l(function(e,t){return t.cols-e}(u>t?e:o,n)+(f-1)*n.cols+1+((u>t?o:e)-1),c(d,r))}},1296:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.DomRenderer=void 0;let a=n(3787),o=n(2550),s=n(2223),c=n(6171),l=n(6052),u=n(4725),d=n(8055),f=n(8460),p=n(844),m=n(2585),h=`xterm-dom-renderer-owner-`,g=`xterm-rows`,_=`xterm-fg-`,v=`xterm-bg-`,y=`xterm-focus`,b=`xterm-selection`,x=1,S=t.DomRenderer=class extends p.Disposable{constructor(e,t,n,r,i,s,u,d,m,_,v,y,S){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=s,this._linkifier2=u,this._charSizeService=m,this._optionsService=_,this._bufferService=v,this._coreBrowserService=y,this._themeService=S,this._terminalClass=x++,this._rowElements=[],this._selectionRenderModel=(0,l.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new f.EventEmitter).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(g),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(b),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=(0,c.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((e=>this._injectCss(e)))),this._injectCss(this._themeService.colors),this._rowFactory=d.createInstance(a.DomRendererRowFactory,document),this._element.classList.add(h+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((e=>this._handleLinkHover(e)))),this.register(this._linkifier2.onHideLinkUnderline((e=>this._handleLinkLeave(e)))),this.register((0,p.toDisposable)((()=>{this._element.classList.remove(h+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new o.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${g} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${g} { color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${g} .xterm-dim { color: ${d.color.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${g}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${g} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${b} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${b} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${b} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${_}${n} { color: ${r.css}; }${this._terminalSelector} .${_}${n}.xterm-dim { color: ${d.color.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${v}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${_}${s.INVERTED_DEFAULT_COLOR} { color: ${d.color.opaque(e.background).css}; }${this._terminalSelector} .${_}${s.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${d.color.multiplyOpacity(d.color.opaque(e.background),.5).css}; }${this._terminalSelector} .${v}${s.INVERTED_DEFAULT_COLOR} { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(y),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(y),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t)return;this._selectionRenderModel.update(this._terminal,e,t,n);let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow;if(a>=this._bufferService.rows||o<0)return;let s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=r*this.dimensions.css.cell.height+`px`,i.style.top=e*this.dimensions.css.cell.height+`px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._optionsService.rawOptions.cursorBlink,o=this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${h}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};t.DomRenderer=S=r([i(7,m.IInstantiationService),i(8,u.ICharSizeService),i(9,m.IOptionsService),i(10,m.IBufferService),i(11,u.ICoreBrowserService),i(12,u.IThemeService)],S)},3787:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.DomRendererRowFactory=void 0;let a=n(2223),o=n(643),s=n(511),c=n(2585),l=n(8055),u=n(4725),d=n(4269),f=n(6171),p=n(3734),m=t.DomRendererRowFactory=class{constructor(e,t,n,r,i,a,o){this._document=e,this._characterJoinerService=t,this._optionsService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._themeService=o,this._workCell=new s.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,n){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=n}createRow(e,t,n,r,i,s,c,u,f,m,g){let _=[],v=this._characterJoinerService.getJoinedCharacters(t),y=this._themeService.colors,b,x=e.getNoBgTrimmedLength();n&&x<s+1&&(x=s+1);let S=0,C=``,w=0,T=0,E=0,D=!1,O=0,k=!1,A=0,j=[],M=m!==-1&&g!==-1;for(let N=0;N<x;N++){e.loadCell(N,this._workCell);let x=this._workCell.getWidth();if(x===0)continue;let P=!1,F=N,I=this._workCell;if(v.length>0&&N===v[0][0]){P=!0;let t=v.shift();I=new d.JoinedCellData(this._workCell,e.translateToString(!0,t[0],t[1]),t[1]-t[0]),F=t[1]-1,x=I.getWidth()}let L=this._isCellInSelection(N,t),R=n&&N===s,z=M&&N>=m&&N<=g,B=!1;this._decorationService.forEachDecorationAtCell(N,t,void 0,(e=>{B=!0}));let V=I.getChars()||o.WHITESPACE_CELL_CHAR;if(V===` `&&(I.isUnderline()||I.isOverline())&&(V=`\xA0`),A=x*u-f.get(V,I.isBold(),I.isItalic()),b){if(S&&(L&&k||!L&&!k&&I.bg===w)&&(L&&k&&y.selectionForeground||I.fg===T)&&I.extended.ext===E&&z===D&&A===O&&!R&&!P&&!B){I.isInvisible()?C+=o.WHITESPACE_CELL_CHAR:C+=V,S++;continue}S&&(b.textContent=C),b=this._document.createElement(`span`),S=0,C=``}else b=this._document.createElement(`span`);if(w=I.bg,T=I.fg,E=I.extended.ext,D=z,O=A,k=L,P&&s>=N&&s<=F&&(s=N),!this._coreService.isCursorHidden&&R&&this._coreService.isCursorInitialized){if(j.push(`xterm-cursor`),this._coreBrowserService.isFocused)c&&j.push(`xterm-cursor-blink`),j.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:j.push(`xterm-cursor-outline`);break;case`block`:j.push(`xterm-cursor-block`);break;case`bar`:j.push(`xterm-cursor-bar`);break;case`underline`:j.push(`xterm-cursor-underline`)}}if(I.isBold()&&j.push(`xterm-bold`),I.isItalic()&&j.push(`xterm-italic`),I.isDim()&&j.push(`xterm-dim`),C=I.isInvisible()?o.WHITESPACE_CELL_CHAR:I.getChars()||o.WHITESPACE_CELL_CHAR,I.isUnderline()&&(j.push(`xterm-underline-${I.extended.underlineStyle}`),C===` `&&(C=`\xA0`),!I.isUnderlineColorDefault()))if(I.isUnderlineColorRGB())b.style.textDecorationColor=`rgb(${p.AttributeData.toColorRGB(I.getUnderlineColor()).join(`,`)})`;else{let e=I.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&I.isBold()&&e<8&&(e+=8),b.style.textDecorationColor=y.ansi[e].css}I.isOverline()&&(j.push(`xterm-overline`),C===` `&&(C=`\xA0`)),I.isStrikethrough()&&j.push(`xterm-strikethrough`),z&&(b.style.textDecoration=`underline`);let H=I.getFgColor(),U=I.getFgColorMode(),W=I.getBgColor(),G=I.getBgColorMode(),ee=!!I.isInverse();if(ee){let e=H;H=W,W=e;let t=U;U=G,G=t}let K,te,q,ne=!1;switch(this._decorationService.forEachDecorationAtCell(N,t,void 0,(e=>{e.options.layer!==`top`&&ne||(e.backgroundColorRGB&&(G=50331648,W=e.backgroundColorRGB.rgba>>8&16777215,K=e.backgroundColorRGB),e.foregroundColorRGB&&(U=50331648,H=e.foregroundColorRGB.rgba>>8&16777215,te=e.foregroundColorRGB),ne=e.options.layer===`top`)})),!ne&&L&&(K=this._coreBrowserService.isFocused?y.selectionBackgroundOpaque:y.selectionInactiveBackgroundOpaque,W=K.rgba>>8&16777215,G=50331648,ne=!0,y.selectionForeground&&(U=50331648,H=y.selectionForeground.rgba>>8&16777215,te=y.selectionForeground)),ne&&j.push(`xterm-decoration-top`),G){case 16777216:case 33554432:q=y.ansi[W],j.push(`xterm-bg-${W}`);break;case 50331648:q=l.channels.toColor(W>>16,W>>8&255,255&W),this._addStyle(b,`background-color:#${h((W>>>0).toString(16),`0`,6)}`);break;default:ee?(q=y.foreground,j.push(`xterm-bg-${a.INVERTED_DEFAULT_COLOR}`)):q=y.background}switch(K||I.isDim()&&(K=l.color.multiplyOpacity(q,.5)),U){case 16777216:case 33554432:I.isBold()&&H<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(H+=8),this._applyMinimumContrast(b,q,y.ansi[H],I,K,void 0)||j.push(`xterm-fg-${H}`);break;case 50331648:let e=l.channels.toColor(H>>16&255,H>>8&255,255&H);this._applyMinimumContrast(b,q,e,I,K,te)||this._addStyle(b,`color:#${h(H.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(b,q,y.foreground,I,K,te)||ee&&j.push(`xterm-fg-${a.INVERTED_DEFAULT_COLOR}`)}j.length&&=(b.className=j.join(` `),0),R||P||B?b.textContent=C:S++,A!==this.defaultSpacing&&(b.style.letterSpacing=`${A}px`),_.push(b),N=F}return b&&S&&(b.textContent=C),_}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,f.treatGlyphAsBackgroundColor)(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(i||a||(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=l.color.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return!!s&&(this._addStyle(e,`color:${s.css}`),!0)}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!(!n||!r)&&(this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e<r[0]&&t<=r[1]:e<n[0]&&t>=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t<r[1]||n[1]===r[1]&&t===n[1]&&e>=n[0]&&e<r[0]||n[1]<r[1]&&t===r[1]&&e<r[0]||n[1]<r[1]&&t===n[1]&&e>=n[0])}};function h(e,t,n){for(;e.length<n;)e=t+e;return e}t.DomRendererRowFactory=m=r([i(1,u.ICharacterJoinerService),i(2,c.IOptionsService),i(3,u.ICoreBrowserService),i(4,c.ICoreService),i(5,c.IDecorationService),i(6,u.IThemeService)],m)},2550:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.WidthCache=void 0,t.WidthCache=class{constructor(e,t){this._flat=new Float32Array(256),this._font=``,this._fontSize=0,this._weight=`normal`,this._weightBold=`bold`,this._measureElements=[],this._container=e.createElement(`div`),this._container.classList.add(`xterm-width-cache-measure-container`),this._container.setAttribute(`aria-hidden`,`true`),this._container.style.whiteSpace=`pre`,this._container.style.fontKerning=`none`;let n=e.createElement(`span`);n.classList.add(`xterm-char-measure-element`);let r=e.createElement(`span`);r.classList.add(`xterm-char-measure-element`),r.style.fontWeight=`bold`;let i=e.createElement(`span`);i.classList.add(`xterm-char-measure-element`),i.style.fontStyle=`italic`;let a=e.createElement(`span`);a.classList.add(`xterm-char-measure-element`),a.style.fontWeight=`bold`,a.style.fontStyle=`italic`,this._measureElements=[n,r,i,a],this._container.appendChild(n),this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(a),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,n,r){e===this._font&&t===this._fontSize&&n===this._weight&&r===this._weightBold||(this._font=e,this._fontSize=t,this._weight=n,this._weightBold=r,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${n}`,this._measureElements[1].style.fontWeight=`${r}`,this._measureElements[2].style.fontWeight=`${n}`,this._measureElements[3].style.fontWeight=`${r}`,this.clear())}get(e,t,n){let r=0;if(!t&&!n&&e.length===1&&(r=e.charCodeAt(0))<256){if(this._flat[r]!==-9999)return this._flat[r];let t=this._measure(e,0);return t>0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}}},2223:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.TEXT_BASELINE=t.DIM_OPACITY=t.INVERTED_DEFAULT_COLOR=void 0;let r=n(6114);t.INVERTED_DEFAULT_COLOR=257,t.DIM_OPACITY=.5,t.TEXT_BASELINE=r.isFirefox||r.isLegacyEdge?`bottom`:`ideographic`},6171:(e,t)=>{function n(e){return 57508<=e&&e<=57558}function r(e){return e>=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}Object.defineProperty(t,`__esModule`,{value:!0}),t.computeNextVariantOffset=t.createRenderDimensions=t.treatGlyphAsBackgroundColor=t.allowRescaling=t.isEmoji=t.isRestrictedPowerlineGlyph=t.isPowerlineGlyph=t.throwIfFalsy=void 0,t.throwIfFalsy=function(e){if(!e)throw Error(`value must not be falsy`);return e},t.isPowerlineGlyph=n,t.isRestrictedPowerlineGlyph=function(e){return 57520<=e&&e<=57527},t.isEmoji=r,t.allowRescaling=function(e,t,i,a){return t===1&&i>Math.ceil(1.5*a)&&e!==void 0&&e>255&&!r(e)&&!n(e)&&!function(e){return 57344<=e&&e<=63743}(e)},t.treatGlyphAsBackgroundColor=function(e){return n(e)||function(e){return 9472<=e&&e<=9631}(e)},t.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},t.computeNextVariantOffset=function(e,t,n=0){return(e-(2*Math.round(t)-n))%(2*Math.round(t))}},6052:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.createSelectionRenderModel=void 0;class n{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1])return void this.clear();let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);s>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0])}isCellSelected(e,t,n){return!!this.hasSelection&&(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t<this.endCol&&n<=this.viewportCappedEndRow:t<this.startCol&&n>=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&n===this.viewportStartRow&&t>=this.startCol)}}t.createSelectionRenderModel=function(){return new n}},456:(e,t)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.SelectionModel=void 0,t.SelectionModel=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!(!e||!t)&&(e[1]>t[1]||e[1]===t[1]&&e[0]>t[0])}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.CharSizeService=void 0;let a=n(2585),o=n(8460),s=n(844),c=t.CharSizeService=class extends s.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this.register(new o.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new d(this._optionsService))}catch{this._measureStrategy=this.register(new u(e,t,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],(()=>this.measure())))}measure(){let e=this._measureStrategy.measure();e.width===this.width&&e.height===this.height||(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};t.CharSizeService=c=r([i(2,a.IOptionsService)],c);class l extends s.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}}class u extends l{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class d extends l{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}}},4269:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.CharacterJoinerService=t.JoinedCellData=void 0;let a=n(3734),o=n(643),s=n(511),c=n(2585);class l extends a.AttributeData{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}t.JoinedCellData=l;let u=t.CharacterJoinerService=class e{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new s.CellData}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let n=[],r=t.translateToString(!0),i=0,a=0,s=0,c=t.getFg(0),l=t.getBg(0);for(let e=0;e<t.getTrimmedLength();e++)if(t.loadCell(e,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==c||this._workCell.bg!==l){if(e-i>1){let e=this._getJoinedRanges(r,s,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}i=e,s=a,c=this._workCell.fg,l=this._workCell.bg}a+=this._workCell.getChars().length||o.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-i>1){let e=this._getJoinedRanges(r,s,a,t,i);for(let t=0;t<e.length;t++)n.push(e[t])}return n}_getJoinedRanges(t,n,r,i,a){let o=t.substring(n,r),s=[];try{s=this._characterJoiners[0].handler(o)}catch(e){console.error(e)}for(let t=1;t<this._characterJoiners.length;t++)try{let n=this._characterJoiners[t].handler(o);for(let t=0;t<n.length;t++)e._mergeRanges(s,n[t])}catch(e){console.error(e)}return this._stringRangesToCellRanges(s,i,a),s}_stringRangesToCellRanges(e,t,n){let r=0,i=!1,a=0,s=e[r];if(s){for(let c=n;c<this._bufferService.cols;c++){let n=t.getWidth(c),l=t.getString(c).length||o.WHITESPACE_CELL_CHAR.length;if(n!==0){if(!i&&s[0]<=a&&(s[0]=c,i=!0),s[1]<=a){if(s[1]=c,s=e[++r],!s)break;s[0]<=a?(s[0]=c,i=!0):i=!1}a+=l}}s&&(s[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(n){if(t[1]<=i[0])return e[r-1][1]=t[1],e;if(t[1]<=i[1])return e[r-1][1]=Math.max(t[1],i[1]),e.splice(r,1),e;e.splice(r,1),r--}else{if(t[1]<=i[0])return e.splice(r,0,t),e;if(t[1]<=i[1])return i[0]=Math.min(t[0],i[0]),e;t[0]<i[1]&&(i[0]=Math.min(t[0],i[0]),n=!0)}}return n?e[e.length-1][1]=t[1]:e.push(t),e}};t.CharacterJoinerService=u=r([i(0,c.IBufferService)],u)},5114:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.CoreBrowserService=void 0;let r=n(844),i=n(8460),a=n(3656);class o extends r.Disposable{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new s(this._window),this._onDprChange=this.register(new i.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new i.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((e=>this._screenDprMonitor.setWindow(e)))),this.register((0,i.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener(`focus`,(()=>this._isFocused=!0)),this._textarea.addEventListener(`blur`,(()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}t.CoreBrowserService=o;class s extends r.Disposable{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this.register(new r.MutableDisposable),this._onDprChange=this.register(new i.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,r.toDisposable)((()=>this.clearListener())))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,a.addDisposableDomListener)(this._parentWindow,`resize`,(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(e,t,n)=>{Object.defineProperty(t,`__esModule`,{value:!0}),t.LinkProviderService=void 0;let r=n(844);class i extends r.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,r.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}}t.LinkProviderService=i},8934:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.MouseService=void 0;let a=n(4725),o=n(9806),s=t.MouseService=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return(0,o.getCoords)(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=(0,o.getCoordsRelativeToElement)(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};t.MouseService=s=r([i(0,a.IRenderService),i(1,a.ICharSizeService)],s)},3230:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.RenderService=void 0;let a=n(6193),o=n(4725),s=n(8460),c=n(844),l=n(7226),u=n(2585),d=t.RenderService=class extends c.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(e,t,n,r,i,o,u,d){super(),this._rowCount=e,this._charSizeService=r,this._renderer=this.register(new c.MutableDisposable),this._pausedResizeTask=new l.DebouncedIdleTask,this._observerDisposable=this.register(new c.MutableDisposable),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new s.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new s.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new s.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new s.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new a.RenderDebouncer(((e,t)=>this._renderRows(e,t)),u),this.register(this._renderDebouncer),this.register(u.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(o.onResize((()=>this._fullRefresh()))),this.register(o.buffers.onBufferActivate((()=>this._renderer.value?.clear()))),this.register(n.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(i.onDecorationRegistered((()=>this._fullRefresh()))),this.register(i.onDecorationRemoved((()=>this._fullRefresh()))),this.register(n.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],(()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()}))),this.register(n.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],(()=>this.refreshRows(o.buffer.y,o.buffer.y,!0)))),this.register(d.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(u.window,t),this.register(u.onWindowChange((e=>this._registerIntersectionObserver(e,t))))}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver((e=>this._handleIntersectionChange(e[e.length-1])),{threshold:0});n.observe(t),this._observerDisposable.value=(0,c.toDisposable)((()=>n.disconnect()))}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){this._isPaused?this._needsFullRefresh=!0:(n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount))}_renderRows(e,t){this._renderer.value&&(e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0)}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw((e=>this.refreshRows(e.start,e.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value?.handleResize(e,t))):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};t.RenderService=d=r([i(2,u.IOptionsService),i(3,o.ICharSizeService),i(4,u.IDecorationService),i(5,u.IBufferService),i(6,o.ICoreBrowserService),i(7,o.IThemeService)],d)},9312:function(e,t,n){var r=this&&this.__decorate||function(e,t,n,r){var i,a=arguments.length,o=a<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)o=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(i=e[s])&&(o=(a<3?i(o):a>3?i(t,n,o):i(t,n))||o);return a>3&&o&&Object.defineProperty(t,n,o),o},i=this&&this.__param||function(e,t){return function(n,r){t(n,r,e)}};Object.defineProperty(t,`__esModule`,{value:!0}),t.SelectionService=void 0;let a=n(9806),o=n(9504),s=n(456),c=n(4725),l=n(8460),u=n(844),d=n(6114),f=n(4841),p=n(511),m=n(2585),h=RegExp(`\xA0`,`g`),g=t.SelectionService=class extends u.Disposable{constructor(e,t,n,r,i,a,o,c,d){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=c,this._coreBrowserService=d,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new p.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new l.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new l.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new l.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new l.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((e=>this._handleTrim(e))),this.register(this._bufferService.buffers.onBufferActivate((e=>this._handleBufferActivate(e)))),this.enable(),this._model=new s.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,u.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!(!e||!t||e[0]===t[0]&&e[1]===t[1])}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]<t[0]?e[0]:t[0],a=e[0]<t[0]?t[0]:e[0];for(let o=e[1];o<=t[1];o++){let e=n.translateBufferLineToString(o,!0,i,a);r.push(e)}}else{let i=e[1]===t[1]?t[0]:void 0;r.push(n.translateBufferLineToString(e[1],!0,e[0],i));for(let i=e[1]+1;i<=t[1]-1;i++){let e=n.lines.get(i),t=n.translateBufferLineToString(i,!0);e?.isWrapped?r[r.length-1]+=t:r.push(t)}if(e[1]!==t[1]){let e=n.lines.get(t[1]),i=n.translateBufferLineToString(t[1],!0,0,t[0]);e&&e.isWrapped?r[r.length-1]+=i:r.push(i)}}return r.map((e=>e.replace(h,` `))).join(d.isWindows?`\r
23
23
  `:`
@@ -188,10 +188,10 @@ void main() {
188
188
  select-none touch-manipulation
189
189
  text-secondary
190
190
  ${t?`opacity-50`:``}
191
- `,onMouseDown:e=>e.preventDefault(),onTouchStart:j(k),onClick:M(k),disabled:t,children:Q_})]}),l&&(0,J.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,J.jsxs)(`div`,{ref:v,className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,J.jsx)(`h3`,{className:`text-base font-medium text-primary mb-1 text-balance`,children:`Paste`}),(0,J.jsx)(`p`,{className:`text-xs text-muted mb-3 text-pretty`,children:`Text or image (long-press → Paste)`}),p?(0,J.jsx)(`div`,{className:`w-full h-11 flex items-center justify-center bg-surface border border-border rounded-md text-secondary`,children:`Uploading image...`}):(0,J.jsx)(`input`,{ref:_,type:`text`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),E()):e.key===`Escape`&&(e.preventDefault(),D())},placeholder:`Paste here...`,className:`w-full h-11 px-3 text-[16px] bg-surface border border-border rounded-md text-primary placeholder:text-muted outline-none focus:border-accent`,style:{fontSize:`16px`}}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 mt-4`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:D,className:`px-4 py-2 text-sm font-medium text-secondary bg-surface border border-border rounded-md active:scale-95 transition-transform`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:E,disabled:p,className:`px-4 py-2 text-sm font-medium bg-accent text-white rounded-md active:scale-95 transition-transform disabled:opacity-50`,children:`Send`})]})]})})]})}function av({isOpen:e,onClose:t,sessions:n,hibernatingSessions:r=[],historySessions:i=[],selectedSessionId:a,selectedHibernatingSessionId:o=null,onSelect:s,onSelectHibernating:c,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:p,loading:m,error:h}){let g=ld(),_=(0,x.useRef)(null),v=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),(0,x.useEffect)(()=>{e?(v.current=document.activeElement,_.current?.focus()):v.current&&=(v.current.focus(),null)},[e]),(0,x.useEffect)(()=>{if(!e)return;let n=_.current;if(!n)return;let r=0,i=0,a=e=>{let t=e.touches[0];r=t.clientX,i=t.clientY},o=e=>{let n=e.changedTouches[0],a=r-n.clientX,o=Math.abs(n.clientY-i);a>=50&&a>o*1.5&&(`vibrate`in navigator&&navigator.vibrate(10),t())};return n.addEventListener(`touchstart`,a,{passive:!0}),n.addEventListener(`touchend`,o,{passive:!0}),()=>{n.removeEventListener(`touchstart`,a),n.removeEventListener(`touchend`,o)}},[e,t]);let y=e=>{s(e),t()},b=e=>{c?.(e),t()},S=g?{transition:`none`}:void 0;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`session-drawer-backdrop ${e?`open`:``}`,style:S,onClick:t,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{ref:_,className:`session-drawer ${e?`open`:``}`,style:S,role:`dialog`,"aria-modal":`true`,"aria-label":`Session list`,tabIndex:-1,children:[(0,J.jsx)(jh,{sessions:n,hibernatingSessions:r,historySessions:i,selectedSessionId:a,selectedHibernatingSessionId:o,onSelect:y,onSelectHibernating:b,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:()=>{p()!==!1&&t()},loading:m,error:h}),(0,J.jsx)(`div`,{className:`shrink-0 border-t border-border px-2 pt-2`,style:{paddingBottom:`max(0.5rem, env(safe-area-inset-bottom, 0.5rem))`},children:(0,J.jsx)(`button`,{onClick:()=>{p()!==!1&&t()},className:`btn btn-primary w-full py-2 text-sm`,children:`New Session`})})]})]})}var ov={working:`Working`,waiting:`Waiting`,permission:`Needs Input`,unknown:`Unknown`},sv={working:`text-working`,waiting:`text-waiting`,permission:`text-approval`,unknown:`text-muted`},cv={working:`bg-green-500/35 text-white`,waiting:`bg-blue-500/35 text-white`,permission:`bg-amber-500/35 text-white`,unknown:`bg-gray-500/35 text-white`},lv={working:`bg-working text-white`,waiting:`bg-waiting text-white`,permission:`bg-approval text-white`,unknown:`bg-muted text-white`};function uv(){`vibrate`in navigator&&navigator.vibrate(10)}function dv({session:e,sessions:t,hibernatingSession:n=null,hibernatingSessions:r=[],historySessions:i=[],connectionStatus:a,connectionEpoch:o=0,sendMessage:s,subscribe:c,onClose:l,onSelectSession:u,onSelectHibernatingSession:d,onNewSession:f,onKillSession:p,onRenameSession:m,onResumeSession:h,onHibernateSession:g,onMoveToHistory:_,onOpenSettings:v,loading:y=!1,error:b=null}){let S=E_[T_(e=>e.theme)],C=G(e=>e.useWebGL),w=G(e=>e.fontSize),T=G(e=>e.lineHeight),E=G(e=>e.letterSpacing),D=R(G(e=>e.fontOption),G(e=>e.customFontFamily)),O=Ge(Ue(G(e=>e.shortcutModifier))),k=Be(),A=x_(),[j,M]=(0,x.useState)(!1),[N,P]=(0,x.useState)(!1),[F,I]=(0,x.useState)(!1),[L,z]=(0,x.useState)(!1),[B,V]=(0,x.useState)(!1),[H,U]=(0,x.useState)(!1),[W,ee]=(0,x.useState)(``),K=(0,x.useRef)(!1),te=(0,x.useRef)(null),ne=(0,x.useRef)(null),re=(0,x.useRef)(null),ie=(0,x.useRef)(null),ae=e?.remote===!0,oe=Um(e=>e.remoteAllowControl),se=Um(e=>e.remoteAllowAttach),ce=ae&&!se,le=!ae||oe&&e?.source===`managed`,ue=n?n.displayName||Mm(n.projectPath)||n.sessionId.slice(0,8):``,fe=n?Mm(n.projectPath):``,me=n?jm(n.lastActivityAt):``,he=!!e&&!!g&&e.source===`managed`&&!e.remote&&!!e.agentSessionId?.trim(),{containerRef:ge,terminalRef:_e,inTmuxCopyModeRef:ve,setTmuxCopyMode:ye,isSwitching:be}=b_({sessionId:e?.id??null,tmuxTarget:e?.tmuxWindow??null,allowAttach:!ce,connectionStatus:a,connectionEpoch:o,sendMessage:s,subscribe:c,theme:S,fontSize:w,lineHeight:T,letterSpacing:E,fontFamily:D,useWebGL:C,onScrollChange:e=>{M(!e)}}),Se=(0,x.useCallback)(()=>{!e||ce||(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),ye(!1),_e.current?.scrollToBottom())},[e,ce,s,ye,_e]),we=(0,x.useCallback)(()=>{V(!0),uv()},[]),Te=w_({enabled:A||k,isOpen:B,onOpen:we});(0,x.useEffect)(()=>{!A&&!k&&B&&V(!1)},[B,A,k]),S_(ne,L,(0,x.useCallback)(()=>z(!1),[])),(0,x.useEffect)(()=>{H&&re.current&&(re.current.focus(),re.current.select())},[H]),(0,x.useEffect)(()=>{F&&ie.current&&ie.current.focus()},[F]),C_(F,(0,x.useCallback)(()=>I(!1),[]));let Ee=()=>{e&&(p(e.id),I(!1))},De=()=>{!e||!he||(g?.(e.agentSessionId.trim()),z(!1))},Oe=()=>{e&&(ee(e.agentSessionName||e.name),U(!0),z(!1))},Ae=()=>{if(!e)return;let t=W.trim(),n=e.agentSessionName||e.name;t&&t!==n&&m(e.id,t),U(!1)},je=e=>{e.key===`Enter`?(e.preventDefault(),Ae()):e.key===`Escape`&&(e.preventDefault(),U(!1))};(0,x.useEffect)(()=>{if(!k||!e){P(!1);return}let t=ge.current;if(!t)return;let n=e=>{let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},r=()=>{let e=t.querySelector(`.xterm-accessibility`),n=t.querySelector(`.xterm-accessibility-tree`);!e||!n||(e.style.setProperty(`opacity`,`0`),n.style.setProperty(`opacity`,`0`),e.style.setProperty(`-webkit-user-select`,`none`),e.style.setProperty(`user-select`,`none`),n.style.setProperty(`-webkit-user-select`,`none`),n.style.setProperty(`user-select`,`none`),e.offsetHeight,requestAnimationFrame(()=>{e.style.removeProperty(`opacity`),n.style.removeProperty(`opacity`),e.style.removeProperty(`-webkit-user-select`),e.style.removeProperty(`user-select`),n.style.removeProperty(`-webkit-user-select`),n.style.removeProperty(`user-select`)}))},i=()=>{K.current=!1;let e=window.getSelection();try{e?.removeAllRanges()}catch{}_e.current?.clearSelection(),r(),P(!1)};te.current=i;let a=()=>{let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed){K.current?i():P(e=>e&&!1);return}let t=n(e);if(!t&&K.current){i();return}K.current=t;let r=t;P(e=>e===r?e:r)},o=()=>{let e=window.getSelection();!e||e.isCollapsed||n(e)&&setTimeout(i,0)},s=null,c=!1,l=e=>{if(e.touches.length===1){let t=e.touches[0];s={x:t.clientX,y:t.clientY},c=!1}},u=e=>{if(c||!s||e.touches.length!==1)return;let t=e.touches[0],n=Math.abs(t.clientX-s.x),r=Math.abs(t.clientY-s.y);(n>10||r>10)&&(c=!0)},d=e=>{let r=c;s=null,c=!1;let a=window.getSelection();if(!a||a.rangeCount===0||a.isCollapsed){P(!1);return}let o=t.querySelector(`.xterm-accessibility-tree`);if(!o)return;if(!n(a)){P(!1);return}if(r)return;let l=e.target,u=l?o.contains(l):!1,d=!1;if(u&&l)try{d=a.containsNode(l,!0)}catch{d=!1}(!u||!d)&&setTimeout(i,0)};return document.addEventListener(`selectionchange`,a),document.addEventListener(`copy`,o),document.addEventListener(`touchstart`,l,{passive:!0}),document.addEventListener(`touchmove`,u,{passive:!0}),document.addEventListener(`touchend`,d,{passive:!0}),()=>{document.removeEventListener(`selectionchange`,a),document.removeEventListener(`copy`,o),document.removeEventListener(`touchstart`,l),document.removeEventListener(`touchmove`,u),document.removeEventListener(`touchend`,d),te.current=null,K.current=!1}},[ge,k,e?.id]),(0,x.useEffect)(()=>{if(!k)return;let t=ge.current;if(!t)return;let n=()=>{let e=_e.current,n=t.querySelector(`.xterm`);if(!e||!n)return;let r=n.querySelector(`.xterm-screen`),i=n.querySelector(`.xterm-accessibility`),a=n.querySelector(`.xterm-accessibility-tree`);if(!r||!i||!a)return;let o=n.getBoundingClientRect(),s=r.getBoundingClientRect(),c=s.left-o.left,l=s.top-o.top;Object.assign(i.style,{left:`${c}px`,top:`${l}px`,right:`auto`,bottom:`auto`,width:`${s.width}px`,height:`${s.height}px`});let u=s.width/e.cols,d=s.height/e.rows,f=document.createElement(`span`);f.textContent=`0`.repeat(200),f.style.cssText=`position:absolute;visibility:hidden;white-space:pre;pointer-events:none;letter-spacing:0px`,a.appendChild(f);let p=f.getBoundingClientRect().width/200;f.remove();let m=Math.max(-2,Math.min(2,u-p));t.style.setProperty(`--xterm-font-size`,`${e.options.fontSize}px`),t.style.setProperty(`--xterm-cell-height`,`${d}px`),t.style.setProperty(`--xterm-a11y-letter-spacing`,`${m}px`)},r=performance.now();n();let i=Math.round(performance.now()-r);i>10&&Z(`switch_a11y_overlay`,{sessionId:e?.id,a11yMs:i});let a=window.requestAnimationFrame(n),o=window.setTimeout(n,100),s=()=>window.requestAnimationFrame(n);return window.visualViewport?.addEventListener(`resize`,s),window.addEventListener(`orientationchange`,s),()=>{window.cancelAnimationFrame(a),window.clearTimeout(o),window.visualViewport?.removeEventListener(`resize`,s),window.removeEventListener(`orientationchange`,s)}},[ge,w,k,e?.id,_e]);let Me=(0,x.useRef)(N);(0,x.useEffect)(()=>{Me.current=N},[N]);let Pe=(0,x.useRef)(e?.id);(0,x.useEffect)(()=>{Pe.current=e?.id},[e?.id]);let Fe=(0,x.useRef)(s);(0,x.useEffect)(()=>{Fe.current=s},[s]);let Ie=(0,x.useRef)(!1);(0,x.useEffect)(()=>{let t=ge.current;if(!t||!e?.id||!A&&!k)return;let n={x:0,y:0},r=0,i=!1,a=null,o=0,s=0,c=0,l=Math.round(w*T),u=null,d=()=>{let e=window.getComputedStyle(t).getPropertyValue(`--xterm-cell-height`).trim(),n=Number.parseFloat(e);return!Number.isNaN(n)&&n>0?n:Math.round(w*T)},f=()=>t.querySelector(`.xterm-helper-textarea`),p=()=>{let e=f();e&&document.activeElement!==e&&(e.disabled=!0)},m=()=>{let e=f();e&&(e.disabled=!1)};p();let h=()=>{if(ve.current)return;let e=f();e&&(e.disabled=!1,e.focus())},g=()=>{u!==null&&(cancelAnimationFrame(u),u=null),s=0},_=e=>{let t=Pe.current;if(!t||e===0)return!1;let n=_e.current,r=n?.cols??80,i=n?.rows??24,a=Math.floor(r/2),o=Math.floor(i/2),s=e>0?65:64,c=Math.abs(e),l=e<0;for(let e=0;e<c;e++)Fe.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${s};${a};${o}M`});return l&&ye(!0),l},v=()=>{a=null,s=0,c=0},y=()=>{if(!k)return!1;let e=window.getSelection();if(!e||e.isCollapsed)return!1;let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},b=()=>{!k||!K.current||y()||te.current?.()},x=e=>{if(g(),b(),Te.current||B){v();return}if(Me.current){v();return}if(e.touches.length===1){let t=e.touches[0];n={x:t.clientX,y:t.clientY},r=performance.now(),i=!1,a=t.clientY,o=r,s=0,c=0,l=d(),m()}},S=e=>{if(e.touches.length!==1||a===null)return;if(b(),Te.current||B){v();return}if(Me.current||y()){v();return}e.preventDefault(),e.stopPropagation();let t=performance.now(),r=e.touches[0],u=r.clientX,d=r.clientY,f=Math.abs(u-n.x),m=Math.abs(d-n.y);!i&&(f>6||m>6)&&(i=!0,p());let h=a-d,g=t-o;if(a=d,o=t,g>0){let e=h/g;s=s*.7+e*.3}c+=h;let x=Math.max(6,l*.6),S=Math.trunc(c/x);S!==0&&(_(S),c-=S*x)},C=e=>{let t=s,n=performance.now()-r;if(v(),Te.current||B)return;let a=y();if(Me.current&&!a&&te.current?.(),Me.current||a){ve.current&&(Ie.current=!0);return}if(!i){if(k&&n>=350)return;if(ve.current){e.preventDefault(),e.stopPropagation(),Ie.current=!0;return}h();return}if(Math.abs(t)>.12){let e=t,n=performance.now(),r=()=>{let t=performance.now(),i=t-n;n=t;let a=e*i;c+=a;let o=Math.max(6,l*.6),s=Math.trunc(c/o);s!==0&&(_(s),c-=s*o),e*=.95**(i/16.67),u=Math.abs(e)>.02?requestAnimationFrame(r):null};u=requestAnimationFrame(r)}},E=e=>{Ie.current&&=(e.preventDefault(),e.stopPropagation(),!1)},D={passive:!0,capture:!0},O={passive:!1,capture:!0},j={passive:!1,capture:!0},M={capture:!0};return t.addEventListener(`touchstart`,x,D),t.addEventListener(`touchmove`,S,O),t.addEventListener(`touchend`,C,j),t.addEventListener(`mousedown`,E,M),()=>{t.removeEventListener(`touchstart`,x,D),t.removeEventListener(`touchmove`,S,O),t.removeEventListener(`touchend`,C,j),t.removeEventListener(`mousedown`,E,M);let e=f();e&&(e.disabled=!1)}},[e?.id,ge,_e,k,A,B,w,T]);let Le=(0,x.useCallback)(t=>{!e||ce||s({type:`terminal-input`,sessionId:e.id,data:t})},[e,ce,s]),Re=(0,x.useCallback)(()=>{let e=ge.current;if(!e)return;let t=e.querySelector(`.xterm-helper-textarea`);t&&(t.removeAttribute(`disabled`),t.focus())},[ge]),Ve=(0,x.useCallback)(()=>{if(!e||ce)return;ve.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),ye(!1));let t=ge.current;if(!t)return;let n=t.querySelector(`.xterm-helper-textarea`);n&&(n.removeAttribute(`disabled`),n.focus())},[e,ce,s,ge,ve,ye]),He=(0,x.useCallback)(()=>{if(typeof document>`u`)return!1;let e=ge.current;if(!e)return!1;let t=e.querySelector(`.xterm-helper-textarea`);if(t&&document.activeElement===t)return!0;let n=document.activeElement,r=typeof HTMLInputElement<`u`&&n instanceof HTMLInputElement,i=typeof HTMLTextAreaElement<`u`&&n instanceof HTMLTextAreaElement;return r||i||n&&n.isContentEditable?!1:!!document.documentElement?.classList?.contains(`keyboard-visible`)},[ge]);return(0,x.useEffect)(()=>{if(!k)return;let e=ge.current;if(!e)return;let t=e.querySelector(`.xterm-accessibility`),n=e.querySelector(`.xterm-accessibility-tree`);if(!t||!n)return;let r=()=>{let r=e.querySelector(`.xterm-helper-textarea`);r&&document.activeElement===r&&!Me.current?(t.style.pointerEvents=`none`,n.style.pointerEvents=`none`):(t.style.removeProperty(`pointer-events`),n.style.removeProperty(`pointer-events`))};return r(),document.addEventListener(`focusin`,r),document.addEventListener(`focusout`,r),()=>{document.removeEventListener(`focusin`,r),document.removeEventListener(`focusout`,r)}},[ge,k,N]),(0,J.jsxs)(`section`,{className:`flex flex-1 flex-col bg-base terminal-mobile-overlay md:relative md:inset-auto ${k?`ios-native-term-selection`:``}`,"data-testid":`terminal-panel`,children:[(0,J.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between border-b border-border bg-elevated px-3 ${e||n?``:`md:hidden`}`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,J.jsx)(`button`,{onClick:()=>V(!0),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all md:hidden shrink-0`,"aria-label":`Open session menu`,children:(0,J.jsx)(xe,{width:16,height:16})}),e&&le&&(0,J.jsx)(`button`,{onClick:()=>I(!0),className:`hidden md:flex h-7 w-7 items-center justify-center rounded bg-danger/10 border border-danger/30 text-danger hover:bg-danger/20 active:scale-95 transition-all shrink-0`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,J.jsx)(ze,{width:16,height:16})}),he&&(0,J.jsx)(`button`,{onClick:De,className:`hidden md:flex h-7 w-7 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all shrink-0`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,J.jsx)(Ce,{width:16,height:16})}),e?(0,J.jsxs)(`div`,{className:`flex items-baseline gap-3 min-w-0`,children:[H?(0,J.jsx)(`input`,{ref:re,type:`text`,value:W,onChange:e=>ee(e.target.value),onBlur:Ae,onKeyDown:je,className:`w-full max-w-[200px] rounded border border-border bg-surface px-2 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,J.jsx)(`span`,{className:`text-sm font-medium text-primary truncate`,children:e.agentSessionName||e.name}),(0,J.jsx)(`span`,{className:`text-xs shrink-0 ${sv[e.status]}`,children:ov[e.status]})]}):n?(0,J.jsxs)(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-primary truncate`,children:ue}),(0,J.jsx)(`span`,{className:`rounded-full bg-blue-500/15 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-blue-400`,children:`Hibernating`})]}):(0,J.jsx)(`span`,{className:`text-sm font-medium text-primary md:hidden`,children:`Sessions`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[a!==`connected`&&(0,J.jsx)(`span`,{className:`text-xs text-approval`,children:a}),(0,J.jsx)(`button`,{onClick:f,className:`flex h-7 w-7 items-center justify-center rounded bg-accent text-white hover:bg-accent/90 active:scale-95 transition-all md:hidden`,title:`New session (${O}N)`,"aria-label":`New session`,children:(0,J.jsx)(ke,{width:16,height:16})}),e&&le&&(0,J.jsx)(`button`,{onClick:()=>I(!0),className:`flex md:hidden h-7 w-7 items-center justify-center rounded bg-danger/10 border border-danger/30 text-danger hover:bg-danger/20 active:scale-95 transition-all`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,J.jsx)(ze,{width:16,height:16})}),he&&(0,J.jsx)(`button`,{onClick:De,className:`flex md:hidden h-7 w-7 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,J.jsx)(Ce,{width:16,height:16})}),n&&(0,J.jsx)(`button`,{onClick:()=>h(n.sessionId),className:`btn btn-primary h-7 px-2 text-xs`,children:`Wake`}),e&&(0,J.jsxs)(`div`,{className:`relative md:hidden`,ref:ne,children:[(0,J.jsx)(`button`,{onClick:()=>z(!L),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all`,title:`More options`,"aria-label":`More options`,children:(0,J.jsx)(de,{width:16,height:16})}),L&&(0,J.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border bg-elevated shadow-lg py-1`,children:[le&&(0,J.jsxs)(`button`,{onClick:Oe,className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,J.jsx)(pe,{width:14,height:14}),`Rename`]}),he&&(0,J.jsxs)(`button`,{onClick:De,className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,J.jsx)(Ce,{width:14,height:14}),`Hibernate`]}),(0,J.jsxs)(`button`,{onClick:()=>{v(),z(!1)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,J.jsx)(Ne,{width:14,height:14}),`Settings`]})]})]})]})]}),e&&t.length>1&&(0,J.jsxs)(`div`,{className:`relative overflow-hidden bg-elevated border-b border-border md:hidden`,children:[(0,J.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-4 bg-gradient-to-l from-elevated to-transparent z-10 pointer-events-none`}),(0,J.jsx)(`div`,{className:`flex items-center gap-1.5 pl-5 pr-3 py-1.5 overflow-x-auto scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:t.map((t,n)=>(0,J.jsx)(`button`,{type:`button`,className:`
191
+ `,onMouseDown:e=>e.preventDefault(),onTouchStart:j(k),onClick:M(k),disabled:t,children:Q_})]}),l&&(0,J.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,J.jsxs)(`div`,{ref:v,className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,J.jsx)(`h3`,{className:`text-base font-medium text-primary mb-1 text-balance`,children:`Paste`}),(0,J.jsx)(`p`,{className:`text-xs text-muted mb-3 text-pretty`,children:`Text or image (long-press → Paste)`}),p?(0,J.jsx)(`div`,{className:`w-full h-11 flex items-center justify-center bg-surface border border-border rounded-md text-secondary`,children:`Uploading image...`}):(0,J.jsx)(`input`,{ref:_,type:`text`,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),E()):e.key===`Escape`&&(e.preventDefault(),D())},placeholder:`Paste here...`,className:`w-full h-11 px-3 text-[16px] bg-surface border border-border rounded-md text-primary placeholder:text-muted outline-none focus:border-accent`,style:{fontSize:`16px`}}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 mt-4`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:D,className:`px-4 py-2 text-sm font-medium text-secondary bg-surface border border-border rounded-md active:scale-95 transition-transform`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:E,disabled:p,className:`px-4 py-2 text-sm font-medium bg-accent text-white rounded-md active:scale-95 transition-transform disabled:opacity-50`,children:`Send`})]})]})})]})}function av({isOpen:e,onClose:t,sessions:n,hibernatingSessions:r=[],historySessions:i=[],selectedSessionId:a,selectedHibernatingSessionId:o=null,onSelect:s,onSelectHibernating:c,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:p,loading:m,error:h}){let g=ld(),_=(0,x.useRef)(null),v=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&(e.preventDefault(),t())};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e,t]),(0,x.useEffect)(()=>{e?(v.current=document.activeElement,_.current?.focus()):v.current&&=(v.current.focus(),null)},[e]),(0,x.useEffect)(()=>{if(!e)return;let n=_.current;if(!n)return;let r=0,i=0,a=e=>{let t=e.touches[0];r=t.clientX,i=t.clientY},o=e=>{let n=e.changedTouches[0],a=r-n.clientX,o=Math.abs(n.clientY-i);a>=50&&a>o*1.5&&(`vibrate`in navigator&&navigator.vibrate(10),t())};return n.addEventListener(`touchstart`,a,{passive:!0}),n.addEventListener(`touchend`,o,{passive:!0}),()=>{n.removeEventListener(`touchstart`,a),n.removeEventListener(`touchend`,o)}},[e,t]);let y=e=>{s(e),t()},b=e=>{c?.(e),t()},S=g?{transition:`none`}:void 0;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`session-drawer-backdrop ${e?`open`:``}`,style:S,onClick:t,"aria-hidden":`true`}),(0,J.jsxs)(`div`,{ref:_,className:`session-drawer ${e?`open`:``}`,style:S,role:`dialog`,"aria-modal":`true`,"aria-label":`Session list`,tabIndex:-1,children:[(0,J.jsx)(jh,{sessions:n,hibernatingSessions:r,historySessions:i,selectedSessionId:a,selectedHibernatingSessionId:o,onSelect:y,onSelectHibernating:b,onRename:l,onResume:u,onHibernate:d,onMoveToHistory:f,onNewSession:()=>{p()!==!1&&t()},loading:m,error:h}),(0,J.jsx)(`div`,{className:`shrink-0 border-t border-border px-2 pt-2`,style:{paddingBottom:`max(0.5rem, env(safe-area-inset-bottom, 0.5rem))`},children:(0,J.jsx)(`button`,{onClick:()=>{p()!==!1&&t()},className:`btn btn-primary w-full py-2 text-sm`,children:`New Session`})})]})]})}var ov={working:`Working`,waiting:`Waiting`,permission:`Needs Input`,unknown:`Unknown`},sv={working:`text-working`,waiting:`text-waiting`,permission:`text-approval`,unknown:`text-muted`},cv={working:`bg-green-500/35 text-white`,waiting:`bg-blue-500/35 text-white`,permission:`bg-amber-500/35 text-white`,unknown:`bg-gray-500/35 text-white`},lv={working:`bg-working text-white`,waiting:`bg-waiting text-white`,permission:`bg-approval text-white`,unknown:`bg-muted text-white`};function uv(){`vibrate`in navigator&&navigator.vibrate(10)}function dv({session:e,sessions:t,hibernatingSession:n=null,hibernatingSessions:r=[],historySessions:i=[],connectionStatus:a,connectionEpoch:o=0,sendMessage:s,subscribe:c,onClose:l,onSelectSession:u,onSelectHibernatingSession:d,onNewSession:f,onKillSession:p,onRenameSession:m,onResumeSession:h,onHibernateSession:g,onMoveToHistory:_,onOpenSettings:v,loading:y=!1,error:b=null}){let S=E_[T_(e=>e.theme)],C=G(e=>e.useWebGL),w=G(e=>e.fontSize),T=G(e=>e.lineHeight),E=G(e=>e.letterSpacing),D=R(G(e=>e.fontOption),G(e=>e.customFontFamily)),O=Ge(Ue(G(e=>e.shortcutModifier))),k=Be(),A=x_(),[j,M]=(0,x.useState)(!1),[N,P]=(0,x.useState)(!1),[F,I]=(0,x.useState)(!1),[L,z]=(0,x.useState)(!1),[B,V]=(0,x.useState)(!1),[H,U]=(0,x.useState)(!1),[W,ee]=(0,x.useState)(``),K=(0,x.useRef)(!1),te=(0,x.useRef)(null),ne=(0,x.useRef)(null),re=(0,x.useRef)(null),ie=(0,x.useRef)(null),ae=e?.remote===!0,oe=Um(e=>e.remoteAllowControl),se=Um(e=>e.remoteAllowAttach),ce=ae&&!se,le=!ae||oe&&e?.source===`managed`,ue=n?n.displayName||Mm(n.projectPath)||n.sessionId.slice(0,8):``,fe=n?Mm(n.projectPath):``,me=n?jm(n.lastActivityAt):``,he=!!e&&!!g&&e.source===`managed`&&!e.remote&&!!e.agentSessionId?.trim(),{containerRef:ge,terminalRef:_e,inTmuxCopyModeRef:ve,setTmuxCopyMode:ye,isSwitching:be}=b_({sessionId:e?.id??null,tmuxTarget:e?.tmuxWindow??null,allowAttach:!ce,connectionStatus:a,connectionEpoch:o,sendMessage:s,subscribe:c,theme:S,fontSize:w,lineHeight:T,letterSpacing:E,fontFamily:D,useWebGL:C,onScrollChange:e=>{M(!e)}}),Se=(0,x.useCallback)(()=>{!e||ce||(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),ye(!1),_e.current?.scrollToBottom())},[e,ce,s,ye,_e]),we=(0,x.useCallback)(()=>{V(!0),uv()},[]),Te=w_({enabled:A||k,isOpen:B,onOpen:we});(0,x.useEffect)(()=>{!A&&!k&&B&&V(!1)},[B,A,k]),S_(ne,L,(0,x.useCallback)(()=>z(!1),[])),(0,x.useEffect)(()=>{H&&re.current&&(re.current.focus(),re.current.select())},[H]),(0,x.useEffect)(()=>{F&&ie.current&&ie.current.focus()},[F]),C_(F,(0,x.useCallback)(()=>I(!1),[]));let Ee=()=>{e&&(p(e.id,`terminal_confirm_modal`),I(!1))},De=()=>{!e||!he||(g?.(e.agentSessionId.trim()),z(!1))},Oe=()=>{e&&(ee(e.agentSessionName||e.name),U(!0),z(!1))},Ae=()=>{if(!e)return;let t=W.trim(),n=e.agentSessionName||e.name;t&&t!==n&&m(e.id,t),U(!1)},je=e=>{e.key===`Enter`?(e.preventDefault(),Ae()):e.key===`Escape`&&(e.preventDefault(),U(!1))};(0,x.useEffect)(()=>{if(!k||!e){P(!1);return}let t=ge.current;if(!t)return;let n=e=>{let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},r=()=>{let e=t.querySelector(`.xterm-accessibility`),n=t.querySelector(`.xterm-accessibility-tree`);!e||!n||(e.style.setProperty(`opacity`,`0`),n.style.setProperty(`opacity`,`0`),e.style.setProperty(`-webkit-user-select`,`none`),e.style.setProperty(`user-select`,`none`),n.style.setProperty(`-webkit-user-select`,`none`),n.style.setProperty(`user-select`,`none`),e.offsetHeight,requestAnimationFrame(()=>{e.style.removeProperty(`opacity`),n.style.removeProperty(`opacity`),e.style.removeProperty(`-webkit-user-select`),e.style.removeProperty(`user-select`),n.style.removeProperty(`-webkit-user-select`),n.style.removeProperty(`user-select`)}))},i=()=>{K.current=!1;let e=window.getSelection();try{e?.removeAllRanges()}catch{}_e.current?.clearSelection(),r(),P(!1)};te.current=i;let a=()=>{let e=window.getSelection();if(!e||e.rangeCount===0||e.isCollapsed){K.current?i():P(e=>e&&!1);return}let t=n(e);if(!t&&K.current){i();return}K.current=t;let r=t;P(e=>e===r?e:r)},o=()=>{let e=window.getSelection();!e||e.isCollapsed||n(e)&&setTimeout(i,0)},s=null,c=!1,l=e=>{if(e.touches.length===1){let t=e.touches[0];s={x:t.clientX,y:t.clientY},c=!1}},u=e=>{if(c||!s||e.touches.length!==1)return;let t=e.touches[0],n=Math.abs(t.clientX-s.x),r=Math.abs(t.clientY-s.y);(n>10||r>10)&&(c=!0)},d=e=>{let r=c;s=null,c=!1;let a=window.getSelection();if(!a||a.rangeCount===0||a.isCollapsed){P(!1);return}let o=t.querySelector(`.xterm-accessibility-tree`);if(!o)return;if(!n(a)){P(!1);return}if(r)return;let l=e.target,u=l?o.contains(l):!1,d=!1;if(u&&l)try{d=a.containsNode(l,!0)}catch{d=!1}(!u||!d)&&setTimeout(i,0)};return document.addEventListener(`selectionchange`,a),document.addEventListener(`copy`,o),document.addEventListener(`touchstart`,l,{passive:!0}),document.addEventListener(`touchmove`,u,{passive:!0}),document.addEventListener(`touchend`,d,{passive:!0}),()=>{document.removeEventListener(`selectionchange`,a),document.removeEventListener(`copy`,o),document.removeEventListener(`touchstart`,l),document.removeEventListener(`touchmove`,u),document.removeEventListener(`touchend`,d),te.current=null,K.current=!1}},[ge,k,e?.id]),(0,x.useEffect)(()=>{if(!k)return;let t=ge.current;if(!t)return;let n=()=>{let e=_e.current,n=t.querySelector(`.xterm`);if(!e||!n)return;let r=n.querySelector(`.xterm-screen`),i=n.querySelector(`.xterm-accessibility`),a=n.querySelector(`.xterm-accessibility-tree`);if(!r||!i||!a)return;let o=n.getBoundingClientRect(),s=r.getBoundingClientRect(),c=s.left-o.left,l=s.top-o.top;Object.assign(i.style,{left:`${c}px`,top:`${l}px`,right:`auto`,bottom:`auto`,width:`${s.width}px`,height:`${s.height}px`});let u=s.width/e.cols,d=s.height/e.rows,f=document.createElement(`span`);f.textContent=`0`.repeat(200),f.style.cssText=`position:absolute;visibility:hidden;white-space:pre;pointer-events:none;letter-spacing:0px`,a.appendChild(f);let p=f.getBoundingClientRect().width/200;f.remove();let m=Math.max(-2,Math.min(2,u-p));t.style.setProperty(`--xterm-font-size`,`${e.options.fontSize}px`),t.style.setProperty(`--xterm-cell-height`,`${d}px`),t.style.setProperty(`--xterm-a11y-letter-spacing`,`${m}px`)},r=performance.now();n();let i=Math.round(performance.now()-r);i>10&&Z(`switch_a11y_overlay`,{sessionId:e?.id,a11yMs:i});let a=window.requestAnimationFrame(n),o=window.setTimeout(n,100),s=()=>window.requestAnimationFrame(n);return window.visualViewport?.addEventListener(`resize`,s),window.addEventListener(`orientationchange`,s),()=>{window.cancelAnimationFrame(a),window.clearTimeout(o),window.visualViewport?.removeEventListener(`resize`,s),window.removeEventListener(`orientationchange`,s)}},[ge,w,k,e?.id,_e]);let Me=(0,x.useRef)(N);(0,x.useEffect)(()=>{Me.current=N},[N]);let Pe=(0,x.useRef)(e?.id);(0,x.useEffect)(()=>{Pe.current=e?.id},[e?.id]);let Fe=(0,x.useRef)(s);(0,x.useEffect)(()=>{Fe.current=s},[s]);let Ie=(0,x.useRef)(!1);(0,x.useEffect)(()=>{let t=ge.current;if(!t||!e?.id||!A&&!k)return;let n={x:0,y:0},r=0,i=!1,a=null,o=0,s=0,c=0,l=Math.round(w*T),u=null,d=()=>{let e=window.getComputedStyle(t).getPropertyValue(`--xterm-cell-height`).trim(),n=Number.parseFloat(e);return!Number.isNaN(n)&&n>0?n:Math.round(w*T)},f=()=>t.querySelector(`.xterm-helper-textarea`),p=()=>{let e=f();e&&document.activeElement!==e&&(e.disabled=!0)},m=()=>{let e=f();e&&(e.disabled=!1)};p();let h=()=>{if(ve.current)return;let e=f();e&&(e.disabled=!1,e.focus())},g=()=>{u!==null&&(cancelAnimationFrame(u),u=null),s=0},_=e=>{let t=Pe.current;if(!t||e===0)return!1;let n=_e.current,r=n?.cols??80,i=n?.rows??24,a=Math.floor(r/2),o=Math.floor(i/2),s=e>0?65:64,c=Math.abs(e),l=e<0;for(let e=0;e<c;e++)Fe.current({type:`terminal-input`,sessionId:t,data:`\x1b[<${s};${a};${o}M`});return l&&ye(!0),l},v=()=>{a=null,s=0,c=0},y=()=>{if(!k)return!1;let e=window.getSelection();if(!e||e.isCollapsed)return!1;let n=t.querySelector(`.xterm-accessibility-tree`);if(!n)return!1;let r=e.anchorNode,i=e.focusNode;return!!r&&n.contains(r)||!!i&&n.contains(i)},b=()=>{!k||!K.current||y()||te.current?.()},x=e=>{if(g(),b(),Te.current||B){v();return}if(Me.current){v();return}if(e.touches.length===1){let t=e.touches[0];n={x:t.clientX,y:t.clientY},r=performance.now(),i=!1,a=t.clientY,o=r,s=0,c=0,l=d(),m()}},S=e=>{if(e.touches.length!==1||a===null)return;if(b(),Te.current||B){v();return}if(Me.current||y()){v();return}e.preventDefault(),e.stopPropagation();let t=performance.now(),r=e.touches[0],u=r.clientX,d=r.clientY,f=Math.abs(u-n.x),m=Math.abs(d-n.y);!i&&(f>6||m>6)&&(i=!0,p());let h=a-d,g=t-o;if(a=d,o=t,g>0){let e=h/g;s=s*.7+e*.3}c+=h;let x=Math.max(6,l*.6),S=Math.trunc(c/x);S!==0&&(_(S),c-=S*x)},C=e=>{let t=s,n=performance.now()-r;if(v(),Te.current||B)return;let a=y();if(Me.current&&!a&&te.current?.(),Me.current||a){ve.current&&(Ie.current=!0);return}if(!i){if(k&&n>=350)return;if(ve.current){e.preventDefault(),e.stopPropagation(),Ie.current=!0;return}h();return}if(Math.abs(t)>.12){let e=t,n=performance.now(),r=()=>{let t=performance.now(),i=t-n;n=t;let a=e*i;c+=a;let o=Math.max(6,l*.6),s=Math.trunc(c/o);s!==0&&(_(s),c-=s*o),e*=.95**(i/16.67),u=Math.abs(e)>.02?requestAnimationFrame(r):null};u=requestAnimationFrame(r)}},E=e=>{Ie.current&&=(e.preventDefault(),e.stopPropagation(),!1)},D={passive:!0,capture:!0},O={passive:!1,capture:!0},j={passive:!1,capture:!0},M={capture:!0};return t.addEventListener(`touchstart`,x,D),t.addEventListener(`touchmove`,S,O),t.addEventListener(`touchend`,C,j),t.addEventListener(`mousedown`,E,M),()=>{t.removeEventListener(`touchstart`,x,D),t.removeEventListener(`touchmove`,S,O),t.removeEventListener(`touchend`,C,j),t.removeEventListener(`mousedown`,E,M);let e=f();e&&(e.disabled=!1)}},[e?.id,ge,_e,k,A,B,w,T]);let Le=(0,x.useCallback)(t=>{!e||ce||s({type:`terminal-input`,sessionId:e.id,data:t})},[e,ce,s]),Re=(0,x.useCallback)(()=>{let e=ge.current;if(!e)return;let t=e.querySelector(`.xterm-helper-textarea`);t&&(t.removeAttribute(`disabled`),t.focus())},[ge]),Ve=(0,x.useCallback)(()=>{if(!e||ce)return;ve.current&&(s({type:`tmux-cancel-copy-mode`,sessionId:e.id}),ye(!1));let t=ge.current;if(!t)return;let n=t.querySelector(`.xterm-helper-textarea`);n&&(n.removeAttribute(`disabled`),n.focus())},[e,ce,s,ge,ve,ye]),He=(0,x.useCallback)(()=>{if(typeof document>`u`)return!1;let e=ge.current;if(!e)return!1;let t=e.querySelector(`.xterm-helper-textarea`);if(t&&document.activeElement===t)return!0;let n=document.activeElement,r=typeof HTMLInputElement<`u`&&n instanceof HTMLInputElement,i=typeof HTMLTextAreaElement<`u`&&n instanceof HTMLTextAreaElement;return r||i||n&&n.isContentEditable?!1:!!document.documentElement?.classList?.contains(`keyboard-visible`)},[ge]);return(0,x.useEffect)(()=>{if(!k)return;let e=ge.current;if(!e)return;let t=e.querySelector(`.xterm-accessibility`),n=e.querySelector(`.xterm-accessibility-tree`);if(!t||!n)return;let r=()=>{let r=e.querySelector(`.xterm-helper-textarea`);r&&document.activeElement===r&&!Me.current?(t.style.pointerEvents=`none`,n.style.pointerEvents=`none`):(t.style.removeProperty(`pointer-events`),n.style.removeProperty(`pointer-events`))};return r(),document.addEventListener(`focusin`,r),document.addEventListener(`focusout`,r),()=>{document.removeEventListener(`focusin`,r),document.removeEventListener(`focusout`,r)}},[ge,k,N]),(0,J.jsxs)(`section`,{className:`flex flex-1 flex-col bg-base terminal-mobile-overlay md:relative md:inset-auto ${k?`ios-native-term-selection`:``}`,"data-testid":`terminal-panel`,children:[(0,J.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center justify-between border-b border-border bg-elevated px-3 ${e||n?``:`md:hidden`}`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,J.jsx)(`button`,{onClick:()=>V(!0),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all md:hidden shrink-0`,"aria-label":`Open session menu`,children:(0,J.jsx)(xe,{width:16,height:16})}),e&&le&&(0,J.jsx)(`button`,{onClick:()=>I(!0),className:`hidden md:flex h-7 w-7 items-center justify-center rounded bg-danger/10 border border-danger/30 text-danger hover:bg-danger/20 active:scale-95 transition-all shrink-0`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,J.jsx)(ze,{width:16,height:16})}),he&&(0,J.jsx)(`button`,{onClick:De,className:`hidden md:flex h-7 w-7 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all shrink-0`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,J.jsx)(Ce,{width:16,height:16})}),e?(0,J.jsxs)(`div`,{className:`flex items-baseline gap-3 min-w-0`,children:[H?(0,J.jsx)(`input`,{ref:re,type:`text`,value:W,onChange:e=>ee(e.target.value),onBlur:Ae,onKeyDown:je,className:`w-full max-w-[200px] rounded border border-border bg-surface px-2 py-0.5 text-sm font-medium text-primary outline-none focus:border-accent`}):(0,J.jsx)(`span`,{className:`text-sm font-medium text-primary truncate`,children:e.agentSessionName||e.name}),(0,J.jsx)(`span`,{className:`text-xs shrink-0 ${sv[e.status]}`,children:ov[e.status]})]}):n?(0,J.jsxs)(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[(0,J.jsx)(`span`,{className:`text-sm font-medium text-primary truncate`,children:ue}),(0,J.jsx)(`span`,{className:`rounded-full bg-blue-500/15 px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-blue-400`,children:`Hibernating`})]}):(0,J.jsx)(`span`,{className:`text-sm font-medium text-primary md:hidden`,children:`Sessions`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[a!==`connected`&&(0,J.jsx)(`span`,{className:`text-xs text-approval`,children:a}),(0,J.jsx)(`button`,{onClick:f,className:`flex h-7 w-7 items-center justify-center rounded bg-accent text-white hover:bg-accent/90 active:scale-95 transition-all md:hidden`,title:`New session (${O}N)`,"aria-label":`New session`,children:(0,J.jsx)(ke,{width:16,height:16})}),e&&le&&(0,J.jsx)(`button`,{onClick:()=>I(!0),className:`flex md:hidden h-7 w-7 items-center justify-center rounded bg-danger/10 border border-danger/30 text-danger hover:bg-danger/20 active:scale-95 transition-all`,title:`Kill session (${O}X)`,"aria-label":`Kill session`,children:(0,J.jsx)(ze,{width:16,height:16})}),he&&(0,J.jsx)(`button`,{onClick:De,className:`flex md:hidden h-7 w-7 items-center justify-center rounded border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all`,title:`Hibernate session`,"aria-label":`Hibernate session`,children:(0,J.jsx)(Ce,{width:16,height:16})}),n&&(0,J.jsx)(`button`,{onClick:()=>h(n.sessionId),className:`btn btn-primary h-7 px-2 text-xs`,children:`Wake`}),e&&(0,J.jsxs)(`div`,{className:`relative md:hidden`,ref:ne,children:[(0,J.jsx)(`button`,{onClick:()=>z(!L),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover hover:text-primary active:scale-95 transition-all`,title:`More options`,"aria-label":`More options`,children:(0,J.jsx)(de,{width:16,height:16})}),L&&(0,J.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 z-20 min-w-[140px] rounded-md border border-border bg-elevated shadow-lg py-1`,children:[le&&(0,J.jsxs)(`button`,{onClick:Oe,className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,J.jsx)(pe,{width:14,height:14}),`Rename`]}),he&&(0,J.jsxs)(`button`,{onClick:De,className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,J.jsx)(Ce,{width:14,height:14}),`Hibernate`]}),(0,J.jsxs)(`button`,{onClick:()=>{v(),z(!1)},className:`w-full px-3 py-2 text-left text-sm text-secondary hover:bg-hover hover:text-primary flex items-center gap-2`,children:[(0,J.jsx)(Ne,{width:14,height:14}),`Settings`]})]})]})]})]}),e&&t.length>1&&(0,J.jsxs)(`div`,{className:`relative overflow-hidden bg-elevated border-b border-border md:hidden`,children:[(0,J.jsx)(`div`,{className:`absolute right-0 top-0 bottom-0 w-4 bg-gradient-to-l from-elevated to-transparent z-10 pointer-events-none`}),(0,J.jsx)(`div`,{className:`flex items-center gap-1.5 pl-5 pr-3 py-1.5 overflow-x-auto scrollbar-none scroll-smooth snap-x snap-mandatory`,style:{WebkitOverflowScrolling:`touch`},children:t.map((t,n)=>(0,J.jsx)(`button`,{type:`button`,className:`
192
192
  flex items-center justify-center shrink-0 snap-start
193
193
  h-8 w-8 text-sm font-extrabold rounded-lg
194
194
  active:scale-95 transition-all duration-75
195
195
  select-none touch-manipulation
196
196
  ${t.id===e.id?lv[t.status]:cv[t.status]}
197
- `,onClick:()=>{uv(),u(t.id)},children:n+1},t.id))})]}),(0,J.jsxs)(`div`,{className:`relative flex-1`,children:[(0,J.jsx)(`div`,{ref:ge,className:`absolute inset-0`}),be&&e&&(0,J.jsxs)(`div`,{className:`absolute top-2 left-2 z-50 flex items-center gap-1.5 rounded-lg bg-black/60 px-2.5 py-1.5 text-xs text-white/90 shadow-lg backdrop-blur-md`,children:[(0,J.jsxs)(`svg`,{className:`h-3 w-3 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,J.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,J.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Loading`]}),!e&&(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted`,children:n?null:`Select a session to view terminal`}),e&&ce&&(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-center text-sm text-muted`,children:`Remote session (read-only). Use SSH to attach on the host.`}),n&&(0,J.jsx)(`div`,{className:`absolute inset-0 overflow-y-auto bg-base`,children:(0,J.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-4xl flex-col gap-6 p-6`,children:[(0,J.jsx)(`div`,{className:`rounded-2xl border border-border bg-elevated p-6`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-start md:justify-between`,children:[(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`rounded-full bg-blue-500/15 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-blue-400`,children:`Hibernating`}),n.lastResumeError&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-amber-500/15 px-2 py-1 text-[11px] text-amber-400`,title:`Last wake failed: ${n.lastResumeError}`,children:[(0,J.jsx)(q,{width:12,height:12}),`Wake failed`]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-xl font-semibold text-primary`,children:ue}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,children:`Wake this session to reopen its underlying app and terminal.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs text-muted`,children:[fe&&(0,J.jsx)(`span`,{className:`rounded-full bg-surface px-2.5 py-1`,children:fe}),(0,J.jsxs)(`span`,{className:`rounded-full bg-surface px-2.5 py-1`,children:[`Last active `,me]})]}),n.lastUserMessage&&(0,J.jsxs)(`p`,{className:`max-w-2xl text-sm italic text-muted`,children:[`"`,n.lastUserMessage,`"`]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>h(n.sessionId),className:`btn btn-primary`,children:`Wake Session`}),_&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>_(n.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,J.jsx)(Eh,{session:n})]})}),j&&e&&!N&&(0,J.jsxs)(`button`,{onClick:Se,className:`absolute bottom-8 left-1/2 z-20 flex h-10 px-4 items-center justify-center gap-1.5 rounded-full bg-blue-600/90 text-white shadow-lg hover:bg-blue-600 active:scale-95 transition-all`,style:{transform:`translateX(-50%)`},title:`Scroll to bottom`,"aria-label":`Scroll to bottom`,children:[(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,J.jsx)(`path`,{d:`M12 5v14M5 12l7 7 7-7`})}),(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]})]}),e&&(0,J.jsx)(iv,{onSendKey:Le,disabled:a!==`connected`||ce,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,onSelectSession:u,hideSessionSwitcher:!0,onRefocus:Re,isKeyboardVisible:He,onEnterTextMode:Ve}),(A||k)&&(0,J.jsx)(av,{isOpen:B,onClose:()=>V(!1),sessions:t,hibernatingSessions:r,historySessions:i,selectedSessionId:e?.id??null,selectedHibernatingSessionId:n?.sessionId??null,onSelect:u,onSelectHibernating:d,onRename:m,onResume:h,onHibernate:g,onMoveToHistory:_,onNewSession:f,loading:y,error:b}),F&&e&&(0,J.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,J.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,J.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,J.jsxs)(`p`,{className:`text-sm text-secondary mb-4 text-pretty`,children:[`Kill "`,e.agentSessionName||e.name,`"? The process will be terminated. Conversation history is preserved in logs.`]}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)(`button`,{onClick:()=>I(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,J.jsx)(`button`,{ref:ie,onClick:Ee,className:`btn btn-danger py-1.5 px-3 text-sm`,children:`Kill Session`})]})]})})]})}function fv({onSelect:e,onCancel:t,initialPath:n}){let[r,i]=(0,x.useState)(n||`~`),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(!0),[d,f]=(0,x.useState)(-1),p=(0,x.useRef)(null),m=G(e=>e.recentPaths),h=(0,x.useCallback)(async e=>{p.current?.abort();let t=new AbortController;p.current=t;let{signal:n}=t;u(!0),c(null),o(null),f(-1),i(e);try{let r=await fetch(`/api/directories?path=${encodeURIComponent(e)}`,{signal:n});if(!r.ok){let e=await r.json();throw Error(e.message||`Failed to load directory`)}let a=await r.json();if(p.current!==t)return;o(a),i(a.path)}catch(e){if(p.current!==t)return;let n=e;n?.name!==`AbortError`&&c(n?.message||`Failed to load directory`)}finally{p.current===t&&u(!1)}},[]);(0,x.useEffect)(()=>(h(n||`~`),()=>{p.current?.abort()}),[h,n]);let g=a?.directories??[],_=a?.path||r,v=a?.parent;return(0,x.useEffect)(()=>{let n=n=>{if(n.key===`Escape`){n.preventDefault(),t();return}if(!l){if(n.key===`ArrowDown`){n.preventDefault(),f(e=>g.length===0?-1:e<0?0:Math.min(e+1,g.length-1));return}if(n.key===`ArrowUp`){n.preventDefault(),f(e=>g.length===0?-1:e<0?g.length-1:Math.max(e-1,0));return}if(n.key===`Enter`){n.preventDefault();let t=g[d];t?h(t.path):_&&e(_);return}n.key===`Backspace`&&v&&(n.preventDefault(),h(v))}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[g,_,h,d,l,t,e,v]),(0,J.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Directory browser`,className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},"data-testid":`directory-browser`,children:(0,J.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,J.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,J.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,J.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,J.jsx)(`p`,{className:`text-danger`,children:s}),(0,J.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,J.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,J.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>h(e.path),onMouseEnter:()=>f(t),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-xs ${t===d?`bg-hover text-primary`:`text-secondary`}`,"data-testid":`directory-entry`,"data-entry-name":e.name,"data-entry-path":e.path,children:[(0,J.jsx)(_e,{width:14,height:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,J.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,J.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,J.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`block w-full truncate text-left text-xs text-secondary hover:text-primary`,onClick:()=>h(e),title:e,"data-testid":`directory-recent`,"data-recent-path":e,children:e},e))})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function pv({isOpen:e,onClose:t,onCreate:n,defaultProjectDir:r,commandPresets:i,defaultPresetId:a,lastProjectPath:o,activeProjectPath:s,remoteHosts:c=[],remoteAllowControl:l=!1,initialHost:u,initialPath:d,initialCommand:f}){let[p,m]=(0,x.useState)(``),[h,g]=(0,x.useState)(``),[_,v]=(0,x.useState)(null),[y,b]=(0,x.useState)(``),[S,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(``),E=(0,x.useRef)(null),D=(0,x.useRef)(null),O=(0,x.useRef)(null),k=l&&c.length>0;if((0,x.useEffect)(()=>{if(!e){m(``),g(``),v(null),b(``),C(!1),T(u??``),setTimeout(()=>{if(typeof document>`u`||typeof document.querySelector!=`function`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300);return}if(typeof document<`u`&&typeof document.querySelector==`function`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}m(d?.trim()||s?.trim()||o||r||``),g(``),T(u??``);let t=f?.trim();if(t){let e=i.find(e=>H(e)===t);e?(v(e.id),b(H(e))):(v(null),b(t))}else{let e=i.find(e=>e.id===a);e?(v(a),b(H(e))):i.length>0?(v(i[0].id),b(H(i[0]))):(v(null),b(``))}setTimeout(()=>{if(O.current?.focus(),D.current){let e=D.current;e.scrollLeft=e.scrollWidth}},50)},[s,i,a,r,e,o,u,d,f]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=()=>E.current?Array.from(E.current.querySelectorAll(`input:not([disabled]), select:not([disabled]), button:not([disabled]):not([tabindex="-1"]), [tabindex="0"]`)):[],r=e=>{if(!S){if(e.key===`Escape`){typeof e.stopPropagation==`function`&&e.stopPropagation(),t();return}if(e.key===`Enter`){let t=document.activeElement;if(!t||t.tagName===`INPUT`||t.closest(`[data-testid="host-select"]`)||!t.closest(`[data-testid="command-select"]`))return;e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation(),E.current?.requestSubmit();return}if(e.key===`Tab`){e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation();let t=n();if(t.length===0)return;let r=document.activeElement,i=t.indexOf(r),a;a=i===-1?e.shiftKey?t.length-1:0:e.shiftKey?i<=0?t.length-1:i-1:i>=t.length-1?0:i+1,t[a]?.focus()}}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,t,S]),!e)return null;let A=e=>{let t=i.find(t=>t.id===e);t&&(v(e),b(H(t)))},j=()=>{v(null),b(``)},M=_===null,N=w!==``,P=e=>{e.preventDefault();let r=p.trim();if(!r)return;let i=y.trim();n(r,h.trim()||void 0,i||void 0,N?w:void 0),t()},F=[...i.map(e=>({id:e.id,label:e.label,isCustom:!1,agentType:e.agentType,command:e.command})),{id:`custom`,label:`Custom`,isCustom:!0,agentType:void 0,command:void 0}],I=[{id:``,label:`Local`,ok:!0,error:void 0},...c.map(e=>({id:e.host,label:e.host,ok:e.ok,error:e.error}))],L=p.trim()||`~`;return(0,J.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-session-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:[(0,J.jsxs)(`form`,{ref:E,onSubmit:P,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,J.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,J.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[k&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Host`,"data-testid":`host-select`,children:I.map((e,t)=>{let n=w===e.id,r=!e.ok&&!n;return(0,J.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":e.label,title:e.ok?void 0:e.error||`Unreachable`,tabIndex:n?0:-1,onClick:()=>T(e.id),onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%I.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+I.length)%I.length;else return;let r=I[n];T(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``} ${r?`opacity-60`:``}`,children:e.label},e.id||`local`)})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Command preset`,"data-testid":`command-select`,children:F.map((e,t)=>{let n=e.isCustom?M:_===e.id;return(0,J.jsxs)(`button`,{ref:n?O:void 0,type:`button`,role:`radio`,"aria-checked":n,tabIndex:n?0:-1,onClick:()=>{e.isCustom?j():A(e.id)},onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%F.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+F.length)%F.length;else return;let r=F[n];r.isCustom?j():A(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``}`,children:[(0,J.jsx)(Xm,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,J.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(`input`,{ref:D,value:p,onChange:e=>m(e.target.value),placeholder:N?`/home/user/project`:s||o||r||`/Users/you/code/my-project`,className:`input flex-1 text-sm`}),!N&&(0,J.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>C(!0),children:`Browse`})]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,J.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,J.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),S&&!N&&(0,J.jsx)(fv,{initialPath:L,onSelect:e=>{m(e),C(!1)},onCancel:()=>C(!1)})]})}function mv({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=x.useRef(e!==void 0),[a,o]=x.useState(t);return[i?e:a,x.useCallback(e=>{i||o(e)},[])]}var hv={};function gv(e,t){let n=x.useRef(hv);return n.current===hv&&(n.current=e(t)),n}var _v=x[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],vv=_v&&_v!==x.useLayoutEffect?_v:e=>e();function yv(e){let t=gv(bv).current;return t.next=e,vv(t.effect),t.trampoline}function bv(){let e={next:void 0,callback:xv,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function xv(){}function Sv(e,t,n,r){let i=gv(wv).current;return Tv(i,e,t,n,r)&&Dv(i,[e,t,n,r]),i.callback}function Cv(e){let t=gv(wv).current;return Ev(t,e)&&Dv(t,e),t.callback}function wv(){return{callback:null,cleanup:null,refs:[]}}function Tv(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Ev(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Dv(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n;break;default:}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null;break;default:}}}}}}var Ov=typeof document<`u`?x.useLayoutEffect:()=>{},kv={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},Av={...kv,position:`fixed`,top:0,left:0},jv={...kv,position:`absolute`};function Mv(){}Object.freeze([]);var Nv=Object.freeze({});function Pv(e,...t){let n=new URL(`https://base-ui.com/production-error`);return n.searchParams.set(`code`,e.toString()),t.forEach(e=>n.searchParams.append(`args[]`,e)),`Base UI error #${e}; visit ${n} for the full message.`}var Fv=18;function Iv(e){return Fv>=e}function Lv(e){if(!x.isValidElement(e))return null;let t=e,n=t.props;return(Iv(19)?n?.ref:t.ref)??null}function Rv(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function zv(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Bv(e,t){return typeof e==`function`?e(t):e}function Vv(e,t){return typeof e==`function`?e(t):e}var Hv={};function Uv(e,t,n,r,i){let a={...Yv(e,Hv)};return t&&(a=Gv(a,t)),n&&(a=Gv(a,n)),r&&(a=Gv(a,r)),i&&(a=Gv(a,i)),a}function Wv(e){if(e.length===0)return Hv;if(e.length===1)return Yv(e[0],Hv);let t={...Yv(e[0],Hv)};for(let n=1;n<e.length;n+=1)t=Gv(t,e[n]);return t}function Gv(e,t){return Jv(t)?t(e):Kv(e,t)}function Kv(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Rv(e.style,r);break;case`className`:e[n]=Qv(e.className,r);break;default:qv(n,r)?e[n]=Xv(e[n],r):e[n]=r}}return e}function qv(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Jv(e){return typeof e==`function`}function Yv(e,t){return Jv(e)?e(t):e??Hv}function Xv(e,t){return t?e?n=>{if($v(n)){let r=n;Zv(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function Zv(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Qv(e,t){return t?e?t+` `+e:t:e}function $v(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function ey(e,t,n={}){let r=t.render,i=ty(t,n);return n.enabled===!1?null:ry(e,r,i,n.state??Nv)}function ty(e,t={}){let{className:n,style:r,render:i}=e,{state:a=Nv,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Bv(n,a):void 0,d=l?Vv(r,a):void 0,f=l?zv(a,c):Nv,p=l?Rv(f,Array.isArray(s)?Wv(s):s)??Nv:Nv;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=Cv([p.ref,Lv(i),...o]):p.ref=Sv(p.ref,Lv(i),o):Sv(null,null)),l?(u!==void 0&&(p.className=Qv(p.className,u)),d!==void 0&&(p.style=Rv(p.style,d)),p):Nv}var ny=Symbol.for(`react.lazy`);function ry(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Uv(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===ny&&(i=x.Children.toArray(t)[0]),x.cloneElement(i,e)}if(e&&typeof e==`string`)return iy(e,n);throw Error(Pv(8))}function iy(e,t){return e===`button`?(0,x.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,x.createElement)(`img`,{alt:``,...t,key:t.key}):x.createElement(e,t)}var ay={...x},oy=0;function sy(e,t=`mui`){let[n,r]=x.useState(e),i=e||n;return x.useEffect(()=>{n??(oy+=1,r(`${t}-${oy}`))},[n,t]),i}var cy=ay.useId;function ly(e,t){if(cy!==void 0){let n=cy();return e??(t?`${t}-${n}`:n)}return sy(e,t)}function uy(e){return ly(e,`base-ui`)}function dy(){return typeof window<`u`}function fy(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function py(e){return dy()?e instanceof Element||e instanceof fy(e).Element:!1}function my(e){return dy()?e instanceof HTMLElement||e instanceof fy(e).HTMLElement:!1}function hy(e){return!dy()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof fy(e).ShadowRoot}var gy=x.createContext(void 0);function _y(e=!1){let t=x.useContext(gy);if(t===void 0&&!e)throw Error(Pv(16));return t}function vy(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:x.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function yy(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=x.useRef(null),o=_y(!0)!==void 0,s=yv(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=vy({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=x.useCallback(()=>{let e=a.current;by(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return Ov(l,[l]),{getButtonProps:x.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return Uv({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Zv(e),o?.(e)),e.baseUIHandlerPrevented)return;let r=e.target===e.currentTarget&&!i&&!s()&&!t,a=e.key===`Enter`,c=e.key===` `;r&&((c||a)&&e.preventDefault(),a&&n?.(e))},onKeyUp(e){t||(Zv(e),a?.(e)),!e.baseUIHandlerPrevented&&e.target===e.currentTarget&&!i&&!t&&e.key===` `&&n?.(e)},onPointerDown(e){if(t){e.preventDefault();return}l?.(e)}},i?void 0:{role:`button`},c,u)},[t,c,i,s]),buttonRef:yv(e=>{a.current=e,l()})}}function by(e){return my(e)&&e.tagName===`BUTTON`}var xy=x.createContext(void 0);function Sy(){let e=x.useContext(xy);if(e===void 0)throw Error(Pv(63));return e}var Cy=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),wy={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Ty={valid(e){return e===null?null:e?{[Cy.valid]:``}:{[Cy.invalid]:``}}},Ey=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Dy={...Ty,checked(e){return e?{[Ey.checked]:``}:{[Ey.unchecked]:``}}};function Oy(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var ky=x.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Mv,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function Ay(){return x.useContext(ky)}var jy=x.createContext({invalid:void 0,name:void 0,validityData:{state:wy,errors:[],error:``,value:``,initialValue:null},setValidityData:Mv,disabled:void 0,touched:!1,setTouched:Mv,dirty:!1,setDirty:Mv,filled:!1,setFilled:Mv,focused:!1,setFocused:Mv,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=Nv)=>e,getInputValidationProps:(e=Nv)=>e,inputRef:{current:null},commit:async()=>{}}});function My(e=!0){let t=x.useContext(jy);if(t.setValidityData===Mv&&!e)throw Error(Pv(28));return t}function Ny(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=Ay(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=My(),f=yv(e.getValue);Ov(()=>{if(!t)return;let e=n;e===void 0&&(e=f()),u.initialValue===null&&e!==null&&d(t=>({...t,initialValue:e}))},[t,d,n,u.initialValue,f]),Ov(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:Oy(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?K.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),Ov(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var Py=x.createContext({controlId:void 0,registerControlId:Mv,labelId:void 0,setLabelId:Mv,messageIds:[],setMessageIds:Mv,getDescriptionProps:e=>e});function Fy(){return x.useContext(Py)}function Iy(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=Fy(),o=uy(t),s=n?i:void 0,c=gv(()=>Symbol(`labelable-control`)),l=x.useRef(!1),u=x.useRef(t!=null),d=yv(()=>{!l.current||a===Mv||(l.current=!1,a(c.current,void 0))});return Ov(()=>{if(a===Mv)return;let e;if(n){let n=r?.current;e=py(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),x.useEffect(()=>d,[d]),i??o}var Ly=`none`;function Ry(e,t,n,r){let i=!1,a=!1,o=r??Nv;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function zy(e,t){let n=x.useRef(e),r=yv(t);Ov(()=>{n.current!==e&&r(n.current)},[e,r]),Ov(()=>{n.current=e},[e])}var By=x.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,id:a,inputRef:o,name:s,nativeButton:c=!1,onCheckedChange:l,readOnly:u=!1,required:d=!1,disabled:f=!1,render:p,uncheckedValue:m,value:h,...g}=e,{clearErrors:_}=Ay(),{state:v,setTouched:y,setDirty:b,validityData:S,setFilled:C,setFocused:w,shouldValidateOnChange:T,validationMode:E,disabled:D,name:O,validation:k}=My(),{labelId:A}=Fy(),j=D||f,M=O??s,N=yv(l),P=x.useRef(null),F=Sv(P,o,k.inputRef),I=x.useRef(null),L=uy(),R=Iy({id:a,implicit:!1,controlRef:I}),z=c?void 0:R,[B,V]=mv({controlled:n,default:!!i,name:`Switch`,state:`checked`});Ny({id:L,commit:k.commit,value:B,controlRef:I,name:M,getValue:()=>B}),Ov(()=>{P.current&&C(P.current.checked)},[P,C]),zy(B,()=>{_(M),b(B!==S.initialValue),C(B),T()?k.commit(B):k.commit(B,!0)});let{getButtonProps:H,buttonRef:U}=yy({disabled:j,native:c}),W={id:c?R:L,role:`switch`,"aria-checked":B,"aria-readonly":u||void 0,"aria-required":d||void 0,"aria-labelledby":A,onFocus(){j||w(!0)},onBlur(){let e=P.current;!e||j||(y(!0),w(!1),E===`onBlur`&&k.commit(e.checked))},onClick(e){u||j||(e.preventDefault(),P.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},G=x.useMemo(()=>Uv({checked:B,disabled:j,id:z,name:M,required:d,style:M?jv:Av,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=Ry(Ly,e.nativeEvent);N?.(t,n),!n.isCanceled&&V(t)},onFocus(){I.current?.focus()}},k.getInputValidationProps,h===void 0?Nv:{value:h}),[B,j,F,z,M,N,d,V,k,h]),ee=x.useMemo(()=>({...v,checked:B,disabled:j,readOnly:u,required:d}),[v,B,j,u,d]),K=ey(`span`,e,{state:ee,ref:[t,I,U],props:[W,k.getValidationProps,g,H],stateAttributesMapping:Dy});return(0,J.jsxs)(xy.Provider,{value:ee,children:[K,!B&&M&&m!==void 0&&(0,J.jsx)(`input`,{type:`hidden`,name:M,value:m}),(0,J.jsx)(`input`,{...G})]})}),Vy=x.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=My(),o=Sy();return ey(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:Dy,props:i})});function Hy(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Hy(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Uy(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Hy(e))&&(r&&(r+=` `),r+=t);return r}var Wy=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Gy=(e,t)=>({classGroupId:e,validator:t}),Ky=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),qy=`-`,Jy=[],Yy=`arbitrary..`,Xy=e=>{let t=$y(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return Qy(e);let n=e.split(qy);return Zy(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?Wy(i,t):t:i||Jy}return n[e]||Jy}}},Zy=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=Zy(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(qy):e.slice(t).join(qy),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},Qy=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?Yy+r:void 0})(),$y=e=>{let{theme:t,classGroups:n}=e;return eb(n,t)},eb=(e,t)=>{let n=Ky();for(let r in e){let i=e[r];tb(i,n,r,t)}return n},tb=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];nb(i,t,n,r)}},nb=(e,t,n,r)=>{if(typeof e==`string`){rb(e,t,n);return}if(typeof e==`function`){ib(e,t,n,r);return}ab(e,t,n,r)},rb=(e,t,n)=>{let r=e===``?t:ob(t,e);r.classGroupId=n},ib=(e,t,n,r)=>{if(sb(e)){tb(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Gy(n,e))},ab=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];tb(o,ob(t,a),n,r)}},ob=(e,t)=>{let n=e,r=t.split(qy),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=Ky(),n.nextPart.set(t,i)),n=i}return n},sb=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,cb=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},lb=`!`,ub=`:`,db=[],fb=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),pb=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===ub){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(lb)?(c=s.slice(0,-1),l=!0):s.startsWith(lb)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return fb(t,l,c,u)};if(t){let e=t+ub,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):fb(db,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},mb=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},hb=e=>({cache:cb(e.cacheSize),parseClassName:pb(e),sortModifiers:mb(e),...Xy(e)}),gb=/\s+/,_b=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(gb),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+lb:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},vb=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=yb(n))&&(i&&(i+=` `),i+=r);return i},yb=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=yb(e[r]))&&(n&&(n+=` `),n+=t);return n},bb=(e,...t)=>{let n,r,i,a,o=o=>(n=hb(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=_b(e,n);return i(e,a),a};return a=o,(...e)=>a(vb(...e))},xb=[],Sb=e=>{let t=t=>t[e]||xb;return t.isThemeGetter=!0,t},Cb=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,wb=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Tb=/^\d+\/\d+$/,Eb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Db=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ob=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,kb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ab=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,jb=e=>Tb.test(e),Mb=e=>!!e&&!Number.isNaN(Number(e)),Nb=e=>!!e&&Number.isInteger(Number(e)),Pb=e=>e.endsWith(`%`)&&Mb(e.slice(0,-1)),Fb=e=>Eb.test(e),Ib=()=>!0,Lb=e=>Db.test(e)&&!Ob.test(e),Rb=()=>!1,zb=e=>kb.test(e),Bb=e=>Ab.test(e),Vb=e=>!Q(e)&&!$(e),Hb=e=>ex(e,ix,Rb),Q=e=>Cb.test(e),Ub=e=>ex(e,ax,Lb),Wb=e=>ex(e,ox,Mb),Gb=e=>ex(e,nx,Rb),Kb=e=>ex(e,rx,Bb),qb=e=>ex(e,cx,zb),$=e=>wb.test(e),Jb=e=>tx(e,ax),Yb=e=>tx(e,sx),Xb=e=>tx(e,nx),Zb=e=>tx(e,ix),Qb=e=>tx(e,rx),$b=e=>tx(e,cx,!0),ex=(e,t,n)=>{let r=Cb.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},tx=(e,t,n=!1)=>{let r=wb.exec(e);return r?r[1]?t(r[1]):n:!1},nx=e=>e===`position`||e===`percentage`,rx=e=>e===`image`||e===`url`,ix=e=>e===`length`||e===`size`||e===`bg-size`,ax=e=>e===`length`,ox=e=>e===`number`,sx=e=>e===`family-name`,cx=e=>e===`shadow`,lx=bb(()=>{let e=Sb(`color`),t=Sb(`font`),n=Sb(`text`),r=Sb(`font-weight`),i=Sb(`tracking`),a=Sb(`leading`),o=Sb(`breakpoint`),s=Sb(`container`),c=Sb(`spacing`),l=Sb(`radius`),u=Sb(`shadow`),d=Sb(`inset-shadow`),f=Sb(`text-shadow`),p=Sb(`drop-shadow`),m=Sb(`blur`),h=Sb(`perspective`),g=Sb(`aspect`),_=Sb(`ease`),v=Sb(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),$,Q],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[$,Q,c],T=()=>[jb,`full`,`auto`,...w()],E=()=>[Nb,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,Nb,$,Q]},Nb,$,Q],O=()=>[Nb,`auto`,$,Q],k=()=>[`auto`,`min`,`max`,`fr`,$,Q],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[jb,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,$,Q],F=()=>[...b(),Xb,Gb,{position:[$,Q]}],I=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],L=()=>[`auto`,`cover`,`contain`,Zb,Hb,{size:[$,Q]}],R=()=>[Pb,Jb,Ub],z=()=>[``,`none`,`full`,l,$,Q],B=()=>[``,Mb,Jb,Ub],V=()=>[`solid`,`dashed`,`dotted`,`double`],H=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],U=()=>[Mb,Pb,Xb,Gb],W=()=>[``,`none`,m,$,Q],G=()=>[`none`,Mb,$,Q],ee=()=>[`none`,Mb,$,Q],K=()=>[Mb,$,Q],te=()=>[jb,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[Fb],breakpoint:[Fb],color:[Ib],container:[Fb],"drop-shadow":[Fb],ease:[`in`,`out`,`in-out`],font:[Vb],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[Fb],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[Fb],shadow:[Fb],spacing:[`px`,Mb],text:[Fb],"text-shadow":[Fb],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,jb,Q,$,g]}],container:[`container`],columns:[{columns:[Mb,Q,$,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{start:T()}],end:[{end:T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[Nb,`auto`,$,Q]}],basis:[{basis:[jb,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[Mb,jb,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,Mb,$,Q]}],shrink:[{shrink:[``,Mb,$,Q]}],order:[{order:[Nb,`first`,`last`,`none`,$,Q]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,Jb,Ub]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,$,Wb]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,Pb,Q]}],"font-family":[{font:[Yb,Q,t]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,$,Q]}],"line-clamp":[{"line-clamp":[Mb,`none`,$,Wb]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,$,Q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,$,Q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...V(),`wavy`]}],"text-decoration-thickness":[{decoration:[Mb,`from-font`,`auto`,$,Ub]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[Mb,`auto`,$,Q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,$,Q]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,$,Q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:L()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},Nb,$,Q],radial:[``,$,Q],conic:[Nb,$,Q]},Qb,Kb]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:R()}],"gradient-via-pos":[{via:R()}],"gradient-to-pos":[{to:R()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:z()}],"rounded-s":[{"rounded-s":z()}],"rounded-e":[{"rounded-e":z()}],"rounded-t":[{"rounded-t":z()}],"rounded-r":[{"rounded-r":z()}],"rounded-b":[{"rounded-b":z()}],"rounded-l":[{"rounded-l":z()}],"rounded-ss":[{"rounded-ss":z()}],"rounded-se":[{"rounded-se":z()}],"rounded-ee":[{"rounded-ee":z()}],"rounded-es":[{"rounded-es":z()}],"rounded-tl":[{"rounded-tl":z()}],"rounded-tr":[{"rounded-tr":z()}],"rounded-br":[{"rounded-br":z()}],"rounded-bl":[{"rounded-bl":z()}],"border-w":[{border:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":B()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...V(),`hidden`,`none`]}],"divide-style":[{divide:[...V(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...V(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[Mb,$,Q]}],"outline-w":[{outline:[``,Mb,Jb,Ub]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,$b,qb]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,$b,qb]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:B()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[Mb,Ub]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,$b,qb]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[Mb,$,Q]}],"mix-blend":[{"mix-blend":[...H(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":H()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[Mb]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[$,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[Mb]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,$,Q]}],filter:[{filter:[``,`none`,$,Q]}],blur:[{blur:W()}],brightness:[{brightness:[Mb,$,Q]}],contrast:[{contrast:[Mb,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,$b,qb]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,Mb,$,Q]}],"hue-rotate":[{"hue-rotate":[Mb,$,Q]}],invert:[{invert:[``,Mb,$,Q]}],saturate:[{saturate:[Mb,$,Q]}],sepia:[{sepia:[``,Mb,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":W()}],"backdrop-brightness":[{"backdrop-brightness":[Mb,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[Mb,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,Mb,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Mb,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,Mb,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[Mb,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[Mb,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,Mb,$,Q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,$,Q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[Mb,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[Mb,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:G()}],"rotate-x":[{"rotate-x":G()}],"rotate-y":[{"rotate-y":G()}],"rotate-z":[{"rotate-z":G()}],scale:[{scale:ee()}],"scale-x":[{"scale-x":ee()}],"scale-y":[{"scale-y":ee()}],"scale-z":[{"scale-z":ee()}],"scale-3d":[`scale-3d`],skew:[{skew:K()}],"skew-x":[{"skew-x":K()}],"skew-y":[{"skew-y":K()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:te()}],"translate-x":[{"translate-x":te()}],"translate-y":[{"translate-y":te()}],"translate-z":[{"translate-z":te()}],"translate-none":[`translate-none`],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,$,Q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,$,Q]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[Mb,Jb,Ub,Wb]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function ux(...e){return lx(Uy(e))}function dx({checked:e,onCheckedChange:t,disabled:n,className:r}){return(0,J.jsx)(By,{checked:e,onCheckedChange:t,disabled:n,className:ux(`group relative inline-flex h-6 w-10 shrink-0 cursor-pointer items-center rounded-full transition-colors`,`bg-border data-[checked]:bg-accent`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-bg-base`,`disabled:cursor-not-allowed disabled:opacity-50`,r),children:(0,J.jsx)(Vy,{className:ux(`pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform`,`translate-x-1 group-data-[checked]:translate-x-5`)})})}var fx=null,px=!1,mx={},hx=500;function gx(){if(typeof window>`u`)return null;if(fx?.state===`closed`&&(fx=null),!fx){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;fx=new e}return fx}function _x(){fx&&=(fx.close().catch(()=>{}),null),gx()}function vx(){return px}function yx(){fx&&(_x(),px=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&yx()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&yx()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&yx(),e=t},5e3)}async function bx(){let e=gx();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),px=!1}async function xx(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function Sx(e){let t=gx();if(!t||(await xx(t),t.state!==`running`))return;let{frequencies:n,durationMs:r,attackMs:i,peakGain:a,type:o=`sine`}=e,s=t.currentTime,c=r/1e3,l=i/1e3,u=t.createGain();u.connect(t.destination);let d=s+c*.7;u.gain.setValueAtTime(0,s),u.gain.linearRampToValueAtTime(a,s+l),u.gain.setValueAtTime(a,d),u.gain.linearRampToValueAtTime(0,s+c);let f=n.map(e=>{let n=t.createOscillator();return n.type=o,n.frequency.setValueAtTime(e,s),n.connect(u),n});for(let e of f)e.start(s),e.stop(s+c);let p=f[f.length-1];p.onended=()=>{for(let e of f)e.disconnect();u.disconnect()}}async function Cx(){let e=Date.now();if(!(e-(mx.permission||0)<hx)){mx.permission=e;try{await Sx({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function wx(){let e=Date.now();if(!(e-(mx.idle||0)<hx)){mx.idle=e;try{await Sx({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function Tx({isOpen:e,onClose:t}){let n=G(e=>e.defaultProjectDir),r=G(e=>e.setDefaultProjectDir),i=G(e=>e.commandPresets),a=G(e=>e.setCommandPresets),o=G(e=>e.defaultPresetId),s=G(e=>e.setDefaultPresetId),c=G(e=>e.sessionSortMode),l=G(e=>e.setSessionSortMode),u=G(e=>e.sessionSortDirection),d=G(e=>e.setSessionSortDirection),f=G(e=>e.useWebGL),p=G(e=>e.setUseWebGL),m=G(e=>e.fontSize),h=G(e=>e.setFontSize),g=G(e=>e.lineHeight),_=G(e=>e.setLineHeight),v=G(e=>e.letterSpacing),y=G(e=>e.setLetterSpacing),b=G(e=>e.fontOption),S=G(e=>e.setFontOption),C=G(e=>e.customFontFamily),w=G(e=>e.setCustomFontFamily),T=G(e=>e.shortcutModifier),E=G(e=>e.setShortcutModifier),D=G(e=>e.showProjectName),O=G(e=>e.setShowProjectName),k=G(e=>e.showLastUserMessage),A=G(e=>e.setShowLastUserMessage),j=G(e=>e.showSessionIdPrefix),M=G(e=>e.setShowSessionIdPrefix),N=T_(e=>e.theme),F=T_(e=>e.setTheme),I=G(e=>e.soundOnPermission),R=G(e=>e.setSoundOnPermission),z=G(e=>e.soundOnIdle),B=G(e=>e.setSoundOnIdle),[V,H]=(0,x.useState)(n),[U,W]=(0,x.useState)(i),[ee,K]=(0,x.useState)(o),[te,q]=(0,x.useState)(c),[ne,re]=(0,x.useState)(u),[ie,ae]=(0,x.useState)(f),[oe,se]=(0,x.useState)(m),[ce,le]=(0,x.useState)(g),[ue,de]=(0,x.useState)(v),[fe,pe]=(0,x.useState)(b),[me,he]=(0,x.useState)(C),[ge,_e]=(0,x.useState)(T),[ve,ye]=(0,x.useState)(D),[be,xe]=(0,x.useState)(k),[Se,Ce]=(0,x.useState)(j),[we,Te]=(0,x.useState)(N),[Ee,De]=(0,x.useState)(I),[Oe,ke]=(0,x.useState)(z),[Ae,je]=(0,x.useState)(!0),[Me,Ne]=(0,x.useState)(!1),[Pe,Fe]=(0,x.useState)(24),[Ie,Le]=(0,x.useState)(!1),[Re,ze]=(0,x.useState)(!1),[Be,Ve]=(0,x.useState)(``),[He,We]=(0,x.useState)(``),[Ke,qe]=(0,x.useState)(``),Je=(0,x.useRef)(null);if((0,x.useEffect)(()=>{if(Je.current&&=(clearTimeout(Je.current),null),e){if(H(n),W(i),K(o),q(c),re(u),ae(f),se(m),le(g),de(v),pe(b),he(C),_e(T),ye(D),xe(k),Ce(j),Te(N),De(I),ke(z),ze(!1),Ve(``),We(``),qe(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>je(e.enabled)).catch(()=>{}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>Fe(e.hours)).catch(()=>{}),typeof document<`u`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}}else typeof document<`u`&&(Je.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{Je.current&&=(clearTimeout(Je.current),null)}},[i,o,n,c,u,f,m,g,v,b,C,T,D,k,j,N,I,z,e]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=e=>{e.key===`Escape`&&(typeof e.stopPropagation==`function`&&e.stopPropagation(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let Ye=e=>{e.preventDefault();let n=V.trim(),i=ie!==f;r(n||`~/Documents/GitHub`),a(U),s(ee),l(te),d(ne),p(ie),h(oe),_(ce),y(ue),S(fe),w(me),E(ge),O(ve),A(be),M(Se),F(we),R(Ee),B(Oe),t({webglChanged:i})},Xe=(e,t)=>{W(n=>n.map(n=>n.id===e?{...n,...t}:n))},Ze=e=>{let t=U.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=U.filter(t=>t.id!==e);W(n),e===ee&&K(n[0]?.id||`claude`)},Qe=()=>{if(!Be.trim()||!He.trim()||U.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:Be.trim(),command:He.trim(),isBuiltIn:!1,agentType:Ke||void 0};W([...U,e]),ze(!1),Ve(``),We(``),qe(``)},$e=U.length<50,et=e=>{Ne(!0),je(e),fetch(`/api/settings/tmux-mouse-mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).catch(()=>je(!e)).finally(()=>Ne(!1))},tt=e=>{let t=Pe;Le(!0),Fe(e),fetch(`/api/settings/history-max-age-hours`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hours:e})}).catch(()=>Fe(t)).finally(()=>Le(!1))};return(0,J.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,J.jsxs)(`form`,{onSubmit:Ye,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,J.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,J.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,J.jsx)(`input`,{value:V,onChange:e=>H(e.target.value),placeholder:P,className:`input`,autoFocus:!0})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,J.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,J.jsx)(`select`,{value:ee,onChange:e=>K(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:U.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,J.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,J.jsx)(`div`,{className:`space-y-3`,children:U.map(e=>(0,J.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,J.jsx)(`input`,{value:e.label,onChange:t=>Xe(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>Ze(e.id),className:`btn text-xs px-2 py-1 text-error hover:bg-error/10`,children:`Delete`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,J.jsx)(`input`,{value:e.command,onChange:t=>Xe(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,J.jsxs)(`select`,{value:e.agentType||``,onChange:t=>Xe(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,J.jsx)(`option`,{value:``,children:`Terminal`}),(0,J.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,J.jsx)(`option`,{value:`codex`,children:`Codex`})]})]})]},e.id))}),Re?(0,J.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,J.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,J.jsx)(`input`,{value:Be,onChange:e=>Ve(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,J.jsx)(`input`,{value:He,onChange:e=>We(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`select`,{value:Ke,onChange:e=>qe(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,J.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,J.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,J.jsx)(`option`,{value:`codex`,children:`Codex Icon`})]}),(0,J.jsx)(`div`,{className:`flex-1`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>ze(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:Qe,disabled:!Be.trim()||!He.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,J.jsx)(`button`,{type:`button`,onClick:()=>ze(!0),disabled:!$e,className:`btn text-xs mt-3 w-full`,children:$e?`+ Add Preset`:`Max 50 presets`})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,J.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`created`?`btn-primary`:``}`,onClick:()=>q(`created`),children:`Created`}),(0,J.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`status`?`btn-primary`:``}`,onClick:()=>q(`status`),children:`Status`}),(0,J.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`manual`?`btn-primary`:``}`,onClick:()=>q(`manual`),children:`Manual`})]}),(0,J.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:te===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:te===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),te===`created`&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ne===`desc`?`btn-primary`:``}`,onClick:()=>re(`desc`),children:`Newest First`}),(0,J.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ne===`asc`?`btn-primary`:``}`,onClick:()=>re(`asc`),children:`Oldest First`})]})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,J.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,J.jsx)(dx,{checked:ve,onCheckedChange:ye})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,J.jsx)(dx,{checked:be,onCheckedChange:xe})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,J.jsx)(dx,{checked:Se,onCheckedChange:Ce})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,J.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`number`,min:1,max:168,value:Pe,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&&tt(t)},disabled:Ie,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,J.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,J.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex-1`,children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>void Cx(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,J.jsx)(dx,{checked:Ee,onCheckedChange:e=>{De(e),e&&bx()}})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex-1`,children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>void wx(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,J.jsx)(dx,{checked:Oe,onCheckedChange:e=>{ke(e),e&&bx()}})]})]})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,J.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,J.jsx)(dx,{checked:ie,onCheckedChange:ae})]}),ie!==f&&(0,J.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,J.jsx)(dx,{checked:Ae,onCheckedChange:et,disabled:Me})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>se(Math.max(6,oe-1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,J.jsx)(`span`,{className:`text-sm font-bold`,children:`−`})}),(0,J.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:oe}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>se(Math.min(24,oe+1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,J.jsx)(`span`,{className:`text-sm font-bold`,children:`+`})})]})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:ce,onChange:e=>le(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,J.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:ce.toFixed(1)})]})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:ue,onChange:e=>de(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,J.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[ue,`px`]})]})]}),(0,J.jsxs)(`div`,{className:`mt-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,J.jsx)(`select`,{value:fe,onChange:e=>pe(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:L.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),fe===`custom`&&(0,J.jsx)(`input`,{value:me,onChange:e=>he(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,J.jsx)(dx,{checked:we===`dark`,onCheckedChange:e=>Te(e?`dark`:`light`)})]})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,J.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,J.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,J.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${ge===e?`btn-primary`:``}`,onClick:()=>_e(e),children:e===`auto`?`Auto`:Ge(e)},e))}),(0,J.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:ge===`auto`?`Platform default: ${Ge(Ue(`auto`))}`:`Shortcuts: ${Ge(ge)}+[N/X/[/]]`})]})]})}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var Ex=[];function Dx(e){x.useEffect(e,Ex)}var Ox=x.createContext(void 0);function kx(){let e=x.useContext(Ox);if(!e)throw Error(Pv(73));return e}var Ax=Symbol(`NOT_FOUND`);function jx(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function Mx(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function Nx(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var Px=e=>Array.isArray(e)?e:[e];function Fx(e){let t=Array.isArray(e[0])?e[0]:e;return Nx(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function Ix(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function Lx(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Ax},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function Rx(e,t){let n=[];function r(e){let r=n.findIndex(n=>t(e,n.key));if(r>-1){let e=n[r];return r>0&&(n.splice(r,1),n.unshift(e)),e.value}return Ax}function i(t,i){r(t)===Ax&&(n.unshift({key:t,value:i}),n.length>e&&n.pop())}function a(){return n}function o(){n=[]}return{get:r,put:i,getEntries:a,clear:o}}var zx=(e,t)=>e===t;function Bx(e){return function(t,n){if(t===null||n===null||t.length!==n.length)return!1;let{length:r}=t;for(let i=0;i<r;i++)if(!e(t[i],n[i]))return!1;return!0}}function Vx(e,t){let{equalityCheck:n=zx,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=Bx(n),o=0,s=r<=1?Lx(a):Rx(r,a);function c(){let t=s.get(arguments);if(t===Ax){if(t=e.apply(null,arguments),o++,i){let e=s.getEntries().find(e=>i(e.value,t));e&&(t=e.value,o!==0&&o--)}s.put(arguments,t)}return t}return c.clearCache=()=>{s.clear(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}var Hx=class{constructor(e){this.value=e}deref(){return this.value}},Ux=typeof WeakRef<`u`?WeakRef:Hx,Wx=0,Gx=1;function Kx(){return{s:Wx,v:void 0,o:null,p:null}}function qx(e,t={}){let n=Kx(),{resultEqualityCheck:r}=t,i,a=0;function o(){let t=n,{length:o}=arguments;for(let e=0,n=o;e<n;e++){let n=arguments[e];if(typeof n==`function`||typeof n==`object`&&n){let e=t.o;e===null&&(t.o=e=new WeakMap);let r=e.get(n);r===void 0?(t=Kx(),e.set(n,t)):t=r}else{let e=t.p;e===null&&(t.p=e=new Map);let r=e.get(n);r===void 0?(t=Kx(),e.set(n,t)):t=r}}let s=t,c;if(t.s===Gx)c=t.v;else if(c=e.apply(null,arguments),a++,r){let e=i?.deref?.()??i;e!=null&&r(e,c)&&(c=e,a!==0&&a--),i=typeof c==`object`&&c||typeof c==`function`?new Ux(c):c}return s.s=Gx,s.v=c,c}return o.clearCache=()=>{n=Kx(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Jx(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),jx(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=qx,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=Px(c),p=Px(u),m=Fx(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=Ix(m,arguments);return i=h.apply(null,e),i},...p);return Object.assign(g,{resultFunc:o,memoizedResultFunc:h,dependencies:m,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var Yx=Jx(qx),Xx=Object.assign((e,t=Yx)=>{Mx(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);let n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>Xx}),Zx=Jx({memoize:Vx,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),Qx=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(Pv(1));let s;if(e&&t&&n&&r&&i&&a)s=(o,s,c,l)=>a(e(o,s,c,l),t(o,s,c,l),n(o,s,c,l),r(o,s,c,l),i(o,s,c,l),s,c,l);else if(e&&t&&n&&r&&i)s=(a,o,s,c)=>i(e(a,o,s,c),t(a,o,s,c),n(a,o,s,c),r(a,o,s,c),o,s,c);else if(e&&t&&n&&r)s=(i,a,o,s)=>r(e(i,a,o,s),t(i,a,o,s),n(i,a,o,s),a,o,s);else if(e&&t&&n)s=(r,i,a,o)=>n(e(r,i,a,o),t(r,i,a,o),i,a,o);else if(e&&t)s=(n,r,i,a)=>t(e(n,r,i,a),r,i,a);else if(e)s=e;else throw Error(`Missing arguments`);return s},$x=(...e)=>{let t=new WeakMap,n=1,r=e[e.length-1],i=e.length-1||1,a=r.length-i;if(a>3)throw Error(Pv(2));return(i,o,s,c)=>{let l=i.__cacheKey__;l||(l={id:n},i.__cacheKey__=l,n+=1);let u=t.get(l);if(!u){let n=e,i=[void 0,void 0,void 0];switch(a){case 0:break;case 1:n=[...e.slice(0,-1),()=>i[0],r];break;case 2:n=[...e.slice(0,-1),()=>i[0],()=>i[1],r];break;case 3:n=[...e.slice(0,-1),()=>i[0],()=>i[1],()=>i[2],r];break;default:throw Error(Pv(2))}u=Zx(...n),u.selectorArgs=i,t.set(l,u)}switch(u.selectorArgs[0]=o,u.selectorArgs[1]=s,u.selectorArgs[2]=c,a){case 0:return u(i);case 1:return u(i,o);case 2:return u(i,o,s);case 3:return u(i,o,s,c);default:throw Error(`unreachable`)}}},eS=s((e=>{var t=p();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),tS=s(((e,t)=>{t.exports=eS()})),nS=s((e=>{var t=p(),n=tS();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),rS=s(((e,t)=>{t.exports=nS()})),iS=[],aS=void 0;function oS(){return aS}function sS(e){iS.push(e)}var cS=tS(),lS=rS(),uS=Iv(19)?pS:mS;function dS(e,t,n,r,i){return uS(e,t,n,r,i)}function fS(e,t,n,r,i){let a=x.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,cS.useSyncExternalStore)(e.subscribe,a,a)}sS({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);(r.didChange||!Object.is(r.value,i))&&(t=!0,r.value=i,r.didChange=!1)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,cS.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function pS(e,t,n,r,i){let a=oS();if(!a)return fS(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.didChange=!0)):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i),didChange:!1},a.syncHooks.push(s)),s.value}function mS(e,t,n,r,i){return(0,lS.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var hS=class{constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return dS(this,e,t,n,r)}},gS=class extends hS{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){x.useDebugValue(e),Ov(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;Ov(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;Ov(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){x.useDebugValue(e);let n=t!==void 0;Ov(()=>{n&&!Object.is(this.state[e],t)&&super.setState({...this.state,[e]:t})},[e,t,n])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return x.useDebugValue(e),dS(this,this.selectors[e],t,n,r)}useContextCallback(e,t){x.useDebugValue(e);let n=yv(t??Mv);this.context[e]=n}useStateSetter(e){let t=x.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},_S=null;globalThis.requestAnimationFrame;var vS=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,--this.callbacksCount)}},yS=class e{static create(){return new e}static request(e){return vS.request(e)}static cancel(e){return vS.cancel(e)}currentId=_S;request(e){this.cancel(),this.currentId=vS.request(()=>{this.currentId=_S,e()})}cancel=()=>{this.currentId!==_S&&(vS.cancel(this.currentId),this.currentId=_S)};disposeEffect=()=>this.cancel};function bS(){let e=gv(yS.create).current;return Dx(e.disposeEffect),e}var xS=0,SS=class e{static create(){return new e}currentId=xS;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=xS,t()},e)}isStarted(){return this.currentId!==xS}clear=()=>{this.currentId!==xS&&(clearTimeout(this.currentId),this.currentId=xS)};disposeEffect=()=>this.clear};function CS(){let e=gv(SS.create).current;return Dx(e.disposeEffect),e}var wS=0;function TS(e){return wS+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${wS}`}function ES(e){return e?.ownerDocument||document}function DS(e,t){if(typeof e==`string`)return{description:e};if(typeof e==`function`){let n=e(t);return typeof n==`string`?{description:n}:n}return e}var OS=typeof navigator<`u`,kS=PS(),AS=IS(),jS=FS();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),kS.platform===`MacIntel`&&kS.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(kS.platform),OS&&/firefox/i.test(jS);var MS=OS&&/apple/i.test(navigator.vendor);OS&&/Edg/i.test(jS),OS&&/android/i.test(AS)||/android/i.test(jS),OS&&AS.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var NS=jS.includes(`jsdom/`);function PS(){if(!OS)return{platform:``,maxTouchPoints:-1};let e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??-1}}function FS(){if(!OS)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function IS(){if(!OS)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function LS(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function RS(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&hy(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function zS(e){return`composedPath`in e?e.composedPath()[0]:e.target}function BS(e){if(!e||NS)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var VS=$x(e=>e.toasts,e=>{let t=new Map,n=0,r=0;return e.forEach((e,i)=>{let a=e.transitionStatus===`ending`;t.set(e.id,{value:e,domIndex:i,visibleIndex:a?-1:n,offsetY:r}),r+=e.height||0,a||(n+=1)}),t}),HS={toasts:Qx(e=>e.toasts),isEmpty:Qx(e=>e.toasts.length===0),toast:Qx(VS,(e,t)=>e.get(t)?.value),toastIndex:Qx(VS,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:Qx(VS,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:Qx(VS,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:Qx(e=>e.hovering),focused:Qx(e=>e.focused),expanded:Qx(e=>e.hovering||e.focused),expandedOrOutOfFocus:Qx(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:Qx(e=>e.prevFocusElement)},US=class extends gS{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},HS)}setFocused(e){this.set(`focused`,e)}setHovering(e){this.set(`hovering`,e)}setIsWindowFocused(e){this.set(`isWindowFocused`,e)}setPrevFocusElement(e){this.set(`prevFocusElement`,e)}setViewport=e=>{this.set(`viewport`,e)};disposeEffect=()=>()=>{this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear()};removeToast(e){let t=HS.toastIndex(this.state,e);if(t===-1)return;this.state.toasts[t]?.onRemove?.();let n=[...this.state.toasts];n.splice(t,1),this.setToasts(n)}addToast=e=>{let{toasts:t,timeout:n,limit:r}=this.state,i=e.id||TS(`toast`),a={...e,id:i,transitionStatus:`starting`},o=[a,...t],s=o.filter(e=>e.transitionStatus!==`ending`);if(s.length>r){let e=s.length-r,t=s.slice(-e),n=new Set(t.map(e=>e.id));this.setToasts(o.map(e=>{let t=n.has(e.id);return e.limited===t?e:{...e,limited:t}}))}else this.setToasts(o.map(e=>e.limited?{...e,limited:!1}:e));let c=a.timeout??n;return a.type!==`loading`&&c>0&&this.scheduleTimer(i,c,()=>this.closeToast(i)),HS.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=HS.toast(this.state,e)??null;if(!i||i.transitionStatus===`ending`)return;let a={...i,...t};this.setToasts(r.map(n=>n.id===e?{...n,...t}:n));let o=a.timeout??n,s=i?.timeout??n,c=Object.hasOwn(t,`timeout`),l=a.transitionStatus!==`ending`&&a.type!==`loading`&&o>0,u=this.timers.has(e),d=s!==o,f=i?.type===`loading`;if(!l&&u){this.timers.get(e)?.timeout?.clear(),this.timers.delete(e);return}if(l&&(!u||d||c||f)){let t=this.timers.get(e);t&&(t.timeout?.clear(),this.timers.delete(e)),this.scheduleTimer(e,o,()=>this.closeToast(e)),HS.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{HS.toast(this.state,e)?.onClose?.();let{limit:t,toasts:n}=this.state,r=0,i=n.map(n=>{if(n.id===e)return{...n,transitionStatus:`ending`,height:0};if(n.transitionStatus===`ending`)return n;let i=r>=t;return r+=1,n.limited===i?n:{...n,limited:i}}),a=this.timers.get(e);a&&a.timeout&&(a.timeout.clear(),this.timers.delete(e)),this.handleFocusManagement(e),this.setToasts(i)};promiseToast=(e,t)=>{let n=DS(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=DS(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=DS(t.error,e);return this.updateToast(r,{...n,type:`error`,timeout:n.timeout}),Promise.reject(e)});return{}.hasOwnProperty.call(t,`setPromise`)&&t.setPromise(i),i};pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(e=>{if(e.timeout){e.timeout.clear();let t=Date.now()-e.start,n=e.delay-t;e.remaining=n>0?n:0}}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((e,t)=>{e.remaining=e.remaining>0?e.remaining:e.delay,e.timeout??=SS.create(),e.timeout.start(e.remaining,()=>{this.timers.delete(t),e.callback()}),e.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}handleDocumentPointerDown=e=>{if(e.pointerType!==`touch`)return;let t=zS(e);RS(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!HS.expandedOrOutOfFocus(this.state),a=i?SS.create():void 0;a?.start(t,()=>{this.timers.delete(e),n()}),this.timers.set(e,{timeout:a,start:i?r:0,delay:t,remaining:t,callback:n})}setToasts(e){let t={toasts:e};e.length===0&&(t.hovering=!1,t.focused=!1),this.update(t)}handleFocusManagement(e){let t=LS(ES(this.state.viewport));if(!this.state.viewport||!RS(this.state.viewport,t)||!BS(t))return;let n=HS.toasts(this.state),r=HS.toastIndex(this.state,e),i=null,a=r+1;for(;a<n.length;){if(n[a].transitionStatus!==`ending`){i=n[a];break}a+=1}if(!i)for(a=r-1;a>=0;){if(n[a].transitionStatus!==`ending`){i=n[a];break}--a}i?i.ref?.current?.focus():this.restoreFocusToPrevElement()}},WS=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=gv(()=>new US({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return Dx(a.disposeEffect),x.useEffect(function(){if(i)return i[` subscribe`](({action:e,options:t})=>{let n=t.id;e===`promise`&&t.promise?a.promiseToast(t.promise,t):e===`update`&&n?a.updateToast(n,t):e===`close`&&n?a.closeToast(n):a.addToast(t)})},[a,n,i]),a.useSyncedValues({timeout:n,limit:r}),(0,J.jsx)(Ox.Provider,{value:a,children:t})},GS=x.forwardRef(function(e,t){let[n,r]=x.useState();Ov(()=>{MS&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,J.jsx)(`span`,{...e,ref:t,style:Av,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),KS=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),qS=x.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=kx(),s=CS(),c=x.useRef(!1),l=x.useRef(!1),u=o.useState(`isEmpty`),d=o.useState(`toasts`),f=o.useState(`focused`),p=o.useState(`expanded`),m=o.useState(`prevFocusElement`),h=d[0]?.height??0,g=x.useMemo(()=>d.some(e=>e.transitionStatus===`ending`),[d]);x.useEffect(()=>{let e=o.state.viewport;if(!e)return;function t(t){u||t.key===`F6`&&t.target!==e&&(t.preventDefault(),o.setPrevFocusElement(LS(ES(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=fy(e);return n.addEventListener(`keydown`,t),()=>{n.removeEventListener(`keydown`,t)}},[o,u]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=fy(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=zS(n),i=LS(ES(e));(!RS(e,r)||!BS(i))&&o.resumeTimers(),s.start(0,()=>o.setIsWindowFocused(!0))}return t.addEventListener(`blur`,n,!0),t.addEventListener(`focus`,r,!0),()=>{t.removeEventListener(`blur`,n,!0),t.removeEventListener(`focus`,r,!0)}},[o,s,u]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=ES(e);return t.addEventListener(`pointerdown`,o.handleDocumentPointerDown,!0),()=>{t.removeEventListener(`pointerdown`,o.handleDocumentPointerDown,!0)}},[u,o]);function _(e){let t=o.state.viewport;t&&(c.current=!0,e.relatedTarget===t?d[0]?.ref?.current?.focus():o.restoreFocusToPrevElement())}function v(e){e.key===`Tab`&&e.shiftKey&&e.target===o.state.viewport&&(e.preventDefault(),o.restoreFocusToPrevElement(),o.resumeTimers())}x.useEffect(()=>{!o.state.isWindowFocused||g||!l.current||(o.resumeTimers(),o.setHovering(!1),l.current=!1)},[g,o]);function y(){o.pauseTimers(),o.setHovering(!0),l.current=!1}function b(){g?l.current=!0:(o.resumeTimers(),o.setHovering(!1))}function S(){if(c.current){c.current=!1;return}f||BS(ES(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function C(e){!f||RS(o.state.viewport,e.relatedTarget)||(o.setFocused(!1),o.resumeTimers())}let w={tabIndex:-1,role:`region`,"aria-live":`polite`,"aria-atomic":!1,"aria-relevant":`additions text`,"aria-label":`Notifications`,onMouseEnter:y,onMouseMove:y,onMouseLeave:b,onFocus:S,onBlur:C,onKeyDown:v,onClick:S},T={expanded:p},E=ey(`div`,e,{ref:[t,o.setViewport],state:T,props:[w,{style:{[KS.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,J.jsxs)(x.Fragment,{children:[!u&&m&&(0,J.jsx)(GS,{onFocus:_}),i,!u&&m&&(0,J.jsx)(GS,{onFocus:_})]})}]}),D=x.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,J.jsxs)(x.Fragment,{children:[!u&&m&&(0,J.jsx)(GS,{onFocus:_}),E,!f&&D.length>0&&(0,J.jsx)(`div`,{style:Av,children:D.map(e=>(0,J.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,J.jsx)(`div`,{children:e.title}),(0,J.jsx)(`div`,{children:e.description})]},e.id))})]})});function JS(e){return Iv(19)?e:e?`true`:void 0}var YS=x.createContext(void 0);function XS(){let e=x.useContext(YS);if(!e)throw Error(Pv(66));return e}var ZS=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),QS={[ZS.startingStyle]:``},$S={[ZS.endingStyle]:``},eC={transitionStatus(e){return e===`starting`?QS:e===`ending`?$S:null}};function tC(e){return e==null?e:`current`in e?e.current:e}function nC(e,t=!1,n=!0){let r=bS();return yv((i,a=null)=>{r.cancel();function o(){K.flushSync(i)}let s=tC(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=ZS.startingStyle;if(!c.hasAttribute(e)){r.request(i);return}let t=new MutationObserver(()=>{c.hasAttribute(e)||(t.disconnect(),i())});t.observe(c,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}function i(){Promise.all(c.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||o()}).catch(()=>{let e=c.getAnimations();if(n){if(a?.aborted)return;o()}else e.length>0&&e.some(e=>e.pending||e.playState!==`finished`)&&i()})}if(t){e();return}r.request(i)}})}function rC(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=yv(i),o=nC(r,n,!1);x.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var iC=function(e){return e.index=`--toast-index`,e.offsetY=`--toast-offset-y`,e.height=`--toast-height`,e.swipeMovementX=`--toast-swipe-movement-x`,e.swipeMovementY=`--toast-swipe-movement-y`,e}({}),aC={...eC,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},oC=40,sC=10,cC=.5,lC=1;function uC(e,t,n){switch(e){case`up`:return-n;case`down`:return n;case`left`:return-t;case`right`:return t;default:return 0}}function dC(e){let t=window.getComputedStyle(e).transform,n=0,r=0,i=1;if(t&&t!==`none`){let e=t.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){let t=e[1].split(`, `).map(parseFloat);t.length===6?(n=t[4],r=t[5],i=Math.sqrt(t[0]*t[0]+t[1]*t[1])):t.length===16&&(n=t[12],r=t[13],i=t[0])}}return{x:n,y:r,scale:i}}var fC=x.forwardRef(function(e,t){let{toast:n,render:r,className:i,swipeDirection:a=[`down`,`right`],...o}=e,s=n.positionerProps?.anchor!==void 0,c=[];s||(c=Array.isArray(a)?a:[a]);let l=c.length>0,u=kx(),[d,f]=x.useState(void 0),[p,m]=x.useState(!1),[h,g]=x.useState(!1),[_,v]=x.useState(!1),[y,b]=x.useState({x:0,y:0}),[S,C]=x.useState({x:0,y:0,scale:1}),[w,T]=x.useState(),[E,D]=x.useState(),[O,k]=x.useState(null),A=x.useRef(null),j=x.useRef({x:0,y:0}),M=x.useRef({x:0,y:0,scale:1}),N=x.useRef(void 0),P=x.useRef(0),F=x.useRef(!1),I=x.useRef({x:0,y:0}),L=x.useRef(!1),R=u.useState(`toastIndex`,n.id),z=u.useState(`toastVisibleIndex`,n.id),B=u.useState(`toastOffsetY`,n.id),V=u.useState(`focused`),H=u.useState(`expanded`);rC({open:n.transitionStatus!==`ending`,ref:A,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let U=yv((e=!1)=>{let t=A.current;if(!t)return;let r=t.style.height;t.style.height=`auto`;let i=t.offsetHeight;t.style.height=r;function a(){u.updateToastInternal(n.id,{ref:A,height:i,...n.transitionStatus===`starting`?{transitionStatus:void 0}:{}})}e?K.flushSync(a):a()});Ov(U,[U]);function W(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**cC:-(Math.abs(e)**cC):(!c.includes(`right`)&&e>0&&(n=e**cC),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**cC))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**cC:-(Math.abs(t)**cC):(!c.includes(`down`)&&t>0&&(r=t**cC),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**cC))),{x:n,y:r}}function G(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=zS(e.nativeEvent);if(!(t&&t.closest(`button,a,input,textarea,[role="button"],[data-swipe-ignore]`))){if(F.current=!1,N.current=void 0,P.current=0,j.current={x:e.clientX,y:e.clientY},I.current=j.current,A.current){let e=dC(A.current);M.current=e,C(e),b({x:e.x,y:e.y})}u.setHovering(!0),m(!0),g(!1),k(null),L.current=!0,A.current?.setPointerCapture(e.pointerId)}}function ee(e){if(!p)return;e.preventDefault(),L.current&&=(j.current={x:e.clientX,y:e.clientY},!1);let{clientY:t,clientX:n,movementX:r,movementY:i}=e;(i<0&&t>I.current.y||i>0&&t<I.current.y)&&(I.current={x:I.current.x,y:t}),(r<0&&n>I.current.x||r>0&&n<I.current.x)&&(I.current={x:n,y:I.current.y});let a=n-j.current.x,o=t-j.current.y,s=t-I.current.y,l=n-I.current.x;if(!h&&Math.sqrt(a*a+o*o)>=lC&&(g(!0),O===null)){let e=c.includes(`left`)||c.includes(`right`),t=c.includes(`up`)||c.includes(`down`);e&&t&&k(Math.abs(a)>Math.abs(o)?`horizontal`:`vertical`)}let u;if(!N.current)O===`vertical`?o>0?u=`down`:o<0&&(u=`up`):O===`horizontal`?a>0?u=`right`:a<0&&(u=`left`):u=Math.abs(a)>=Math.abs(o)?a>0?`right`:`left`:o>0?`down`:`up`,u&&c.includes(u)&&(N.current=u,P.current=uC(u,a,o),f(u));else{let e=N.current,t=uC(e,l,s);t>oC?(F.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&P.current-t>=sC&&(F.current=!0)}let d=W(a,o),m=M.current.x,_=M.current.y;O===`horizontal`?(c.includes(`left`)||c.includes(`right`))&&(m+=d.x):(O===`vertical`||(c.includes(`left`)||c.includes(`right`))&&(m+=d.x),(c.includes(`up`)||c.includes(`down`))&&(_+=d.y)),b({x:m,y:_})}function te(e){if(!p)return;if(m(!1),g(!1),k(null),A.current?.releasePointerCapture(e.pointerId),F.current){b({x:S.x,y:S.y}),f(void 0);return}let t=!1,r=y.x-S.x,i=y.y-S.y,a;for(let e of c){switch(e){case`right`:r>oC&&(t=!0,a=`right`);break;case`left`:r<-oC&&(t=!0,a=`left`);break;case`down`:i>oC&&(t=!0,a=`down`);break;case`up`:i<-oC&&(t=!0,a=`up`);break;default:break}if(t)break}t?(f(a),v(!0),u.closeToast(n.id)):(b({x:S.x,y:S.y}),f(void 0))}function q(e){if(e.key===`Escape`){if(!A.current||!RS(A.current,LS(ES(A.current))))return;u.closeToast(n.id)}}x.useEffect(()=>{if(!l)return;let e=A.current;if(!e)return;function t(t){RS(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function ne(){if(!p&&y.x===S.x&&y.y===S.y&&!_)return{[iC.swipeMovementX]:`0px`,[iC.swipeMovementY]:`0px`};let e=y.x-S.x,t=y.y-S.y;return{transition:p?`none`:void 0,transform:p?`translateX(${y.x}px) translateY(${y.y}px) scale(${S.scale})`:void 0,[iC.swipeMovementX]:`${e}px`,[iC.swipeMovementY]:`${t}px`}}let re=n.priority===`high`,ie={role:re?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":w,"aria-describedby":E,"aria-hidden":re&&!V?!0:void 0,onPointerDown:l?G:void 0,onPointerMove:l?ee:void 0,onPointerUp:l?te:void 0,onKeyDown:q,inert:JS(n.limited),style:{...ne(),[iC.index]:n.transitionStatus===`ending`?R:z,[iC.offsetY]:`${B}px`,[iC.height]:n.height?`${n.height}px`:void 0}},ae=x.useMemo(()=>({rootRef:A,toast:n,titleId:w,setTitleId:T,descriptionId:E,setDescriptionId:D,swiping:p,swipeDirection:d,recalculateHeight:U,index:R,visibleIndex:z,expanded:H}),[n,w,E,p,d,U,R,z,H]),oe={transitionStatus:n.transitionStatus,expanded:H,limited:n.limited||!1,type:n.type,swiping:ae.swiping,swipeDirection:ae.swipeDirection},se=ey(`div`,e,{ref:[t,ae.rootRef],state:oe,stateAttributesMapping:aC,props:[ie,o]});return(0,J.jsx)(YS.Provider,{value:ae,children:se})}),pC=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=XS(),l=a??s.description,u=!!l,d=ly(i);Ov(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=ey(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),mC=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=XS(),l=a??s.title,u=!!l,d=ly(i);Ov(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=ey(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),hC=x.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=kx(),{toast:c}=XS(),l=s.useState(`expanded`),[u,d]=x.useState(!1),{getButtonProps:f,buttonRef:p}=yy({disabled:i,native:a}),m={type:c.type};return ey(`button`,e,{ref:[t,p],state:m,props:[{"aria-hidden":!l&&!u,onClick(){s.closeToast(c.id)},onFocus(){d(!0)},onBlur(){d(!1)}},o,f]})});function gC(){let e=x.useContext(Ox);if(!e)throw Error(Pv(73));let t=e.useState(`toasts`);return x.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function _C(){let e=new Set;function t(t){e.forEach(e=>e(t))}return{" subscribe":function(t){return e.add(t),()=>{e.delete(t)}},add(e){let n=e.id||TS(`toast`);return t({action:`add`,options:{...e,id:n,transitionStatus:`starting`}}),n},close(e){t({action:`close`,options:{id:e}})},update(e,n){t({action:`update`,options:{...n,id:e}})},promise(e,n){let r=e;return t({action:`promise`,options:{...n,promise:e,setPromise(e){r=e}}}),r}}}var vC=5e3,yC=_C();function bC({toast:e}){return(0,J.jsxs)(fC,{toast:e,className:ux(`relative flex w-80 items-start gap-3 border bg-elevated p-4 shadow-lg`,`data-[swipe=move]:translate-x-[var(--toast-swipe-move-x)]`,`data-[ending-style]:translate-x-[var(--toast-swipe-end-x)]`,`data-[ending-style]:opacity-0`,`data-[starting-style]:translate-y-2 data-[starting-style]:opacity-0`,`transition-all duration-200`,e.type===`error`&&`border-error/50`,e.type===`success`&&`border-approval/50`,(!e.type||e.type===`info`)&&`border-border`),children:[(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(mC,{className:ux(`text-sm font-medium`,e.type===`error`&&`text-error`,e.type===`success`&&`text-approval`,(!e.type||e.type===`info`)&&`text-primary`),children:e.title}),e.description&&(0,J.jsx)(pC,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,J.jsx)(hC,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,J.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,J.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,J.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function xC(){let{toasts:e}=gC();return(0,J.jsx)(J.Fragment,{children:e.map(e=>(0,J.jsx)(bC,{toast:e},e.id))})}function SC(){return(0,J.jsxs)(WS,{timeout:vC,toastManager:yC,children:[(0,J.jsx)(xC,{}),(0,J.jsx)(qS,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var CC=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],wC=3e3,TC=8e3,EC=15e3,DC=5e3,OC=2e4,kC=1e4,AC=1500,jC=5e3,MC=750,NC=4,PC=5e3,FC=new class{constructor(){this.ws=null,this.listeners=new Set,this.statusListeners=new Set,this.status=`connecting`,this.error=null,this.reconnectAttempts=0,this.reconnectTimer=null,this.connectTimer=null,this.manualClose=!1,this.lastTick=Date.now(),this.wakeCheckInterval=null,this.lifecycleStarted=!1,this.heartbeatTimer=null,this.pongTimer=null,this.lastForceReconnectTs=0,this.lastConnectTs=0,this.pingSeq=0,this.connectionEpoch=0,this.consecutiveFailures=0,this.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{if(Z(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,Z(`ws_resume`,{gapMs:t,...this.wsSnap()},`info`),this.ws?.readyState===WebSocket.OPEN?this.verifyConnection():this.forceReconnect(`visibilitychange`,!0)}else this.stopHeartbeat(),this.cancelVerify(),this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null)},this.onPageShow=e=>{Z(`ws_pageshow`,{persisted:e.persisted,...this.wsSnap()},`info`),e.persisted&&(this.lastTick=Date.now(),this.forceReconnect(`pageshow`,!0))}}wsSnap(){return{status:this.status,ws:this.ws?CC[this.ws.readyState]:null,attempt:this.reconnectAttempts,failures:this.consecutiveFailures,leaked:this.leakedSockets.size,online:typeof navigator<`u`?navigator.onLine:void 0,verifying:this.verifyTimer!==null,buffered:this.ws?this.ws.bufferedAmount:void 0}}connect(){if(this.ws){let e=this.ws.readyState===WebSocket.OPEN;if(e&&this.status===`connected`){Z(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){Z(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}Z(`ws_connect_destroy_zombie`,{reason:e?`open_desynced`:`not_open`,...this.wsSnap()}),this.destroySocket()}this.manualClose=!1,this.clearConnectTimer(),this.setStatus(`connecting`);let e=`${window.location.protocol===`https:`?`wss`:`ws`}://${window.location.host}/ws`;Z(`ws_connect`,{url:e,resume:this.isResumeAttempt,...this.wsSnap()},`info`);let t=new WebSocket(e);this.ws=t,this.lastConnectTs=Date.now(),this.leakedSockets.add(t);let n=this.isResumeAttempt?TC:wC;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(Z(`ws_connect_timeout`,{wsState:CC[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){Z(`ws_onopen_stale`,this.wsSnap(),`info`);return}Z(`ws_onopen`,this.wsSnap(),`info`),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=0,this.connectionEpoch+=1,this.leakedSockets.delete(t),this.setStatus(`connected`),this.startHeartbeat()},t.onmessage=e=>{try{let t=e.data,n=performance.now(),r=JSON.parse(t),i=performance.now()-n,a=r;if(a._parseMs=Math.round(i),a._rawLength=t.length,r.type===`pong`){r.seq===this.pingSeq&&(this.clearPongTimer(),this.verifyTimer!==null&&(this.cancelVerify(),Z(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(jC)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(Z(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){Z(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}Z(`ws_onclose`,{code:e.code,reason:e.reason,clean:e.wasClean,...this.wsSnap()},`info`),this.clearConnectTimer(),this.cancelVerify(),this.consecutiveFailures+=1,this.ws=null,this.manualClose?this.setStatus(`disconnected`):this.scheduleReconnect()}}disconnect(){this.manualClose=!0,this.clearConnectTimer(),this.cancelVerify(),this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null),this.destroySocket(),this.setStatus(`disconnected`)}startLifecycleListeners(){this.lifecycleStarted||typeof document>`u`||typeof window>`u`||(this.lifecycleStarted=!0,document.addEventListener(`visibilitychange`,this.onVisibilityChange),window.addEventListener(`pageshow`,this.onPageShow),this.lastTick=Date.now(),this.wakeCheckInterval=window.setInterval(()=>{let e=Date.now(),t=e-this.lastTick;this.isHidden()||(t>EC&&(Z(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},DC))}stopLifecycleListeners(){this.lifecycleStarted&&(this.lifecycleStarted=!1,document.removeEventListener(`visibilitychange`,this.onVisibilityChange),window.removeEventListener(`pageshow`,this.onPageShow),this.wakeCheckInterval!==null&&(window.clearInterval(this.wakeCheckInterval),this.wakeCheckInterval=null))}send(e){if(this.ws?.readyState!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(e)),!0}catch(t){return Z(`ws_send_error`,{messageType:e.type,error:t instanceof Error?t.message:String(t),...this.wsSnap()},`info`),this.destroySocket(),this.scheduleReconnect(),!1}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}subscribeStatus(e){return this.statusListeners.add(e),e(this.status,this.error,this.connectionEpoch),()=>this.statusListeners.delete(e)}getStatus(){return this.status}getConnectionEpoch(){return this.connectionEpoch}verifyConnection(){this.cancelVerify(),this.stopHeartbeat(),this.pingSeq+=1;let e=this.pingSeq,t=this.ws;if(Z(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){Z(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(Z(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},AC)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){Z(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){Z(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){Z(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,Z(`ws_force_reconnect`,{trigger:e,force:t,...this.wsSnap()},`info`),this.reconnectAttempts=0,this.consecutiveFailures=0,this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null),this.destroySocket(),t?(this.purgeLeakedSockets(),this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},MC)):this.connect()}startHeartbeat(e){this.stopHeartbeat();let t=()=>{this.ws?.readyState===WebSocket.OPEN&&(this.pingSeq+=1,this.send({type:`ping`,seq:this.pingSeq})&&(this.clearPongTimer(),this.pongTimer=window.setTimeout(()=>{this.pongTimer=null,Z(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},kC)))};e!==void 0&&e<OC?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,OC)},e):this.heartbeatTimer=window.setInterval(t,OC)}stopHeartbeat(){this.heartbeatTimer!==null&&(window.clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null),this.clearPongTimer()}clearPongTimer(){this.pongTimer!==null&&(window.clearTimeout(this.pongTimer),this.pongTimer=null)}setStatus(e,t=null){this.status=e,this.error=t,this.statusListeners.forEach(n=>n(e,t,this.connectionEpoch))}scheduleReconnect(){if(this.stopHeartbeat(),this.isHidden()){Z(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=NC){Z(`ws_stall_detected`,this.wsSnap(),`info`),this.purgeLeakedSockets(),this.consecutiveFailures=0,this.reconnectAttempts=0,this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},PC);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);Z(`ws_schedule_reconnect`,{delay:e,...this.wsSnap()}),this.setStatus(`reconnecting`),this.reconnectTimer&&window.clearTimeout(this.reconnectTimer),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}isHidden(){return typeof document<`u`&&document.visibilityState===`hidden`}clearConnectTimer(){this.connectTimer&&=(window.clearTimeout(this.connectTimer),null)}destroySocket(){if(this.clearConnectTimer(),this.stopHeartbeat(),this.cancelVerify(),!this.ws)return;let e=this.ws;this.ws=null,this.leakedSockets.add(e),e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}purgeLeakedSockets(){if(this.leakedSockets.size!==0){Z(`ws_purge_leaked`,{count:this.leakedSockets.size},`info`);for(let e of this.leakedSockets)try{e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,e.close()}catch{}this.leakedSockets.clear()}}};function IC(){let e=Um(e=>e.setConnectionState);return(0,x.useEffect)(()=>{FC.connect(),FC.startLifecycleListeners();let t=FC.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),FC.stopLifecycleListeners()}},[e]),{sendMessage:(0,x.useMemo)(()=>e=>{FC.send(e)},[]),subscribe:(0,x.useMemo)(()=>FC.subscribe.bind(FC),[]),getConnectionEpoch:(0,x.useMemo)(()=>()=>FC.getConnectionEpoch(),[])}}var LC=100;function RC({viewport:e,win:t,doc:n}){if(!e)return!1;let r=Math.max(0,e.offsetTop||0),i=Math.max(0,e.offsetLeft||0),a=t.innerHeight-(e.height+r),o=Math.max(0,a),s=Math.max(0,e.height||0),c=Math.max(0,e.width||0);return n.documentElement.style.setProperty(`--keyboard-inset`,`${o}px`),n.documentElement.style.setProperty(`--viewport-offset-top`,`${r}px`),n.documentElement.style.setProperty(`--viewport-offset-left`,`${i}px`),n.documentElement.style.setProperty(`--visual-viewport-height`,`${s}px`),n.documentElement.style.setProperty(`--visual-viewport-width`,`${c}px`),o>LC?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function zC(e){e.documentElement.style.removeProperty(`--keyboard-inset`),e.documentElement.style.removeProperty(`--viewport-offset-top`),e.documentElement.style.removeProperty(`--viewport-offset-left`),e.documentElement.style.removeProperty(`--visual-viewport-height`),e.documentElement.style.removeProperty(`--visual-viewport-width`),e.documentElement.classList.remove(`keyboard-visible`)}function BC(){(0,x.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=null,n=null,r=()=>{let e=document.activeElement;if(!e)return!1;let t=e.tagName?.toLowerCase();return t===`input`||t===`textarea`?!0:!!e.isContentEditable},i=()=>{RC({viewport:e,win:window,doc:document})},a=()=>{if(typeof window.requestAnimationFrame!=`function`){i();return}t!==null&&window.cancelAnimationFrame(t);let e=performance.now(),n=()=>{i(),t=performance.now()-e<1500?window.requestAnimationFrame(n):null};t=window.requestAnimationFrame(n)},o=()=>{if(!r()){c();return}i()},s=()=>{n!==null||typeof window.setInterval!=`function`||(n=window.setInterval(o,250),o())},c=()=>{n===null||typeof window.clearInterval!=`function`||(window.clearInterval(n),n=null)},l=()=>{r()?(a(),s(),i()):c()},u=()=>{l()},d=()=>{l()},f=()=>{a()};return i(),l(),e.addEventListener(`resize`,i),e.addEventListener(`scroll`,i),typeof window.addEventListener==`function`&&(window.addEventListener(`resize`,i),window.addEventListener(`orientationchange`,f)),typeof document.addEventListener==`function`&&(document.addEventListener(`focusin`,u),document.addEventListener(`focusout`,d),document.addEventListener(`focus`,u,!0),document.addEventListener(`blur`,d,!0)),()=>{e.removeEventListener(`resize`,i),e.removeEventListener(`scroll`,i),typeof window.removeEventListener==`function`&&(window.removeEventListener(`resize`,i),window.removeEventListener(`orientationchange`,f)),typeof document.removeEventListener==`function`&&(document.removeEventListener(`focusin`,u),document.removeEventListener(`focusout`,d),document.removeEventListener(`focus`,u,!0),document.removeEventListener(`blur`,d,!0)),t!==null&&typeof window.cancelAnimationFrame==`function`&&window.cancelAnimationFrame(t),c(),zC(document)}},[])}function VC(e,t,n){let r=e;return t.length>0&&(r=r.filter(e=>t.includes(e.projectPath))),n.length>0&&(r=r.filter(e=>n.includes(e.host??``))),r}function HC(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(void 0),[i,a]=(0,x.useState)(void 0),[o,s]=(0,x.useState)(void 0),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(null),g=Um(e=>e.sessions),_=Um(e=>e.agentSessions),v=Um(e=>e.agentSessionsEpoch),y=Um(e=>e.selectedSessionId),b=Um(e=>e.selectedHibernatingSessionId),S=Um(e=>e.setSessions),C=Um(e=>e.setAgentSessions),w=Um(e=>e.setActiveAgentSessions),T=Um(e=>e.setHostStatuses),E=Um(e=>e.updateSession),D=Um(e=>e.setSelectedSessionId),O=Um(e=>e.setSelectedHibernatingSessionId),k=Um(e=>e.hasLoaded),A=Um(e=>e.connectionStatus),j=Um(e=>e.connectionError),M=Um(e=>e.clearExitingSession),N=Um(e=>e.markSessionExiting),P=Um(e=>e.setRemoteAllowControl),F=Um(e=>e.setRemoteAllowAttach),I=Um(e=>e.setHostLabel),L=Um(e=>e.hostStatuses),R=Um(e=>e.remoteAllowControl),z=Um(e=>e.hostLabel),B=T_(e=>e.theme),V=ee(),H=G(e=>e.defaultProjectDir),U=G(e=>e.commandPresets),W=G(e=>e.defaultPresetId),te=G(e=>e.lastProjectPath),q=G(e=>e.setLastProjectPath),ne=G(e=>e.addRecentPath),re=G(e=>e.shortcutModifier),ie=G(e=>e.sidebarWidth),ae=G(e=>e.setSidebarWidth),oe=G(e=>e.projectFilters),se=G(e=>e.hostFilters),ce=G(e=>e.soundOnPermission),le=G(e=>e.soundOnIdle),ue=Um(e=>e.connectionEpoch),{sendMessage:de,subscribe:fe,getConnectionEpoch:pe}=IC();BC(),(0,x.useEffect)(()=>{if(typeof document>`u`||!ce&&!le)return;let e=!1,t=()=>{e&&!vx()||(e=!0,bx())};return document.addEventListener(`click`,t,{passive:!0}),document.addEventListener(`keydown`,t,{passive:!0}),document.addEventListener(`touchstart`,t,{passive:!0}),()=>{document.removeEventListener(`click`,t),document.removeEventListener(`keydown`,t),document.removeEventListener(`touchstart`,t)}},[ce,le]);let me=(0,x.useRef)(!1),he=(0,x.useCallback)(e=>{e.preventDefault(),me.current=!0,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[]);(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=e=>{if(!me.current)return;let t=e.clientX;ae(Math.max(180,Math.min(400,t)))},t=()=>{me.current&&(me.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[ae]),(0,x.useEffect)(()=>{let e=fe(e=>{if(e.type===`sessions`){let t=Um.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=G.getState();if(n||r)for(let i of e.sessions){let e=t.find(e=>e.id===i.id);e&&e.status!==i.status&&(e.status!==`permission`&&i.status===`permission`&&n&&Cx(),e.status===`working`&&i.status===`waiting`&&r&&wx())}if(je.current.size>0){let e=pe();for(let[t,n]of je.current)n.epoch!==e&&je.current.delete(t)}let i=je.current.size>0?e.sessions.filter(e=>!je.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=Um.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(De.current=s),S(i);let c=Oe.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=Um.getState(),{projectFilters:d,hostFilters:f}=G.getState();if(c&&l===null&&u===null){let e=i.find(e=>!(e.agentSessionId?.trim()!==c||d.length>0&&!d.includes(e.projectPath)||f.length>0&&!f.includes(e.host??``)));e&&(Oe.current=null,D(e.id))}}if(e.type===`host-status`&&T(e.hosts),e.type===`server-config`&&(P(e.remoteAllowControl),F(e.remoteAllowAttach),I(e.hostLabel),e.clientLogLevel&&Ih(e.clientLogLevel)),e.type===`session-update`){let t=Um.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(E(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=G.getState();t!==`permission`&&n===`permission`&&e&&Cx(),t===`working`&&n===`waiting`&&r&&wx()}}if(e.type===`session-created`){let t=Um.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id),ne(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=G.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){o_(e.sessionId);let t=Um.getState().sessions,n=t.filter(t=>t.id!==e.sessionId);n.length!==t.length&&S(n)}if(e.type===`agent-sessions`){let t=Array.isArray(e.active)?e.active:[],n=Array.isArray(e.hibernating)?e.hibernating:[],r=Array.isArray(e.history)?e.history:[],{selectedHibernatingSessionId:i}=Um.getState(),a=De.current;i&&!n.some(e=>e.sessionId===i)&&(Oe.current=i),C(t,n,r),h(e=>e&&n.some(t=>t.sessionId===e.sessionId)?null:e),a&&n.some(e=>e.sessionId===a)?(De.current=null,O(a)):a&&(De.current=null)}if(e.type===`agent-sessions-active`&&w(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=Um.getState().sessions,n=t.filter(t=>t.agentSessionId?.trim()!==e.session.sessionId);n.length!==t.length&&S(n)}if(e.type===`session-activated`){let t=Um.getState().sessions.find(t=>t.tmuxWindow===e.window);t&&E({...t,agentSessionId:e.session.sessionId,agentSessionName:e.session.displayName,logFilePath:e.session.logFilePath,isPinned:e.session.isPinned,lastUserMessage:e.session.lastUserMessage??t.lastUserMessage})}if(e.type===`session-wake-result`)if(e.ok&&e.session){h(t=>t?.sessionId===e.sessionId?null:t);let t=Um.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id)}else e.ok||(d(`${e.error?.code}: ${e.error?.message}`),window.setTimeout(()=>d(null),6e3));if(e.type===`session-hibernate-result`&&(e.ok?(e.session&&h(e.session),O(e.sessionId)):(d(e.error??`Failed to hibernate session`),window.setTimeout(()=>d(null),6e3))),e.type===`terminal-error`&&(!e.sessionId||e.sessionId===y)&&(d(`${e.code}: ${e.message}`),window.setTimeout(()=>d(null),6e3)),e.type===`terminal-ready`&&e.sessionId===y&&d(null),e.type===`error`&&(d(e.message),window.setTimeout(()=>d(null),6e3)),e.type===`kill-failed`){let t=je.current.get(e.sessionId);if(t){let n=Um.getState().sessions;n.some(t=>t.id===e.sessionId)||S([t.session,...n]),t.wasSelected&&D(e.sessionId),je.current.delete(e.sessionId)}M(e.sessionId),d(e.message),window.setTimeout(()=>d(null),6e3)}e.type===`session-move-to-history-result`&&!e.ok&&e.error&&(d(e.error),window.setTimeout(()=>d(null),6e3))});return()=>{e()}},[y,b,ne,M,de,D,O,h,S,C,w,T,P,F,I,fe,E]);let ge=(0,x.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),_e=_.hibernating??[],ve=_.history??[],ye=(0,x.useMemo)(()=>VC(_e,oe,se),[_e,oe,se]),be=(0,x.useMemo)(()=>ye.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[ye,m,b]);(0,x.useEffect)(()=>{ge?.projectPath&&!ge.remote&&q(ge.projectPath)},[ge?.projectPath,ge?.remote,q]);let xe=G(e=>e.sessionSortMode),Se=G(e=>e.sessionSortDirection),Ce=G(e=>e.manualSessionOrder),we=(0,x.useMemo)(()=>Om(g,{mode:xe,direction:Se,manualOrder:Ce}),[g,xe,Se,Ce]),Te=(0,x.useMemo)(()=>{let e=we;return oe.length>0&&(e=e.filter(e=>oe.includes(e.projectPath))),se.length>0&&(e=e.filter(e=>se.includes(e.host??``))),e},[we,oe,se]),Ee=(0,x.useRef)(b),De=(0,x.useRef)(null),Oe=(0,x.useRef)(null),ke=(0,x.useRef)(ue),Ae=(0,x.useCallback)(()=>Te.length>0?(D(Te[0].id),!0):ye.length>0?(O(ye[0].sessionId),!0):!1,[Te,ye,D,O]);(0,x.useEffect)(()=>{let e=Ee.current;e&&b===null&&!_e.some(t=>t.sessionId===e)?Oe.current=e:b!==null&&(Oe.current=null),Ee.current=b},[_e,b]),(0,x.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,x.useEffect)(()=>{ke.current!==ue&&(ke.current=ue,De.current=null,Oe.current=null,h(null))},[ue]),(0,x.useEffect)(()=>{k&&(b||y&&(Te.some(e=>e.id===y)||Ae()||D(null)))},[k,y,b,Ae,D]),(0,x.useEffect)(()=>{if(!b||m?.sessionId===b||v!==ue||ye.some(e=>e.sessionId===b))return;let e=Te.find(e=>e.agentSessionId?.trim()===b);if(e){D(e.id);return}Ae()||O(null)},[ye,Te,v,m,b,Ae,D,O,ue]),(0,x.useEffect)(()=>{let e=Oe.current;if(!e)return;if(b!==null){Oe.current=null;return}let t=Te.find(t=>t.agentSessionId?.trim()===e);if(t){Oe.current=null,D(t.id);return}if(y!==null){Oe.current=null;return}Ae()&&(Oe.current=null)},[Te,y,b,Ae,D]),(0,x.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&k&&y===null&&b===null&&(Te.length>0||ye.length>0)&&Ae()},[ye.length,Te.length,k,Ae,y,b]);let je=(0,x.useRef)(new Map),Me=(0,x.useCallback)(e=>{o_(e);let{sessions:t,selectedSessionId:n}=Um.getState(),r=t.find(t=>t.id===e);r&&je.current.set(e,{session:r,wasSelected:n===e,epoch:pe()}),(0,K.flushSync)(()=>{N(e),S(t.filter(t=>t.id!==e))}),de({type:`session-kill`,sessionId:e})},[N,S,de]);(0,x.useEffect)(()=>{let n=Ue(re),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=Ke(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=i===`BracketLeft`?-1:1,t=Te;if(t.length===0){let t=ye;if(t.length===0)return;let n=t.findIndex(e=>e.sessionId===b);if(n===-1){O(t[0].sessionId);return}O(t[(n+e+t.length)%t.length].sessionId);return}let n=t.findIndex(e=>e.id===y);if(n===-1){D(t[0].id);return}D(t[(n+e+t.length)%t.length].id);return}if(a&&i===`KeyN`){r.preventDefault(),!e&&V&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Me(y);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,D,O,Te,ye,Me,re,V]);let Ne=()=>V?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,Pe=()=>l(!0),Fe=(e,t,n,r)=>{de({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||q(e)},Ie=e=>{de({type:`session-wake`,sessionId:e})},Le=(0,x.useCallback)(e=>{de({type:`session-hibernate`,sessionId:e})},[de]),Re=(e,t)=>{de({type:`session-rename`,sessionId:e,newName:t})},ze=(0,x.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&de({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,de]),Be=(0,x.useCallback)(e=>{de({type:`session-move-to-history`,sessionId:e})},[de]);(0,x.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,B)},[B]),(0,x.useEffect)(()=>{fetch(`/api/server-info`).then(e=>e.json()).then(e=>p(e)).catch(()=>{})},[]);let Ve=(0,x.useMemo)(()=>z?L.filter(e=>e.host!==z):L,[L,z]);return(0,J.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:ie},children:[(0,J.jsx)(Ye,{connectionStatus:A,onNewSession:Ne,onOpenSettings:Pe,tailscaleIp:f?.tailscaleIp??null}),(0,J.jsx)(jh,{sessions:g,hibernatingSessions:_e,historySessions:ve,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:D,onSelectHibernating:O,onRename:Re,onResume:Ie,onHibernate:Le,onKill:Me,onDuplicate:ze,onMoveToHistory:Be,onNewSession:Ne,loading:!k,error:j||u})]}),(0,J.jsx)(`div`,{className:`hidden md:block w-1 shrink-0 cursor-col-resize bg-transparent transition-colors hover:bg-white/10 active:bg-white/20`,onMouseDown:he}),(0,J.jsx)(dv,{session:ge,sessions:Te,hibernatingSession:be,hibernatingSessions:_e,connectionStatus:A,connectionEpoch:ue,sendMessage:de,subscribe:fe,onClose:()=>D(null),onSelectSession:D,onSelectHibernatingSession:O,onNewSession:Ne,onKillSession:Me,onRenameSession:Re,onOpenSettings:Pe,onResumeSession:Ie,onHibernateSession:Le,onMoveToHistory:Be,historySessions:ve,loading:!k,error:j||u}),(0,J.jsx)(pv,{isOpen:e,onClose:()=>t(!1),onCreate:Fe,defaultProjectDir:H,commandPresets:U,defaultPresetId:W,lastProjectPath:te,activeProjectPath:ge&&!ge.remote?ge.projectPath:void 0,remoteHosts:Ve,remoteAllowControl:R,initialHost:n,initialPath:i,initialCommand:o}),(0,J.jsx)(Tx,{isOpen:c,onClose:()=>l(!1)}),(0,J.jsx)(SC,{})]})}var UC=`modulepreload`,WC=function(e){return`/`+e},GC={},KC=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=WC(t,n),t in GC)return;GC[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:UC,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},qC=`true`,JC=`false`,YC=qC===`true`,XC=JC===`true`;function ZC(e={}){let{immediate:t=!1,onNeedRefresh:n,onOfflineReady:r,onRegistered:i,onRegisteredSW:a,onRegisterError:o}=e,s,c,l,u=async(e=!0)=>{await c,YC||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await KC(async()=>{let{Workbox:e}=await import(`./workbox-window.prod.es5-Bq4GJJid.js`);return{Workbox:e}},[]).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{o?.(e)}),!s)return;if(l=()=>{s?.messageSkipWaiting()},!XC)if(YC)s.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&window.location.reload()}),s.addEventListener(`installed`,e=>{e.isUpdate||r?.()});else{let e=!1,t=()=>{e=!0,s?.addEventListener(`controlling`,e=>{e.isUpdate&&window.location.reload()}),n?.()};s.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&r?.():n.isExternal?t():!e&&r?.():n.isUpdate||r?.()}),s.addEventListener(`waiting`,t)}s.register({immediate:t}).then(e=>{a?a(`/sw.js`,e):i?.(e)}).catch(e=>{o?.(e)})}}return c=d(),u}Be()&&document.documentElement.classList.add(`ios`),Ve()&&document.documentElement.classList.add(`ios-pwa`),ZC({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var QC=document.getElementById(`root`);if(!QC)throw Error(`Root element not found`);(0,E.createRoot)(QC).render((0,J.jsx)(x.StrictMode,{children:(0,J.jsx)(HC,{})}));
197
+ `,onClick:()=>{uv(),u(t.id)},children:n+1},t.id))})]}),(0,J.jsxs)(`div`,{className:`relative flex-1`,children:[(0,J.jsx)(`div`,{ref:ge,className:`absolute inset-0`}),be&&e&&(0,J.jsxs)(`div`,{className:`absolute top-2 left-2 z-50 flex items-center gap-1.5 rounded-lg bg-black/60 px-2.5 py-1.5 text-xs text-white/90 shadow-lg backdrop-blur-md`,children:[(0,J.jsxs)(`svg`,{className:`h-3 w-3 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,J.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,J.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z`})]}),`Loading`]}),!e&&(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted`,children:n?null:`Select a session to view terminal`}),e&&ce&&(0,J.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-center text-sm text-muted`,children:`Remote session (read-only). Use SSH to attach on the host.`}),n&&(0,J.jsx)(`div`,{className:`absolute inset-0 overflow-y-auto bg-base`,children:(0,J.jsxs)(`div`,{className:`mx-auto flex h-full w-full max-w-4xl flex-col gap-6 p-6`,children:[(0,J.jsx)(`div`,{className:`rounded-2xl border border-border bg-elevated p-6`,children:(0,J.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-start md:justify-between`,children:[(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`span`,{className:`rounded-full bg-blue-500/15 px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide text-blue-400`,children:`Hibernating`}),n.lastResumeError&&(0,J.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-amber-500/15 px-2 py-1 text-[11px] text-amber-400`,title:`Last wake failed: ${n.lastResumeError}`,children:[(0,J.jsx)(q,{width:12,height:12}),`Wake failed`]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`text-xl font-semibold text-primary`,children:ue}),(0,J.jsx)(`p`,{className:`mt-1 text-sm text-secondary`,children:`Wake this session to reopen its underlying app and terminal.`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-xs text-muted`,children:[fe&&(0,J.jsx)(`span`,{className:`rounded-full bg-surface px-2.5 py-1`,children:fe}),(0,J.jsxs)(`span`,{className:`rounded-full bg-surface px-2.5 py-1`,children:[`Last active `,me]})]}),n.lastUserMessage&&(0,J.jsxs)(`p`,{className:`max-w-2xl text-sm italic text-muted`,children:[`"`,n.lastUserMessage,`"`]})]}),(0,J.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>h(n.sessionId),className:`btn btn-primary`,children:`Wake Session`}),_&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>_(n.sessionId),className:`btn btn-secondary`,children:`Move to History`})]})]})}),(0,J.jsx)(Eh,{session:n})]})}),j&&e&&!N&&(0,J.jsxs)(`button`,{onClick:Se,className:`absolute bottom-8 left-1/2 z-20 flex h-10 px-4 items-center justify-center gap-1.5 rounded-full bg-blue-600/90 text-white shadow-lg hover:bg-blue-600 active:scale-95 transition-all`,style:{transform:`translateX(-50%)`},title:`Scroll to bottom`,"aria-label":`Scroll to bottom`,children:[(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,J.jsx)(`path`,{d:`M12 5v14M5 12l7 7 7-7`})}),(0,J.jsx)(`span`,{className:`text-sm font-medium`,children:`Jump to bottom`})]})]}),e&&(0,J.jsx)(iv,{onSendKey:Le,disabled:a!==`connected`||ce,sessions:t.map(e=>({id:e.id,name:e.name,status:e.status})),currentSessionId:e.id,onSelectSession:u,hideSessionSwitcher:!0,onRefocus:Re,isKeyboardVisible:He,onEnterTextMode:Ve}),(A||k)&&(0,J.jsx)(av,{isOpen:B,onClose:()=>V(!1),sessions:t,hibernatingSessions:r,historySessions:i,selectedSessionId:e?.id??null,selectedHibernatingSessionId:n?.sessionId??null,onSelect:u,onSelectHibernating:d,onRename:m,onResume:h,onHibernate:g,onMoveToHistory:_,onNewSession:f,loading:y,error:b}),F&&e&&(0,J.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,children:(0,J.jsxs)(`div`,{className:`mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl`,children:[(0,J.jsx)(`h3`,{className:`text-base font-medium text-primary mb-2 text-balance`,children:`Kill Session`}),(0,J.jsxs)(`p`,{className:`text-sm text-secondary mb-4 text-pretty`,children:[`Kill "`,e.agentSessionName||e.name,`"? The process will be terminated. Conversation history is preserved in logs.`]}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,J.jsx)(`button`,{onClick:()=>I(!1),className:`btn py-1.5 px-3 text-sm`,children:`Cancel`}),(0,J.jsx)(`button`,{ref:ie,onClick:Ee,className:`btn btn-danger py-1.5 px-3 text-sm`,children:`Kill Session`})]})]})})]})}function fv({onSelect:e,onCancel:t,initialPath:n}){let[r,i]=(0,x.useState)(n||`~`),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(null),[l,u]=(0,x.useState)(!0),[d,f]=(0,x.useState)(-1),p=(0,x.useRef)(null),m=G(e=>e.recentPaths),h=(0,x.useCallback)(async e=>{p.current?.abort();let t=new AbortController;p.current=t;let{signal:n}=t;u(!0),c(null),o(null),f(-1),i(e);try{let r=await fetch(`/api/directories?path=${encodeURIComponent(e)}`,{signal:n});if(!r.ok){let e=await r.json();throw Error(e.message||`Failed to load directory`)}let a=await r.json();if(p.current!==t)return;o(a),i(a.path)}catch(e){if(p.current!==t)return;let n=e;n?.name!==`AbortError`&&c(n?.message||`Failed to load directory`)}finally{p.current===t&&u(!1)}},[]);(0,x.useEffect)(()=>(h(n||`~`),()=>{p.current?.abort()}),[h,n]);let g=a?.directories??[],_=a?.path||r,v=a?.parent;return(0,x.useEffect)(()=>{let n=n=>{if(n.key===`Escape`){n.preventDefault(),t();return}if(!l){if(n.key===`ArrowDown`){n.preventDefault(),f(e=>g.length===0?-1:e<0?0:Math.min(e+1,g.length-1));return}if(n.key===`ArrowUp`){n.preventDefault(),f(e=>g.length===0?-1:e<0?g.length-1:Math.max(e-1,0));return}if(n.key===`Enter`){n.preventDefault();let t=g[d];t?h(t.path):_&&e(_);return}n.key===`Backspace`&&v&&(n.preventDefault(),h(v))}};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[g,_,h,d,l,t,e,v]),(0,J.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Directory browser`,className:`fixed inset-0 z-[60] flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},"data-testid":`directory-browser`,children:(0,J.jsxs)(`div`,{className:`w-full max-w-lg border border-border bg-elevated p-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border pb-2`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>{v&&h(v)},disabled:!v||l,children:`Up`}),(0,J.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-xs font-mono text-secondary`,title:_,"data-testid":`directory-current-path`,children:_})]}),(0,J.jsx)(`div`,{className:`mt-3 max-h-60 overflow-y-auto border border-border bg-surface`,children:l?(0,J.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-loading`,children:`Loading directories...`}):s?(0,J.jsxs)(`div`,{className:`px-3 py-4 text-xs`,"data-testid":`directory-error`,children:[(0,J.jsx)(`p`,{className:`text-danger`,children:s}),(0,J.jsx)(`button`,{type:`button`,className:`btn mt-3`,onClick:()=>h(r),children:`Retry`})]}):g.length===0?(0,J.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted`,"data-testid":`directory-empty`,children:`No subdirectories`}):(0,J.jsx)(`div`,{className:`py-1`,children:g.map((e,t)=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>h(e.path),onMouseEnter:()=>f(t),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-xs ${t===d?`bg-hover text-primary`:`text-secondary`}`,"data-testid":`directory-entry`,"data-entry-name":e.name,"data-entry-path":e.path,children:[(0,J.jsx)(_e,{width:14,height:14,className:`shrink-0 text-muted`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`truncate`,children:e.name})]},e.path))})}),a?.truncated?(0,J.jsx)(`p`,{className:`mt-2 text-[10px] text-muted`,children:`Showing first 200 directories.`}):null,(0,J.jsxs)(`div`,{className:`mt-4 border-t border-border pt-3`,children:[(0,J.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-secondary`,children:`Recent`}),m.length===0?(0,J.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:`No recent paths yet.`}):(0,J.jsx)(`div`,{className:`mt-2 space-y-1`,children:m.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`block w-full truncate text-left text-xs text-secondary hover:text-primary`,onClick:()=>h(e),title:e,"data-testid":`directory-recent`,"data-recent-path":e,children:e},e))})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>{_&&e(_)},className:`btn btn-primary`,disabled:l||!_,children:`Select`})]})]})})}function pv({isOpen:e,onClose:t,onCreate:n,defaultProjectDir:r,commandPresets:i,defaultPresetId:a,lastProjectPath:o,activeProjectPath:s,remoteHosts:c=[],remoteAllowControl:l=!1,initialHost:u,initialPath:d,initialCommand:f}){let[p,m]=(0,x.useState)(``),[h,g]=(0,x.useState)(``),[_,v]=(0,x.useState)(null),[y,b]=(0,x.useState)(``),[S,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(``),E=(0,x.useRef)(null),D=(0,x.useRef)(null),O=(0,x.useRef)(null),k=l&&c.length>0;if((0,x.useEffect)(()=>{if(!e){m(``),g(``),v(null),b(``),C(!1),T(u??``),setTimeout(()=>{if(typeof document>`u`||typeof document.querySelector!=`function`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300);return}if(typeof document<`u`&&typeof document.querySelector==`function`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}m(d?.trim()||s?.trim()||o||r||``),g(``),T(u??``);let t=f?.trim();if(t){let e=i.find(e=>H(e)===t);e?(v(e.id),b(H(e))):(v(null),b(t))}else{let e=i.find(e=>e.id===a);e?(v(a),b(H(e))):i.length>0?(v(i[0].id),b(H(i[0]))):(v(null),b(``))}setTimeout(()=>{if(O.current?.focus(),D.current){let e=D.current;e.scrollLeft=e.scrollWidth}},50)},[s,i,a,r,e,o,u,d,f]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=()=>E.current?Array.from(E.current.querySelectorAll(`input:not([disabled]), select:not([disabled]), button:not([disabled]):not([tabindex="-1"]), [tabindex="0"]`)):[],r=e=>{if(!S){if(e.key===`Escape`){typeof e.stopPropagation==`function`&&e.stopPropagation(),t();return}if(e.key===`Enter`){let t=document.activeElement;if(!t||t.tagName===`INPUT`||t.closest(`[data-testid="host-select"]`)||!t.closest(`[data-testid="command-select"]`))return;e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation(),E.current?.requestSubmit();return}if(e.key===`Tab`){e.preventDefault(),typeof e.stopPropagation==`function`&&e.stopPropagation();let t=n();if(t.length===0)return;let r=document.activeElement,i=t.indexOf(r),a;a=i===-1?e.shiftKey?t.length-1:0:e.shiftKey?i<=0?t.length-1:i-1:i>=t.length-1?0:i+1,t[a]?.focus()}}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,t,S]),!e)return null;let A=e=>{let t=i.find(t=>t.id===e);t&&(v(e),b(H(t)))},j=()=>{v(null),b(``)},M=_===null,N=w!==``,P=e=>{e.preventDefault();let r=p.trim();if(!r)return;let i=y.trim();n(r,h.trim()||void 0,i||void 0,N?w:void 0),t()},F=[...i.map(e=>({id:e.id,label:e.label,isCustom:!1,agentType:e.agentType,command:e.command})),{id:`custom`,label:`Custom`,isCustom:!0,agentType:void 0,command:void 0}],I=[{id:``,label:`Local`,ok:!0,error:void 0},...c.map(e=>({id:e.host,label:e.host,ok:e.ok,error:e.error}))],L=p.trim()||`~`;return(0,J.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`new-session-title`,className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:[(0,J.jsxs)(`form`,{ref:E,onSubmit:P,className:`w-full max-w-md border border-border bg-elevated p-6`,children:[(0,J.jsx)(`h2`,{id:`new-session-title`,className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`New Session`}),(0,J.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[k&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Host`}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Host`,"data-testid":`host-select`,children:I.map((e,t)=>{let n=w===e.id,r=!e.ok&&!n;return(0,J.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":e.label,title:e.ok?void 0:e.error||`Unreachable`,tabIndex:n?0:-1,onClick:()=>T(e.id),onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%I.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+I.length)%I.length;else return;let r=I[n];T(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``} ${r?`opacity-60`:``}`,children:e.label},e.id||`local`)})})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Command`}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`radiogroup`,"aria-label":`Command preset`,"data-testid":`command-select`,children:F.map((e,t)=>{let n=e.isCustom?M:_===e.id;return(0,J.jsxs)(`button`,{ref:n?O:void 0,type:`button`,role:`radio`,"aria-checked":n,tabIndex:n?0:-1,onClick:()=>{e.isCustom?j():A(e.id)},onKeyDown:e=>{let n=t;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),n=(t+1)%F.length;else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),n=(t-1+F.length)%F.length;else return;let r=F[n];r.isCustom?j():A(r.id),(e.currentTarget.parentElement?.querySelectorAll(`[role="radio"]`))?.[n]?.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${n?`btn-primary`:``}`,children:[(0,J.jsx)(Xm,{agentType:e.agentType,command:e.command,className:`inline-block h-3.5 w-3.5 shrink-0`}),e.label]},e.id)})}),(0,J.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),placeholder:`Enter command...`,className:`input mt-2 font-mono text-xs`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Project Path`}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(`input`,{ref:D,value:p,onChange:e=>m(e.target.value),placeholder:N?`/home/user/project`:s||o||r||`/Users/you/code/my-project`,className:`input flex-1 text-sm`}),!N&&(0,J.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>C(!0),children:`Browse`})]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Display Name`}),(0,J.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`auto-generated`,className:`input text-sm placeholder:italic`})]})]}),(0,J.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:t,className:`btn`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Create`})]})]}),S&&!N&&(0,J.jsx)(fv,{initialPath:L,onSelect:e=>{m(e),C(!1)},onCancel:()=>C(!1)})]})}function mv({controlled:e,default:t,name:n,state:r=`value`}){let{current:i}=x.useRef(e!==void 0),[a,o]=x.useState(t);return[i?e:a,x.useCallback(e=>{i||o(e)},[])]}var hv={};function gv(e,t){let n=x.useRef(hv);return n.current===hv&&(n.current=e(t)),n}var _v=x[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],vv=_v&&_v!==x.useLayoutEffect?_v:e=>e();function yv(e){let t=gv(bv).current;return t.next=e,vv(t.effect),t.trampoline}function bv(){let e={next:void 0,callback:xv,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function xv(){}function Sv(e,t,n,r){let i=gv(wv).current;return Tv(i,e,t,n,r)&&Dv(i,[e,t,n,r]),i.callback}function Cv(e){let t=gv(wv).current;return Ev(t,e)&&Dv(t,e),t.callback}function wv(){return{callback:null,cleanup:null,refs:[]}}function Tv(e,t,n,r,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==r||e.refs[3]!==i}function Ev(e,t){return e.refs.length!==t.length||e.refs.some((e,n)=>e!==t[n])}function Dv(e,t){if(e.refs=t,t.every(e=>e==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&=(e.cleanup(),null),n!=null){let r=Array(t.length).fill(null);for(let e=0;e<t.length;e+=1){let i=t[e];if(i!=null)switch(typeof i){case`function`:{let t=i(n);typeof t==`function`&&(r[e]=t);break}case`object`:i.current=n;break;default:}}e.cleanup=()=>{for(let e=0;e<t.length;e+=1){let n=t[e];if(n!=null)switch(typeof n){case`function`:{let t=r[e];typeof t==`function`?t():n(null);break}case`object`:n.current=null;break;default:}}}}}}var Ov=typeof document<`u`?x.useLayoutEffect:()=>{},kv={clipPath:`inset(50%)`,overflow:`hidden`,whiteSpace:`nowrap`,border:0,padding:0,width:1,height:1,margin:-1},Av={...kv,position:`fixed`,top:0,left:0},jv={...kv,position:`absolute`};function Mv(){}Object.freeze([]);var Nv=Object.freeze({});function Pv(e,...t){let n=new URL(`https://base-ui.com/production-error`);return n.searchParams.set(`code`,e.toString()),t.forEach(e=>n.searchParams.append(`args[]`,e)),`Base UI error #${e}; visit ${n} for the full message.`}var Fv=18;function Iv(e){return Fv>=e}function Lv(e){if(!x.isValidElement(e))return null;let t=e,n=t.props;return(Iv(19)?n?.ref:t.ref)??null}function Rv(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function zv(e,t){let n={};for(let r in e){let i=e[r];if(t?.hasOwnProperty(r)){let e=t[r](i);e!=null&&Object.assign(n,e);continue}i===!0?n[`data-${r.toLowerCase()}`]=``:i&&(n[`data-${r.toLowerCase()}`]=i.toString())}return n}function Bv(e,t){return typeof e==`function`?e(t):e}function Vv(e,t){return typeof e==`function`?e(t):e}var Hv={};function Uv(e,t,n,r,i){let a={...Yv(e,Hv)};return t&&(a=Gv(a,t)),n&&(a=Gv(a,n)),r&&(a=Gv(a,r)),i&&(a=Gv(a,i)),a}function Wv(e){if(e.length===0)return Hv;if(e.length===1)return Yv(e[0],Hv);let t={...Yv(e[0],Hv)};for(let n=1;n<e.length;n+=1)t=Gv(t,e[n]);return t}function Gv(e,t){return Jv(t)?t(e):Kv(e,t)}function Kv(e,t){if(!t)return e;for(let n in t){let r=t[n];switch(n){case`style`:e[n]=Rv(e.style,r);break;case`className`:e[n]=Qv(e.className,r);break;default:qv(n,r)?e[n]=Xv(e[n],r):e[n]=r}}return e}function qv(e,t){let n=e.charCodeAt(0),r=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&r===110&&i>=65&&i<=90&&(typeof t==`function`||t===void 0)}function Jv(e){return typeof e==`function`}function Yv(e,t){return Jv(e)?e(t):e??Hv}function Xv(e,t){return t?e?n=>{if($v(n)){let r=n;Zv(r);let i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}let r=t(n);return e?.(n),r}:t:e}function Zv(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Qv(e,t){return t?e?t+` `+e:t:e}function $v(e){return typeof e==`object`&&!!e&&`nativeEvent`in e}function ey(e,t,n={}){let r=t.render,i=ty(t,n);return n.enabled===!1?null:ry(e,r,i,n.state??Nv)}function ty(e,t={}){let{className:n,style:r,render:i}=e,{state:a=Nv,ref:o,props:s,stateAttributesMapping:c,enabled:l=!0}=t,u=l?Bv(n,a):void 0,d=l?Vv(r,a):void 0,f=l?zv(a,c):Nv,p=l?Rv(f,Array.isArray(s)?Wv(s):s)??Nv:Nv;return typeof document<`u`&&(l?Array.isArray(o)?p.ref=Cv([p.ref,Lv(i),...o]):p.ref=Sv(p.ref,Lv(i),o):Sv(null,null)),l?(u!==void 0&&(p.className=Qv(p.className,u)),d!==void 0&&(p.style=Rv(p.style,d)),p):Nv}var ny=Symbol.for(`react.lazy`);function ry(e,t,n,r){if(t){if(typeof t==`function`)return t(n,r);let e=Uv(n,t.props);e.ref=n.ref;let i=t;return i?.$$typeof===ny&&(i=x.Children.toArray(t)[0]),x.cloneElement(i,e)}if(e&&typeof e==`string`)return iy(e,n);throw Error(Pv(8))}function iy(e,t){return e===`button`?(0,x.createElement)(`button`,{type:`button`,...t,key:t.key}):e===`img`?(0,x.createElement)(`img`,{alt:``,...t,key:t.key}):x.createElement(e,t)}var ay={...x},oy=0;function sy(e,t=`mui`){let[n,r]=x.useState(e),i=e||n;return x.useEffect(()=>{n??(oy+=1,r(`${t}-${oy}`))},[n,t]),i}var cy=ay.useId;function ly(e,t){if(cy!==void 0){let n=cy();return e??(t?`${t}-${n}`:n)}return sy(e,t)}function uy(e){return ly(e,`base-ui`)}function dy(){return typeof window<`u`}function fy(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function py(e){return dy()?e instanceof Element||e instanceof fy(e).Element:!1}function my(e){return dy()?e instanceof HTMLElement||e instanceof fy(e).HTMLElement:!1}function hy(e){return!dy()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof fy(e).ShadowRoot}var gy=x.createContext(void 0);function _y(e=!1){let t=x.useContext(gy);if(t===void 0&&!e)throw Error(Pv(16));return t}function vy(e){let{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:i=0,isNativeButton:a}=e,o=r&&t!==!1,s=r&&t===!1;return{props:x.useMemo(()=>{let e={onKeyDown(e){n&&t&&e.key!==`Tab`&&e.preventDefault()}};return r||(e.tabIndex=i,!a&&n&&(e.tabIndex=t?i:-1)),(a&&(t||o)||!a&&n)&&(e[`aria-disabled`]=n),a&&(!t||s)&&(e.disabled=n),e},[r,n,t,o,s,a,i])}}function yy(e={}){let{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:i=!0}=e,a=x.useRef(null),o=_y(!0)!==void 0,s=yv(()=>{let e=a.current;return!!(e?.tagName===`A`&&e?.href)}),{props:c}=vy({focusableWhenDisabled:n,disabled:t,composite:o,tabIndex:r,isNativeButton:i}),l=x.useCallback(()=>{let e=a.current;by(e)&&o&&t&&c.disabled===void 0&&e.disabled&&(e.disabled=!1)},[t,c.disabled,o]);return Ov(l,[l]),{getButtonProps:x.useCallback((e={})=>{let{onClick:n,onMouseDown:r,onKeyUp:a,onKeyDown:o,onPointerDown:l,...u}=e;return Uv({type:i?`button`:void 0,onClick(e){if(t){e.preventDefault();return}n?.(e)},onMouseDown(e){t||r?.(e)},onKeyDown(e){if(t||(Zv(e),o?.(e)),e.baseUIHandlerPrevented)return;let r=e.target===e.currentTarget&&!i&&!s()&&!t,a=e.key===`Enter`,c=e.key===` `;r&&((c||a)&&e.preventDefault(),a&&n?.(e))},onKeyUp(e){t||(Zv(e),a?.(e)),!e.baseUIHandlerPrevented&&e.target===e.currentTarget&&!i&&!t&&e.key===` `&&n?.(e)},onPointerDown(e){if(t){e.preventDefault();return}l?.(e)}},i?void 0:{role:`button`},c,u)},[t,c,i,s]),buttonRef:yv(e=>{a.current=e,l()})}}function by(e){return my(e)&&e.tagName===`BUTTON`}var xy=x.createContext(void 0);function Sy(){let e=x.useContext(xy);if(e===void 0)throw Error(Pv(63));return e}var Cy=function(e){return e.disabled=`data-disabled`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),wy={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Ty={valid(e){return e===null?null:e?{[Cy.valid]:``}:{[Cy.invalid]:``}}},Ey=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Dy={...Ty,checked(e){return e?{[Ey.checked]:``}:{[Ey.unchecked]:``}}};function Oy(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}var ky=x.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:Mv,validationMode:`onSubmit`,submitAttemptedRef:{current:!1}});function Ay(){return x.useContext(ky)}var jy=x.createContext({invalid:void 0,name:void 0,validityData:{state:wy,errors:[],error:``,value:``,initialValue:null},setValidityData:Mv,disabled:void 0,touched:!1,setTouched:Mv,dirty:!1,setDirty:Mv,filled:!1,setFilled:Mv,focused:!1,setFocused:Mv,validate:()=>null,validationMode:`onSubmit`,validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:{disabled:!1,valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},markedDirtyRef:{current:!1},validation:{getValidationProps:(e=Nv)=>e,getInputValidationProps:(e=Nv)=>e,inputRef:{current:null},commit:async()=>{}}});function My(e=!0){let t=x.useContext(jy);if(t.setValidityData===Mv&&!e)throw Error(Pv(28));return t}function Ny(e){let{enabled:t=!0,value:n,id:r,name:i,controlRef:a,commit:o}=e,{formRef:s}=Ay(),{invalid:c,markedDirtyRef:l,validityData:u,setValidityData:d}=My(),f=yv(e.getValue);Ov(()=>{if(!t)return;let e=n;e===void 0&&(e=f()),u.initialValue===null&&e!==null&&d(t=>({...t,initialValue:e}))},[t,d,n,u.initialValue,f]),Ov(()=>{!t||!r||s.current.fields.set(r,{getValue:f,name:i,controlRef:a,validityData:Oy(u,c),validate(e=!0){let t=n;t===void 0&&(t=f()),l.current=!0,e?K.flushSync(()=>o(t)):o(t)}})},[o,a,t,s,f,r,c,l,i,u,n]),Ov(()=>{let e=s.current.fields;return()=>{r&&e.delete(r)}},[s,r])}var Py=x.createContext({controlId:void 0,registerControlId:Mv,labelId:void 0,setLabelId:Mv,messageIds:[],setMessageIds:Mv,getDescriptionProps:e=>e});function Fy(){return x.useContext(Py)}function Iy(e={}){let{id:t,implicit:n=!1,controlRef:r}=e,{controlId:i,registerControlId:a}=Fy(),o=uy(t),s=n?i:void 0,c=gv(()=>Symbol(`labelable-control`)),l=x.useRef(!1),u=x.useRef(t!=null),d=yv(()=>{!l.current||a===Mv||(l.current=!1,a(c.current,void 0))});return Ov(()=>{if(a===Mv)return;let e;if(n){let n=r?.current;e=py(n)&&n.closest(`label`)!=null?t??null:s??o}else if(t!=null)u.current=!0,e=t;else if(u.current)e=o;else{d();return}if(e===void 0){d();return}l.current=!0,a(c.current,e)},[t,r,s,a,n,o,c,d]),x.useEffect(()=>d,[d]),i??o}var Ly=`none`;function Ry(e,t,n,r){let i=!1,a=!1,o=r??Nv;return{reason:e,event:t??new Event(`base-ui`),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:n,...o}}function zy(e,t){let n=x.useRef(e),r=yv(t);Ov(()=>{n.current!==e&&r(n.current)},[e,r]),Ov(()=>{n.current=e},[e])}var By=x.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i,id:a,inputRef:o,name:s,nativeButton:c=!1,onCheckedChange:l,readOnly:u=!1,required:d=!1,disabled:f=!1,render:p,uncheckedValue:m,value:h,...g}=e,{clearErrors:_}=Ay(),{state:v,setTouched:y,setDirty:b,validityData:S,setFilled:C,setFocused:w,shouldValidateOnChange:T,validationMode:E,disabled:D,name:O,validation:k}=My(),{labelId:A}=Fy(),j=D||f,M=O??s,N=yv(l),P=x.useRef(null),F=Sv(P,o,k.inputRef),I=x.useRef(null),L=uy(),R=Iy({id:a,implicit:!1,controlRef:I}),z=c?void 0:R,[B,V]=mv({controlled:n,default:!!i,name:`Switch`,state:`checked`});Ny({id:L,commit:k.commit,value:B,controlRef:I,name:M,getValue:()=>B}),Ov(()=>{P.current&&C(P.current.checked)},[P,C]),zy(B,()=>{_(M),b(B!==S.initialValue),C(B),T()?k.commit(B):k.commit(B,!0)});let{getButtonProps:H,buttonRef:U}=yy({disabled:j,native:c}),W={id:c?R:L,role:`switch`,"aria-checked":B,"aria-readonly":u||void 0,"aria-required":d||void 0,"aria-labelledby":A,onFocus(){j||w(!0)},onBlur(){let e=P.current;!e||j||(y(!0),w(!1),E===`onBlur`&&k.commit(e.checked))},onClick(e){u||j||(e.preventDefault(),P.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},G=x.useMemo(()=>Uv({checked:B,disabled:j,id:z,name:M,required:d,style:M?jv:Av,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,ref:F,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=Ry(Ly,e.nativeEvent);N?.(t,n),!n.isCanceled&&V(t)},onFocus(){I.current?.focus()}},k.getInputValidationProps,h===void 0?Nv:{value:h}),[B,j,F,z,M,N,d,V,k,h]),ee=x.useMemo(()=>({...v,checked:B,disabled:j,readOnly:u,required:d}),[v,B,j,u,d]),K=ey(`span`,e,{state:ee,ref:[t,I,U],props:[W,k.getValidationProps,g,H],stateAttributesMapping:Dy});return(0,J.jsxs)(xy.Provider,{value:ee,children:[K,!B&&M&&m!==void 0&&(0,J.jsx)(`input`,{type:`hidden`,name:M,value:m}),(0,J.jsx)(`input`,{...G})]})}),Vy=x.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=My(),o=Sy();return ey(`span`,e,{state:{...a,...o},ref:t,stateAttributesMapping:Dy,props:i})});function Hy(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Hy(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Uy(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Hy(e))&&(r&&(r+=` `),r+=t);return r}var Wy=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Gy=(e,t)=>({classGroupId:e,validator:t}),Ky=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),qy=`-`,Jy=[],Yy=`arbitrary..`,Xy=e=>{let t=$y(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return Qy(e);let n=e.split(qy);return Zy(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?Wy(i,t):t:i||Jy}return n[e]||Jy}}},Zy=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=Zy(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(qy):e.slice(t).join(qy),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},Qy=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?Yy+r:void 0})(),$y=e=>{let{theme:t,classGroups:n}=e;return eb(n,t)},eb=(e,t)=>{let n=Ky();for(let r in e){let i=e[r];tb(i,n,r,t)}return n},tb=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];nb(i,t,n,r)}},nb=(e,t,n,r)=>{if(typeof e==`string`){rb(e,t,n);return}if(typeof e==`function`){ib(e,t,n,r);return}ab(e,t,n,r)},rb=(e,t,n)=>{let r=e===``?t:ob(t,e);r.classGroupId=n},ib=(e,t,n,r)=>{if(sb(e)){tb(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Gy(n,e))},ab=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];tb(o,ob(t,a),n,r)}},ob=(e,t)=>{let n=e,r=t.split(qy),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=Ky(),n.nextPart.set(t,i)),n=i}return n},sb=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,cb=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},lb=`!`,ub=`:`,db=[],fb=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),pb=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===ub){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(lb)?(c=s.slice(0,-1),l=!0):s.startsWith(lb)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return fb(t,l,c,u)};if(t){let e=t+ub,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):fb(db,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},mb=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},hb=e=>({cache:cb(e.cacheSize),parseClassName:pb(e),sortModifiers:mb(e),...Xy(e)}),gb=/\s+/,_b=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a}=t,o=[],s=e.trim().split(gb),c=``;for(let e=s.length-1;e>=0;--e){let t=s[e],{isExternal:l,modifiers:u,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:p}=n(t);if(l){c=t+(c.length>0?` `+c:c);continue}let m=!!p,h=r(m?f.substring(0,p):f);if(!h){if(!m){c=t+(c.length>0?` `+c:c);continue}if(h=r(f),!h){c=t+(c.length>0?` `+c:c);continue}m=!1}let g=u.length===0?``:u.length===1?u[0]:a(u).join(`:`),_=d?g+lb:g,v=_+h;if(o.indexOf(v)>-1)continue;o.push(v);let y=i(h,m);for(let e=0;e<y.length;++e){let t=y[e];o.push(_+t)}c=t+(c.length>0?` `+c:c)}return c},vb=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=yb(n))&&(i&&(i+=` `),i+=r);return i},yb=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=yb(e[r]))&&(n&&(n+=` `),n+=t);return n},bb=(e,...t)=>{let n,r,i,a,o=o=>(n=hb(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=_b(e,n);return i(e,a),a};return a=o,(...e)=>a(vb(...e))},xb=[],Sb=e=>{let t=t=>t[e]||xb;return t.isThemeGetter=!0,t},Cb=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,wb=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Tb=/^\d+\/\d+$/,Eb=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Db=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ob=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,kb=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Ab=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,jb=e=>Tb.test(e),Mb=e=>!!e&&!Number.isNaN(Number(e)),Nb=e=>!!e&&Number.isInteger(Number(e)),Pb=e=>e.endsWith(`%`)&&Mb(e.slice(0,-1)),Fb=e=>Eb.test(e),Ib=()=>!0,Lb=e=>Db.test(e)&&!Ob.test(e),Rb=()=>!1,zb=e=>kb.test(e),Bb=e=>Ab.test(e),Vb=e=>!Q(e)&&!$(e),Hb=e=>ex(e,ix,Rb),Q=e=>Cb.test(e),Ub=e=>ex(e,ax,Lb),Wb=e=>ex(e,ox,Mb),Gb=e=>ex(e,nx,Rb),Kb=e=>ex(e,rx,Bb),qb=e=>ex(e,cx,zb),$=e=>wb.test(e),Jb=e=>tx(e,ax),Yb=e=>tx(e,sx),Xb=e=>tx(e,nx),Zb=e=>tx(e,ix),Qb=e=>tx(e,rx),$b=e=>tx(e,cx,!0),ex=(e,t,n)=>{let r=Cb.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},tx=(e,t,n=!1)=>{let r=wb.exec(e);return r?r[1]?t(r[1]):n:!1},nx=e=>e===`position`||e===`percentage`,rx=e=>e===`image`||e===`url`,ix=e=>e===`length`||e===`size`||e===`bg-size`,ax=e=>e===`length`,ox=e=>e===`number`,sx=e=>e===`family-name`,cx=e=>e===`shadow`,lx=bb(()=>{let e=Sb(`color`),t=Sb(`font`),n=Sb(`text`),r=Sb(`font-weight`),i=Sb(`tracking`),a=Sb(`leading`),o=Sb(`breakpoint`),s=Sb(`container`),c=Sb(`spacing`),l=Sb(`radius`),u=Sb(`shadow`),d=Sb(`inset-shadow`),f=Sb(`text-shadow`),p=Sb(`drop-shadow`),m=Sb(`blur`),h=Sb(`perspective`),g=Sb(`aspect`),_=Sb(`ease`),v=Sb(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),$,Q],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[$,Q,c],T=()=>[jb,`full`,`auto`,...w()],E=()=>[Nb,`none`,`subgrid`,$,Q],D=()=>[`auto`,{span:[`full`,Nb,$,Q]},Nb,$,Q],O=()=>[Nb,`auto`,$,Q],k=()=>[`auto`,`min`,`max`,`fr`,$,Q],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[jb,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[e,$,Q],F=()=>[...b(),Xb,Gb,{position:[$,Q]}],I=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],L=()=>[`auto`,`cover`,`contain`,Zb,Hb,{size:[$,Q]}],R=()=>[Pb,Jb,Ub],z=()=>[``,`none`,`full`,l,$,Q],B=()=>[``,Mb,Jb,Ub],V=()=>[`solid`,`dashed`,`dotted`,`double`],H=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],U=()=>[Mb,Pb,Xb,Gb],W=()=>[``,`none`,m,$,Q],G=()=>[`none`,Mb,$,Q],ee=()=>[`none`,Mb,$,Q],K=()=>[Mb,$,Q],te=()=>[jb,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[Fb],breakpoint:[Fb],color:[Ib],container:[Fb],"drop-shadow":[Fb],ease:[`in`,`out`,`in-out`],font:[Vb],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[Fb],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[Fb],shadow:[Fb],spacing:[`px`,Mb],text:[Fb],"text-shadow":[Fb],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,jb,Q,$,g]}],container:[`container`],columns:[{columns:[Mb,Q,$,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{start:T()}],end:[{end:T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[Nb,`auto`,$,Q]}],basis:[{basis:[jb,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[Mb,jb,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,Mb,$,Q]}],shrink:[{shrink:[``,Mb,$,Q]}],order:[{order:[Nb,`first`,`last`,`none`,$,Q]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,Jb,Ub]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,$,Wb]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,Pb,Q]}],"font-family":[{font:[Yb,Q,t]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,$,Q]}],"line-clamp":[{"line-clamp":[Mb,`none`,$,Wb]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,$,Q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,$,Q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:P()}],"text-color":[{text:P()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...V(),`wavy`]}],"text-decoration-thickness":[{decoration:[Mb,`from-font`,`auto`,$,Ub]}],"text-decoration-color":[{decoration:P()}],"underline-offset":[{"underline-offset":[Mb,`auto`,$,Q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,$,Q]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,$,Q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:F()}],"bg-repeat":[{bg:I()}],"bg-size":[{bg:L()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},Nb,$,Q],radial:[``,$,Q],conic:[Nb,$,Q]},Qb,Kb]}],"bg-color":[{bg:P()}],"gradient-from-pos":[{from:R()}],"gradient-via-pos":[{via:R()}],"gradient-to-pos":[{to:R()}],"gradient-from":[{from:P()}],"gradient-via":[{via:P()}],"gradient-to":[{to:P()}],rounded:[{rounded:z()}],"rounded-s":[{"rounded-s":z()}],"rounded-e":[{"rounded-e":z()}],"rounded-t":[{"rounded-t":z()}],"rounded-r":[{"rounded-r":z()}],"rounded-b":[{"rounded-b":z()}],"rounded-l":[{"rounded-l":z()}],"rounded-ss":[{"rounded-ss":z()}],"rounded-se":[{"rounded-se":z()}],"rounded-ee":[{"rounded-ee":z()}],"rounded-es":[{"rounded-es":z()}],"rounded-tl":[{"rounded-tl":z()}],"rounded-tr":[{"rounded-tr":z()}],"rounded-br":[{"rounded-br":z()}],"rounded-bl":[{"rounded-bl":z()}],"border-w":[{border:B()}],"border-w-x":[{"border-x":B()}],"border-w-y":[{"border-y":B()}],"border-w-s":[{"border-s":B()}],"border-w-e":[{"border-e":B()}],"border-w-t":[{"border-t":B()}],"border-w-r":[{"border-r":B()}],"border-w-b":[{"border-b":B()}],"border-w-l":[{"border-l":B()}],"divide-x":[{"divide-x":B()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":B()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...V(),`hidden`,`none`]}],"divide-style":[{divide:[...V(),`hidden`,`none`]}],"border-color":[{border:P()}],"border-color-x":[{"border-x":P()}],"border-color-y":[{"border-y":P()}],"border-color-s":[{"border-s":P()}],"border-color-e":[{"border-e":P()}],"border-color-t":[{"border-t":P()}],"border-color-r":[{"border-r":P()}],"border-color-b":[{"border-b":P()}],"border-color-l":[{"border-l":P()}],"divide-color":[{divide:P()}],"outline-style":[{outline:[...V(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[Mb,$,Q]}],"outline-w":[{outline:[``,Mb,Jb,Ub]}],"outline-color":[{outline:P()}],shadow:[{shadow:[``,`none`,u,$b,qb]}],"shadow-color":[{shadow:P()}],"inset-shadow":[{"inset-shadow":[`none`,d,$b,qb]}],"inset-shadow-color":[{"inset-shadow":P()}],"ring-w":[{ring:B()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:P()}],"ring-offset-w":[{"ring-offset":[Mb,Ub]}],"ring-offset-color":[{"ring-offset":P()}],"inset-ring-w":[{"inset-ring":B()}],"inset-ring-color":[{"inset-ring":P()}],"text-shadow":[{"text-shadow":[`none`,f,$b,qb]}],"text-shadow-color":[{"text-shadow":P()}],opacity:[{opacity:[Mb,$,Q]}],"mix-blend":[{"mix-blend":[...H(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":H()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[Mb]}],"mask-image-linear-from-pos":[{"mask-linear-from":U()}],"mask-image-linear-to-pos":[{"mask-linear-to":U()}],"mask-image-linear-from-color":[{"mask-linear-from":P()}],"mask-image-linear-to-color":[{"mask-linear-to":P()}],"mask-image-t-from-pos":[{"mask-t-from":U()}],"mask-image-t-to-pos":[{"mask-t-to":U()}],"mask-image-t-from-color":[{"mask-t-from":P()}],"mask-image-t-to-color":[{"mask-t-to":P()}],"mask-image-r-from-pos":[{"mask-r-from":U()}],"mask-image-r-to-pos":[{"mask-r-to":U()}],"mask-image-r-from-color":[{"mask-r-from":P()}],"mask-image-r-to-color":[{"mask-r-to":P()}],"mask-image-b-from-pos":[{"mask-b-from":U()}],"mask-image-b-to-pos":[{"mask-b-to":U()}],"mask-image-b-from-color":[{"mask-b-from":P()}],"mask-image-b-to-color":[{"mask-b-to":P()}],"mask-image-l-from-pos":[{"mask-l-from":U()}],"mask-image-l-to-pos":[{"mask-l-to":U()}],"mask-image-l-from-color":[{"mask-l-from":P()}],"mask-image-l-to-color":[{"mask-l-to":P()}],"mask-image-x-from-pos":[{"mask-x-from":U()}],"mask-image-x-to-pos":[{"mask-x-to":U()}],"mask-image-x-from-color":[{"mask-x-from":P()}],"mask-image-x-to-color":[{"mask-x-to":P()}],"mask-image-y-from-pos":[{"mask-y-from":U()}],"mask-image-y-to-pos":[{"mask-y-to":U()}],"mask-image-y-from-color":[{"mask-y-from":P()}],"mask-image-y-to-color":[{"mask-y-to":P()}],"mask-image-radial":[{"mask-radial":[$,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":U()}],"mask-image-radial-to-pos":[{"mask-radial-to":U()}],"mask-image-radial-from-color":[{"mask-radial-from":P()}],"mask-image-radial-to-color":[{"mask-radial-to":P()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[Mb]}],"mask-image-conic-from-pos":[{"mask-conic-from":U()}],"mask-image-conic-to-pos":[{"mask-conic-to":U()}],"mask-image-conic-from-color":[{"mask-conic-from":P()}],"mask-image-conic-to-color":[{"mask-conic-to":P()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:F()}],"mask-repeat":[{mask:I()}],"mask-size":[{mask:L()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,$,Q]}],filter:[{filter:[``,`none`,$,Q]}],blur:[{blur:W()}],brightness:[{brightness:[Mb,$,Q]}],contrast:[{contrast:[Mb,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,$b,qb]}],"drop-shadow-color":[{"drop-shadow":P()}],grayscale:[{grayscale:[``,Mb,$,Q]}],"hue-rotate":[{"hue-rotate":[Mb,$,Q]}],invert:[{invert:[``,Mb,$,Q]}],saturate:[{saturate:[Mb,$,Q]}],sepia:[{sepia:[``,Mb,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":W()}],"backdrop-brightness":[{"backdrop-brightness":[Mb,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[Mb,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,Mb,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Mb,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,Mb,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[Mb,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[Mb,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,Mb,$,Q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,$,Q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[Mb,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[Mb,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:G()}],"rotate-x":[{"rotate-x":G()}],"rotate-y":[{"rotate-y":G()}],"rotate-z":[{"rotate-z":G()}],scale:[{scale:ee()}],"scale-x":[{"scale-x":ee()}],"scale-y":[{"scale-y":ee()}],"scale-z":[{"scale-z":ee()}],"scale-3d":[`scale-3d`],skew:[{skew:K()}],"skew-x":[{"skew-x":K()}],"skew-y":[{"skew-y":K()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:te()}],"translate-x":[{"translate-x":te()}],"translate-y":[{"translate-y":te()}],"translate-z":[{"translate-z":te()}],"translate-none":[`translate-none`],accent:[{accent:P()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:P()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,$,Q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,$,Q]}],fill:[{fill:[`none`,...P()]}],"stroke-w":[{stroke:[Mb,Jb,Ub,Wb]}],stroke:[{stroke:[`none`,...P()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function ux(...e){return lx(Uy(e))}function dx({checked:e,onCheckedChange:t,disabled:n,className:r}){return(0,J.jsx)(By,{checked:e,onCheckedChange:t,disabled:n,className:ux(`group relative inline-flex h-6 w-10 shrink-0 cursor-pointer items-center rounded-full transition-colors`,`bg-border data-[checked]:bg-accent`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-bg-base`,`disabled:cursor-not-allowed disabled:opacity-50`,r),children:(0,J.jsx)(Vy,{className:ux(`pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform`,`translate-x-1 group-data-[checked]:translate-x-5`)})})}var fx=null,px=!1,mx={},hx=500;function gx(){if(typeof window>`u`)return null;if(fx?.state===`closed`&&(fx=null),!fx){let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;fx=new e}return fx}function _x(){fx&&=(fx.close().catch(()=>{}),null),gx()}function vx(){return px}function yx(){fx&&(_x(),px=!0)}if(typeof window<`u`){window.addEventListener(`pageshow`,e=>{e.persisted&&yx()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&yx()});let e=Date.now();setInterval(()=>{let t=Date.now();t-e>15e3&&yx(),e=t},5e3)}async function bx(){let e=gx();e&&e.state===`suspended`&&await e.resume().catch(()=>{}),px=!1}async function xx(e){e.state===`suspended`&&await e.resume().catch(()=>{})}async function Sx(e){let t=gx();if(!t||(await xx(t),t.state!==`running`))return;let{frequencies:n,durationMs:r,attackMs:i,peakGain:a,type:o=`sine`}=e,s=t.currentTime,c=r/1e3,l=i/1e3,u=t.createGain();u.connect(t.destination);let d=s+c*.7;u.gain.setValueAtTime(0,s),u.gain.linearRampToValueAtTime(a,s+l),u.gain.setValueAtTime(a,d),u.gain.linearRampToValueAtTime(0,s+c);let f=n.map(e=>{let n=t.createOscillator();return n.type=o,n.frequency.setValueAtTime(e,s),n.connect(u),n});for(let e of f)e.start(s),e.stop(s+c);let p=f[f.length-1];p.onended=()=>{for(let e of f)e.disconnect();u.disconnect()}}async function Cx(){let e=Date.now();if(!(e-(mx.permission||0)<hx)){mx.permission=e;try{await Sx({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:`sine`})}catch{}}}async function wx(){let e=Date.now();if(!(e-(mx.idle||0)<hx)){mx.idle=e;try{await Sx({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:`sine`})}catch{}}}function Tx({isOpen:e,onClose:t}){let n=G(e=>e.defaultProjectDir),r=G(e=>e.setDefaultProjectDir),i=G(e=>e.commandPresets),a=G(e=>e.setCommandPresets),o=G(e=>e.defaultPresetId),s=G(e=>e.setDefaultPresetId),c=G(e=>e.sessionSortMode),l=G(e=>e.setSessionSortMode),u=G(e=>e.sessionSortDirection),d=G(e=>e.setSessionSortDirection),f=G(e=>e.useWebGL),p=G(e=>e.setUseWebGL),m=G(e=>e.fontSize),h=G(e=>e.setFontSize),g=G(e=>e.lineHeight),_=G(e=>e.setLineHeight),v=G(e=>e.letterSpacing),y=G(e=>e.setLetterSpacing),b=G(e=>e.fontOption),S=G(e=>e.setFontOption),C=G(e=>e.customFontFamily),w=G(e=>e.setCustomFontFamily),T=G(e=>e.shortcutModifier),E=G(e=>e.setShortcutModifier),D=G(e=>e.showProjectName),O=G(e=>e.setShowProjectName),k=G(e=>e.showLastUserMessage),A=G(e=>e.setShowLastUserMessage),j=G(e=>e.showSessionIdPrefix),M=G(e=>e.setShowSessionIdPrefix),N=T_(e=>e.theme),F=T_(e=>e.setTheme),I=G(e=>e.soundOnPermission),R=G(e=>e.setSoundOnPermission),z=G(e=>e.soundOnIdle),B=G(e=>e.setSoundOnIdle),[V,H]=(0,x.useState)(n),[U,W]=(0,x.useState)(i),[ee,K]=(0,x.useState)(o),[te,q]=(0,x.useState)(c),[ne,re]=(0,x.useState)(u),[ie,ae]=(0,x.useState)(f),[oe,se]=(0,x.useState)(m),[ce,le]=(0,x.useState)(g),[ue,de]=(0,x.useState)(v),[fe,pe]=(0,x.useState)(b),[me,he]=(0,x.useState)(C),[ge,_e]=(0,x.useState)(T),[ve,ye]=(0,x.useState)(D),[be,xe]=(0,x.useState)(k),[Se,Ce]=(0,x.useState)(j),[we,Te]=(0,x.useState)(N),[Ee,De]=(0,x.useState)(I),[Oe,ke]=(0,x.useState)(z),[Ae,je]=(0,x.useState)(!0),[Me,Ne]=(0,x.useState)(!1),[Pe,Fe]=(0,x.useState)(24),[Ie,Le]=(0,x.useState)(!1),[Re,ze]=(0,x.useState)(!1),[Be,Ve]=(0,x.useState)(``),[He,We]=(0,x.useState)(``),[Ke,qe]=(0,x.useState)(``),Je=(0,x.useRef)(null);if((0,x.useEffect)(()=>{if(Je.current&&=(clearTimeout(Je.current),null),e){if(H(n),W(i),K(o),q(c),re(u),ae(f),se(m),le(g),de(v),pe(b),he(C),_e(T),ye(D),xe(k),Ce(j),Te(N),De(I),ke(z),ze(!1),Ve(``),We(``),qe(``),fetch(`/api/settings/tmux-mouse-mode`).then(e=>e.json()).then(e=>je(e.enabled)).catch(()=>{}),fetch(`/api/settings/history-max-age-hours`).then(e=>e.json()).then(e=>Fe(e.hours)).catch(()=>{}),typeof document<`u`){let e=document.querySelector(`.xterm-helper-textarea`);e&&typeof e.setAttribute==`function`&&(typeof e.blur==`function`&&e.blur(),e.setAttribute(`disabled`,`true`))}}else typeof document<`u`&&(Je.current=setTimeout(()=>{if(typeof document>`u`)return;let e=document.querySelector(`.xterm-helper-textarea`);e&&(e.removeAttribute(`disabled`),e.focus())},300));return()=>{Je.current&&=(clearTimeout(Je.current),null)}},[i,o,n,c,u,f,m,g,v,b,C,T,D,k,j,N,I,z,e]),(0,x.useEffect)(()=>{if(!e||typeof window>`u`||typeof window.addEventListener!=`function`)return;let n=e=>{e.key===`Escape`&&(typeof e.stopPropagation==`function`&&e.stopPropagation(),t())};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),!e)return null;let Ye=e=>{e.preventDefault();let n=V.trim(),i=ie!==f;r(n||`~/Documents/GitHub`),a(U),s(ee),l(te),d(ne),p(ie),h(oe),_(ce),y(ue),S(fe),w(me),E(ge),O(ve),A(be),M(Se),F(we),R(Ee),B(Oe),t({webglChanged:i})},Xe=(e,t)=>{W(n=>n.map(n=>n.id===e?{...n,...t}:n))},Ze=e=>{let t=U.find(t=>t.id===e);if(!t||t.isBuiltIn)return;let n=U.filter(t=>t.id!==e);W(n),e===ee&&K(n[0]?.id||`claude`)},Qe=()=>{if(!Be.trim()||!He.trim()||U.length>=50)return;let e={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:Be.trim(),command:He.trim(),isBuiltIn:!1,agentType:Ke||void 0};W([...U,e]),ze(!1),Ve(``),We(``),qe(``)},$e=U.length<50,et=e=>{Ne(!0),je(e),fetch(`/api/settings/tmux-mouse-mode`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:e})}).catch(()=>je(!e)).finally(()=>Ne(!1))},tt=e=>{let t=Pe;Le(!0),Fe(e),fetch(`/api/settings/history-max-age-hours`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hours:e})}).catch(()=>Fe(t)).finally(()=>Le(!1))};return(0,J.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e=>{e.target===e.currentTarget&&t()},children:(0,J.jsxs)(`form`,{onSubmit:Ye,className:`w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated`,children:[(0,J.jsxs)(`div`,{className:`p-6 pb-0`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold uppercase tracking-wider text-primary text-balance`,children:`Settings`}),(0,J.jsx)(`p`,{className:`mt-2 text-xs text-muted text-pretty`,children:`Configure default directory, command presets, and display options.`})]}),(0,J.jsx)(`div`,{className:`flex-1 overflow-y-auto px-6 pb-4`,children:(0,J.jsxs)(`div`,{className:`mt-5 space-y-4`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-1.5 block text-xs text-secondary`,children:`Default Project Directory`}),(0,J.jsx)(`input`,{value:V,onChange:e=>H(e.target.value),placeholder:P,className:`input`,autoFocus:!0})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,J.jsx)(`label`,{className:`text-xs text-secondary`,children:`Command Presets`}),(0,J.jsx)(`select`,{value:ee,onChange:e=>K(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:U.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),(0,J.jsx)(`p`,{className:`text-[10px] text-muted mb-3`,children:`Default preset is pre-selected when creating new sessions.`}),(0,J.jsx)(`div`,{className:`space-y-3`,children:U.map(e=>(0,J.jsxs)(`div`,{className:`border border-border p-3 space-y-2`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,J.jsx)(`input`,{value:e.label,onChange:t=>Xe(e.id,{label:t.target.value}),className:`input text-sm py-1 px-2 w-32`,placeholder:`Label`})}),!e.isBuiltIn&&(0,J.jsx)(`button`,{type:`button`,onClick:()=>Ze(e.id),className:`btn text-xs px-2 py-1 text-error hover:bg-error/10`,children:`Delete`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Command`}),(0,J.jsx)(`input`,{value:e.command,onChange:t=>Xe(e.id,{command:t.target.value}),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`})]}),!e.isBuiltIn&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`text-[10px] text-muted block mb-1`,children:`Icon`}),(0,J.jsxs)(`select`,{value:e.agentType||``,onChange:t=>Xe(e.id,{agentType:t.target.value||void 0}),className:`input text-xs py-1 px-2 w-auto`,children:[(0,J.jsx)(`option`,{value:``,children:`Terminal`}),(0,J.jsx)(`option`,{value:`claude`,children:`Claude`}),(0,J.jsx)(`option`,{value:`codex`,children:`Codex`})]})]})]},e.id))}),Re?(0,J.jsxs)(`div`,{className:`mt-3 border border-border p-3 space-y-2`,children:[(0,J.jsx)(`div`,{className:`text-xs text-secondary mb-2`,children:`New Preset`}),(0,J.jsx)(`input`,{value:Be,onChange:e=>Ve(e.target.value),className:`input text-xs py-1 px-2 w-full`,placeholder:`Label`}),(0,J.jsx)(`input`,{value:He,onChange:e=>We(e.target.value),className:`input text-xs py-1 px-2 font-mono w-full`,placeholder:`command --flags`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`select`,{value:Ke,onChange:e=>qe(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:[(0,J.jsx)(`option`,{value:``,children:`Terminal Icon`}),(0,J.jsx)(`option`,{value:`claude`,children:`Claude Icon`}),(0,J.jsx)(`option`,{value:`codex`,children:`Codex Icon`})]}),(0,J.jsx)(`div`,{className:`flex-1`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>ze(!1),className:`btn text-xs px-2 py-1`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`button`,onClick:Qe,disabled:!Be.trim()||!He.trim(),className:`btn btn-primary text-xs px-2 py-1`,children:`Add`})]})]}):(0,J.jsx)(`button`,{type:`button`,onClick:()=>ze(!0),disabled:!$e,className:`btn text-xs mt-3 w-full`,children:$e?`+ Add Preset`:`Max 50 presets`})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,J.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Session List Order`}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`created`?`btn-primary`:``}`,onClick:()=>q(`created`),children:`Created`}),(0,J.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`status`?`btn-primary`:``}`,onClick:()=>q(`status`),children:`Status`}),(0,J.jsx)(`button`,{type:`button`,className:`btn flex-1 ${te===`manual`?`btn-primary`:``}`,onClick:()=>q(`manual`),children:`Manual`})]}),(0,J.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:te===`status`?`Sessions auto-resort by status (waiting, working, unknown)`:te===`manual`?`Drag sessions to reorder manually`:`Sessions stay in creation order`})]}),te===`created`&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Sort Direction`}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ne===`desc`?`btn-primary`:``}`,onClick:()=>re(`desc`),children:`Newest First`}),(0,J.jsx)(`button`,{type:`button`,className:`btn flex-1 ${ne===`asc`?`btn-primary`:``}`,onClick:()=>re(`asc`),children:`Oldest First`})]})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,J.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Session List Details`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Project Name`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the project folder name under each session.`})]}),(0,J.jsx)(dx,{checked:ve,onCheckedChange:ye})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Last User Message`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show the most recent user input next to the project name.`})]}),(0,J.jsx)(dx,{checked:be,onCheckedChange:xe})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Session ID Prefix`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Show first 5 characters of agent session IDs in the list.`})]}),(0,J.jsx)(dx,{checked:Se,onCheckedChange:Ce})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`History Sessions Lookback`}),(0,J.jsxs)(`div`,{className:`text-[10px] text-muted`,children:[`Show history sessions from the last N hours (`,1,`-`,168,`).`]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`number`,min:1,max:168,value:Pe,onChange:e=>{let t=parseInt(e.target.value,10);t>=1&&t<=168&&tt(t)},disabled:Ie,className:`input text-xs py-1 px-2 w-16 text-center`}),(0,J.jsx)(`span`,{className:`text-xs text-muted`,children:`hrs`})]})]})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4 space-y-3`,children:[(0,J.jsx)(`label`,{className:`mb-1 block text-xs text-secondary`,children:`Notifications`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex-1`,children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Permission Sound`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a ping when any session needs permission.`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>void Cx(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,J.jsx)(dx,{checked:Ee,onCheckedChange:e=>{De(e),e&&bx()}})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex-1`,children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Idle Sound`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Play a chime when a session finishes working.`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>void wx(),className:`btn text-xs px-2 py-1`,children:`Test`}),(0,J.jsx)(dx,{checked:Oe,onCheckedChange:e=>{ke(e),e&&bx()}})]})]})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,J.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Terminal Rendering`}),(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`WebGL Acceleration`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`GPU rendering for better performance. Turn off if text looks fuzzy or flickering.`})]}),(0,J.jsx)(dx,{checked:ie,onCheckedChange:ae})]}),ie!==f&&(0,J.jsx)(`p`,{className:`mt-2 text-[10px] text-approval`,children:`Terminal will reload when saved`}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Mouse Mode`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Enable tmux mouse mode for trackpad/scroll wheel support.`})]}),(0,J.jsx)(dx,{checked:Ae,onCheckedChange:et,disabled:Me})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Size`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal text size in pixels (6-24)`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>se(Math.max(6,oe-1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,J.jsx)(`span`,{className:`text-sm font-bold`,children:`−`})}),(0,J.jsx)(`span`,{className:`text-sm text-secondary w-6 text-center`,children:oe}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>se(Math.min(24,oe+1)),className:`flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover`,children:(0,J.jsx)(`span`,{className:`text-sm font-bold`,children:`+`})})]})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Line Height`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Vertical spacing (1.0 = compact, 2.0 = spacious)`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`range`,min:`1.0`,max:`2.0`,step:`0.1`,value:ce,onChange:e=>le(parseFloat(e.target.value)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,J.jsx)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:ce.toFixed(1)})]})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Letter Spacing`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Horizontal spacing between characters in pixels`})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`input`,{type:`range`,min:`-3`,max:`3`,step:`1`,value:ue,onChange:e=>de(parseInt(e.target.value,10)),className:`w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent`}),(0,J.jsxs)(`span`,{className:`text-xs text-secondary w-8 text-right`,children:[ue,`px`]})]})]}),(0,J.jsxs)(`div`,{className:`mt-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Font Family`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Terminal typeface`})]}),(0,J.jsx)(`select`,{value:fe,onChange:e=>pe(e.target.value),className:`input text-xs py-1 px-2 w-auto`,children:L.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.label},e.id))})]}),fe===`custom`&&(0,J.jsx)(`input`,{value:me,onChange:e=>he(e.target.value),placeholder:`"Fira Code", monospace`,className:`input text-xs mt-2 font-mono`})]}),(0,J.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`text-sm text-primary`,children:`Dark Mode`}),(0,J.jsx)(`div`,{className:`text-[10px] text-muted`,children:`Switch between dark and light themes.`})]}),(0,J.jsx)(dx,{checked:we===`dark`,onCheckedChange:e=>Te(e?`dark`:`light`)})]})]}),(0,J.jsxs)(`div`,{className:`border-t border-border pt-4`,children:[(0,J.jsx)(`label`,{className:`mb-2 block text-xs text-secondary`,children:`Keyboard Shortcut Modifier`}),(0,J.jsx)(`div`,{className:`grid grid-cols-5 gap-1`,children:[`auto`,`ctrl-option`,`ctrl-shift`,`cmd-option`,`cmd-shift`].map(e=>(0,J.jsx)(`button`,{type:`button`,className:`btn text-xs px-2 ${ge===e?`btn-primary`:``}`,onClick:()=>_e(e),children:e===`auto`?`Auto`:Ge(e)},e))}),(0,J.jsx)(`p`,{className:`mt-1.5 text-[10px] text-muted`,children:ge===`auto`?`Platform default: ${Ge(Ue(`auto`))}`:`Shortcuts: ${Ge(ge)}+[N/X/[/]]`})]})]})}),(0,J.jsxs)(`div`,{className:`flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>t(),className:`btn`,children:`Cancel`}),(0,J.jsx)(`button`,{type:`submit`,className:`btn btn-primary`,children:`Save`})]})]})})}var Ex=[];function Dx(e){x.useEffect(e,Ex)}var Ox=x.createContext(void 0);function kx(){let e=x.useContext(Ox);if(!e)throw Error(Pv(73));return e}var Ax=Symbol(`NOT_FOUND`);function jx(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function Mx(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!=`object`)throw TypeError(t)}function Nx(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var Px=e=>Array.isArray(e)?e:[e];function Fx(e){let t=Array.isArray(e[0])?e[0]:e;return Nx(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function Ix(e,t){let n=[],{length:r}=e;for(let i=0;i<r;i++)n.push(e[i].apply(null,t));return n}function Lx(e){let t;return{get(n){return t&&e(t.key,n)?t.value:Ax},put(e,n){t={key:e,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function Rx(e,t){let n=[];function r(e){let r=n.findIndex(n=>t(e,n.key));if(r>-1){let e=n[r];return r>0&&(n.splice(r,1),n.unshift(e)),e.value}return Ax}function i(t,i){r(t)===Ax&&(n.unshift({key:t,value:i}),n.length>e&&n.pop())}function a(){return n}function o(){n=[]}return{get:r,put:i,getEntries:a,clear:o}}var zx=(e,t)=>e===t;function Bx(e){return function(t,n){if(t===null||n===null||t.length!==n.length)return!1;let{length:r}=t;for(let i=0;i<r;i++)if(!e(t[i],n[i]))return!1;return!0}}function Vx(e,t){let{equalityCheck:n=zx,maxSize:r=1,resultEqualityCheck:i}=typeof t==`object`?t:{equalityCheck:t},a=Bx(n),o=0,s=r<=1?Lx(a):Rx(r,a);function c(){let t=s.get(arguments);if(t===Ax){if(t=e.apply(null,arguments),o++,i){let e=s.getEntries().find(e=>i(e.value,t));e&&(t=e.value,o!==0&&o--)}s.put(arguments,t)}return t}return c.clearCache=()=>{s.clear(),c.resetResultsCount()},c.resultsCount=()=>o,c.resetResultsCount=()=>{o=0},c}var Hx=class{constructor(e){this.value=e}deref(){return this.value}},Ux=typeof WeakRef<`u`?WeakRef:Hx,Wx=0,Gx=1;function Kx(){return{s:Wx,v:void 0,o:null,p:null}}function qx(e,t={}){let n=Kx(),{resultEqualityCheck:r}=t,i,a=0;function o(){let t=n,{length:o}=arguments;for(let e=0,n=o;e<n;e++){let n=arguments[e];if(typeof n==`function`||typeof n==`object`&&n){let e=t.o;e===null&&(t.o=e=new WeakMap);let r=e.get(n);r===void 0?(t=Kx(),e.set(n,t)):t=r}else{let e=t.p;e===null&&(t.p=e=new Map);let r=e.get(n);r===void 0?(t=Kx(),e.set(n,t)):t=r}}let s=t,c;if(t.s===Gx)c=t.v;else if(c=e.apply(null,arguments),a++,r){let e=i?.deref?.()??i;e!=null&&r(e,c)&&(c=e,a!==0&&a--),i=typeof c==`object`&&c||typeof c==`function`?new Ux(c):c}return s.s=Gx,s.v=c,c}return o.clearCache=()=>{n=Kx(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function Jx(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),jx(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=qx,argsMemoizeOptions:u=[],devModeChecks:d={}}={...n,...a},f=Px(c),p=Px(u),m=Fx(e),h=s(function(){return t++,o.apply(null,arguments)},...f),g=l(function(){r++;let e=Ix(m,arguments);return i=h.apply(null,e),i},...p);return Object.assign(g,{resultFunc:o,memoizedResultFunc:h,dependencies:m,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var Yx=Jx(qx),Xx=Object.assign((e,t=Yx)=>{Mx(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);let n=Object.keys(e);return t(n.map(t=>e[t]),(...e)=>e.reduce((e,t,r)=>(e[n[r]]=t,e),{}))},{withTypes:()=>Xx}),Zx=Jx({memoize:Vx,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),Qx=(e,t,n,r,i,a,...o)=>{if(o.length>0)throw Error(Pv(1));let s;if(e&&t&&n&&r&&i&&a)s=(o,s,c,l)=>a(e(o,s,c,l),t(o,s,c,l),n(o,s,c,l),r(o,s,c,l),i(o,s,c,l),s,c,l);else if(e&&t&&n&&r&&i)s=(a,o,s,c)=>i(e(a,o,s,c),t(a,o,s,c),n(a,o,s,c),r(a,o,s,c),o,s,c);else if(e&&t&&n&&r)s=(i,a,o,s)=>r(e(i,a,o,s),t(i,a,o,s),n(i,a,o,s),a,o,s);else if(e&&t&&n)s=(r,i,a,o)=>n(e(r,i,a,o),t(r,i,a,o),i,a,o);else if(e&&t)s=(n,r,i,a)=>t(e(n,r,i,a),r,i,a);else if(e)s=e;else throw Error(`Missing arguments`);return s},$x=(...e)=>{let t=new WeakMap,n=1,r=e[e.length-1],i=e.length-1||1,a=r.length-i;if(a>3)throw Error(Pv(2));return(i,o,s,c)=>{let l=i.__cacheKey__;l||(l={id:n},i.__cacheKey__=l,n+=1);let u=t.get(l);if(!u){let n=e,i=[void 0,void 0,void 0];switch(a){case 0:break;case 1:n=[...e.slice(0,-1),()=>i[0],r];break;case 2:n=[...e.slice(0,-1),()=>i[0],()=>i[1],r];break;case 3:n=[...e.slice(0,-1),()=>i[0],()=>i[1],()=>i[2],r];break;default:throw Error(Pv(2))}u=Zx(...n),u.selectorArgs=i,t.set(l,u)}switch(u.selectorArgs[0]=o,u.selectorArgs[1]=s,u.selectorArgs[2]=c,a){case 0:return u(i);case 1:return u(i,o);case 2:return u(i,o,s);case 3:return u(i,o,s,c);default:throw Error(`unreachable`)}}},eS=s((e=>{var t=p();function n(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var r=typeof Object.is==`function`?Object.is:n,i=t.useState,a=t.useEffect,o=t.useLayoutEffect,s=t.useDebugValue;function c(e,t){var n=t(),r=i({inst:{value:n,getSnapshot:t}}),c=r[0].inst,u=r[1];return o(function(){c.value=n,c.getSnapshot=t,l(c)&&u({inst:c})},[e,n,t]),a(function(){return l(c)&&u({inst:c}),e(function(){l(c)&&u({inst:c})})},[e]),s(n),n}function l(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!r(e,n)}catch{return!0}}function u(e,t){return t()}var d=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?u:c;e.useSyncExternalStore=t.useSyncExternalStore===void 0?d:t.useSyncExternalStore})),tS=s(((e,t)=>{t.exports=eS()})),nS=s((e=>{var t=p(),n=tS();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),rS=s(((e,t)=>{t.exports=nS()})),iS=[],aS=void 0;function oS(){return aS}function sS(e){iS.push(e)}var cS=tS(),lS=rS(),uS=Iv(19)?pS:mS;function dS(e,t,n,r,i){return uS(e,t,n,r,i)}function fS(e,t,n,r,i){let a=x.useCallback(()=>t(e.getSnapshot(),n,r,i),[e,t,n,r,i]);return(0,cS.useSyncExternalStore)(e.subscribe,a,a)}sS({before(e){e.syncIndex=0,e.didInitialize||(e.syncTick=1,e.syncHooks=[],e.didChangeStore=!0,e.getSnapshot=()=>{let t=!1;for(let n=0;n<e.syncHooks.length;n+=1){let r=e.syncHooks[n],i=r.selector(r.store.state,r.a1,r.a2,r.a3);(r.didChange||!Object.is(r.value,i))&&(t=!0,r.value=i,r.didChange=!1)}return t&&(e.syncTick+=1),e.syncTick})},after(e){e.syncHooks.length>0&&(e.didChangeStore&&(e.didChangeStore=!1,e.subscribe=t=>{let n=new Set;for(let t of e.syncHooks)n.add(t.store);let r=[];for(let e of n)r.push(e.subscribe(t));return()=>{for(let e of r)e()}}),(0,cS.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot))}});function pS(e,t,n,r,i){let a=oS();if(!a)return fS(e,t,n,r,i);let o=a.syncIndex;a.syncIndex+=1;let s;return a.didInitialize?(s=a.syncHooks[o],(s.store!==e||s.selector!==t||!Object.is(s.a1,n)||!Object.is(s.a2,r)||!Object.is(s.a3,i))&&(s.store!==e&&(a.didChangeStore=!0),s.store=e,s.selector=t,s.a1=n,s.a2=r,s.a3=i,s.didChange=!0)):(s={store:e,selector:t,a1:n,a2:r,a3:i,value:t(e.getSnapshot(),n,r,i),didChange:!1},a.syncHooks.push(s)),s.value}function mS(e,t,n,r,i){return(0,lS.useSyncExternalStoreWithSelector)(e.subscribe,e.getSnapshot,e.getSnapshot,e=>t(e,n,r,i))}var hS=class{constructor(e){this.state=e,this.listeners=new Set,this.updateTick=0}subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.state;setState(e){if(this.state===e)return;this.state=e,this.updateTick+=1;let t=this.updateTick;for(let n of this.listeners){if(t!==this.updateTick)return;n(e)}}update(e){for(let t in e)if(!Object.is(this.state[t],e[t])){this.setState({...this.state,...e});return}}set(e,t){Object.is(this.state[e],t)||this.setState({...this.state,[e]:t})}notifyAll(){let e={...this.state};this.setState(e)}use(e,t,n,r){return dS(this,e,t,n,r)}},gS=class extends hS{constructor(e,t={},n){super(e),this.context=t,this.selectors=n}useSyncedValue(e,t){x.useDebugValue(e),Ov(()=>{this.state[e]!==t&&this.set(e,t)},[e,t])}useSyncedValueWithCleanup(e,t){let n=this;Ov(()=>(n.state[e]!==t&&n.set(e,t),()=>{n.set(e,void 0)}),[n,e,t])}useSyncedValues(e){let t=this;Ov(()=>{t.update(e)},[t,...Object.values(e)])}useControlledProp(e,t){x.useDebugValue(e);let n=t!==void 0;Ov(()=>{n&&!Object.is(this.state[e],t)&&super.setState({...this.state,[e]:t})},[e,t,n])}select(e,t,n,r){let i=this.selectors[e];return i(this.state,t,n,r)}useState(e,t,n,r){return x.useDebugValue(e),dS(this,this.selectors[e],t,n,r)}useContextCallback(e,t){x.useDebugValue(e);let n=yv(t??Mv);this.context[e]=n}useStateSetter(e){let t=x.useRef(void 0);return t.current===void 0&&(t.current=t=>{this.set(e,t)}),t.current}observe(e,t){let n;n=typeof e==`function`?e:this.selectors[e];let r=n(this.state);return t(r,r,this),this.subscribe(e=>{let i=n(e);if(!Object.is(r,i)){let e=r;r=i,t(i,e,this)}})}},_S=null;globalThis.requestAnimationFrame;var vS=new class{callbacks=[];callbacksCount=0;nextId=1;startId=1;isScheduled=!1;tick=e=>{this.isScheduled=!1;let t=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let n=0;n<t.length;n+=1)t[n]?.(e)};request(e){let t=this.nextId;return this.nextId+=1,this.callbacks.push(e),this.callbacksCount+=1,this.isScheduled||=(requestAnimationFrame(this.tick),!0),t}cancel(e){let t=e-this.startId;t<0||t>=this.callbacks.length||(this.callbacks[t]=null,--this.callbacksCount)}},yS=class e{static create(){return new e}static request(e){return vS.request(e)}static cancel(e){return vS.cancel(e)}currentId=_S;request(e){this.cancel(),this.currentId=vS.request(()=>{this.currentId=_S,e()})}cancel=()=>{this.currentId!==_S&&(vS.cancel(this.currentId),this.currentId=_S)};disposeEffect=()=>this.cancel};function bS(){let e=gv(yS.create).current;return Dx(e.disposeEffect),e}var xS=0,SS=class e{static create(){return new e}currentId=xS;start(e,t){this.clear(),this.currentId=setTimeout(()=>{this.currentId=xS,t()},e)}isStarted(){return this.currentId!==xS}clear=()=>{this.currentId!==xS&&(clearTimeout(this.currentId),this.currentId=xS)};disposeEffect=()=>this.clear};function CS(){let e=gv(SS.create).current;return Dx(e.disposeEffect),e}var wS=0;function TS(e){return wS+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${wS}`}function ES(e){return e?.ownerDocument||document}function DS(e,t){if(typeof e==`string`)return{description:e};if(typeof e==`function`){let n=e(t);return typeof n==`string`?{description:n}:n}return e}var OS=typeof navigator<`u`,kS=PS(),AS=IS(),jS=FS();typeof CSS>`u`||!CSS.supports||CSS.supports(`-webkit-backdrop-filter:none`),kS.platform===`MacIntel`&&kS.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(kS.platform),OS&&/firefox/i.test(jS);var MS=OS&&/apple/i.test(navigator.vendor);OS&&/Edg/i.test(jS),OS&&/android/i.test(AS)||/android/i.test(jS),OS&&AS.toLowerCase().startsWith(`mac`)&&navigator.maxTouchPoints;var NS=jS.includes(`jsdom/`);function PS(){if(!OS)return{platform:``,maxTouchPoints:-1};let e=navigator.userAgentData;return e?.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??``,maxTouchPoints:navigator.maxTouchPoints??-1}}function FS(){if(!OS)return``;let e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:e,version:t})=>`${e}/${t}`).join(` `):navigator.userAgent}function IS(){if(!OS)return``;let e=navigator.userAgentData;return e?.platform?e.platform:navigator.platform??``}function LS(e){let t=e.activeElement;for(;t?.shadowRoot?.activeElement!=null;)t=t.shadowRoot.activeElement;return t}function RS(e,t){if(!e||!t)return!1;let n=t.getRootNode?.();if(e.contains(t))return!0;if(n&&hy(n)){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode||n.host}}return!1}function zS(e){return`composedPath`in e?e.composedPath()[0]:e.target}function BS(e){if(!e||NS)return!0;try{return e.matches(`:focus-visible`)}catch{return!0}}var VS=$x(e=>e.toasts,e=>{let t=new Map,n=0,r=0;return e.forEach((e,i)=>{let a=e.transitionStatus===`ending`;t.set(e.id,{value:e,domIndex:i,visibleIndex:a?-1:n,offsetY:r}),r+=e.height||0,a||(n+=1)}),t}),HS={toasts:Qx(e=>e.toasts),isEmpty:Qx(e=>e.toasts.length===0),toast:Qx(VS,(e,t)=>e.get(t)?.value),toastIndex:Qx(VS,(e,t)=>e.get(t)?.domIndex??-1),toastOffsetY:Qx(VS,(e,t)=>e.get(t)?.offsetY??0),toastVisibleIndex:Qx(VS,(e,t)=>e.get(t)?.visibleIndex??-1),hovering:Qx(e=>e.hovering),focused:Qx(e=>e.focused),expanded:Qx(e=>e.hovering||e.focused),expandedOrOutOfFocus:Qx(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:Qx(e=>e.prevFocusElement)},US=class extends gS{timers=new Map;areTimersPaused=!1;constructor(e){super(e,{},HS)}setFocused(e){this.set(`focused`,e)}setHovering(e){this.set(`hovering`,e)}setIsWindowFocused(e){this.set(`isWindowFocused`,e)}setPrevFocusElement(e){this.set(`prevFocusElement`,e)}setViewport=e=>{this.set(`viewport`,e)};disposeEffect=()=>()=>{this.timers.forEach(e=>{e.timeout?.clear()}),this.timers.clear()};removeToast(e){let t=HS.toastIndex(this.state,e);if(t===-1)return;this.state.toasts[t]?.onRemove?.();let n=[...this.state.toasts];n.splice(t,1),this.setToasts(n)}addToast=e=>{let{toasts:t,timeout:n,limit:r}=this.state,i=e.id||TS(`toast`),a={...e,id:i,transitionStatus:`starting`},o=[a,...t],s=o.filter(e=>e.transitionStatus!==`ending`);if(s.length>r){let e=s.length-r,t=s.slice(-e),n=new Set(t.map(e=>e.id));this.setToasts(o.map(e=>{let t=n.has(e.id);return e.limited===t?e:{...e,limited:t}}))}else this.setToasts(o.map(e=>e.limited?{...e,limited:!1}:e));let c=a.timeout??n;return a.type!==`loading`&&c>0&&this.scheduleTimer(i,c,()=>this.closeToast(i)),HS.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),i};updateToast=(e,t)=>{this.updateToastInternal(e,t)};updateToastInternal=(e,t)=>{let{timeout:n,toasts:r}=this.state,i=HS.toast(this.state,e)??null;if(!i||i.transitionStatus===`ending`)return;let a={...i,...t};this.setToasts(r.map(n=>n.id===e?{...n,...t}:n));let o=a.timeout??n,s=i?.timeout??n,c=Object.hasOwn(t,`timeout`),l=a.transitionStatus!==`ending`&&a.type!==`loading`&&o>0,u=this.timers.has(e),d=s!==o,f=i?.type===`loading`;if(!l&&u){this.timers.get(e)?.timeout?.clear(),this.timers.delete(e);return}if(l&&(!u||d||c||f)){let t=this.timers.get(e);t&&(t.timeout?.clear(),this.timers.delete(e)),this.scheduleTimer(e,o,()=>this.closeToast(e)),HS.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}};closeToast=e=>{HS.toast(this.state,e)?.onClose?.();let{limit:t,toasts:n}=this.state,r=0,i=n.map(n=>{if(n.id===e)return{...n,transitionStatus:`ending`,height:0};if(n.transitionStatus===`ending`)return n;let i=r>=t;return r+=1,n.limited===i?n:{...n,limited:i}}),a=this.timers.get(e);a&&a.timeout&&(a.timeout.clear(),this.timers.delete(e)),this.handleFocusManagement(e),this.setToasts(i)};promiseToast=(e,t)=>{let n=DS(t.loading),r=this.addToast({...n,type:`loading`}),i=e.then(e=>{let n=DS(t.success,e);return this.updateToast(r,{...n,type:`success`,timeout:n.timeout}),e}).catch(e=>{let n=DS(t.error,e);return this.updateToast(r,{...n,type:`error`,timeout:n.timeout}),Promise.reject(e)});return{}.hasOwnProperty.call(t,`setPromise`)&&t.setPromise(i),i};pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(e=>{if(e.timeout){e.timeout.clear();let t=Date.now()-e.start,n=e.delay-t;e.remaining=n>0?n:0}}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((e,t)=>{e.remaining=e.remaining>0?e.remaining:e.delay,e.timeout??=SS.create(),e.timeout.start(e.remaining,()=>{this.timers.delete(t),e.callback()}),e.start=Date.now()}))}restoreFocusToPrevElement(){this.state.prevFocusElement?.focus({preventScroll:!0})}handleDocumentPointerDown=e=>{if(e.pointerType!==`touch`)return;let t=zS(e);RS(this.state.viewport,t)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))};scheduleTimer(e,t,n){let r=Date.now(),i=!HS.expandedOrOutOfFocus(this.state),a=i?SS.create():void 0;a?.start(t,()=>{this.timers.delete(e),n()}),this.timers.set(e,{timeout:a,start:i?r:0,delay:t,remaining:t,callback:n})}setToasts(e){let t={toasts:e};e.length===0&&(t.hovering=!1,t.focused=!1),this.update(t)}handleFocusManagement(e){let t=LS(ES(this.state.viewport));if(!this.state.viewport||!RS(this.state.viewport,t)||!BS(t))return;let n=HS.toasts(this.state),r=HS.toastIndex(this.state,e),i=null,a=r+1;for(;a<n.length;){if(n[a].transitionStatus!==`ending`){i=n[a];break}a+=1}if(!i)for(a=r-1;a>=0;){if(n[a].transitionStatus!==`ending`){i=n[a];break}--a}i?i.ref?.current?.focus():this.restoreFocusToPrevElement()}},WS=function(e){let{children:t,timeout:n=5e3,limit:r=3,toastManager:i}=e,a=gv(()=>new US({timeout:n,limit:r,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return Dx(a.disposeEffect),x.useEffect(function(){if(i)return i[` subscribe`](({action:e,options:t})=>{let n=t.id;e===`promise`&&t.promise?a.promiseToast(t.promise,t):e===`update`&&n?a.updateToast(n,t):e===`close`&&n?a.closeToast(n):a.addToast(t)})},[a,n,i]),a.useSyncedValues({timeout:n,limit:r}),(0,J.jsx)(Ox.Provider,{value:a,children:t})},GS=x.forwardRef(function(e,t){let[n,r]=x.useState();Ov(()=>{MS&&r(`button`)},[]);let i={tabIndex:0,role:n};return(0,J.jsx)(`span`,{...e,ref:t,style:Av,"aria-hidden":n?void 0:!0,...i,"data-base-ui-focus-guard":``})}),KS=function(e){return e.frontmostHeight=`--toast-frontmost-height`,e}({}),qS=x.forwardRef(function(e,t){let{render:n,className:r,children:i,...a}=e,o=kx(),s=CS(),c=x.useRef(!1),l=x.useRef(!1),u=o.useState(`isEmpty`),d=o.useState(`toasts`),f=o.useState(`focused`),p=o.useState(`expanded`),m=o.useState(`prevFocusElement`),h=d[0]?.height??0,g=x.useMemo(()=>d.some(e=>e.transitionStatus===`ending`),[d]);x.useEffect(()=>{let e=o.state.viewport;if(!e)return;function t(t){u||t.key===`F6`&&t.target!==e&&(t.preventDefault(),o.setPrevFocusElement(LS(ES(e))),e?.focus({preventScroll:!0}),o.pauseTimers(),o.setFocused(!0))}let n=fy(e);return n.addEventListener(`keydown`,t),()=>{n.removeEventListener(`keydown`,t)}},[o,u]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=fy(e);function n(e){e.target===t&&(o.setIsWindowFocused(!1),o.pauseTimers())}function r(n){if(n.relatedTarget||n.target===t)return;let r=zS(n),i=LS(ES(e));(!RS(e,r)||!BS(i))&&o.resumeTimers(),s.start(0,()=>o.setIsWindowFocused(!0))}return t.addEventListener(`blur`,n,!0),t.addEventListener(`focus`,r,!0),()=>{t.removeEventListener(`blur`,n,!0),t.removeEventListener(`focus`,r,!0)}},[o,s,u]),x.useEffect(()=>{let e=o.state.viewport;if(!e||u)return;let t=ES(e);return t.addEventListener(`pointerdown`,o.handleDocumentPointerDown,!0),()=>{t.removeEventListener(`pointerdown`,o.handleDocumentPointerDown,!0)}},[u,o]);function _(e){let t=o.state.viewport;t&&(c.current=!0,e.relatedTarget===t?d[0]?.ref?.current?.focus():o.restoreFocusToPrevElement())}function v(e){e.key===`Tab`&&e.shiftKey&&e.target===o.state.viewport&&(e.preventDefault(),o.restoreFocusToPrevElement(),o.resumeTimers())}x.useEffect(()=>{!o.state.isWindowFocused||g||!l.current||(o.resumeTimers(),o.setHovering(!1),l.current=!1)},[g,o]);function y(){o.pauseTimers(),o.setHovering(!0),l.current=!1}function b(){g?l.current=!0:(o.resumeTimers(),o.setHovering(!1))}function S(){if(c.current){c.current=!1;return}f||BS(ES(o.state.viewport).activeElement)&&(o.setFocused(!0),o.pauseTimers())}function C(e){!f||RS(o.state.viewport,e.relatedTarget)||(o.setFocused(!1),o.resumeTimers())}let w={tabIndex:-1,role:`region`,"aria-live":`polite`,"aria-atomic":!1,"aria-relevant":`additions text`,"aria-label":`Notifications`,onMouseEnter:y,onMouseMove:y,onMouseLeave:b,onFocus:S,onBlur:C,onKeyDown:v,onClick:S},T={expanded:p},E=ey(`div`,e,{ref:[t,o.setViewport],state:T,props:[w,{style:{[KS.frontmostHeight]:h?`${h}px`:void 0}},a,{children:(0,J.jsxs)(x.Fragment,{children:[!u&&m&&(0,J.jsx)(GS,{onFocus:_}),i,!u&&m&&(0,J.jsx)(GS,{onFocus:_})]})}]}),D=x.useMemo(()=>d.filter(e=>e.priority===`high`),[d]);return(0,J.jsxs)(x.Fragment,{children:[!u&&m&&(0,J.jsx)(GS,{onFocus:_}),E,!f&&D.length>0&&(0,J.jsx)(`div`,{style:Av,children:D.map(e=>(0,J.jsxs)(`div`,{role:`alert`,"aria-atomic":!0,children:[(0,J.jsx)(`div`,{children:e.title}),(0,J.jsx)(`div`,{children:e.description})]},e.id))})]})});function JS(e){return Iv(19)?e:e?`true`:void 0}var YS=x.createContext(void 0);function XS(){let e=x.useContext(YS);if(!e)throw Error(Pv(66));return e}var ZS=function(e){return e.startingStyle=`data-starting-style`,e.endingStyle=`data-ending-style`,e}({}),QS={[ZS.startingStyle]:``},$S={[ZS.endingStyle]:``},eC={transitionStatus(e){return e===`starting`?QS:e===`ending`?$S:null}};function tC(e){return e==null?e:`current`in e?e.current:e}function nC(e,t=!1,n=!0){let r=bS();return yv((i,a=null)=>{r.cancel();function o(){K.flushSync(i)}let s=tC(e);if(s==null)return;let c=s;if(typeof c.getAnimations!=`function`||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{function e(){let e=ZS.startingStyle;if(!c.hasAttribute(e)){r.request(i);return}let t=new MutationObserver(()=>{c.hasAttribute(e)||(t.disconnect(),i())});t.observe(c,{attributes:!0,attributeFilter:[e]}),a?.addEventListener(`abort`,()=>t.disconnect(),{once:!0})}function i(){Promise.all(c.getAnimations().map(e=>e.finished)).then(()=>{a?.aborted||o()}).catch(()=>{let e=c.getAnimations();if(n){if(a?.aborted)return;o()}else e.length>0&&e.some(e=>e.pending||e.playState!==`finished`)&&i()})}if(t){e();return}r.request(i)}})}function rC(e){let{enabled:t=!0,open:n,ref:r,onComplete:i}=e,a=yv(i),o=nC(r,n,!1);x.useEffect(()=>{if(!t)return;let e=new AbortController;return o(a,e.signal),()=>{e.abort()}},[t,n,a,o])}var iC=function(e){return e.index=`--toast-index`,e.offsetY=`--toast-offset-y`,e.height=`--toast-height`,e.swipeMovementX=`--toast-swipe-movement-x`,e.swipeMovementY=`--toast-swipe-movement-y`,e}({}),aC={...eC,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},oC=40,sC=10,cC=.5,lC=1;function uC(e,t,n){switch(e){case`up`:return-n;case`down`:return n;case`left`:return-t;case`right`:return t;default:return 0}}function dC(e){let t=window.getComputedStyle(e).transform,n=0,r=0,i=1;if(t&&t!==`none`){let e=t.match(/matrix(?:3d)?\(([^)]+)\)/);if(e){let t=e[1].split(`, `).map(parseFloat);t.length===6?(n=t[4],r=t[5],i=Math.sqrt(t[0]*t[0]+t[1]*t[1])):t.length===16&&(n=t[12],r=t[13],i=t[0])}}return{x:n,y:r,scale:i}}var fC=x.forwardRef(function(e,t){let{toast:n,render:r,className:i,swipeDirection:a=[`down`,`right`],...o}=e,s=n.positionerProps?.anchor!==void 0,c=[];s||(c=Array.isArray(a)?a:[a]);let l=c.length>0,u=kx(),[d,f]=x.useState(void 0),[p,m]=x.useState(!1),[h,g]=x.useState(!1),[_,v]=x.useState(!1),[y,b]=x.useState({x:0,y:0}),[S,C]=x.useState({x:0,y:0,scale:1}),[w,T]=x.useState(),[E,D]=x.useState(),[O,k]=x.useState(null),A=x.useRef(null),j=x.useRef({x:0,y:0}),M=x.useRef({x:0,y:0,scale:1}),N=x.useRef(void 0),P=x.useRef(0),F=x.useRef(!1),I=x.useRef({x:0,y:0}),L=x.useRef(!1),R=u.useState(`toastIndex`,n.id),z=u.useState(`toastVisibleIndex`,n.id),B=u.useState(`toastOffsetY`,n.id),V=u.useState(`focused`),H=u.useState(`expanded`);rC({open:n.transitionStatus!==`ending`,ref:A,onComplete(){n.transitionStatus===`ending`&&u.removeToast(n.id)}});let U=yv((e=!1)=>{let t=A.current;if(!t)return;let r=t.style.height;t.style.height=`auto`;let i=t.offsetHeight;t.style.height=r;function a(){u.updateToastInternal(n.id,{ref:A,height:i,...n.transitionStatus===`starting`?{transitionStatus:void 0}:{}})}e?K.flushSync(a):a()});Ov(U,[U]);function W(e,t){let n=e,r=t;return!c.includes(`left`)&&!c.includes(`right`)?n=e>0?e**cC:-(Math.abs(e)**cC):(!c.includes(`right`)&&e>0&&(n=e**cC),!c.includes(`left`)&&e<0&&(n=-(Math.abs(e)**cC))),!c.includes(`up`)&&!c.includes(`down`)?r=t>0?t**cC:-(Math.abs(t)**cC):(!c.includes(`down`)&&t>0&&(r=t**cC),!c.includes(`up`)&&t<0&&(r=-(Math.abs(t)**cC))),{x:n,y:r}}function G(e){if(e.button!==0)return;e.pointerType===`touch`&&u.pauseTimers();let t=zS(e.nativeEvent);if(!(t&&t.closest(`button,a,input,textarea,[role="button"],[data-swipe-ignore]`))){if(F.current=!1,N.current=void 0,P.current=0,j.current={x:e.clientX,y:e.clientY},I.current=j.current,A.current){let e=dC(A.current);M.current=e,C(e),b({x:e.x,y:e.y})}u.setHovering(!0),m(!0),g(!1),k(null),L.current=!0,A.current?.setPointerCapture(e.pointerId)}}function ee(e){if(!p)return;e.preventDefault(),L.current&&=(j.current={x:e.clientX,y:e.clientY},!1);let{clientY:t,clientX:n,movementX:r,movementY:i}=e;(i<0&&t>I.current.y||i>0&&t<I.current.y)&&(I.current={x:I.current.x,y:t}),(r<0&&n>I.current.x||r>0&&n<I.current.x)&&(I.current={x:n,y:I.current.y});let a=n-j.current.x,o=t-j.current.y,s=t-I.current.y,l=n-I.current.x;if(!h&&Math.sqrt(a*a+o*o)>=lC&&(g(!0),O===null)){let e=c.includes(`left`)||c.includes(`right`),t=c.includes(`up`)||c.includes(`down`);e&&t&&k(Math.abs(a)>Math.abs(o)?`horizontal`:`vertical`)}let u;if(!N.current)O===`vertical`?o>0?u=`down`:o<0&&(u=`up`):O===`horizontal`?a>0?u=`right`:a<0&&(u=`left`):u=Math.abs(a)>=Math.abs(o)?a>0?`right`:`left`:o>0?`down`:`up`,u&&c.includes(u)&&(N.current=u,P.current=uC(u,a,o),f(u));else{let e=N.current,t=uC(e,l,s);t>oC?(F.current=!1,f(e)):!(c.includes(`left`)&&c.includes(`right`))&&!(c.includes(`up`)&&c.includes(`down`))&&P.current-t>=sC&&(F.current=!0)}let d=W(a,o),m=M.current.x,_=M.current.y;O===`horizontal`?(c.includes(`left`)||c.includes(`right`))&&(m+=d.x):(O===`vertical`||(c.includes(`left`)||c.includes(`right`))&&(m+=d.x),(c.includes(`up`)||c.includes(`down`))&&(_+=d.y)),b({x:m,y:_})}function te(e){if(!p)return;if(m(!1),g(!1),k(null),A.current?.releasePointerCapture(e.pointerId),F.current){b({x:S.x,y:S.y}),f(void 0);return}let t=!1,r=y.x-S.x,i=y.y-S.y,a;for(let e of c){switch(e){case`right`:r>oC&&(t=!0,a=`right`);break;case`left`:r<-oC&&(t=!0,a=`left`);break;case`down`:i>oC&&(t=!0,a=`down`);break;case`up`:i<-oC&&(t=!0,a=`up`);break;default:break}if(t)break}t?(f(a),v(!0),u.closeToast(n.id)):(b({x:S.x,y:S.y}),f(void 0))}function q(e){if(e.key===`Escape`){if(!A.current||!RS(A.current,LS(ES(A.current))))return;u.closeToast(n.id)}}x.useEffect(()=>{if(!l)return;let e=A.current;if(!e)return;function t(t){RS(e,t.target)&&t.preventDefault()}return e.addEventListener(`touchmove`,t,{passive:!1}),()=>{e.removeEventListener(`touchmove`,t)}},[l]);function ne(){if(!p&&y.x===S.x&&y.y===S.y&&!_)return{[iC.swipeMovementX]:`0px`,[iC.swipeMovementY]:`0px`};let e=y.x-S.x,t=y.y-S.y;return{transition:p?`none`:void 0,transform:p?`translateX(${y.x}px) translateY(${y.y}px) scale(${S.scale})`:void 0,[iC.swipeMovementX]:`${e}px`,[iC.swipeMovementY]:`${t}px`}}let re=n.priority===`high`,ie={role:re?`alertdialog`:`dialog`,tabIndex:0,"aria-modal":!1,"aria-labelledby":w,"aria-describedby":E,"aria-hidden":re&&!V?!0:void 0,onPointerDown:l?G:void 0,onPointerMove:l?ee:void 0,onPointerUp:l?te:void 0,onKeyDown:q,inert:JS(n.limited),style:{...ne(),[iC.index]:n.transitionStatus===`ending`?R:z,[iC.offsetY]:`${B}px`,[iC.height]:n.height?`${n.height}px`:void 0}},ae=x.useMemo(()=>({rootRef:A,toast:n,titleId:w,setTitleId:T,descriptionId:E,setDescriptionId:D,swiping:p,swipeDirection:d,recalculateHeight:U,index:R,visibleIndex:z,expanded:H}),[n,w,E,p,d,U,R,z,H]),oe={transitionStatus:n.transitionStatus,expanded:H,limited:n.limited||!1,type:n.type,swiping:ae.swiping,swipeDirection:ae.swipeDirection},se=ey(`div`,e,{ref:[t,ae.rootRef],state:oe,stateAttributesMapping:aC,props:[ie,o]});return(0,J.jsx)(YS.Provider,{value:ae,children:se})}),pC=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setDescriptionId:c}=XS(),l=a??s.description,u=!!l,d=ly(i);Ov(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=ey(`p`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),mC=x.forwardRef(function(e,t){let{render:n,className:r,id:i,children:a,...o}=e,{toast:s,setTitleId:c}=XS(),l=a??s.title,u=!!l,d=ly(i);Ov(()=>{if(u)return c(d),()=>{c(void 0)}},[u,d,c]);let f=ey(`h2`,e,{ref:t,state:{type:s.type},props:{...o,id:d,children:l}});return u?f:null}),hC=x.forwardRef(function(e,t){let{render:n,className:r,disabled:i,nativeButton:a=!0,...o}=e,s=kx(),{toast:c}=XS(),l=s.useState(`expanded`),[u,d]=x.useState(!1),{getButtonProps:f,buttonRef:p}=yy({disabled:i,native:a}),m={type:c.type};return ey(`button`,e,{ref:[t,p],state:m,props:[{"aria-hidden":!l&&!u,onClick(){s.closeToast(c.id)},onFocus(){d(!0)},onBlur(){d(!1)}},o,f]})});function gC(){let e=x.useContext(Ox);if(!e)throw Error(Pv(73));let t=e.useState(`toasts`);return x.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function _C(){let e=new Set;function t(t){e.forEach(e=>e(t))}return{" subscribe":function(t){return e.add(t),()=>{e.delete(t)}},add(e){let n=e.id||TS(`toast`);return t({action:`add`,options:{...e,id:n,transitionStatus:`starting`}}),n},close(e){t({action:`close`,options:{id:e}})},update(e,n){t({action:`update`,options:{...n,id:e}})},promise(e,n){let r=e;return t({action:`promise`,options:{...n,promise:e,setPromise(e){r=e}}}),r}}}var vC=5e3,yC=_C();function bC({toast:e}){return(0,J.jsxs)(fC,{toast:e,className:ux(`relative flex w-80 items-start gap-3 border bg-elevated p-4 shadow-lg`,`data-[swipe=move]:translate-x-[var(--toast-swipe-move-x)]`,`data-[ending-style]:translate-x-[var(--toast-swipe-end-x)]`,`data-[ending-style]:opacity-0`,`data-[starting-style]:translate-y-2 data-[starting-style]:opacity-0`,`transition-all duration-200`,e.type===`error`&&`border-error/50`,e.type===`success`&&`border-approval/50`,(!e.type||e.type===`info`)&&`border-border`),children:[(0,J.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,J.jsx)(mC,{className:ux(`text-sm font-medium`,e.type===`error`&&`text-error`,e.type===`success`&&`text-approval`,(!e.type||e.type===`info`)&&`text-primary`),children:e.title}),e.description&&(0,J.jsx)(pC,{className:`mt-1 text-xs text-muted line-clamp-2`,children:e.description})]}),(0,J.jsx)(hC,{className:`shrink-0 text-muted hover:text-primary transition-colors`,"aria-label":`Close`,children:(0,J.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,J.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,J.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})}function xC(){let{toasts:e}=gC();return(0,J.jsx)(J.Fragment,{children:e.map(e=>(0,J.jsx)(bC,{toast:e},e.id))})}function SC(){return(0,J.jsxs)(WS,{timeout:vC,toastManager:yC,children:[(0,J.jsx)(xC,{}),(0,J.jsx)(qS,{className:`fixed bottom-4 right-4 z-[100] flex flex-col gap-2`})]})}var CC=[`CONNECTING`,`OPEN`,`CLOSING`,`CLOSED`],wC=3e3,TC=8e3,EC=15e3,DC=5e3,OC=2e4,kC=1e4,AC=1500,jC=5e3,MC=750,NC=4,PC=5e3,FC=new class{constructor(){this.ws=null,this.listeners=new Set,this.statusListeners=new Set,this.status=`connecting`,this.error=null,this.reconnectAttempts=0,this.reconnectTimer=null,this.connectTimer=null,this.manualClose=!1,this.lastTick=Date.now(),this.wakeCheckInterval=null,this.lifecycleStarted=!1,this.heartbeatTimer=null,this.pongTimer=null,this.lastForceReconnectTs=0,this.lastConnectTs=0,this.pingSeq=0,this.connectionEpoch=0,this.consecutiveFailures=0,this.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{if(Z(`ws_visibility`,{state:document.visibilityState,...this.wsSnap()},`info`),document.visibilityState===`visible`){let e=Date.now(),t=e-this.lastTick;this.lastTick=e,Z(`ws_resume`,{gapMs:t,...this.wsSnap()},`info`),this.ws?.readyState===WebSocket.OPEN?this.verifyConnection():this.forceReconnect(`visibilitychange`,!0)}else this.stopHeartbeat(),this.cancelVerify(),this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null)},this.onPageShow=e=>{Z(`ws_pageshow`,{persisted:e.persisted,...this.wsSnap()},`info`),e.persisted&&(this.lastTick=Date.now(),this.forceReconnect(`pageshow`,!0))}}wsSnap(){return{status:this.status,ws:this.ws?CC[this.ws.readyState]:null,attempt:this.reconnectAttempts,failures:this.consecutiveFailures,leaked:this.leakedSockets.size,online:typeof navigator<`u`?navigator.onLine:void 0,verifying:this.verifyTimer!==null,buffered:this.ws?this.ws.bufferedAmount:void 0}}connect(){if(this.ws){let e=this.ws.readyState===WebSocket.OPEN;if(e&&this.status===`connected`){Z(`ws_connect_skip`,{reason:`already_open`,...this.wsSnap()});return}let t=Date.now();if(this.ws.readyState===WebSocket.CONNECTING&&t-this.lastConnectTs<200){Z(`ws_connect_skip`,{reason:`already_connecting`,...this.wsSnap()});return}Z(`ws_connect_destroy_zombie`,{reason:e?`open_desynced`:`not_open`,...this.wsSnap()}),this.destroySocket()}this.manualClose=!1,this.clearConnectTimer(),this.setStatus(`connecting`);let e=`${window.location.protocol===`https:`?`wss`:`ws`}://${window.location.host}/ws`;Z(`ws_connect`,{url:e,resume:this.isResumeAttempt,...this.wsSnap()},`info`);let t=new WebSocket(e);this.ws=t,this.lastConnectTs=Date.now(),this.leakedSockets.add(t);let n=this.isResumeAttempt?TC:wC;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{this.ws===t&&(this.connectTimer=null,t.readyState===WebSocket.OPEN&&this.status===`connected`||(Z(`ws_connect_timeout`,{wsState:CC[t.readyState],managerStatus:this.status,timeoutMs:n,...this.wsSnap()},`info`),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect()))},n),t.onopen=()=>{if(this.ws!==t){Z(`ws_onopen_stale`,this.wsSnap(),`info`);return}Z(`ws_onopen`,this.wsSnap(),`info`),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=0,this.connectionEpoch+=1,this.leakedSockets.delete(t),this.setStatus(`connected`),this.startHeartbeat()},t.onmessage=e=>{try{let t=e.data,n=performance.now(),r=JSON.parse(t),i=performance.now()-n,a=r;if(a._parseMs=Math.round(i),a._rawLength=t.length,r.type===`pong`){r.seq===this.pingSeq&&(this.clearPongTimer(),this.verifyTimer!==null&&(this.cancelVerify(),Z(`ws_verify_ok`,this.wsSnap(),`info`),this.startHeartbeat(jC)));return}this.listeners.forEach(e=>e(r))}catch{}},t.onerror=()=>{this.ws===t&&(Z(`ws_onerror`,this.wsSnap(),`info`),this.clearConnectTimer())},t.onclose=e=>{if(this.ws!==t){Z(`ws_onclose_stale`,{code:e.code,...this.wsSnap()},`info`);return}Z(`ws_onclose`,{code:e.code,reason:e.reason,clean:e.wasClean,...this.wsSnap()},`info`),this.clearConnectTimer(),this.cancelVerify(),this.consecutiveFailures+=1,this.ws=null,this.manualClose?this.setStatus(`disconnected`):this.scheduleReconnect()}}disconnect(){this.manualClose=!0,this.clearConnectTimer(),this.cancelVerify(),this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null),this.destroySocket(),this.setStatus(`disconnected`)}startLifecycleListeners(){this.lifecycleStarted||typeof document>`u`||typeof window>`u`||(this.lifecycleStarted=!0,document.addEventListener(`visibilitychange`,this.onVisibilityChange),window.addEventListener(`pageshow`,this.onPageShow),this.lastTick=Date.now(),this.wakeCheckInterval=window.setInterval(()=>{let e=Date.now(),t=e-this.lastTick;this.isHidden()||(t>EC&&(Z(`ws_time_jump`,{gapMs:t,...this.wsSnap()},`info`),this.forceReconnect(`time_jump`,!0)),this.lastTick=e)},DC))}stopLifecycleListeners(){this.lifecycleStarted&&(this.lifecycleStarted=!1,document.removeEventListener(`visibilitychange`,this.onVisibilityChange),window.removeEventListener(`pageshow`,this.onPageShow),this.wakeCheckInterval!==null&&(window.clearInterval(this.wakeCheckInterval),this.wakeCheckInterval=null))}send(e){if(this.ws?.readyState!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(e)),!0}catch(t){return Z(`ws_send_error`,{messageType:e.type,error:t instanceof Error?t.message:String(t),...this.wsSnap()},`info`),this.destroySocket(),this.scheduleReconnect(),!1}}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}subscribeStatus(e){return this.statusListeners.add(e),e(this.status,this.error,this.connectionEpoch),()=>this.statusListeners.delete(e)}getStatus(){return this.status}getConnectionEpoch(){return this.connectionEpoch}verifyConnection(){this.cancelVerify(),this.stopHeartbeat(),this.pingSeq+=1;let e=this.pingSeq,t=this.ws;if(Z(`ws_verify`,{seq:e,...this.wsSnap()},`info`),!this.send({type:`ping`,seq:e})){Z(`ws_verify_send_fail`,this.wsSnap(),`info`),this.forceReconnect(`verify_send_fail`,!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===t&&(Z(`ws_verify_timeout`,this.wsSnap(),`info`),this.forceReconnect(`verify_timeout`,!0))},AC)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(e=`unknown`,t=!1){if(this.manualClose){Z(`ws_force_skip`,{trigger:e,reason:`manual_close`});return}let n=Date.now(),r=t?200:500;if(n-this.lastForceReconnectTs<r){Z(`ws_force_skip`,{trigger:e,reason:`debounce`,force:t});return}if(!t&&this.ws?.readyState===WebSocket.OPEN&&this.status===`connected`){Z(`ws_force_skip`,{trigger:e,reason:`already_connected`});return}this.lastForceReconnectTs=n,Z(`ws_force_reconnect`,{trigger:e,force:t,...this.wsSnap()},`info`),this.reconnectAttempts=0,this.consecutiveFailures=0,this.reconnectTimer&&=(window.clearTimeout(this.reconnectTimer),null),this.destroySocket(),t?(this.purgeLeakedSockets(),this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},MC)):this.connect()}startHeartbeat(e){this.stopHeartbeat();let t=()=>{this.ws?.readyState===WebSocket.OPEN&&(this.pingSeq+=1,this.send({type:`ping`,seq:this.pingSeq})&&(this.clearPongTimer(),this.pongTimer=window.setTimeout(()=>{this.pongTimer=null,Z(`ws_pong_timeout`,this.wsSnap(),`info`),this.destroySocket(),this.scheduleReconnect()},kC)))};e!==void 0&&e<OC?this.heartbeatTimer=window.setTimeout(()=>{t(),this.heartbeatTimer=window.setInterval(t,OC)},e):this.heartbeatTimer=window.setInterval(t,OC)}stopHeartbeat(){this.heartbeatTimer!==null&&(window.clearTimeout(this.heartbeatTimer),this.heartbeatTimer=null),this.clearPongTimer()}clearPongTimer(){this.pongTimer!==null&&(window.clearTimeout(this.pongTimer),this.pongTimer=null)}setStatus(e,t=null){this.status=e,this.error=t,this.statusListeners.forEach(n=>n(e,t,this.connectionEpoch))}scheduleReconnect(){if(this.stopHeartbeat(),this.isHidden()){Z(`ws_schedule_skip`,{reason:`hidden`,...this.wsSnap()}),this.setStatus(`reconnecting`);return}if(this.consecutiveFailures>=NC){Z(`ws_stall_detected`,this.wsSnap(),`info`),this.purgeLeakedSockets(),this.consecutiveFailures=0,this.reconnectAttempts=0,this.isResumeAttempt=!0,this.setStatus(`reconnecting`),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},PC);return}this.reconnectAttempts+=1;let e=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);Z(`ws_schedule_reconnect`,{delay:e,...this.wsSnap()}),this.setStatus(`reconnecting`),this.reconnectTimer&&window.clearTimeout(this.reconnectTimer),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},e)}isHidden(){return typeof document<`u`&&document.visibilityState===`hidden`}clearConnectTimer(){this.connectTimer&&=(window.clearTimeout(this.connectTimer),null)}destroySocket(){if(this.clearConnectTimer(),this.stopHeartbeat(),this.cancelVerify(),!this.ws)return;let e=this.ws;this.ws=null,this.leakedSockets.add(e),e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}purgeLeakedSockets(){if(this.leakedSockets.size!==0){Z(`ws_purge_leaked`,{count:this.leakedSockets.size},`info`);for(let e of this.leakedSockets)try{e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null,e.close()}catch{}this.leakedSockets.clear()}}};function IC(){let e=Um(e=>e.setConnectionState);return(0,x.useEffect)(()=>{FC.connect(),FC.startLifecycleListeners();let t=FC.subscribeStatus((t,n,r)=>{e(t,n,r)});return()=>{t(),FC.stopLifecycleListeners()}},[e]),{sendMessage:(0,x.useMemo)(()=>e=>{FC.send(e)},[]),subscribe:(0,x.useMemo)(()=>FC.subscribe.bind(FC),[]),getConnectionEpoch:(0,x.useMemo)(()=>()=>FC.getConnectionEpoch(),[])}}var LC=100;function RC({viewport:e,win:t,doc:n}){if(!e)return!1;let r=Math.max(0,e.offsetTop||0),i=Math.max(0,e.offsetLeft||0),a=t.innerHeight-(e.height+r),o=Math.max(0,a),s=Math.max(0,e.height||0),c=Math.max(0,e.width||0);return n.documentElement.style.setProperty(`--keyboard-inset`,`${o}px`),n.documentElement.style.setProperty(`--viewport-offset-top`,`${r}px`),n.documentElement.style.setProperty(`--viewport-offset-left`,`${i}px`),n.documentElement.style.setProperty(`--visual-viewport-height`,`${s}px`),n.documentElement.style.setProperty(`--visual-viewport-width`,`${c}px`),o>LC?n.documentElement.classList.add(`keyboard-visible`):n.documentElement.classList.remove(`keyboard-visible`),!0}function zC(e){e.documentElement.style.removeProperty(`--keyboard-inset`),e.documentElement.style.removeProperty(`--viewport-offset-top`),e.documentElement.style.removeProperty(`--viewport-offset-left`),e.documentElement.style.removeProperty(`--visual-viewport-height`),e.documentElement.style.removeProperty(`--visual-viewport-width`),e.documentElement.classList.remove(`keyboard-visible`)}function BC(){(0,x.useEffect)(()=>{let e=window.visualViewport;if(!e)return;let t=null,n=null,r=()=>{let e=document.activeElement;if(!e)return!1;let t=e.tagName?.toLowerCase();return t===`input`||t===`textarea`?!0:!!e.isContentEditable},i=()=>{RC({viewport:e,win:window,doc:document})},a=()=>{if(typeof window.requestAnimationFrame!=`function`){i();return}t!==null&&window.cancelAnimationFrame(t);let e=performance.now(),n=()=>{i(),t=performance.now()-e<1500?window.requestAnimationFrame(n):null};t=window.requestAnimationFrame(n)},o=()=>{if(!r()){c();return}i()},s=()=>{n!==null||typeof window.setInterval!=`function`||(n=window.setInterval(o,250),o())},c=()=>{n===null||typeof window.clearInterval!=`function`||(window.clearInterval(n),n=null)},l=()=>{r()?(a(),s(),i()):c()},u=()=>{l()},d=()=>{l()},f=()=>{a()};return i(),l(),e.addEventListener(`resize`,i),e.addEventListener(`scroll`,i),typeof window.addEventListener==`function`&&(window.addEventListener(`resize`,i),window.addEventListener(`orientationchange`,f)),typeof document.addEventListener==`function`&&(document.addEventListener(`focusin`,u),document.addEventListener(`focusout`,d),document.addEventListener(`focus`,u,!0),document.addEventListener(`blur`,d,!0)),()=>{e.removeEventListener(`resize`,i),e.removeEventListener(`scroll`,i),typeof window.removeEventListener==`function`&&(window.removeEventListener(`resize`,i),window.removeEventListener(`orientationchange`,f)),typeof document.removeEventListener==`function`&&(document.removeEventListener(`focusin`,u),document.removeEventListener(`focusout`,d),document.removeEventListener(`focus`,u,!0),document.removeEventListener(`blur`,d,!0)),t!==null&&typeof window.cancelAnimationFrame==`function`&&window.cancelAnimationFrame(t),c(),zC(document)}},[])}function VC(e,t,n){let r=e;return t.length>0&&(r=r.filter(e=>t.includes(e.projectPath))),n.length>0&&(r=r.filter(e=>n.includes(e.host??``))),r}function HC(){let[e,t]=(0,x.useState)(!1),[n,r]=(0,x.useState)(void 0),[i,a]=(0,x.useState)(void 0),[o,s]=(0,x.useState)(void 0),[c,l]=(0,x.useState)(!1),[u,d]=(0,x.useState)(null),[f,p]=(0,x.useState)(null),[m,h]=(0,x.useState)(null),g=Um(e=>e.sessions),_=Um(e=>e.agentSessions),v=Um(e=>e.agentSessionsEpoch),y=Um(e=>e.selectedSessionId),b=Um(e=>e.selectedHibernatingSessionId),S=Um(e=>e.setSessions),C=Um(e=>e.setAgentSessions),w=Um(e=>e.setActiveAgentSessions),T=Um(e=>e.setHostStatuses),E=Um(e=>e.updateSession),D=Um(e=>e.setSelectedSessionId),O=Um(e=>e.setSelectedHibernatingSessionId),k=Um(e=>e.hasLoaded),A=Um(e=>e.connectionStatus),j=Um(e=>e.connectionError),M=Um(e=>e.clearExitingSession),N=Um(e=>e.markSessionExiting),P=Um(e=>e.setRemoteAllowControl),F=Um(e=>e.setRemoteAllowAttach),I=Um(e=>e.setHostLabel),L=Um(e=>e.hostStatuses),R=Um(e=>e.remoteAllowControl),z=Um(e=>e.hostLabel),B=T_(e=>e.theme),V=ee(),H=G(e=>e.defaultProjectDir),U=G(e=>e.commandPresets),W=G(e=>e.defaultPresetId),te=G(e=>e.lastProjectPath),q=G(e=>e.setLastProjectPath),ne=G(e=>e.addRecentPath),re=G(e=>e.shortcutModifier),ie=G(e=>e.sidebarWidth),ae=G(e=>e.setSidebarWidth),oe=G(e=>e.projectFilters),se=G(e=>e.hostFilters),ce=G(e=>e.soundOnPermission),le=G(e=>e.soundOnIdle),ue=Um(e=>e.connectionEpoch),{sendMessage:de,subscribe:fe,getConnectionEpoch:pe}=IC();BC(),(0,x.useEffect)(()=>{if(typeof document>`u`||!ce&&!le)return;let e=!1,t=()=>{e&&!vx()||(e=!0,bx())};return document.addEventListener(`click`,t,{passive:!0}),document.addEventListener(`keydown`,t,{passive:!0}),document.addEventListener(`touchstart`,t,{passive:!0}),()=>{document.removeEventListener(`click`,t),document.removeEventListener(`keydown`,t),document.removeEventListener(`touchstart`,t)}},[ce,le]);let me=(0,x.useRef)(!1),he=(0,x.useCallback)(e=>{e.preventDefault(),me.current=!0,document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[]);(0,x.useEffect)(()=>{if(typeof document>`u`||typeof document.addEventListener!=`function`)return;let e=e=>{if(!me.current)return;let t=e.clientX;ae(Math.max(180,Math.min(400,t)))},t=()=>{me.current&&(me.current=!1,document.body.style.cursor=``,document.body.style.userSelect=``)};return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,t),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,t)}},[ae]),(0,x.useEffect)(()=>{let e=fe(e=>{if(e.type===`sessions`){let t=Um.getState().sessions,{soundOnPermission:n,soundOnIdle:r}=G.getState();if(n||r)for(let i of e.sessions){let e=t.find(e=>e.id===i.id);e&&e.status!==i.status&&(e.status!==`permission`&&i.status===`permission`&&n&&Cx(),e.status===`working`&&i.status===`waiting`&&r&&wx())}if(je.current.size>0){let e=pe();for(let[t,n]of je.current)n.epoch!==e&&je.current.delete(t)}let i=je.current.size>0?e.sessions.filter(e=>!je.current.has(e.id)):e.sessions,{selectedSessionId:a,selectedHibernatingSessionId:o}=Um.getState(),s=a!==null&&o===null&&!i.some(e=>e.id===a)?t.find(e=>e.id===a)?.agentSessionId?.trim()??null:null;s&&(De.current=s),S(i);let c=Oe.current,{selectedSessionId:l,selectedHibernatingSessionId:u}=Um.getState(),{projectFilters:d,hostFilters:f}=G.getState();if(c&&l===null&&u===null){let e=i.find(e=>!(e.agentSessionId?.trim()!==c||d.length>0&&!d.includes(e.projectPath)||f.length>0&&!f.includes(e.host??``)));e&&(Oe.current=null,D(e.id))}}if(e.type===`host-status`&&T(e.hosts),e.type===`server-config`&&(P(e.remoteAllowControl),F(e.remoteAllowAttach),I(e.hostLabel),e.clientLogLevel&&Ih(e.clientLogLevel)),e.type===`session-update`){let t=Um.getState().sessions.find(t=>t.id===e.session.id)?.status,n=e.session.status;if(E(e.session),t){let{soundOnPermission:e,soundOnIdle:r}=G.getState();t!==`permission`&&n===`permission`&&e&&Cx(),t===`working`&&n===`waiting`&&r&&wx()}}if(e.type===`session-created`){let t=Um.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id),ne(e.session.projectPath);let{projectFilters:n,setProjectFilters:r}=G.getState();n.length>0&&!n.includes(e.session.projectPath)&&r([...n,e.session.projectPath])}if(e.type===`session-removed`){o_(e.sessionId);let t=Um.getState().sessions,n=t.filter(t=>t.id!==e.sessionId);n.length!==t.length&&S(n)}if(e.type===`agent-sessions`){let t=Array.isArray(e.active)?e.active:[],n=Array.isArray(e.hibernating)?e.hibernating:[],r=Array.isArray(e.history)?e.history:[],{selectedHibernatingSessionId:i}=Um.getState(),a=De.current;i&&!n.some(e=>e.sessionId===i)&&(Oe.current=i),C(t,n,r),h(e=>e&&n.some(t=>t.sessionId===e.sessionId)?null:e),a&&n.some(e=>e.sessionId===a)?(De.current=null,O(a)):a&&(De.current=null)}if(e.type===`agent-sessions-active`&&w(Array.isArray(e.active)?e.active:[]),e.type===`session-orphaned`&&!e.supersededBy){let t=Um.getState().sessions,n=t.filter(t=>t.agentSessionId?.trim()!==e.session.sessionId);n.length!==t.length&&S(n)}if(e.type===`session-activated`){let t=Um.getState().sessions.find(t=>t.tmuxWindow===e.window);t&&E({...t,agentSessionId:e.session.sessionId,agentSessionName:e.session.displayName,logFilePath:e.session.logFilePath,isPinned:e.session.isPinned,lastUserMessage:e.session.lastUserMessage??t.lastUserMessage})}if(e.type===`session-wake-result`)if(e.ok&&e.session){h(t=>t?.sessionId===e.sessionId?null:t);let t=Um.getState().sessions;t.some(t=>t.id===e.session.id)||S([e.session,...t]),D(e.session.id)}else e.ok||(d(`${e.error?.code}: ${e.error?.message}`),window.setTimeout(()=>d(null),6e3));if(e.type===`session-hibernate-result`&&(e.ok?(e.session&&h(e.session),O(e.sessionId)):(d(e.error??`Failed to hibernate session`),window.setTimeout(()=>d(null),6e3))),e.type===`terminal-error`&&(!e.sessionId||e.sessionId===y)&&(d(`${e.code}: ${e.message}`),window.setTimeout(()=>d(null),6e3)),e.type===`terminal-ready`&&e.sessionId===y&&d(null),e.type===`error`&&(d(e.message),window.setTimeout(()=>d(null),6e3)),e.type===`kill-failed`){let t=je.current.get(e.sessionId);if(t){let n=Um.getState().sessions;n.some(t=>t.id===e.sessionId)||S([t.session,...n]),t.wasSelected&&D(e.sessionId),je.current.delete(e.sessionId)}M(e.sessionId),d(e.message),window.setTimeout(()=>d(null),6e3)}e.type===`session-move-to-history-result`&&!e.ok&&e.error&&(d(e.error),window.setTimeout(()=>d(null),6e3))});return()=>{e()}},[y,b,ne,M,de,D,O,h,S,C,w,T,P,F,I,fe,E]);let ge=(0,x.useMemo)(()=>g.find(e=>e.id===y)||null,[y,g]),_e=_.hibernating??[],ve=_.history??[],ye=(0,x.useMemo)(()=>VC(_e,oe,se),[_e,oe,se]),be=(0,x.useMemo)(()=>ye.find(e=>e.sessionId===b)||(m?.sessionId===b?m:null),[ye,m,b]);(0,x.useEffect)(()=>{ge?.projectPath&&!ge.remote&&q(ge.projectPath)},[ge?.projectPath,ge?.remote,q]);let xe=G(e=>e.sessionSortMode),Se=G(e=>e.sessionSortDirection),Ce=G(e=>e.manualSessionOrder),we=(0,x.useMemo)(()=>Om(g,{mode:xe,direction:Se,manualOrder:Ce}),[g,xe,Se,Ce]),Te=(0,x.useMemo)(()=>{let e=we;return oe.length>0&&(e=e.filter(e=>oe.includes(e.projectPath))),se.length>0&&(e=e.filter(e=>se.includes(e.host??``))),e},[we,oe,se]),Ee=(0,x.useRef)(b),De=(0,x.useRef)(null),Oe=(0,x.useRef)(null),ke=(0,x.useRef)(ue),Ae=(0,x.useCallback)(()=>Te.length>0?(D(Te[0].id),!0):ye.length>0?(O(ye[0].sessionId),!0):!1,[Te,ye,D,O]);(0,x.useEffect)(()=>{let e=Ee.current;e&&b===null&&!_e.some(t=>t.sessionId===e)?Oe.current=e:b!==null&&(Oe.current=null),Ee.current=b},[_e,b]),(0,x.useEffect)(()=>{m&&b!==m.sessionId&&h(null)},[m,b]),(0,x.useEffect)(()=>{ke.current!==ue&&(ke.current=ue,De.current=null,Oe.current=null,h(null))},[ue]),(0,x.useEffect)(()=>{k&&(b||y&&(Te.some(e=>e.id===y)||Ae()||D(null)))},[k,y,b,Ae,D]),(0,x.useEffect)(()=>{if(!b||m?.sessionId===b||v!==ue||ye.some(e=>e.sessionId===b))return;let e=Te.find(e=>e.agentSessionId?.trim()===b);if(e){D(e.id);return}Ae()||O(null)},[ye,Te,v,m,b,Ae,D,O,ue]),(0,x.useEffect)(()=>{let e=Oe.current;if(!e)return;if(b!==null){Oe.current=null;return}let t=Te.find(t=>t.agentSessionId?.trim()===e);if(t){Oe.current=null,D(t.id);return}if(y!==null){Oe.current=null;return}Ae()&&(Oe.current=null)},[Te,y,b,Ae,D]),(0,x.useEffect)(()=>{window.matchMedia(`(max-width: 767px)`).matches&&k&&y===null&&b===null&&(Te.length>0||ye.length>0)&&Ae()},[ye.length,Te.length,k,Ae,y,b]);let je=(0,x.useRef)(new Map),Me=(0,x.useCallback)((e,t=`unknown`)=>{o_(e);let{sessions:n,selectedSessionId:r}=Um.getState(),i=n.find(t=>t.id===e);i&&je.current.set(e,{session:i,wasSelected:r===e,epoch:pe()}),(0,K.flushSync)(()=>{N(e),S(n.filter(t=>t.id!==e))}),de({type:`session-kill`,sessionId:e,source:t})},[N,S,de]);(0,x.useEffect)(()=>{let n=Ue(re),r=r=>{if(r.defaultPrevented)return;let i=r.code,a=Ke(r,n);if(a&&(i===`BracketLeft`||i===`BracketRight`)){r.preventDefault();let e=i===`BracketLeft`?-1:1,t=Te;if(t.length===0){let t=ye;if(t.length===0)return;let n=t.findIndex(e=>e.sessionId===b);if(n===-1){O(t[0].sessionId);return}O(t[(n+e+t.length)%t.length].sessionId);return}let n=t.findIndex(e=>e.id===y);if(n===-1){D(t[0].id);return}D(t[(n+e+t.length)%t.length].id);return}if(a&&i===`KeyN`){r.preventDefault(),!e&&V&&t(!0);return}if(a&&i===`KeyX`){r.preventDefault(),y&&!e&&Me(y,`keyboard_shortcut`);return}};return window.addEventListener(`keydown`,r),()=>window.removeEventListener(`keydown`,r)},[e,y,b,D,O,Te,ye,Me,re,V]);let Ne=()=>V?(r(void 0),a(void 0),s(void 0),t(!0),!0):!1,Pe=()=>l(!0),Fe=(e,t,n,r)=>{de({type:`session-create`,projectPath:e,name:t,command:n,host:r}),r||q(e)},Ie=e=>{de({type:`session-wake`,sessionId:e})},Le=(0,x.useCallback)(e=>{de({type:`session-hibernate`,sessionId:e})},[de]),Re=(e,t)=>{de({type:`session-rename`,sessionId:e,newName:t})},ze=(0,x.useCallback)(e=>{let t=g.find(t=>t.id===e);t&&de({type:`session-create`,projectPath:t.projectPath,command:t.command||void 0,host:t.remote&&t.host?t.host:void 0})},[g,de]),Be=(0,x.useCallback)(e=>{de({type:`session-move-to-history`,sessionId:e})},[de]);(0,x.useEffect)(()=>{document.documentElement.setAttribute(`data-theme`,B)},[B]),(0,x.useEffect)(()=>{fetch(`/api/server-info`).then(e=>e.json()).then(e=>p(e)).catch(()=>{})},[]);let Ve=(0,x.useMemo)(()=>z?L.filter(e=>e.host!==z):L,[L,z]);return(0,J.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`hidden h-full flex-col md:flex md:shrink-0`,style:{width:ie},children:[(0,J.jsx)(Ye,{connectionStatus:A,onNewSession:Ne,onOpenSettings:Pe,tailscaleIp:f?.tailscaleIp??null}),(0,J.jsx)(jh,{sessions:g,hibernatingSessions:_e,historySessions:ve,selectedSessionId:y,selectedHibernatingSessionId:b,onSelect:D,onSelectHibernating:O,onRename:Re,onResume:Ie,onHibernate:Le,onKill:Me,onDuplicate:ze,onMoveToHistory:Be,onNewSession:Ne,loading:!k,error:j||u})]}),(0,J.jsx)(`div`,{className:`hidden md:block w-1 shrink-0 cursor-col-resize bg-transparent transition-colors hover:bg-white/10 active:bg-white/20`,onMouseDown:he}),(0,J.jsx)(dv,{session:ge,sessions:Te,hibernatingSession:be,hibernatingSessions:_e,connectionStatus:A,connectionEpoch:ue,sendMessage:de,subscribe:fe,onClose:()=>D(null),onSelectSession:D,onSelectHibernatingSession:O,onNewSession:Ne,onKillSession:Me,onRenameSession:Re,onOpenSettings:Pe,onResumeSession:Ie,onHibernateSession:Le,onMoveToHistory:Be,historySessions:ve,loading:!k,error:j||u}),(0,J.jsx)(pv,{isOpen:e,onClose:()=>t(!1),onCreate:Fe,defaultProjectDir:H,commandPresets:U,defaultPresetId:W,lastProjectPath:te,activeProjectPath:ge&&!ge.remote?ge.projectPath:void 0,remoteHosts:Ve,remoteAllowControl:R,initialHost:n,initialPath:i,initialCommand:o}),(0,J.jsx)(Tx,{isOpen:c,onClose:()=>l(!1)}),(0,J.jsx)(SC,{})]})}var UC=`modulepreload`,WC=function(e){return`/`+e},GC={},KC=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}r=o(t.map(t=>{if(t=WC(t,n),t in GC)return;GC[t]=!0;let r=t.endsWith(`.css`),i=r?`[rel="stylesheet"]`:``;if(n)for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}else if(document.querySelector(`link[href="${t}"]${i}`))return;let o=document.createElement(`link`);if(o.rel=r?`stylesheet`:UC,r||(o.as=`script`),o.crossOrigin=``,o.href=t,a&&o.setAttribute(`nonce`,a),document.head.appendChild(o),r)return new Promise((e,n)=>{o.addEventListener(`load`,e),o.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},qC=`true`,JC=`false`,YC=qC===`true`,XC=JC===`true`;function ZC(e={}){let{immediate:t=!1,onNeedRefresh:n,onOfflineReady:r,onRegistered:i,onRegisteredSW:a,onRegisterError:o}=e,s,c,l,u=async(e=!0)=>{await c,YC||l?.()};async function d(){if(`serviceWorker`in navigator){if(s=await KC(async()=>{let{Workbox:e}=await import(`./workbox-window.prod.es5-Bq4GJJid.js`);return{Workbox:e}},[]).then(({Workbox:e})=>new e(`/sw.js`,{scope:`/`,type:`classic`})).catch(e=>{o?.(e)}),!s)return;if(l=()=>{s?.messageSkipWaiting()},!XC)if(YC)s.addEventListener(`activated`,e=>{(e.isUpdate||e.isExternal)&&window.location.reload()}),s.addEventListener(`installed`,e=>{e.isUpdate||r?.()});else{let e=!1,t=()=>{e=!0,s?.addEventListener(`controlling`,e=>{e.isUpdate&&window.location.reload()}),n?.()};s.addEventListener(`installed`,n=>{n.isUpdate===void 0?n.isExternal===void 0?!e&&r?.():n.isExternal?t():!e&&r?.():n.isUpdate||r?.()}),s.addEventListener(`waiting`,t)}s.register({immediate:t}).then(e=>{a?a(`/sw.js`,e):i?.(e)}).catch(e=>{o?.(e)})}}return c=d(),u}Be()&&document.documentElement.classList.add(`ios`),Ve()&&document.documentElement.classList.add(`ios-pwa`),ZC({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},300*1e3),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&t.update()}))}});var QC=document.getElementById(`root`);if(!QC)throw Error(`Root element not found`);(0,E.createRoot)(QC).render((0,J.jsx)(x.StrictMode,{children:(0,J.jsx)(HC,{})}));