@gbasin/agentboard-linux-arm64 0.2.28 → 0.2.30

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.
@@ -49,7 +49,7 @@ Error generating stack: `+a.message+`
49
49
  To pick up a draggable item, press the space bar.
50
50
  While dragging, use the arrow keys to move the item.
51
51
  Press space again to drop the item in its new position, or press escape to cancel.
52
- `},NL={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function jL(e){let{announcements:t=NL,container:r,hiddenTextDescribedById:n,screenReaderInstructions:i=BL}=e;const{announce:a,announcement:l}=PL(),s=aa("DndLiveRegion"),[o,c]=E.useState(!1);if(E.useEffect(()=>{c(!0)},[]),IL(E.useMemo(()=>({onDragStart(u){let{active:p}=u;a(t.onDragStart({active:p}))},onDragMove(u){let{active:p,over:_}=u;t.onDragMove&&a(t.onDragMove({active:p,over:_}))},onDragOver(u){let{active:p,over:_}=u;a(t.onDragOver({active:p,over:_}))},onDragEnd(u){let{active:p,over:_}=u;a(t.onDragEnd({active:p,over:_}))},onDragCancel(u){let{active:p,over:_}=u;a(t.onDragCancel({active:p,over:_}))}}),[a,t])),!o)return null;const f=gt.createElement(gt.Fragment,null,gt.createElement(ML,{id:n,value:i.draggable}),gt.createElement(AL,{id:s,announcement:l}));return r?hn.createPortal(f,r):f}var xt;(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"})(xt||(xt={}));function Vl(){}function FL(e,t){return E.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function HL(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return E.useMemo(()=>[...t].filter(n=>n!=null),[...t])}const jr=Object.freeze({x:0,y:0});function $L(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function zL(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return r-n}function UL(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return n-r}function WL(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function ev(e,t,r){return t===void 0&&(t=e.left),r===void 0&&(r=e.top),{x:t+e.width*.5,y:r+e.height*.5}}const VL=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const i=ev(t,t.left,t.top),a=[];for(const l of n){const{id:s}=l,o=r.get(s);if(o){const c=$L(ev(o),i);a.push({id:s,data:{droppableContainer:l,value:c}})}}return a.sort(zL)};function KL(e,t){const r=Math.max(t.top,e.top),n=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),l=i-n,s=a-r;if(n<i&&r<a){const o=t.width*t.height,c=e.width*e.height,f=l*s,u=f/(o+c-f);return Number(u.toFixed(4))}return 0}const GL=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const i=[];for(const a of n){const{id:l}=a,s=r.get(l);if(s){const o=KL(s,t);o>0&&i.push({id:l,data:{droppableContainer:a,value:o}})}}return i.sort(UL)};function qL(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function V1(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:jr}function XL(e){return function(r){for(var n=arguments.length,i=new Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=arguments[a];return i.reduce((l,s)=>({...l,top:l.top+e*s.y,bottom:l.bottom+e*s.y,left:l.left+e*s.x,right:l.right+e*s.x}),{...r})}}const YL=XL(1);function JL(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function QL(e,t,r){const n=JL(t);if(!n)return e;const{scaleX:i,scaleY:a,x:l,y:s}=n,o=e.left-l-(1-i)*parseFloat(r),c=e.top-s-(1-a)*parseFloat(r.slice(r.indexOf(" ")+1)),f=i?e.width/i:e.width,u=a?e.height/a:e.height;return{width:f,height:u,top:c,right:o+f,bottom:c+u,left:o}}const ZL={ignoreTransform:!1};function Ti(e,t){t===void 0&&(t=ZL);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:f}=lr(e).getComputedStyle(e);c&&(r=QL(r,c,f))}const{top:n,left:i,width:a,height:l,bottom:s,right:o}=r;return{top:n,left:i,width:a,height:l,bottom:s,right:o}}function tv(e){return Ti(e,{ignoreTransform:!0})}function eT(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function tT(e,t){return t===void 0&&(t=lr(e).getComputedStyle(e)),t.position==="fixed"}function rT(e,t){t===void 0&&(t=lr(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=t[i];return typeof a=="string"?r.test(a):!1})}function Zf(e,t){const r=[];function n(i){if(t!=null&&r.length>=t||!i)return r;if(Yf(i)&&i.scrollingElement!=null&&!r.includes(i.scrollingElement))return r.push(i.scrollingElement),r;if(!ia(i)||z1(i)||r.includes(i))return r;const a=lr(e).getComputedStyle(i);return i!==e&&rT(i,a)&&r.push(i),tT(i,a)?r:n(i.parentNode)}return e?n(e):r}function K1(e){const[t]=Zf(e,1);return t??null}function vu(e){return!Sc||!e?null:ki(e)?e:Xf(e)?Yf(e)||e===Li(e).scrollingElement?window:ia(e)?e:null:null}function G1(e){return ki(e)?e.scrollX:e.scrollLeft}function q1(e){return ki(e)?e.scrollY:e.scrollTop}function td(e){return{x:G1(e),y:q1(e)}}var Tt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Tt||(Tt={}));function X1(e){return!Sc||!e?!1:e===document.scrollingElement}function Y1(e){const t={x:0,y:0},r=X1(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},i=e.scrollTop<=t.y,a=e.scrollLeft<=t.x,l=e.scrollTop>=n.y,s=e.scrollLeft>=n.x;return{isTop:i,isLeft:a,isBottom:l,isRight:s,maxScroll:n,minScroll:t}}const nT={x:.2,y:.2};function sT(e,t,r,n,i){let{top:a,left:l,right:s,bottom:o}=r;n===void 0&&(n=10),i===void 0&&(i=nT);const{isTop:c,isBottom:f,isLeft:u,isRight:p}=Y1(e),_={x:0,y:0},y={x:0,y:0},v={height:t.height*i.y,width:t.width*i.x};return!c&&a<=t.top+v.height?(_.y=Tt.Backward,y.y=n*Math.abs((t.top+v.height-a)/v.height)):!f&&o>=t.bottom-v.height&&(_.y=Tt.Forward,y.y=n*Math.abs((t.bottom-v.height-o)/v.height)),!p&&s>=t.right-v.width?(_.x=Tt.Forward,y.x=n*Math.abs((t.right-v.width-s)/v.width)):!u&&l<=t.left+v.width&&(_.x=Tt.Backward,y.x=n*Math.abs((t.left+v.width-l)/v.width)),{direction:_,speed:y}}function iT(e){if(e===document.scrollingElement){const{innerWidth:a,innerHeight:l}=window;return{top:0,left:0,right:a,bottom:l,width:a,height:l}}const{top:t,left:r,right:n,bottom:i}=e.getBoundingClientRect();return{top:t,left:r,right:n,bottom:i,width:e.clientWidth,height:e.clientHeight}}function J1(e){return e.reduce((t,r)=>ai(t,td(r)),jr)}function oT(e){return e.reduce((t,r)=>t+G1(r),0)}function aT(e){return e.reduce((t,r)=>t+q1(r),0)}function lT(e,t){if(t===void 0&&(t=Ti),!e)return;const{top:r,left:n,bottom:i,right:a}=t(e);K1(e)&&(i<=0||a<=0||r>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const cT=[["x",["left","right"],oT],["y",["top","bottom"],aT]];class ep{constructor(t,r){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;const n=Zf(r),i=J1(n);this.rect={...t},this.width=t.width,this.height=t.height;for(const[a,l,s]of cT)for(const o of l)Object.defineProperty(this,o,{get:()=>{const c=s(n),f=i[a]-c;return this.rect[o]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class po{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=t}add(t,r,n){var i;(i=this.target)==null||i.addEventListener(t,r,n),this.listeners.push([t,r,n])}}function uT(e){const{EventTarget:t}=lr(e);return e instanceof t?e:Li(e)}function _u(e,t){const r=Math.abs(e.x),n=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+n**2)>t:"x"in t&&"y"in t?r>t.x&&n>t.y:"x"in t?r>t.x:"y"in t?n>t.y:!1}var vr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(vr||(vr={}));function rv(e){e.preventDefault()}function hT(e){e.stopPropagation()}var Je;(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"})(Je||(Je={}));const Q1={start:[Je.Space,Je.Enter],cancel:[Je.Esc],end:[Je.Space,Je.Enter,Je.Tab]},dT=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case Je.Right:return{...r,x:r.x+25};case Je.Left:return{...r,x:r.x-25};case Je.Down:return{...r,y:r.y+25};case Je.Up:return{...r,y:r.y-25}}};class Z1{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new po(Li(r)),this.windowListeners=new po(lr(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(vr.Resize,this.handleCancel),this.windowListeners.add(vr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(vr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,n=t.node.current;n&&lT(n),r(jr)}handleKeyDown(t){if(Qf(t)){const{active:r,context:n,options:i}=this.props,{keyboardCodes:a=Q1,coordinateGetter:l=dT,scrollBehavior:s="smooth"}=i,{code:o}=t;if(a.end.includes(o)){this.handleEnd(t);return}if(a.cancel.includes(o)){this.handleCancel(t);return}const{collisionRect:c}=n.current,f=c?{x:c.left,y:c.top}:jr;this.referenceCoordinates||(this.referenceCoordinates=f);const u=l(t,{active:r,context:n.current,currentCoordinates:f});if(u){const p=Wl(u,f),_={x:0,y:0},{scrollableAncestors:y}=n.current;for(const v of y){const h=t.code,{isTop:m,isRight:d,isLeft:g,isBottom:w,maxScroll:b,minScroll:x}=Y1(v),C=iT(v),S={x:Math.min(h===Je.Right?C.right-C.width/2:C.right,Math.max(h===Je.Right?C.left:C.left+C.width/2,u.x)),y:Math.min(h===Je.Down?C.bottom-C.height/2:C.bottom,Math.max(h===Je.Down?C.top:C.top+C.height/2,u.y))},k=h===Je.Right&&!d||h===Je.Left&&!g,L=h===Je.Down&&!w||h===Je.Up&&!m;if(k&&S.x!==u.x){const A=v.scrollLeft+p.x,M=h===Je.Right&&A<=b.x||h===Je.Left&&A>=x.x;if(M&&!p.y){v.scrollTo({left:A,behavior:s});return}M?_.x=v.scrollLeft-A:_.x=h===Je.Right?v.scrollLeft-b.x:v.scrollLeft-x.x,_.x&&v.scrollBy({left:-_.x,behavior:s});break}else if(L&&S.y!==u.y){const A=v.scrollTop+p.y,M=h===Je.Down&&A<=b.y||h===Je.Up&&A>=x.y;if(M&&!p.x){v.scrollTo({top:A,behavior:s});return}M?_.y=v.scrollTop-A:_.y=h===Je.Down?v.scrollTop-b.y:v.scrollTop-x.y,_.y&&v.scrollBy({top:-_.y,behavior:s});break}}this.handleMove(t,ai(Wl(u,this.referenceCoordinates),_))}}}handleMove(t,r){const{onMove:n}=this.props;t.preventDefault(),n(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Z1.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:n=Q1,onActivation:i}=t,{active:a}=r;const{code:l}=e.nativeEvent;if(n.start.includes(l)){const s=a.activatorNode.current;return s&&e.target!==s?!1:(e.preventDefault(),i==null||i({event:e.nativeEvent}),!0)}return!1}}];function nv(e){return!!(e&&"distance"in e)}function sv(e){return!!(e&&"delay"in e)}class tp{constructor(t,r,n){var i;n===void 0&&(n=uT(t.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=t,this.events=r;const{event:a}=t,{target:l}=a;this.props=t,this.events=r,this.document=Li(l),this.documentListeners=new po(this.document),this.listeners=new po(n),this.windowListeners=new po(lr(l)),this.initialCoordinates=(i=ed(a))!=null?i:jr,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(){const{events:t,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(vr.Resize,this.handleCancel),this.windowListeners.add(vr.DragStart,rv),this.windowListeners.add(vr.VisibilityChange,this.handleCancel),this.windowListeners.add(vr.ContextMenu,rv),this.documentListeners.add(vr.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(sv(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(nv(r)){this.handlePending(r);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(t,r){const{active:n,onPending:i}=this.props;i(n,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(vr.Click,hT,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(vr.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:n,initialCoordinates:i,props:a}=this,{onMove:l,options:{activationConstraint:s}}=a;if(!i)return;const o=(r=ed(t))!=null?r:jr,c=Wl(i,o);if(!n&&s){if(nv(s)){if(s.tolerance!=null&&_u(c,s.tolerance))return this.handleCancel();if(_u(c,s.distance))return this.handleStart()}if(sv(s)&&_u(c,s.tolerance))return this.handleCancel();this.handlePending(s,c);return}t.cancelable&&t.preventDefault(),l(o)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===Je.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const fT={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class rp extends tp{constructor(t){const{event:r}=t,n=Li(r.target);super(t,fT,n)}}rp.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return!r.isPrimary||r.button!==0?!1:(n==null||n({event:r}),!0)}}];const pT={move:{name:"mousemove"},end:{name:"mouseup"}};var rd;(function(e){e[e.RightClick=2]="RightClick"})(rd||(rd={}));class mT extends tp{constructor(t){super(t,pT,Li(t.event.target))}}mT.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return r.button===rd.RightClick?!1:(n==null||n({event:r}),!0)}}];const yu={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class gT extends tp{constructor(t){super(t,yu)}static setup(){return window.addEventListener(yu.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(yu.move.name,t)};function t(){}}}gT.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;const{touches:i}=r;return i.length>1?!1:(n==null||n({event:r}),!0)}}];var mo;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(mo||(mo={}));var Kl;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Kl||(Kl={}));function vT(e){let{acceleration:t,activator:r=mo.Pointer,canScroll:n,draggingRect:i,enabled:a,interval:l=5,order:s=Kl.TreeOrder,pointerCoordinates:o,scrollableAncestors:c,scrollableAncestorRects:f,delta:u,threshold:p}=e;const _=yT({delta:u,disabled:!a}),[y,v]=kL(),h=E.useRef({x:0,y:0}),m=E.useRef({x:0,y:0}),d=E.useMemo(()=>{switch(r){case mo.Pointer:return o?{top:o.y,bottom:o.y,left:o.x,right:o.x}:null;case mo.DraggableRect:return i}},[r,i,o]),g=E.useRef(null),w=E.useCallback(()=>{const x=g.current;if(!x)return;const C=h.current.x*m.current.x,S=h.current.y*m.current.y;x.scrollBy(C,S)},[]),b=E.useMemo(()=>s===Kl.TreeOrder?[...c].reverse():c,[s,c]);E.useEffect(()=>{if(!a||!c.length||!d){v();return}for(const x of b){if((n==null?void 0:n(x))===!1)continue;const C=c.indexOf(x),S=f[C];if(!S)continue;const{direction:k,speed:L}=sT(x,S,d,t,p);for(const A of["x","y"])_[A][k[A]]||(L[A]=0,k[A]=0);if(L.x>0||L.y>0){v(),g.current=x,y(w,l),h.current=L,m.current=k;return}}h.current={x:0,y:0},m.current={x:0,y:0},v()},[t,w,n,v,a,l,JSON.stringify(d),JSON.stringify(_),y,c,b,f,JSON.stringify(p)])}const _T={x:{[Tt.Backward]:!1,[Tt.Forward]:!1},y:{[Tt.Backward]:!1,[Tt.Forward]:!1}};function yT(e){let{delta:t,disabled:r}=e;const n=Zh(t);return oa(i=>{if(r||!n||!i)return _T;const a={x:Math.sign(t.x-n.x),y:Math.sign(t.y-n.y)};return{x:{[Tt.Backward]:i.x[Tt.Backward]||a.x===-1,[Tt.Forward]:i.x[Tt.Forward]||a.x===1},y:{[Tt.Backward]:i.y[Tt.Backward]||a.y===-1,[Tt.Forward]:i.y[Tt.Forward]||a.y===1}}},[r,t,n])}function wT(e,t){const r=t!=null?e.get(t):void 0,n=r?r.node.current:null;return oa(i=>{var a;return t==null?null:(a=n??i)!=null?a:null},[n,t])}function ST(e,t){return E.useMemo(()=>e.reduce((r,n)=>{const{sensor:i}=n,a=i.activators.map(l=>({eventName:l.eventName,handler:t(l.handler,n)}));return[...r,...a]},[]),[e,t])}var Uo;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Uo||(Uo={}));var nd;(function(e){e.Optimized="optimized"})(nd||(nd={}));const iv=new Map;function xT(e,t){let{dragging:r,dependencies:n,config:i}=t;const[a,l]=E.useState(null),{frequency:s,measure:o,strategy:c}=i,f=E.useRef(e),u=h(),p=$o(u),_=E.useCallback(function(m){m===void 0&&(m=[]),!p.current&&l(d=>d===null?m:d.concat(m.filter(g=>!d.includes(g))))},[p]),y=E.useRef(null),v=oa(m=>{if(u&&!r)return iv;if(!m||m===iv||f.current!==e||a!=null){const d=new Map;for(let g of e){if(!g)continue;if(a&&a.length>0&&!a.includes(g.id)&&g.rect.current){d.set(g.id,g.rect.current);continue}const w=g.node.current,b=w?new ep(o(w),w):null;g.rect.current=b,b&&d.set(g.id,b)}return d}return m},[e,a,r,u,o]);return E.useEffect(()=>{f.current=e},[e]),E.useEffect(()=>{u||_()},[r,u]),E.useEffect(()=>{a&&a.length>0&&l(null)},[JSON.stringify(a)]),E.useEffect(()=>{u||typeof s!="number"||y.current!==null||(y.current=setTimeout(()=>{_(),y.current=null},s))},[s,u,_,...n]),{droppableRects:v,measureDroppableContainers:_,measuringScheduled:a!=null};function h(){switch(c){case Uo.Always:return!1;case Uo.BeforeDragging:return r;default:return!r}}}function ew(e,t){return oa(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function bT(e,t){return ew(e,t)}function CT(e){let{callback:t,disabled:r}=e;const n=Jf(t),i=E.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(n)},[n,r]);return E.useEffect(()=>()=>i==null?void 0:i.disconnect(),[i]),i}function xc(e){let{callback:t,disabled:r}=e;const n=Jf(t),i=E.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(n)},[r]);return E.useEffect(()=>()=>i==null?void 0:i.disconnect(),[i]),i}function ET(e){return new ep(Ti(e),e)}function ov(e,t,r){t===void 0&&(t=ET);const[n,i]=E.useState(null);function a(){i(o=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=o??r)!=null?c:null}const f=t(e);return JSON.stringify(o)===JSON.stringify(f)?o:f})}const l=CT({callback(o){if(e)for(const c of o){const{type:f,target:u}=c;if(f==="childList"&&u instanceof HTMLElement&&u.contains(e)){a();break}}}}),s=xc({callback:a});return Gr(()=>{a(),e?(s==null||s.observe(e),l==null||l.observe(document.body,{childList:!0,subtree:!0})):(s==null||s.disconnect(),l==null||l.disconnect())},[e]),n}function kT(e){const t=ew(e);return V1(e,t)}const av=[];function LT(e){const t=E.useRef(e),r=oa(n=>e?n&&n!==av&&e&&t.current&&e.parentNode===t.current.parentNode?n:Zf(e):av,[e]);return E.useEffect(()=>{t.current=e},[e]),r}function TT(e){const[t,r]=E.useState(null),n=E.useRef(e),i=E.useCallback(a=>{const l=vu(a.target);l&&r(s=>s?(s.set(l,td(l)),new Map(s)):null)},[]);return E.useEffect(()=>{const a=n.current;if(e!==a){l(a);const s=e.map(o=>{const c=vu(o);return c?(c.addEventListener("scroll",i,{passive:!0}),[c,td(c)]):null}).filter(o=>o!=null);r(s.length?new Map(s):null),n.current=e}return()=>{l(e),l(a)};function l(s){s.forEach(o=>{const c=vu(o);c==null||c.removeEventListener("scroll",i)})}},[i,e]),E.useMemo(()=>e.length?t?Array.from(t.values()).reduce((a,l)=>ai(a,l),jr):J1(e):jr,[e,t])}function lv(e,t){t===void 0&&(t=[]);const r=E.useRef(null);return E.useEffect(()=>{r.current=null},t),E.useEffect(()=>{const n=e!==jr;n&&!r.current&&(r.current=e),!n&&r.current&&(r.current=null)},[e]),r.current?Wl(e,r.current):jr}function RT(e){E.useEffect(()=>{if(!Sc)return;const t=e.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of t)r==null||r()}},e.map(t=>{let{sensor:r}=t;return r}))}function DT(e,t){return E.useMemo(()=>e.reduce((r,n)=>{let{eventName:i,handler:a}=n;return r[i]=l=>{a(l,t)},r},{}),[e,t])}function tw(e){return E.useMemo(()=>e?eT(e):null,[e])}const cv=[];function MT(e,t){t===void 0&&(t=Ti);const[r]=e,n=tw(r?lr(r):null),[i,a]=E.useState(cv);function l(){a(()=>e.length?e.map(o=>X1(o)?n:new ep(t(o),o)):cv)}const s=xc({callback:l});return Gr(()=>{s==null||s.disconnect(),l(),e.forEach(o=>s==null?void 0:s.observe(o))},[e]),i}function AT(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return ia(t)?t:e}function PT(e){let{measure:t}=e;const[r,n]=E.useState(null),i=E.useCallback(c=>{for(const{target:f}of c)if(ia(f)){n(u=>{const p=t(f);return u?{...u,width:p.width,height:p.height}:p});break}},[t]),a=xc({callback:i}),l=E.useCallback(c=>{const f=AT(c);a==null||a.disconnect(),f&&(a==null||a.observe(f)),n(f?t(f):null)},[t,a]),[s,o]=Ul(l);return E.useMemo(()=>({nodeRef:s,rect:r,setRef:o}),[r,s,o])}const IT=[{sensor:rp,options:{}},{sensor:Z1,options:{}}],OT={current:{}},ol={draggable:{measure:tv},droppable:{measure:tv,strategy:Uo.WhileDragging,frequency:nd.Optimized},dragOverlay:{measure:Ti}};class go extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,n;return(r=(n=this.get(t))==null?void 0:n.node.current)!=null?r:void 0}}const BT={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new go,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Vl},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ol,measureDroppableContainers:Vl,windowRect:null,measuringScheduled:!1},NT={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Vl,draggableNodes:new Map,over:null,measureDroppableContainers:Vl},bc=E.createContext(NT),rw=E.createContext(BT);function jT(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new go}}}function FT(e,t){switch(t.type){case xt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case xt.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 xt.DragEnd:case xt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case xt.RegisterDroppable:{const{element:r}=t,{id:n}=r,i=new go(e.droppable.containers);return i.set(n,r),{...e,droppable:{...e.droppable,containers:i}}}case xt.SetDroppableDisabled:{const{id:r,key:n,disabled:i}=t,a=e.droppable.containers.get(r);if(!a||n!==a.key)return e;const l=new go(e.droppable.containers);return l.set(r,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:l}}}case xt.UnregisterDroppable:{const{id:r,key:n}=t,i=e.droppable.containers.get(r);if(!i||n!==i.key)return e;const a=new go(e.droppable.containers);return a.delete(r),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function HT(e){let{disabled:t}=e;const{active:r,activatorEvent:n,draggableNodes:i}=E.useContext(bc),a=Zh(n),l=Zh(r==null?void 0:r.id);return E.useEffect(()=>{if(!t&&!n&&a&&l!=null){if(!Qf(a)||document.activeElement===a.target)return;const s=i.get(l);if(!s)return;const{activatorNode:o,node:c}=s;if(!o.current&&!c.current)return;requestAnimationFrame(()=>{for(const f of[o.current,c.current]){if(!f)continue;const u=RL(f);if(u){u.focus();break}}})}},[n,t,i,l,a]),null}function $T(e,t){let{transform:r,...n}=t;return e!=null&&e.length?e.reduce((i,a)=>a({transform:i,...n}),r):r}function zT(e){return E.useMemo(()=>({draggable:{...ol.draggable,...e==null?void 0:e.draggable},droppable:{...ol.droppable,...e==null?void 0:e.droppable},dragOverlay:{...ol.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function UT(e){let{activeNode:t,measure:r,initialRect:n,config:i=!0}=e;const a=E.useRef(!1),{x:l,y:s}=typeof i=="boolean"?{x:i,y:i}:i;Gr(()=>{if(!l&&!s||!t){a.current=!1;return}if(a.current||!n)return;const c=t==null?void 0:t.node.current;if(!c||c.isConnected===!1)return;const f=r(c),u=V1(f,n);if(l||(u.x=0),s||(u.y=0),a.current=!0,Math.abs(u.x)>0||Math.abs(u.y)>0){const p=K1(c);p&&p.scrollBy({top:u.y,left:u.x})}},[t,l,s,n,r])}const nw=E.createContext({...jr,scaleX:1,scaleY:1});var Rn;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Rn||(Rn={}));const WT=E.memo(function(t){var r,n,i,a;let{id:l,accessibility:s,autoScroll:o=!0,children:c,sensors:f=IT,collisionDetection:u=GL,measuring:p,modifiers:_,...y}=t;const v=E.useReducer(FT,void 0,jT),[h,m]=v,[d,g]=OL(),[w,b]=E.useState(Rn.Uninitialized),x=w===Rn.Initialized,{draggable:{active:C,nodes:S,translate:k},droppable:{containers:L}}=h,A=C!=null?S.get(C):null,M=E.useRef({initial:null,translated:null}),D=E.useMemo(()=>{var he;return C!=null?{id:C,data:(he=A==null?void 0:A.data)!=null?he:OT,rect:M}:null},[C,A]),O=E.useRef(null),[z,F]=E.useState(null),[H,I]=E.useState(null),R=$o(y,Object.values(y)),P=aa("DndDescribedBy",l),N=E.useMemo(()=>L.getEnabled(),[L]),j=zT(p),{droppableRects:W,measureDroppableContainers:V,measuringScheduled:Z}=xT(N,{dragging:x,dependencies:[k.x,k.y],config:j.droppable}),Q=wT(S,C),$=E.useMemo(()=>H?ed(H):null,[H]),B=ie(),K=bT(Q,j.draggable.measure);UT({activeNode:C!=null?S.get(C):null,config:B.layoutShiftCompensation,initialRect:K,measure:j.draggable.measure});const U=ov(Q,j.draggable.measure,K),te=ov(Q?Q.parentElement:null),Y=E.useRef({activatorEvent:null,active:null,activeNode:Q,collisionRect:null,collisions:null,droppableRects:W,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:L,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),_e=L.getNodeFor((r=Y.current.over)==null?void 0:r.id),de=PT({measure:j.dragOverlay.measure}),re=(n=de.nodeRef.current)!=null?n:Q,le=x?(i=de.rect)!=null?i:U:null,ne=!!(de.nodeRef.current&&de.rect),fe=kT(ne?null:U),ge=tw(re?lr(re):null),se=LT(x?_e??Q:null),oe=MT(se),ue=$T(_,{transform:{x:k.x-fe.x,y:k.y-fe.y,scaleX:1,scaleY:1},activatorEvent:H,active:D,activeNodeRect:U,containerNodeRect:te,draggingNodeRect:le,over:Y.current.over,overlayNodeRect:de.rect,scrollableAncestors:se,scrollableAncestorRects:oe,windowRect:ge}),ae=$?ai($,k):null,ve=TT(se),Ce=lv(ve),Le=lv(ve,[U]),je=ai(ue,Ce),Fe=le?YL(le,ue):null,Pe=D&&Fe?u({active:D,collisionRect:Fe,droppableRects:W,droppableContainers:N,pointerCoordinates:ae}):null,Oe=WL(Pe,"id"),[Ee,q]=E.useState(null),ee=ne?ue:ai(ue,Le),Ne=qL(ee,(a=Ee==null?void 0:Ee.rect)!=null?a:null,U),Ge=E.useRef(null),Ae=E.useCallback((he,ke)=>{let{sensor:Re,options:$e}=ke;if(O.current==null)return;const Ue=S.get(O.current);if(!Ue)return;const Ie=he.nativeEvent,De=new Re({active:O.current,activeNode:Ue,event:Ie,options:$e,context:Y,onAbort(ze){if(!S.get(ze))return;const{onDragAbort:Me}=R.current,We={id:ze};Me==null||Me(We),d({type:"onDragAbort",event:We})},onPending(ze,Te,Me,We){if(!S.get(ze))return;const{onDragPending:$t}=R.current,_t={id:ze,constraint:Te,initialCoordinates:Me,offset:We};$t==null||$t(_t),d({type:"onDragPending",event:_t})},onStart(ze){const Te=O.current;if(Te==null)return;const Me=S.get(Te);if(!Me)return;const{onDragStart:We}=R.current,Ye={activatorEvent:Ie,active:{id:Te,data:Me.data,rect:M}};hn.unstable_batchedUpdates(()=>{We==null||We(Ye),b(Rn.Initializing),m({type:xt.DragStart,initialCoordinates:ze,active:Te}),d({type:"onDragStart",event:Ye}),F(Ge.current),I(Ie)})},onMove(ze){m({type:xt.DragMove,coordinates:ze})},onEnd:et(xt.DragEnd),onCancel:et(xt.DragCancel)});Ge.current=De;function et(ze){return async function(){const{active:Me,collisions:We,over:Ye,scrollAdjustedTranslate:$t}=Y.current;let _t=null;if(Me&&$t){const{cancelDrop:zt}=R.current;_t={activatorEvent:Ie,active:Me,collisions:We,delta:$t,over:Ye},ze===xt.DragEnd&&typeof zt=="function"&&await Promise.resolve(zt(_t))&&(ze=xt.DragCancel)}O.current=null,hn.unstable_batchedUpdates(()=>{m({type:ze}),b(Rn.Uninitialized),q(null),F(null),I(null),Ge.current=null;const zt=ze===xt.DragEnd?"onDragEnd":"onDragCancel";if(_t){const It=R.current[zt];It==null||It(_t),d({type:zt,event:_t})}})}}},[S]),G=E.useCallback((he,ke)=>(Re,$e)=>{const Ue=Re.nativeEvent,Ie=S.get($e);if(O.current!==null||!Ie||Ue.dndKit||Ue.defaultPrevented)return;const De={active:Ie};he(Re,ke.options,De)===!0&&(Ue.dndKit={capturedBy:ke.sensor},O.current=$e,Ae(Re,ke))},[S,Ae]),me=ST(f,G);RT(f),Gr(()=>{U&&w===Rn.Initializing&&b(Rn.Initialized)},[U,w]),E.useEffect(()=>{const{onDragMove:he}=R.current,{active:ke,activatorEvent:Re,collisions:$e,over:Ue}=Y.current;if(!ke||!Re)return;const Ie={active:ke,activatorEvent:Re,collisions:$e,delta:{x:je.x,y:je.y},over:Ue};hn.unstable_batchedUpdates(()=>{he==null||he(Ie),d({type:"onDragMove",event:Ie})})},[je.x,je.y]),E.useEffect(()=>{const{active:he,activatorEvent:ke,collisions:Re,droppableContainers:$e,scrollAdjustedTranslate:Ue}=Y.current;if(!he||O.current==null||!ke||!Ue)return;const{onDragOver:Ie}=R.current,De=$e.get(Oe),et=De&&De.rect.current?{id:De.id,rect:De.rect.current,data:De.data,disabled:De.disabled}:null,ze={active:he,activatorEvent:ke,collisions:Re,delta:{x:Ue.x,y:Ue.y},over:et};hn.unstable_batchedUpdates(()=>{q(et),Ie==null||Ie(ze),d({type:"onDragOver",event:ze})})},[Oe]),Gr(()=>{Y.current={activatorEvent:H,active:D,activeNode:Q,collisionRect:Fe,collisions:Pe,droppableRects:W,draggableNodes:S,draggingNode:re,draggingNodeRect:le,droppableContainers:L,over:Ee,scrollableAncestors:se,scrollAdjustedTranslate:je},M.current={initial:le,translated:Fe}},[D,Q,Pe,Fe,S,re,le,W,L,Ee,se,je]),vT({...B,delta:k,draggingRect:Fe,pointerCoordinates:ae,scrollableAncestors:se,scrollableAncestorRects:oe});const J=E.useMemo(()=>({active:D,activeNode:Q,activeNodeRect:U,activatorEvent:H,collisions:Pe,containerNodeRect:te,dragOverlay:de,draggableNodes:S,droppableContainers:L,droppableRects:W,over:Ee,measureDroppableContainers:V,scrollableAncestors:se,scrollableAncestorRects:oe,measuringConfiguration:j,measuringScheduled:Z,windowRect:ge}),[D,Q,U,H,Pe,te,de,S,L,W,Ee,V,se,oe,j,Z,ge]),Se=E.useMemo(()=>({activatorEvent:H,activators:me,active:D,activeNodeRect:U,ariaDescribedById:{draggable:P},dispatch:m,draggableNodes:S,over:Ee,measureDroppableContainers:V}),[H,me,D,U,m,P,S,Ee,V]);return gt.createElement(W1.Provider,{value:g},gt.createElement(bc.Provider,{value:Se},gt.createElement(rw.Provider,{value:J},gt.createElement(nw.Provider,{value:Ne},c)),gt.createElement(HT,{disabled:(s==null?void 0:s.restoreFocus)===!1})),gt.createElement(jL,{...s,hiddenTextDescribedById:P}));function ie(){const he=(z==null?void 0:z.autoScrollEnabled)===!1,ke=typeof o=="object"?o.enabled===!1:o===!1,Re=x&&!he&&!ke;return typeof o=="object"?{...o,enabled:Re}:{enabled:Re}}}),VT=E.createContext(null),uv="button",KT="Draggable";function GT(e){let{id:t,data:r,disabled:n=!1,attributes:i}=e;const a=aa(KT),{activators:l,activatorEvent:s,active:o,activeNodeRect:c,ariaDescribedById:f,draggableNodes:u,over:p}=E.useContext(bc),{role:_=uv,roleDescription:y="draggable",tabIndex:v=0}=i??{},h=(o==null?void 0:o.id)===t,m=E.useContext(h?nw:VT),[d,g]=Ul(),[w,b]=Ul(),x=DT(l,t),C=$o(r);Gr(()=>(u.set(t,{id:t,key:a,node:d,activatorNode:w,data:C}),()=>{const k=u.get(t);k&&k.key===a&&u.delete(t)}),[u,t]);const S=E.useMemo(()=>({role:_,tabIndex:v,"aria-disabled":n,"aria-pressed":h&&_===uv?!0:void 0,"aria-roledescription":y,"aria-describedby":f.draggable}),[n,_,v,h,y,f.draggable]);return{active:o,activatorEvent:s,activeNodeRect:c,attributes:S,isDragging:h,listeners:n?void 0:x,node:d,over:p,setNodeRef:g,setActivatorNodeRef:b,transform:m}}function qT(){return E.useContext(rw)}const XT="Droppable",YT={timeout:25};function JT(e){let{data:t,disabled:r=!1,id:n,resizeObserverConfig:i}=e;const a=aa(XT),{active:l,dispatch:s,over:o,measureDroppableContainers:c}=E.useContext(bc),f=E.useRef({disabled:r}),u=E.useRef(!1),p=E.useRef(null),_=E.useRef(null),{disabled:y,updateMeasurementsFor:v,timeout:h}={...YT,...i},m=$o(v??n),d=E.useCallback(()=>{if(!u.current){u.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{c(Array.isArray(m.current)?m.current:[m.current]),_.current=null},h)},[h]),g=xc({callback:d,disabled:y||!l}),w=E.useCallback((S,k)=>{g&&(k&&(g.unobserve(k),u.current=!1),S&&g.observe(S))},[g]),[b,x]=Ul(w),C=$o(t);return E.useEffect(()=>{!g||!b.current||(g.disconnect(),u.current=!1,g.observe(b.current))},[b,g]),E.useEffect(()=>(s({type:xt.RegisterDroppable,element:{id:n,key:a,disabled:r,node:b,rect:p,data:C}}),()=>s({type:xt.UnregisterDroppable,key:a,id:n})),[n]),E.useEffect(()=>{r!==f.current.disabled&&(s({type:xt.SetDroppableDisabled,id:n,key:a,disabled:r}),f.current.disabled=r)},[n,a,r,s]),{active:l,rect:p,isOver:(o==null?void 0:o.id)===n,node:b,over:o,setNodeRef:x}}function sw(e,t,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function QT(e,t){return e.reduce((r,n,i)=>{const a=t.get(n);return a&&(r[i]=a),r},Array(e.length))}function Aa(e){return e!==null&&e>=0}function ZT(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function eR(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const iw=e=>{let{rects:t,activeIndex:r,overIndex:n,index:i}=e;const a=sw(t,n,r),l=t[i],s=a[i];return!s||!l?null:{x:s.left-l.left,y:s.top-l.top,scaleX:s.width/l.width,scaleY:s.height/l.height}},Pa={scaleX:1,scaleY:1},tR=e=>{var t;let{activeIndex:r,activeNodeRect:n,index:i,rects:a,overIndex:l}=e;const s=(t=a[r])!=null?t:n;if(!s)return null;if(i===r){const c=a[l];return c?{x:0,y:r<l?c.top+c.height-(s.top+s.height):c.top-s.top,...Pa}:null}const o=rR(a,i,r);return i>r&&i<=l?{x:0,y:-s.height-o,...Pa}:i<r&&i>=l?{x:0,y:s.height+o,...Pa}:{x:0,y:0,...Pa}};function rR(e,t,r){const n=e[t],i=e[t-1],a=e[t+1];return n?r<t?i?n.top-(i.top+i.height):a?a.top-(n.top+n.height):0:a?a.top-(n.top+n.height):i?n.top-(i.top+i.height):0:0}const ow="Sortable",aw=gt.createContext({activeIndex:-1,containerId:ow,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:iw,disabled:{draggable:!1,droppable:!1}});function nR(e){let{children:t,id:r,items:n,strategy:i=iw,disabled:a=!1}=e;const{active:l,dragOverlay:s,droppableRects:o,over:c,measureDroppableContainers:f}=qT(),u=aa(ow,r),p=s.rect!==null,_=E.useMemo(()=>n.map(x=>typeof x=="object"&&"id"in x?x.id:x),[n]),y=l!=null,v=l?_.indexOf(l.id):-1,h=c?_.indexOf(c.id):-1,m=E.useRef(_),d=!ZT(_,m.current),g=h!==-1&&v===-1||d,w=eR(a);Gr(()=>{d&&y&&f(_)},[d,_,y,f]),E.useEffect(()=>{m.current=_},[_]);const b=E.useMemo(()=>({activeIndex:v,containerId:u,disabled:w,disableTransforms:g,items:_,overIndex:h,useDragOverlay:p,sortedRects:QT(_,o),strategy:i}),[v,u,w.draggable,w.droppable,g,_,h,o,p,i]);return gt.createElement(aw.Provider,{value:b},t)}const sR=e=>{let{id:t,items:r,activeIndex:n,overIndex:i}=e;return sw(r,n,i).indexOf(t)},iR=e=>{let{containerId:t,isSorting:r,wasDragging:n,index:i,items:a,newIndex:l,previousItems:s,previousContainerId:o,transition:c}=e;return!c||!n||s!==a&&i===l?!1:r?!0:l!==i&&t===o},oR={duration:200,easing:"ease"},lw="transform",aR=zo.Transition.toString({property:lw,duration:0,easing:"linear"}),lR={roleDescription:"sortable"};function cR(e){let{disabled:t,index:r,node:n,rect:i}=e;const[a,l]=E.useState(null),s=E.useRef(r);return Gr(()=>{if(!t&&r!==s.current&&n.current){const o=i.current;if(o){const c=Ti(n.current,{ignoreTransform:!0}),f={x:o.left-c.left,y:o.top-c.top,scaleX:o.width/c.width,scaleY:o.height/c.height};(f.x||f.y)&&l(f)}}r!==s.current&&(s.current=r)},[t,r,n,i]),E.useEffect(()=>{a&&l(null)},[a]),a}function uR(e){let{animateLayoutChanges:t=iR,attributes:r,disabled:n,data:i,getNewIndex:a=sR,id:l,strategy:s,resizeObserverConfig:o,transition:c=oR}=e;const{items:f,containerId:u,activeIndex:p,disabled:_,disableTransforms:y,sortedRects:v,overIndex:h,useDragOverlay:m,strategy:d}=E.useContext(aw),g=hR(n,_),w=f.indexOf(l),b=E.useMemo(()=>({sortable:{containerId:u,index:w,items:f},...i}),[u,i,w,f]),x=E.useMemo(()=>f.slice(f.indexOf(l)),[f,l]),{rect:C,node:S,isOver:k,setNodeRef:L}=JT({id:l,data:b,disabled:g.droppable,resizeObserverConfig:{updateMeasurementsFor:x,...o}}),{active:A,activatorEvent:M,activeNodeRect:D,attributes:O,setNodeRef:z,listeners:F,isDragging:H,over:I,setActivatorNodeRef:R,transform:P}=GT({id:l,data:b,attributes:{...lR,...r},disabled:g.draggable}),N=EL(L,z),j=!!A,W=j&&!y&&Aa(p)&&Aa(h),V=!m&&H,Z=V&&W?P:null,$=W?Z??(s??d)({rects:v,activeNodeRect:D,activeIndex:p,overIndex:h,index:w}):null,B=Aa(p)&&Aa(h)?a({id:l,items:f,activeIndex:p,overIndex:h}):w,K=A==null?void 0:A.id,U=E.useRef({activeId:K,items:f,newIndex:B,containerId:u}),te=f!==U.current.items,Y=t({active:A,containerId:u,isDragging:H,isSorting:j,id:l,index:w,items:f,newIndex:U.current.newIndex,previousItems:U.current.items,previousContainerId:U.current.containerId,transition:c,wasDragging:U.current.activeId!=null}),_e=cR({disabled:!Y,index:w,node:S,rect:C});return E.useEffect(()=>{j&&U.current.newIndex!==B&&(U.current.newIndex=B),u!==U.current.containerId&&(U.current.containerId=u),f!==U.current.items&&(U.current.items=f)},[j,B,u,f]),E.useEffect(()=>{if(K===U.current.activeId)return;if(K!=null&&U.current.activeId==null){U.current.activeId=K;return}const re=setTimeout(()=>{U.current.activeId=K},50);return()=>clearTimeout(re)},[K]),{active:A,activeIndex:p,attributes:O,data:b,rect:C,index:w,newIndex:B,items:f,isOver:k,isSorting:j,isDragging:H,listeners:F,node:S,overIndex:h,over:I,setNodeRef:N,setActivatorNodeRef:R,setDroppableNodeRef:L,setDraggableNodeRef:z,transform:_e??$,transition:de()};function de(){if(_e||te&&U.current.newIndex===w)return aR;if(!(V&&!Qf(M)||!c)&&(j||Y))return zo.Transition.toString({...c,property:lw})}}function hR(e,t){var r,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e==null?void 0:e.draggable)!=null?r:t.draggable,droppable:(n=e==null?void 0:e.droppable)!=null?n:t.droppable}}Je.Down,Je.Right,Je.Up,Je.Left;const Ia={permission:0,waiting:1,working:2,unknown:3};function vo(e){var r;const t=(r=e.agentSessionId)==null?void 0:r.trim();return t&&t.length>0?t:e.id}const dR={mode:"created",direction:"desc"};function np(e,t=dR){const{mode:r,direction:n,manualOrder:i}=t;if(r==="manual"&&i&&i.length>0){const a=new Map(i.map((l,s)=>[l,s]));return e.toSorted((l,s)=>{const o=vo(l),c=vo(s),f=a.get(o)??a.get(l.id)??1/0,u=a.get(c)??a.get(s.id)??1/0;return f===1/0&&u===1/0?Date.parse(s.createdAt)-Date.parse(l.createdAt):f-u})}return e.toSorted((a,l)=>{if(r==="status"){const c=Ia[a.status]??Ia.unknown,f=Ia[l.status]??Ia.unknown;return c!==f?c-f:Date.parse(l.lastActivity)-Date.parse(a.lastActivity)}const s=Date.parse(a.createdAt),o=Date.parse(l.createdAt);return n==="desc"?o-s:s-o})}function fR(e,t){var n,i;const r=new Map;for(const a of e){const l=(n=a.projectPath)==null?void 0:n.trim();if(l){const s=Date.parse(a.lastActivity)||0,o=r.get(l)||0;s>o&&r.set(l,s)}}for(const a of t){const l=(i=a.projectPath)==null?void 0:i.trim();if(l){const s=Date.parse(a.lastActivityAt)||0,o=r.get(l)||0;s>o&&r.set(l,s)}}return Array.from(r.keys()).toSorted((a,l)=>{const s=r.get(a)||0;return(r.get(l)||0)-s})}function pR(e,t){var n,i;const r=new Map;for(const a of e){const l=(n=a.host)==null?void 0:n.trim();if(l){const s=Date.parse(a.lastActivity)||0,o=r.get(l)||0;s>o&&r.set(l,s)}}for(const a of t){const l=(i=a.host)==null?void 0:i.trim();if(l){const s=Date.parse(a.lastActivityAt)||0,o=r.get(l)||0;s>o&&r.set(l,s)}}return Array.from(r.keys()).toSorted((a,l)=>{const s=r.get(a)||0;return(r.get(l)||0)-s})}function sp(e){const t=Date.parse(e);if(Number.isNaN(t))return"";const r=Date.now()-t,n=Math.floor(r/6e4);if(n<1)return"now";if(n<60)return`${n}m`;const i=Math.floor(n/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function _s(e){const t=e.trim();if(!t)return null;const r=t.replace(/[\\/]+$/,"");if(!r)return null;const n=r.split(/[\\/]/);return n[n.length-1]||null}function mR(e){const t=e.map(s=>{const o=s.trim(),c=o.replace(/[\\/]+$/,""),f=c.split(/[\\/]/).filter(Boolean);return{path:s,parts:f,fallback:c||o||s}}),r=new Map;for(const s of t)r.set(s.path,1);let n=!0;for(;n;){n=!1;const s=new Map;for(const o of t){if(o.parts.length===0)continue;const c=r.get(o.path)??1,f=o.parts.slice(-c).join("/");s.set(f,(s.get(f)??0)+1)}for(const o of t){if(o.parts.length===0)continue;const c=r.get(o.path)??1,f=o.parts.slice(-c).join("/");(s.get(f)??0)>1&&c<o.parts.length&&(r.set(o.path,c+1),n=!0)}}const i=new Map,a=new Map;for(const s of t){let o=s.fallback;if(s.parts.length>0){const c=r.get(s.path)??1;o=s.parts.slice(-c).join("/")}i.set(s.path,o),a.set(o,(a.get(o)??0)+1)}const l=new Map;for(const s of t){let o=i.get(s.path)??s.fallback;(a.get(o)??0)>1&&(o=s.fallback),l.set(s.path,o)}return l}function cw(e){const t=e.trim();return!t||t.length<=6?t:`${t.slice(0,3)}…${t.slice(-3)}`}function uw(e){var r;const 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{(r=navigator.clipboard)==null||r.writeText(e).catch(()=>{})}document.body.removeChild(t)}function gR({useSafariLayoutFallback:e,isDragging:t,dndTransform:r,generatedTransform:n}){return e&&!t&&!r||!r?n:!n||n==="none"?r:`${r} ${n}`}const vR="agentboard-session",_R=sC();function yR(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 wR(e,t){if(e.length!==t.length)return!1;const r=new Map(e.map(n=>[n.id,n]));for(const n of t){const i=r.get(n.id);if(!i||!yR(i,n))return!1}return!0}const qe=df()(ff((e,t)=>({sessions:[],agentSessions:{active:[],inactive:[]},hostStatuses:[],exitingSessions:new Map,selectedSessionId:null,hasLoaded:!1,connectionStatus:"connecting",connectionError:null,remoteAllowControl:!1,remoteAllowAttach:!1,hostLabel:null,setSessions:r=>{var f;const n=t(),i=n.selectedSessionId,a=n.sessions,l=n.exitingSessions;if(n.hasLoaded&&wR(a,r))return;const s=new Set(r.map(u=>u.id)),o=a.filter(u=>!s.has(u.id)&&!l.has(u.id));let c=i;if(i!==null&&!r.some(u=>u.id===i)){const{sessionSortMode:u,sessionSortDirection:p}=pe.getState();c=((f=np(r,{mode:u,direction:p})[0])==null?void 0:f.id)??null}if(o.length>0){const u=new Map(l);for(const p of o)u.set(p.id,p);e({sessions:r,hasLoaded:!0,selectedSessionId:c,exitingSessions:u})}else e({sessions:r,hasLoaded:!0,selectedSessionId:c})},setAgentSessions:(r,n)=>e({agentSessions:{active:r,inactive:n}}),setHostStatuses:r=>e({hostStatuses:r}),updateSession:r=>e(n=>({sessions:n.sessions.map(i=>i.id===r.id?r:i)})),setSelectedSessionId:r=>e({selectedSessionId:r}),setConnectionStatus:r=>e({connectionStatus:r}),setConnectionError:r=>e({connectionError:r}),setRemoteAllowControl:r=>e({remoteAllowControl:r}),setRemoteAllowAttach:r=>e({remoteAllowAttach:r}),setHostLabel:r=>e({hostLabel:r}),markSessionExiting:r=>{const n=t().sessions.find(i=>i.id===r);if(n){const i=new Map(t().exitingSessions);i.set(r,n),e({exitingSessions:i})}},clearExitingSession:r=>{const n=new Map(t().exitingSessions);n.delete(r),e({exitingSessions:n})}}),{name:vR,storage:gc(()=>_R),partialize:e=>({selectedSessionId:e.selectedSessionId})}));function hv(e,t,r=!1){const[n,i]=E.useState(!1),a=E.useRef(e),l=E.useRef(!1);return E.useEffect(()=>{const o=a.current;if(r?e>o:e!==o){l.current=!0;const f=setTimeout(()=>{l.current&&(i(!0),l.current=!1)},t);return a.current=e,()=>clearTimeout(f)}a.current=e},[e,t,r]),[n,()=>i(!1)]}function SR(e,t,r,n){const i=E.useRef(new Map);E.useEffect(()=>{const a=new Set(e.map(l=>l.id));for(const l of t.keys())if(a.has(l)){const s=i.current.get(l);s&&(clearTimeout(s),i.current.delete(l)),r(l)}else if(!i.current.has(l)){const s=setTimeout(()=>{i.current.delete(l),r(l)},n+100);i.current.set(l,s)}},[e,t,r,n]),E.useEffect(()=>()=>{for(const a of i.current.values())clearTimeout(a);i.current.clear()},[])}function xR({className:e}){return T.jsx("svg",{viewBox:"0 0 92.2 92.2",fill:"currentColor",className:e,"aria-label":"Anthropic",children:T.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 bR({className:e}){return T.jsx("svg",{viewBox:"-1 -1 26 26",fill:"currentColor",className:e,"aria-label":"OpenAI",children:T.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 CR({className:e}){return T.jsx("svg",{viewBox:"0 0 588.42 568.88",fill:"currentColor",className:e,"aria-label":"Pi",children:T.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"})})}const ER=[["claude",xR],["codex",bR],["pi",CR]];function Cc({agentType:e,command:t,className:r=""}){const n=(e||(t==null?void 0:t.split(" ")[0])||"").toLowerCase();for(const[i,a]of ER)if(n.startsWith(i))return T.jsx(a,{className:r});return T.jsx(FC,{className:r})}const kR=360;function LR(e){let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);t=(t<<5)-t+n,t=t&t}return Math.abs(t)}function hw(e){return{"--badge-hue":`${LR(e)%kR}`}}function dw({name:e,fullPath:t,className:r=""}){const n=hw(e);return T.jsx("span",{className:`project-badge inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none ${r}`,style:n,title:t,children:e})}const TR=E.memo(function({session:t,showSessionIdPrefix:r,showProjectName:n,showLastUserMessage:i,onResume:a,onPreview:l,onSetPinned:s}){const o=sp(t.lastActivityAt),c=_s(t.projectPath),f=t.displayName||c||t.sessionId.slice(0,8),u=n&&!!c,p=i&&!!t.lastUserMessage,_=r?cw(t.sessionId):"",y=E.useRef(null),[v,h]=E.useState(null);E.useEffect(()=>{if(!v)return;const d=w=>{y.current&&!y.current.contains(w.target)&&h(null)},g=w=>{w.key==="Escape"&&h(null)};return document.addEventListener("mousedown",d),document.addEventListener("touchstart",d),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("touchstart",d),document.removeEventListener("keydown",g)}},[v]);const m=d=>{d.preventDefault(),d.stopPropagation(),h({x:d.clientX,y:d.clientY})};return T.jsxs("div",{className:"group relative cursor-pointer px-3 py-2 hover:bg-hover",role:"button",tabIndex:0,title:"Click to preview",onClick:()=>l(t),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),l(t))},onContextMenu:m,children:[T.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:"Resume directly",onClick:d=>{d.stopPropagation(),a(t.sessionId)},children:"▶"}),T.jsxs("div",{className:"flex flex-col gap-0.5 pl-2.5 group-hover:pr-4",children:[T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx(Cc,{agentType:t.agentType,className:"h-3.5 w-3.5 shrink-0 text-muted"}),T.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-primary",children:f}),t.lastResumeError&&T.jsx(fC,{className:"h-3 w-3 shrink-0 text-amber-500","aria-label":"Resume failed",title:`Last resume failed: ${t.lastResumeError}`}),t.isPinned&&T.jsx(Ol,{className:"h-3 w-3 shrink-0 text-muted","aria-label":"Pinned",title:"Pinned - will auto-resume on server restart"}),_&&T.jsx("span",{className:"shrink-0 text-[11px] font-mono text-muted",title:t.sessionId,children:_}),T.jsx("span",{className:"ml-1 w-8 shrink-0 text-right text-xs tabular-nums text-muted",children:o})]}),(u||p)&&T.jsxs("div",{className:"flex flex-wrap items-center gap-1 pl-[1.375rem]",children:[u&&T.jsx(dw,{name:c,fullPath:t.projectPath}),p&&T.jsxs("span",{className:"truncate text-xs italic text-muted",children:['"',t.lastUserMessage.length>200?t.lastUserMessage.slice(0,200)+"…":t.lastUserMessage,'"']})]})]}),v&&T.jsxs("div",{ref:y,className:"fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1",style:{left:v.x,top:v.y},role:"menu",children:[s&&T.jsxs("button",{onClick:d=>{d.stopPropagation(),h(null),s(t.sessionId,!t.isPinned)},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:t.isPinned?"Remove from auto-resume list":"Auto-resume on server restart",children:[T.jsx(Ol,{width:14,height:14}),t.isPinned?"Unpin":"Pin"]}),t.logFilePath&&T.jsxs("button",{onClick:d=>{d.stopPropagation(),h(null),t.logFilePath&&uw(t.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:t.logFilePath,children:[T.jsx(iy,{width:14,height:14}),"Copy Log Path"]})]})]})});function RR({name:e,className:t=""}){const r=hw(`host:${e}`);return T.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:r,title:e,children:e})}function DR({hosts:e,selectedHosts:t,onSelect:r,statuses:n=[]}){const[i,a]=E.useState(!1),l=E.useId(),s=E.useRef(null),o=E.useMemo(()=>new Set(t),[t]),c=E.useMemo(()=>new Map(n.map(_=>[_.host,_])),[n]),f=E.useMemo(()=>t.length===0?"All Hosts":t.join(", "),[t]),u=E.useMemo(()=>t.length===0?"All Hosts":t.length===1?t[0]:`${t.length} hosts`,[t]);E.useEffect(()=>{if(!i||typeof document>"u"||!document.addEventListener||!document.removeEventListener)return;const _=v=>{var m;const h=v.target;h&&((m=s.current)!=null&&m.contains(h))||a(!1)},y=v=>{v.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",_),document.addEventListener("touchstart",_,{passive:!0}),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("touchstart",_),document.removeEventListener("keydown",y)}},[i]);const p=_=>{const y=new Set(o);y.has(_)?y.delete(_):y.add(_);const v=e.filter(h=>y.has(h));r(v)};return T.jsxs("div",{ref:s,className:"relative",children:[T.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":i,"aria-controls":l,"aria-label":"Filter by host",onClick:()=>a(_=>!_),className:"flex h-6 max-w-[9rem] items-center gap-1 rounded border border-border bg-base px-2 text-[11px] text-primary hover:bg-hover focus:border-accent focus:outline-none",title:f,children:[T.jsx("span",{className:"truncate",children:u}),T.jsx(pf,{className:"h-3 w-3 shrink-0 text-muted"})]}),i&&T.jsxs("div",{id:l,role:"menu",className:"absolute right-0 z-20 mt-1 w-48 rounded border border-border bg-surface p-2 text-xs shadow-lg",children:[T.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:[T.jsx("input",{type:"checkbox",checked:t.length===0,onChange:()=>r([]),className:"h-3.5 w-3.5 accent-approval"}),T.jsx("span",{children:"All Hosts"})]}),T.jsx("div",{className:"my-2 h-px bg-border"}),e.length===0?T.jsx("div",{className:"px-2 py-1 text-muted",children:"No hosts"}):T.jsx("div",{className:"max-h-48 overflow-y-auto pr-1",children:e.map(_=>{const y=c.get(_),v=y?!y.ok:!1;return T.jsxs("label",{role:"menuitemcheckbox","aria-checked":o.has(_),className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover",title:y!=null&&y.error?`${_}: ${y.error}`:_,children:[T.jsx("input",{type:"checkbox",checked:o.has(_),onChange:()=>p(_),className:"h-3.5 w-3.5 accent-approval"}),T.jsx("span",{className:"truncate",children:_}),v&&T.jsx("span",{className:"ml-auto text-[10px] uppercase text-danger",children:"offline"})]},_)})})]})]})}function MR({projects:e,selectedProjects:t,onSelect:r,hasHiddenPermissions:n}){const[i,a]=E.useState(!1),l=E.useId(),s=E.useRef(null),o=E.useMemo(()=>mR(e),[e]),c=E.useMemo(()=>new Set(t),[t]),f=n&&t.length>0,u=E.useMemo(()=>t.length===0?"All Projects":t.map(y=>o.get(y)??_s(y)??y).join(", "),[o,t]),p=E.useMemo(()=>{if(t.length===0)return"All Projects";if(t.length===1){const y=t[0];return o.get(y)??_s(y)??y}return`${t.length} projects`},[o,t]);E.useEffect(()=>{if(!i||typeof document>"u"||!document.addEventListener||!document.removeEventListener)return;const y=h=>{var d;const m=h.target;m&&((d=s.current)!=null&&d.contains(m))||a(!1)},v=h=>{h.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",y),document.addEventListener("touchstart",y,{passive:!0}),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("touchstart",y),document.removeEventListener("keydown",v)}},[i]);const _=y=>{const v=new Set(c);v.has(y)?v.delete(y):v.add(y);const h=e.filter(m=>v.has(m));r(h)};return T.jsxs("div",{ref:s,className:"relative",children:[T.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":i,"aria-controls":l,"aria-label":"Filter by project",onClick:()=>a(y=>!y),className:"flex h-6 max-w-[11rem] items-center gap-1 rounded border border-border bg-base px-2 text-[11px] text-primary hover:bg-hover focus:border-accent focus:outline-none",title:u,children:[T.jsx("span",{className:"truncate",children:p}),T.jsx(pf,{className:"h-3 w-3 shrink-0 text-muted"})]}),i&&T.jsxs("div",{id:l,role:"menu",className:"absolute right-0 z-20 mt-1 w-60 rounded border border-border bg-surface p-2 text-xs shadow-lg",children:[T.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover",children:[T.jsx("input",{type:"checkbox",checked:t.length===0,onChange:()=>r([]),className:"h-3.5 w-3.5 accent-approval"}),T.jsx("span",{children:"All Projects"})]}),T.jsx("div",{className:"my-2 h-px bg-border"}),e.length===0?T.jsx("div",{className:"px-2 py-1 text-muted",children:"No projects"}):T.jsx("div",{className:"max-h-48 overflow-y-auto pr-1",children:e.map(y=>{const v=o.get(y)??_s(y)??y;return T.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover",title:y,children:[T.jsx("input",{type:"checkbox",checked:c.has(y),onChange:()=>_(y),className:"h-3.5 w-3.5 accent-approval"}),T.jsx("span",{className:"truncate",children:v})]},y)})})]}),f&&T.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:y=>{y.stopPropagation(),r([])},children:T.jsx("span",{className:"sr-only",children:"Clear project filters"})})]})}const Gl=new Set(["tool_result","custom_tool_call_output"]),AR=new Set(["text","input_text","output_text"]);function qr(e){return!e||typeof e!="object"?null:e}function At(e){return typeof e=="string"?e:null}function Wo(e){return e==="user"?"user":e==="assistant"?"assistant":e==="system"||e==="developer"?"system":e==="tool"?"tool":"other"}function PR(e){const t=At(e.type)??"",r=qr(e.payload),n=At(r==null?void 0:r.type)??"",i=At(e.source)??At(r==null?void 0:r.source)??"",a=At(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":n==="user_message"||n==="assistant_message"?"codex":"unknown"}function IR(e){const t=qr(e.payload),r=At(t==null?void 0:t.type);return{family:PR(e),rawType:At(e.type)??"unknown",...r?{payloadType:r}:{}}}function bt(e){if(!e)return[];if(typeof e=="string")return e.trim()?[e]:[];if(Array.isArray(e)){const r=[];for(const n of e){if(typeof n=="string"){n.trim()&&r.push(n);continue}const i=qr(n);if(!i)continue;const a=At(i.type);if(a&&Gl.has(a)||a&&!AR.has(a))continue;const l=At(i.text);l&&l.trim()&&r.push(l)}return r}const t=qr(e);if(t){const r=At(t.type);if(r&&Gl.has(r))return[];const n=At(t.text);return n&&n.trim()?[n]:[...bt(t.content),...bt(t.message)]}return[]}function OR(e,t){if(e.type!=="response_item")return[];const r=qr(e.payload);if(!r||r.type!=="message")return[];const n=Wo(r.role);return bt(r.content).map(i=>({kind:"message",role:n,text:i,source:t}))}function BR(e,t){if(e.type!=="event_msg")return[];const r=qr(e.payload);if(!r)return[];const n=At(r.type);let i=null;if(n==="user_message"?i="user":n==="assistant_message"?i="assistant":n==="system_message"?i="system":n==="message"&&(i=Wo(r.role)),!i||!["user","assistant","system"].includes(i))return[];const a=Array.from(new Set([...bt(r.message),...bt(r.content),...bt(r.text)]));return a.length===0?[]:a.map(l=>({kind:"message",role:i,text:l,source:t}))}function NR(e,t){const r=Wo(e.type),n=qr(e.message);if(n){const a=Wo(n.role??e.type);return[...bt(n.content),...bt(n.text),...bt(n.message)].map(s=>({kind:"message",role:a,text:s,source:t}))}return["user","assistant","system"].includes(r)?[...bt(e.content),...bt(e.text)].map(a=>({kind:"message",role:r,text:a,source:t})):[]}function jR(e,t){const r=Wo(e.role);return["user","assistant","system"].includes(r)?[...bt(e.content),...bt(e.message),...bt(e.text)].map(i=>({kind:"message",role:r,text:i,source:t})):[]}function FR(e,t){const r=At(e.type),n=At(e.event);return r!=="tool_use"&&n!=="tool_use"?[]:[{kind:"tool_call",role:"assistant",text:`[Tool: ${At(e.name)??"tool"}]`,source:t}]}function HR(e,t){if(e.type!=="result")return[];const r=At(e.result);return!r||!r.trim()?[]:[{kind:"result",role:"system",text:r,source:t}]}function $R(e,t){const r=qr(e.payload),n=[...bt(e.message),...bt(e.content),...bt(e.text),...bt(r==null?void 0:r.message),...bt(r==null?void 0:r.content)];return n.length===0?[]:n.map(i=>({kind:"unknown",role:"other",text:i,source:t}))}function zR(e,t){const r=At(e.type),n=qr(e.payload),i=At(n==null?void 0:n.type);return r&&Gl.has(r)||i&&Gl.has(i)?[{kind:"tool_result",role:"tool",text:"",source:t}]:[]}function UR(e){const t=qr(e);if(!t)return[];const r=IR(t),n=[...OR(t,r),...BR(t,r),...NR(t,r),...FR(t,r),...HR(t,r),...zR(t,r)];if(n.length>0)return n;const i=jR(t,r);return i.length>0?i:$R(t,r)}function WR(e){const t=e.trim();if(!t)return null;try{const r=JSON.parse(t);return{parsed:!0,events:UR(r),raw:r}}catch{return{parsed:!1,events:[{kind:"unknown",role:"other",text:t,source:{family:"unknown",rawType:"raw_text"}}],raw:e}}}function VR(e){return e==="user"?"user":e==="assistant"?"assistant":e==="system"?"system":"other"}function KR(e){const t=WR(e);if(!t)return[];const r=t.events.map(n=>({type:VR(n.role),content:n.text.trim(),raw:e})).filter(n=>n.content.length>0);return r.length>0?r:!t.parsed&&e.trim()?[{type:"other",content:e.trim(),raw:e}]:[]}function GR({session:e,onClose:t,onResume:r}){const[n,i]=E.useState(!0),[a,l]=E.useState(null),[s,o]=E.useState(null),[c,f]=E.useState(!1),u=E.useRef(null),p=E.useRef(null);E.useEffect(()=>{(async()=>{try{const m=await fetch(`/api/session-preview/${e.sessionId}`);if(!m.ok){const g=await m.json();throw new Error(g.error||"Failed to load preview")}const d=await m.json();o(d)}catch(m){l(m instanceof Error?m.message:"Failed to load preview")}finally{i(!1)}})()},[e.sessionId]),E.useEffect(()=>{u.current&&s&&(u.current.scrollTop=u.current.scrollHeight)},[s,c]),E.useEffect(()=>{const h=m=>{m.key==="Escape"?(m.stopPropagation(),t()):m.key==="Enter"&&!n&&!a&&(m.preventDefault(),r(e.sessionId))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t,r,e.sessionId,n,a]),E.useEffect(()=>{var h;(h=p.current)==null||h.focus()},[]);const _=e.displayName||_s(e.projectPath)||e.sessionId.slice(0,8),y=sp(e.lastActivityAt),v=(s==null?void 0:s.lines.flatMap(KR).slice(-30))??[];return T.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:h=>{h.target===h.currentTarget&&t()},children:T.jsxs("div",{ref:p,tabIndex:-1,className:"flex max-h-[80vh] w-full max-w-2xl flex-col border border-border bg-elevated",children:[T.jsxs("div",{className:"flex items-center gap-3 border-b border-border px-4 py-3",children:[T.jsx(Cc,{agentType:e.agentType,className:"h-5 w-5 shrink-0 text-muted"}),T.jsxs("div",{className:"min-w-0 flex-1",children:[T.jsx("h2",{id:"preview-title",className:"truncate text-sm font-semibold text-primary",children:_}),T.jsxs("p",{className:"truncate text-xs text-muted",title:e.projectPath,children:[_s(e.projectPath)," · ",y]})]}),T.jsx("button",{type:"button",onClick:()=>f(h=>!h),className:`btn text-xs ${c?"btn-primary":""}`,children:c?"Parsed":"Raw"})]}),T.jsxs("div",{ref:u,className:"flex-1 overflow-y-auto p-4 font-mono text-xs",children:[n&&T.jsx("div",{className:"flex items-center justify-center py-8 text-muted",children:"Loading preview..."}),a&&T.jsx("div",{className:"flex items-center justify-center py-8 text-danger",children:a}),s&&!c&&T.jsx("div",{className:"space-y-2",children:v.length===0?T.jsx("div",{className:"py-8 text-center text-muted",children:"No readable content found. Try raw view."}):v.map((h,m)=>T.jsx("div",{className:`rounded px-2 py-1 ${h.type==="user"?"bg-blue-500/10 text-blue-400":h.type==="assistant"?"bg-emerald-500/10 text-emerald-400":h.type==="system"?"bg-yellow-500/10 text-yellow-400":"text-muted"}`,children:T.jsx("span",{className:"whitespace-pre-wrap break-words",children:h.content.length>500?`${h.content.slice(0,500)}...`:h.content})},m))}),s&&c&&T.jsx("div",{className:"space-y-1",children:s.lines.slice(-50).map((h,m)=>T.jsx("div",{className:"whitespace-pre-wrap break-all text-muted",children:h||" "},m))})]}),T.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3",children:[T.jsx("button",{type:"button",onClick:t,className:"btn",children:"Cancel"}),T.jsx("button",{type:"button",onClick:()=>r(e.sessionId),disabled:n||!!a,className:"btn btn-primary",children:"Resume"})]})]})})}const dv={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 qR(){const[,e]=E.useState(0);E.useEffect(()=>{const t=setInterval(()=>e(r=>r+1),3e4);return()=>clearInterval(t)},[])}function fw({sessions:e,inactiveSessions:t=[],selectedSessionId:r,loading:n,error:i,onSelect:a,onRename:l,onResume:s,onKill:o,onDuplicate:c,onSetPinned:f}){qR();const u=E.useMemo(()=>typeof navigator>"u"?!1:/^((?!chrome|android).)*safari/i.test(navigator.userAgent),[]),[p,_]=E.useState(null),y=pe(G=>G.inactiveSessionsExpanded),v=pe(G=>G.setInactiveSessionsExpanded),[h,m]=E.useState(null),[d,g]=E.useState(20),w=$1(),b=u&&!w;E.useEffect(()=>{y||g(20)},[y]);const x=200,[C,S]=hv(e.length,x),[k,L]=hv(t.length,x,!0),A=E.useRef(new Set(e.map(G=>G.id))),M=E.useRef(new Set(t.map(G=>G.sessionId))),[D,O]=E.useState(new Set);E.useEffect(()=>{var Se;const G=new Set(e.map(ie=>ie.id)),me=new Set(t.map(ie=>ie.sessionId)),J=new Set;for(const ie of G)A.current.has(ie)||J.add(ie);for(const ie of e){const he=(Se=ie.agentSessionId)==null?void 0:Se.trim();he&&M.current.has(he)&&!me.has(he)&&J.add(ie.id)}A.current=G,M.current=me,J.size>0&&O(J)},[e,t]),E.useEffect(()=>{if(D.size===0)return;const G=setTimeout(()=>O(new Set),500);return()=>clearTimeout(G)},[D]);const z=pe(G=>G.shortcutModifier),F=ii(ea(z)),H=pe(G=>G.sessionSortMode),I=pe(G=>G.setSessionSortMode),R=pe(G=>G.sessionSortDirection),P=pe(G=>G.manualSessionOrder),N=pe(G=>G.setManualSessionOrder),j=pe(G=>G.showProjectName),W=pe(G=>G.showLastUserMessage),V=pe(G=>G.showSessionIdPrefix),Z=pe(G=>G.projectFilters),Q=pe(G=>G.setProjectFilters),$=pe(G=>G.hostFilters),B=pe(G=>G.setHostFilters),K=qe(G=>G.exitingSessions),U=qe(G=>G.clearExitingSession),te=qe(G=>G.hostStatuses),Y=qe(G=>G.remoteAllowControl);SR(e,K,U,x),E.useEffect(()=>{if(P.length===0)return;const G=new Set;for(const J of e)G.add(vo(J)),G.add(J.id);for(const J of t)G.add(J.sessionId);const me=P.filter(J=>G.has(J));me.length!==P.length&&N(me)},[e,t,P,N]);const de=E.useMemo(()=>np(e,{mode:H,direction:R,manualOrder:P}),[e,H,R,P]),re=E.useMemo(()=>fR(e,t),[e,t]),le=E.useMemo(()=>{const G=pR(e,t),me=te.map(ie=>ie.host),J=new Set,Se=[];for(const ie of me)!ie||J.has(ie)||(J.add(ie),Se.push(ie));for(const ie of G)!ie||J.has(ie)||(J.add(ie),Se.push(ie));return Se},[e,t,te]),ne=E.useMemo(()=>le.length>1,[le]),fe=E.useMemo(()=>{let G=de;return Z.length>0&&(G=G.filter(me=>Z.includes(me.projectPath))),$.length>0&&(G=G.filter(me=>$.includes(me.host??""))),G},[de,Z,$]),ge=E.useMemo(()=>{const G=Z.length===0?"all-projects":Z.join("|"),me=$.length===0?"all-hosts":$.join("|");return`${G}::${me}`},[Z,$]),se=E.useRef(new Set(fe.map(G=>G.id))),[oe,ue]=E.useState(new Set);E.useEffect(()=>{const G=new Set(fe.map(J=>J.id)),me=new Set;for(const J of G)se.current.has(J)||D.has(J)||me.add(J);se.current=G,me.size>0&&ue(me)},[fe,D]),E.useEffect(()=>{if(oe.size===0)return;const G=setTimeout(()=>ue(new Set),500);return()=>clearTimeout(G)},[oe]);const ae=E.useMemo(()=>{let G=t;return Z.length>0&&(G=G.filter(me=>Z.includes(me.projectPath))),$.length>0&&(G=G.filter(me=>$.includes(me.host??""))),G},[t,Z,$]),ve=E.useMemo(()=>{if(Z.length===0)return 0;const G=new Set(Z);return e.filter(me=>!G.has(me.projectPath)&&me.status==="permission").length},[e,Z]);E.useEffect(()=>{if(Z.length===0||re.length===0)return;const G=new Set(re),me=Z.filter(J=>G.has(J));me.length!==Z.length&&Q(me)},[Z,re,Q]),E.useEffect(()=>{if($.length===0||le.length===0)return;const G=new Set(le),me=$.filter(J=>G.has(J));me.length!==$.length&&B(me)},[$,le,B]);const Ce=HL(FL(rp,{activationConstraint:{distance:8}})),[Le,je]=E.useState(null),[Fe,Pe]=E.useState(null),[Oe,Ee]=E.useState(!1),q=E.useCallback(G=>{je(G.active.id),Ee(!0)},[]),ee=E.useCallback(G=>{var me;Pe((me=G.over)==null?void 0:me.id)},[]),Ne=E.useCallback(G=>{const{active:me,over:J}=G;if(je(null),Pe(null),!J||me.id===J.id){setTimeout(()=>Ee(!1),100);return}const Se=fe.findIndex(De=>De.id===me.id),ie=fe.findIndex(De=>De.id===J.id);if(Se===-1||ie===-1){setTimeout(()=>Ee(!1),100);return}const he=fe.map(De=>vo(De)),[ke]=he.splice(Se,1);he.splice(ie,0,ke);const Re=de.map(De=>vo(De)),$e=new Set(he);let Ue=0;const Ie=Re.map(De=>{if(!$e.has(De))return De;const et=he[Ue];return Ue+=1,et});H!=="manual"&&I("manual"),N(Ie),setTimeout(()=>Ee(!1),100)},[fe,de,H,I,N]),Ge=E.useCallback(()=>{je(null),Pe(null),setTimeout(()=>Ee(!1),100)},[]);E.useEffect(()=>{if(!Le&&!Fe)return;const G=new Set(fe.map(J=>J.id));let me=!1;Le&&!G.has(Le)&&(je(null),me=!0),Fe&&!G.has(Fe)&&(Pe(null),me=!0),me&&Ee(!1)},[fe,Le,Fe]);const Ae=(G,me)=>{l(G,me),_(null)};return T.jsxs("aside",{className:"flex min-h-0 flex-1 flex-col border-r border-border bg-elevated",children:[i&&T.jsx("div",{className:"shrink-0 border-b border-danger/30 bg-danger/10 px-3 py-2 text-xs text-danger",children:i}),T.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[T.jsxs("div",{className:"sticky top-0 z-10 flex h-10 items-center justify-between border-b border-border bg-elevated px-3",children:[T.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted",children:"Sessions"}),T.jsxs("div",{className:"flex items-center gap-4",children:[ne&&T.jsx(DR,{hosts:le,selectedHosts:$,onSelect:B,statuses:te}),T.jsx(MR,{projects:re,selectedProjects:Z,onSelect:Q,hasHiddenPermissions:ve>0}),T.jsx(Qh.span,{className:"w-8 text-right text-xs text-muted",animate:C&&!w?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:S,children:fe.length})]})]}),n?T.jsx("div",{className:"space-y-1 p-2",children:[0,1,2].map(G=>T.jsx("div",{className:"h-14 animate-pulse rounded bg-surface"},G))}):fe.length===0?T.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted",children:"No sessions"}):T.jsx(WT,{sensors:Ce,collisionDetection:VL,onDragStart:q,onDragOver:ee,onDragEnd:Ne,onDragCancel:Ge,children:T.jsx(nR,{items:fe.map(G=>G.id),strategy:tR,children:T.jsx("div",{children:T.jsx(q5,{initial:!1,mode:b?"sync":"popLayout",children:fe.map((G,me)=>{const J=D.has(G.id),Se=oe.has(G.id),ie=G.remote===!0,he=G.source==="managed",ke=!ie||Y&&he,Re=Le?fe.findIndex(De=>De.id===Le):-1,Ue=Fe===G.id&&Le!==G.id?Re>me?"above":"below":null,Ie=J||Se;return T.jsx(pw,{session:G,isNew:Ie,exitDuration:x,prefersReducedMotion:w,useSafariLayoutFallback:b,layoutAnimationsDisabled:Oe,isSelected:G.id===r,isEditing:G.id===p,showSessionIdPrefix:V,showProjectName:j,showLastUserMessage:W,showHostInfo:ne,dropIndicator:Ue,onSelect:()=>a(G.id),onStartEdit:ke?()=>_(G.id):void 0,onCancelEdit:()=>_(null),onRename:De=>Ae(G.id,De),onKill:o&&ke?()=>o(G.id):void 0,onDuplicate:c&&ke?()=>c(G.id):void 0,onSetPinned:f&&G.agentSessionId?De=>f(G.agentSessionId.trim(),De):void 0},G.id)})})},ge)})}),ae.length>0&&T.jsxs("div",{className:"border-t border-border",children:[T.jsxs("button",{type:"button",onClick:()=>v(!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:[T.jsxs("span",{className:"flex items-center gap-2",children:[y?T.jsx(pf,{className:"h-4 w-4"}):T.jsx(gC,{className:"h-4 w-4"}),"Inactive Sessions"]}),T.jsx(Qh.span,{className:"w-8 text-right text-xs",animate:k&&!w?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:L,children:ae.length})]}),y&&T.jsxs("div",{className:"py-1",children:[ae.slice(0,d).map(G=>T.jsx(TR,{session:G,showSessionIdPrefix:V,showProjectName:j,showLastUserMessage:W,onResume:me=>s==null?void 0:s(me),onPreview:m,onSetPinned:f},G.sessionId)),ae.length>d&&T.jsxs("button",{type:"button",onClick:()=>g(G=>G+20),className:"w-full px-3 py-2 text-center text-xs text-muted hover:text-primary hover:bg-hover",children:["Show more (",ae.length-d," remaining)"]})]})]})]}),T.jsx("div",{className:"hidden shrink-0 border-t border-border px-3 py-2 md:block",children:T.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 text-[10px] text-muted",children:[T.jsxs("span",{children:[F,"[ ] nav"]}),T.jsxs("span",{children:[F,"N new"]}),T.jsxs("span",{children:[F,"X kill"]})]})}),h&&T.jsx(GR,{session:h,onClose:()=>m(null),onResume:G=>{m(null),s==null||s(G)}})]})}const pw=E.forwardRef(function({session:t,isNew:r,exitDuration:n,prefersReducedMotion:i,useSafariLayoutFallback:a,layoutAnimationsDisabled:l,isSelected:s,isEditing:o,showSessionIdPrefix:c,showProjectName:f,showLastUserMessage:u,showHostInfo:p,dropIndicator:_,onSelect:y,onStartEdit:v,onCancelEdit:h,onRename:m,onKill:d,onDuplicate:g,onSetPinned:w},b){const{attributes:x,listeners:C,setNodeRef:S,transform:k,transition:L,isDragging:A}=uR({id:t.id,animateLayoutChanges:({isSorting:F,wasDragging:H})=>F||H}),M=zo.Transform.toString(k),O={...!!(i&&M)?{transform:M,transition:L}:{},zIndex:A?10:void 0,opacity:A?.9:void 0},z=E.useCallback(F=>{S(F),typeof b=="function"?b(F):b&&(b.current=F)},[S,b]);return T.jsxs(Qh.div,{ref:z,style:{...O,overflow:"hidden"},className:"relative",layout:!i&&!A&&!l&&!r?!a:!1,transformTemplate:(F,H)=>gR({useSafariLayoutFallback:a,isDragging:A,dndTransform:M,generatedTransform:H}),initial:i||!r?!1:a?{opacity:0}:{opacity:0,scale:.97},animate:i?{opacity:1}:r?a?{opacity:1}:{opacity:1,scale:[1.02,.99,1]}:{opacity:1,scale:1},exit:i?{opacity:0}:a?{opacity:0,height:0}:{opacity:0,height:0,scale:.97},transition:i?{duration:0}:a?{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"}},...x,...C,children:[_==="above"&&T.jsx("div",{className:"absolute -top-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent"}),T.jsx(XR,{session:t,isSelected:s,isEditing:o,showSessionIdPrefix:c,showProjectName:f,showLastUserMessage:u,showHostInfo:p,isDragging:A,onSelect:y,onStartEdit:v,onCancelEdit:h,onRename:m,onKill:d,onDuplicate:g,onSetPinned:w}),_==="below"&&T.jsx("div",{className:"absolute -bottom-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent"})]})});pw.displayName="SortableSessionItem";function XR({session:e,isSelected:t,isEditing:r,showSessionIdPrefix:n,showProjectName:i,showLastUserMessage:a,showHostInfo:l,isDragging:s=!1,onSelect:o,onStartEdit:c,onCancelEdit:f,onRename:u,onKill:p,onDuplicate:_,onSetPinned:y}){var Q,$,B,K;const v=sp(e.lastActivity),h=E.useRef(null),m=E.useRef(null),d=((Q=e.agentSessionName)==null?void 0:Q.trim())||(($=e.name)==null?void 0:$.trim())||e.id,[g,w]=E.useState(d),b=E.useRef(null),[x,C]=E.useState(null),S=_s(e.projectPath),k=(B=e.host)==null?void 0:B.trim(),L=e.status==="permission",A=(K=e.agentSessionId)==null?void 0:K.trim(),M=n&&A?cw(A):"",D=i&&!!S,O=l&&!!k,z=a&&!!e.lastUserMessage,F=E.useRef(e.status),[H,I]=E.useState(!1);E.useEffect(()=>{const U=F.current,te=e.status;U==="working"&&te==="waiting"?I(!0):F.current=te},[e.status]);const R=()=>{I(!1),F.current=e.status};E.useEffect(()=>{r&&h.current&&(h.current.focus(),h.current.select())},[r]),E.useEffect(()=>{w(d)},[d]);const P=()=>{const U=g.trim();U&&U!==d?u(U):f()},N=U=>{U.key==="Enter"?(U.preventDefault(),P()):U.key==="Escape"&&(U.preventDefault(),w(d),f())},j=E.useRef(null),W=U=>{if(s)return;const te=U.touches[0];j.current={x:te.clientX,y:te.clientY},b.current=setTimeout(()=>{j.current&&C(j.current)},500)},V=()=>{b.current&&(clearTimeout(b.current),b.current=null)};E.useEffect(()=>{if(!x)return;const U=Y=>{m.current&&!m.current.contains(Y.target)&&C(null)},te=Y=>{Y.key==="Escape"&&C(null)};return document.addEventListener("mousedown",U),document.addEventListener("touchstart",U),document.addEventListener("keydown",te),()=>{document.removeEventListener("mousedown",U),document.removeEventListener("touchstart",U),document.removeEventListener("keydown",te)}},[x]);const Z=U=>{U.preventDefault(),U.stopPropagation(),C({x:U.clientX,y:U.clientY})};return T.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:o,onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&o()},onContextMenu:Z,onTouchStart:W,onTouchEnd:V,onTouchCancel:V,children:[T.jsxs("div",{className:"flex flex-col gap-0.5 pl-0.5",children:[T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx(Cc,{agentType:e.agentType,command:e.command,className:"h-3.5 w-3.5 shrink-0 text-muted"}),r?T.jsx("input",{ref:h,type:"text",value:g,onChange:U=>w(U.target.value),onBlur:P,onKeyDown:N,onClick:U=>U.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"}):T.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-primary",children:d}),e.isPinned&&T.jsx(Ol,{className:"h-3 w-3 shrink-0 text-primary","aria-label":"Pinned",title:"Pinned - will auto-resume on server restart"}),M&&T.jsx("span",{className:"shrink-0 text-[11px] font-mono text-muted",title:A,children:M}),L?T.jsx("span",{className:`ml-1 flex shrink-0 items-center justify-center rounded-full px-1.5 py-0.5 ${dv[e.status]} pulse-approval`,onAnimationEnd:R,children:T.jsx(LC,{className:"h-3 w-3","aria-label":"Needs input"})}):T.jsx("span",{className:`ml-1 shrink-0 rounded-full px-1.5 py-0.5 text-right text-xs tabular-nums ${dv[e.status]}${H?" pulse-complete":""}`,onAnimationEnd:R,children:v})]}),(D||O||z)&&T.jsxs("div",{className:"flex flex-wrap items-center gap-1 pl-[1.375rem]",children:[O&&T.jsx(RR,{name:k}),D&&T.jsx(dw,{name:S,fullPath:e.projectPath}),z&&T.jsxs("span",{className:"line-clamp-2 text-xs italic text-muted",children:['"',e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+"…":e.lastUserMessage,'"']})]})]}),x&&T.jsxs("div",{ref:m,className:"fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1",style:{left:x.x,top:x.y},role:"menu",children:[c&&T.jsxs("button",{onClick:U=>{U.stopPropagation(),C(null),c()},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:[T.jsx(sy,{width:14,height:14}),"Rename"]}),_&&T.jsxs("button",{onClick:U=>{U.stopPropagation(),C(null),_()},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:[T.jsx(ny,{width:14,height:14}),"Duplicate"]}),y&&T.jsxs("button",{onClick:U=>{U.stopPropagation(),C(null),y(!e.isPinned)},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.isPinned?"Remove from auto-resume list":"Auto-resume on server restart",children:[T.jsx(Ol,{width:14,height:14}),e.isPinned?"Unpin":"Pin"]}),e.logFilePath&&T.jsxs("button",{onClick:U=>{U.stopPropagation(),C(null),e.logFilePath&&uw(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:[T.jsx(iy,{width:14,height:14}),"Copy Log Path"]}),p&&T.jsxs(T.Fragment,{children:[T.jsx("div",{className:"my-1 border-t border-border"}),T.jsxs("button",{onClick:U=>{U.stopPropagation(),C(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:[T.jsx(Dh,{width:14,height:14}),"Kill Session"]})]})]})]})}const sd={debug:0,info:1,warn:2,error:3};let mw="info";function YR(e){const t=e.toLowerCase();t in sd&&(mw=t)}function Ke(e,t,r="debug"){if(!(sd[r]<sd[mw]))try{fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:e,data:t,level:r})}).catch(()=>{})}catch{}}var gw={exports:{}};(function(e,t){(function(r,n){e.exports=n()})(globalThis,()=>(()=>{var r={4567:function(l,s,o){var c=this&&this.__decorate||function(d,g,w,b){var x,C=arguments.length,S=C<3?g:b===null?b=Object.getOwnPropertyDescriptor(g,w):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(d,g,w,b);else for(var k=d.length-1;k>=0;k--)(x=d[k])&&(S=(C<3?x(S):C>3?x(g,w,S):x(g,w))||S);return C>3&&S&&Object.defineProperty(g,w,S),S},f=this&&this.__param||function(d,g){return function(w,b){g(w,b,d)}};Object.defineProperty(s,"__esModule",{value:!0}),s.AccessibilityManager=void 0;const u=o(9042),p=o(9924),_=o(844),y=o(4725),v=o(2585),h=o(3656);let m=s.AccessibilityManager=class extends _.Disposable{constructor(d,g,w,b){super(),this._terminal=d,this._coreBrowserService=w,this._renderService=b,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 x=0;x<this._terminal.rows;x++)this._rowElements[x]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[x]);if(this._topBoundaryFocusListener=x=>this._handleBoundaryFocus(x,0),this._bottomBoundaryFocusListener=x=>this._handleBoundaryFocus(x,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 p.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(x=>this._handleResize(x.rows))),this.register(this._terminal.onRender(x=>this._refreshRows(x.start,x.end))),this.register(this._terminal.onScroll(()=>this._refreshRows())),this.register(this._terminal.onA11yChar(x=>this._handleChar(x))),this.register(this._terminal.onLineFeed(()=>this._handleChar(`
52
+ `},NL={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function jL(e){let{announcements:t=NL,container:r,hiddenTextDescribedById:n,screenReaderInstructions:i=BL}=e;const{announce:a,announcement:l}=PL(),s=aa("DndLiveRegion"),[o,c]=E.useState(!1);if(E.useEffect(()=>{c(!0)},[]),IL(E.useMemo(()=>({onDragStart(u){let{active:p}=u;a(t.onDragStart({active:p}))},onDragMove(u){let{active:p,over:_}=u;t.onDragMove&&a(t.onDragMove({active:p,over:_}))},onDragOver(u){let{active:p,over:_}=u;a(t.onDragOver({active:p,over:_}))},onDragEnd(u){let{active:p,over:_}=u;a(t.onDragEnd({active:p,over:_}))},onDragCancel(u){let{active:p,over:_}=u;a(t.onDragCancel({active:p,over:_}))}}),[a,t])),!o)return null;const f=gt.createElement(gt.Fragment,null,gt.createElement(ML,{id:n,value:i.draggable}),gt.createElement(AL,{id:s,announcement:l}));return r?hn.createPortal(f,r):f}var xt;(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"})(xt||(xt={}));function Vl(){}function FL(e,t){return E.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function HL(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return E.useMemo(()=>[...t].filter(n=>n!=null),[...t])}const jr=Object.freeze({x:0,y:0});function $L(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function zL(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return r-n}function UL(e,t){let{data:{value:r}}=e,{data:{value:n}}=t;return n-r}function WL(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function ev(e,t,r){return t===void 0&&(t=e.left),r===void 0&&(r=e.top),{x:t+e.width*.5,y:r+e.height*.5}}const VL=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const i=ev(t,t.left,t.top),a=[];for(const l of n){const{id:s}=l,o=r.get(s);if(o){const c=$L(ev(o),i);a.push({id:s,data:{droppableContainer:l,value:c}})}}return a.sort(zL)};function KL(e,t){const r=Math.max(t.top,e.top),n=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),l=i-n,s=a-r;if(n<i&&r<a){const o=t.width*t.height,c=e.width*e.height,f=l*s,u=f/(o+c-f);return Number(u.toFixed(4))}return 0}const GL=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:n}=e;const i=[];for(const a of n){const{id:l}=a,s=r.get(l);if(s){const o=KL(s,t);o>0&&i.push({id:l,data:{droppableContainer:a,value:o}})}}return i.sort(UL)};function qL(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function V1(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:jr}function XL(e){return function(r){for(var n=arguments.length,i=new Array(n>1?n-1:0),a=1;a<n;a++)i[a-1]=arguments[a];return i.reduce((l,s)=>({...l,top:l.top+e*s.y,bottom:l.bottom+e*s.y,left:l.left+e*s.x,right:l.right+e*s.x}),{...r})}}const YL=XL(1);function JL(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function QL(e,t,r){const n=JL(t);if(!n)return e;const{scaleX:i,scaleY:a,x:l,y:s}=n,o=e.left-l-(1-i)*parseFloat(r),c=e.top-s-(1-a)*parseFloat(r.slice(r.indexOf(" ")+1)),f=i?e.width/i:e.width,u=a?e.height/a:e.height;return{width:f,height:u,top:c,right:o+f,bottom:c+u,left:o}}const ZL={ignoreTransform:!1};function Ti(e,t){t===void 0&&(t=ZL);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:f}=lr(e).getComputedStyle(e);c&&(r=QL(r,c,f))}const{top:n,left:i,width:a,height:l,bottom:s,right:o}=r;return{top:n,left:i,width:a,height:l,bottom:s,right:o}}function tv(e){return Ti(e,{ignoreTransform:!0})}function eT(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function tT(e,t){return t===void 0&&(t=lr(e).getComputedStyle(e)),t.position==="fixed"}function rT(e,t){t===void 0&&(t=lr(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const a=t[i];return typeof a=="string"?r.test(a):!1})}function Zf(e,t){const r=[];function n(i){if(t!=null&&r.length>=t||!i)return r;if(Yf(i)&&i.scrollingElement!=null&&!r.includes(i.scrollingElement))return r.push(i.scrollingElement),r;if(!ia(i)||z1(i)||r.includes(i))return r;const a=lr(e).getComputedStyle(i);return i!==e&&rT(i,a)&&r.push(i),tT(i,a)?r:n(i.parentNode)}return e?n(e):r}function K1(e){const[t]=Zf(e,1);return t??null}function vu(e){return!Sc||!e?null:ki(e)?e:Xf(e)?Yf(e)||e===Li(e).scrollingElement?window:ia(e)?e:null:null}function G1(e){return ki(e)?e.scrollX:e.scrollLeft}function q1(e){return ki(e)?e.scrollY:e.scrollTop}function td(e){return{x:G1(e),y:q1(e)}}var Tt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Tt||(Tt={}));function X1(e){return!Sc||!e?!1:e===document.scrollingElement}function Y1(e){const t={x:0,y:0},r=X1(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},n={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},i=e.scrollTop<=t.y,a=e.scrollLeft<=t.x,l=e.scrollTop>=n.y,s=e.scrollLeft>=n.x;return{isTop:i,isLeft:a,isBottom:l,isRight:s,maxScroll:n,minScroll:t}}const nT={x:.2,y:.2};function sT(e,t,r,n,i){let{top:a,left:l,right:s,bottom:o}=r;n===void 0&&(n=10),i===void 0&&(i=nT);const{isTop:c,isBottom:f,isLeft:u,isRight:p}=Y1(e),_={x:0,y:0},y={x:0,y:0},v={height:t.height*i.y,width:t.width*i.x};return!c&&a<=t.top+v.height?(_.y=Tt.Backward,y.y=n*Math.abs((t.top+v.height-a)/v.height)):!f&&o>=t.bottom-v.height&&(_.y=Tt.Forward,y.y=n*Math.abs((t.bottom-v.height-o)/v.height)),!p&&s>=t.right-v.width?(_.x=Tt.Forward,y.x=n*Math.abs((t.right-v.width-s)/v.width)):!u&&l<=t.left+v.width&&(_.x=Tt.Backward,y.x=n*Math.abs((t.left+v.width-l)/v.width)),{direction:_,speed:y}}function iT(e){if(e===document.scrollingElement){const{innerWidth:a,innerHeight:l}=window;return{top:0,left:0,right:a,bottom:l,width:a,height:l}}const{top:t,left:r,right:n,bottom:i}=e.getBoundingClientRect();return{top:t,left:r,right:n,bottom:i,width:e.clientWidth,height:e.clientHeight}}function J1(e){return e.reduce((t,r)=>ai(t,td(r)),jr)}function oT(e){return e.reduce((t,r)=>t+G1(r),0)}function aT(e){return e.reduce((t,r)=>t+q1(r),0)}function lT(e,t){if(t===void 0&&(t=Ti),!e)return;const{top:r,left:n,bottom:i,right:a}=t(e);K1(e)&&(i<=0||a<=0||r>=window.innerHeight||n>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const cT=[["x",["left","right"],oT],["y",["top","bottom"],aT]];class ep{constructor(t,r){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;const n=Zf(r),i=J1(n);this.rect={...t},this.width=t.width,this.height=t.height;for(const[a,l,s]of cT)for(const o of l)Object.defineProperty(this,o,{get:()=>{const c=s(n),f=i[a]-c;return this.rect[o]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class po{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var n;return(n=this.target)==null?void 0:n.removeEventListener(...r)})},this.target=t}add(t,r,n){var i;(i=this.target)==null||i.addEventListener(t,r,n),this.listeners.push([t,r,n])}}function uT(e){const{EventTarget:t}=lr(e);return e instanceof t?e:Li(e)}function _u(e,t){const r=Math.abs(e.x),n=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+n**2)>t:"x"in t&&"y"in t?r>t.x&&n>t.y:"x"in t?r>t.x:"y"in t?n>t.y:!1}var vr;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(vr||(vr={}));function rv(e){e.preventDefault()}function hT(e){e.stopPropagation()}var Je;(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"})(Je||(Je={}));const Q1={start:[Je.Space,Je.Enter],cancel:[Je.Esc],end:[Je.Space,Je.Enter,Je.Tab]},dT=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case Je.Right:return{...r,x:r.x+25};case Je.Left:return{...r,x:r.x-25};case Je.Down:return{...r,y:r.y+25};case Je.Up:return{...r,y:r.y-25}}};class Z1{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new po(Li(r)),this.windowListeners=new po(lr(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(vr.Resize,this.handleCancel),this.windowListeners.add(vr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(vr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,n=t.node.current;n&&lT(n),r(jr)}handleKeyDown(t){if(Qf(t)){const{active:r,context:n,options:i}=this.props,{keyboardCodes:a=Q1,coordinateGetter:l=dT,scrollBehavior:s="smooth"}=i,{code:o}=t;if(a.end.includes(o)){this.handleEnd(t);return}if(a.cancel.includes(o)){this.handleCancel(t);return}const{collisionRect:c}=n.current,f=c?{x:c.left,y:c.top}:jr;this.referenceCoordinates||(this.referenceCoordinates=f);const u=l(t,{active:r,context:n.current,currentCoordinates:f});if(u){const p=Wl(u,f),_={x:0,y:0},{scrollableAncestors:y}=n.current;for(const v of y){const h=t.code,{isTop:m,isRight:d,isLeft:g,isBottom:w,maxScroll:b,minScroll:x}=Y1(v),C=iT(v),S={x:Math.min(h===Je.Right?C.right-C.width/2:C.right,Math.max(h===Je.Right?C.left:C.left+C.width/2,u.x)),y:Math.min(h===Je.Down?C.bottom-C.height/2:C.bottom,Math.max(h===Je.Down?C.top:C.top+C.height/2,u.y))},k=h===Je.Right&&!d||h===Je.Left&&!g,L=h===Je.Down&&!w||h===Je.Up&&!m;if(k&&S.x!==u.x){const A=v.scrollLeft+p.x,M=h===Je.Right&&A<=b.x||h===Je.Left&&A>=x.x;if(M&&!p.y){v.scrollTo({left:A,behavior:s});return}M?_.x=v.scrollLeft-A:_.x=h===Je.Right?v.scrollLeft-b.x:v.scrollLeft-x.x,_.x&&v.scrollBy({left:-_.x,behavior:s});break}else if(L&&S.y!==u.y){const A=v.scrollTop+p.y,M=h===Je.Down&&A<=b.y||h===Je.Up&&A>=x.y;if(M&&!p.x){v.scrollTo({top:A,behavior:s});return}M?_.y=v.scrollTop-A:_.y=h===Je.Down?v.scrollTop-b.y:v.scrollTop-x.y,_.y&&v.scrollBy({top:-_.y,behavior:s});break}}this.handleMove(t,ai(Wl(u,this.referenceCoordinates),_))}}}handleMove(t,r){const{onMove:n}=this.props;t.preventDefault(),n(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Z1.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:n=Q1,onActivation:i}=t,{active:a}=r;const{code:l}=e.nativeEvent;if(n.start.includes(l)){const s=a.activatorNode.current;return s&&e.target!==s?!1:(e.preventDefault(),i==null||i({event:e.nativeEvent}),!0)}return!1}}];function nv(e){return!!(e&&"distance"in e)}function sv(e){return!!(e&&"delay"in e)}class tp{constructor(t,r,n){var i;n===void 0&&(n=uT(t.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=t,this.events=r;const{event:a}=t,{target:l}=a;this.props=t,this.events=r,this.document=Li(l),this.documentListeners=new po(this.document),this.listeners=new po(n),this.windowListeners=new po(lr(l)),this.initialCoordinates=(i=ed(a))!=null?i:jr,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(){const{events:t,props:{options:{activationConstraint:r,bypassActivationConstraint:n}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(vr.Resize,this.handleCancel),this.windowListeners.add(vr.DragStart,rv),this.windowListeners.add(vr.VisibilityChange,this.handleCancel),this.windowListeners.add(vr.ContextMenu,rv),this.documentListeners.add(vr.Keydown,this.handleKeydown),r){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(sv(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(nv(r)){this.handlePending(r);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(t,r){const{active:n,onPending:i}=this.props;i(n,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(vr.Click,hT,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(vr.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:n,initialCoordinates:i,props:a}=this,{onMove:l,options:{activationConstraint:s}}=a;if(!i)return;const o=(r=ed(t))!=null?r:jr,c=Wl(i,o);if(!n&&s){if(nv(s)){if(s.tolerance!=null&&_u(c,s.tolerance))return this.handleCancel();if(_u(c,s.distance))return this.handleStart()}if(sv(s)&&_u(c,s.tolerance))return this.handleCancel();this.handlePending(s,c);return}t.cancelable&&t.preventDefault(),l(o)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===Je.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const fT={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class rp extends tp{constructor(t){const{event:r}=t,n=Li(r.target);super(t,fT,n)}}rp.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return!r.isPrimary||r.button!==0?!1:(n==null||n({event:r}),!0)}}];const pT={move:{name:"mousemove"},end:{name:"mouseup"}};var rd;(function(e){e[e.RightClick=2]="RightClick"})(rd||(rd={}));class mT extends tp{constructor(t){super(t,pT,Li(t.event.target))}}mT.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;return r.button===rd.RightClick?!1:(n==null||n({event:r}),!0)}}];const yu={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class gT extends tp{constructor(t){super(t,yu)}static setup(){return window.addEventListener(yu.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(yu.move.name,t)};function t(){}}}gT.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:n}=t;const{touches:i}=r;return i.length>1?!1:(n==null||n({event:r}),!0)}}];var mo;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(mo||(mo={}));var Kl;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Kl||(Kl={}));function vT(e){let{acceleration:t,activator:r=mo.Pointer,canScroll:n,draggingRect:i,enabled:a,interval:l=5,order:s=Kl.TreeOrder,pointerCoordinates:o,scrollableAncestors:c,scrollableAncestorRects:f,delta:u,threshold:p}=e;const _=yT({delta:u,disabled:!a}),[y,v]=kL(),h=E.useRef({x:0,y:0}),m=E.useRef({x:0,y:0}),d=E.useMemo(()=>{switch(r){case mo.Pointer:return o?{top:o.y,bottom:o.y,left:o.x,right:o.x}:null;case mo.DraggableRect:return i}},[r,i,o]),g=E.useRef(null),w=E.useCallback(()=>{const x=g.current;if(!x)return;const C=h.current.x*m.current.x,S=h.current.y*m.current.y;x.scrollBy(C,S)},[]),b=E.useMemo(()=>s===Kl.TreeOrder?[...c].reverse():c,[s,c]);E.useEffect(()=>{if(!a||!c.length||!d){v();return}for(const x of b){if((n==null?void 0:n(x))===!1)continue;const C=c.indexOf(x),S=f[C];if(!S)continue;const{direction:k,speed:L}=sT(x,S,d,t,p);for(const A of["x","y"])_[A][k[A]]||(L[A]=0,k[A]=0);if(L.x>0||L.y>0){v(),g.current=x,y(w,l),h.current=L,m.current=k;return}}h.current={x:0,y:0},m.current={x:0,y:0},v()},[t,w,n,v,a,l,JSON.stringify(d),JSON.stringify(_),y,c,b,f,JSON.stringify(p)])}const _T={x:{[Tt.Backward]:!1,[Tt.Forward]:!1},y:{[Tt.Backward]:!1,[Tt.Forward]:!1}};function yT(e){let{delta:t,disabled:r}=e;const n=Zh(t);return oa(i=>{if(r||!n||!i)return _T;const a={x:Math.sign(t.x-n.x),y:Math.sign(t.y-n.y)};return{x:{[Tt.Backward]:i.x[Tt.Backward]||a.x===-1,[Tt.Forward]:i.x[Tt.Forward]||a.x===1},y:{[Tt.Backward]:i.y[Tt.Backward]||a.y===-1,[Tt.Forward]:i.y[Tt.Forward]||a.y===1}}},[r,t,n])}function wT(e,t){const r=t!=null?e.get(t):void 0,n=r?r.node.current:null;return oa(i=>{var a;return t==null?null:(a=n??i)!=null?a:null},[n,t])}function ST(e,t){return E.useMemo(()=>e.reduce((r,n)=>{const{sensor:i}=n,a=i.activators.map(l=>({eventName:l.eventName,handler:t(l.handler,n)}));return[...r,...a]},[]),[e,t])}var Uo;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Uo||(Uo={}));var nd;(function(e){e.Optimized="optimized"})(nd||(nd={}));const iv=new Map;function xT(e,t){let{dragging:r,dependencies:n,config:i}=t;const[a,l]=E.useState(null),{frequency:s,measure:o,strategy:c}=i,f=E.useRef(e),u=h(),p=$o(u),_=E.useCallback(function(m){m===void 0&&(m=[]),!p.current&&l(d=>d===null?m:d.concat(m.filter(g=>!d.includes(g))))},[p]),y=E.useRef(null),v=oa(m=>{if(u&&!r)return iv;if(!m||m===iv||f.current!==e||a!=null){const d=new Map;for(let g of e){if(!g)continue;if(a&&a.length>0&&!a.includes(g.id)&&g.rect.current){d.set(g.id,g.rect.current);continue}const w=g.node.current,b=w?new ep(o(w),w):null;g.rect.current=b,b&&d.set(g.id,b)}return d}return m},[e,a,r,u,o]);return E.useEffect(()=>{f.current=e},[e]),E.useEffect(()=>{u||_()},[r,u]),E.useEffect(()=>{a&&a.length>0&&l(null)},[JSON.stringify(a)]),E.useEffect(()=>{u||typeof s!="number"||y.current!==null||(y.current=setTimeout(()=>{_(),y.current=null},s))},[s,u,_,...n]),{droppableRects:v,measureDroppableContainers:_,measuringScheduled:a!=null};function h(){switch(c){case Uo.Always:return!1;case Uo.BeforeDragging:return r;default:return!r}}}function ew(e,t){return oa(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function bT(e,t){return ew(e,t)}function CT(e){let{callback:t,disabled:r}=e;const n=Jf(t),i=E.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:a}=window;return new a(n)},[n,r]);return E.useEffect(()=>()=>i==null?void 0:i.disconnect(),[i]),i}function xc(e){let{callback:t,disabled:r}=e;const n=Jf(t),i=E.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:a}=window;return new a(n)},[r]);return E.useEffect(()=>()=>i==null?void 0:i.disconnect(),[i]),i}function ET(e){return new ep(Ti(e),e)}function ov(e,t,r){t===void 0&&(t=ET);const[n,i]=E.useState(null);function a(){i(o=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=o??r)!=null?c:null}const f=t(e);return JSON.stringify(o)===JSON.stringify(f)?o:f})}const l=CT({callback(o){if(e)for(const c of o){const{type:f,target:u}=c;if(f==="childList"&&u instanceof HTMLElement&&u.contains(e)){a();break}}}}),s=xc({callback:a});return Gr(()=>{a(),e?(s==null||s.observe(e),l==null||l.observe(document.body,{childList:!0,subtree:!0})):(s==null||s.disconnect(),l==null||l.disconnect())},[e]),n}function kT(e){const t=ew(e);return V1(e,t)}const av=[];function LT(e){const t=E.useRef(e),r=oa(n=>e?n&&n!==av&&e&&t.current&&e.parentNode===t.current.parentNode?n:Zf(e):av,[e]);return E.useEffect(()=>{t.current=e},[e]),r}function TT(e){const[t,r]=E.useState(null),n=E.useRef(e),i=E.useCallback(a=>{const l=vu(a.target);l&&r(s=>s?(s.set(l,td(l)),new Map(s)):null)},[]);return E.useEffect(()=>{const a=n.current;if(e!==a){l(a);const s=e.map(o=>{const c=vu(o);return c?(c.addEventListener("scroll",i,{passive:!0}),[c,td(c)]):null}).filter(o=>o!=null);r(s.length?new Map(s):null),n.current=e}return()=>{l(e),l(a)};function l(s){s.forEach(o=>{const c=vu(o);c==null||c.removeEventListener("scroll",i)})}},[i,e]),E.useMemo(()=>e.length?t?Array.from(t.values()).reduce((a,l)=>ai(a,l),jr):J1(e):jr,[e,t])}function lv(e,t){t===void 0&&(t=[]);const r=E.useRef(null);return E.useEffect(()=>{r.current=null},t),E.useEffect(()=>{const n=e!==jr;n&&!r.current&&(r.current=e),!n&&r.current&&(r.current=null)},[e]),r.current?Wl(e,r.current):jr}function RT(e){E.useEffect(()=>{if(!Sc)return;const t=e.map(r=>{let{sensor:n}=r;return n.setup==null?void 0:n.setup()});return()=>{for(const r of t)r==null||r()}},e.map(t=>{let{sensor:r}=t;return r}))}function DT(e,t){return E.useMemo(()=>e.reduce((r,n)=>{let{eventName:i,handler:a}=n;return r[i]=l=>{a(l,t)},r},{}),[e,t])}function tw(e){return E.useMemo(()=>e?eT(e):null,[e])}const cv=[];function MT(e,t){t===void 0&&(t=Ti);const[r]=e,n=tw(r?lr(r):null),[i,a]=E.useState(cv);function l(){a(()=>e.length?e.map(o=>X1(o)?n:new ep(t(o),o)):cv)}const s=xc({callback:l});return Gr(()=>{s==null||s.disconnect(),l(),e.forEach(o=>s==null?void 0:s.observe(o))},[e]),i}function AT(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return ia(t)?t:e}function PT(e){let{measure:t}=e;const[r,n]=E.useState(null),i=E.useCallback(c=>{for(const{target:f}of c)if(ia(f)){n(u=>{const p=t(f);return u?{...u,width:p.width,height:p.height}:p});break}},[t]),a=xc({callback:i}),l=E.useCallback(c=>{const f=AT(c);a==null||a.disconnect(),f&&(a==null||a.observe(f)),n(f?t(f):null)},[t,a]),[s,o]=Ul(l);return E.useMemo(()=>({nodeRef:s,rect:r,setRef:o}),[r,s,o])}const IT=[{sensor:rp,options:{}},{sensor:Z1,options:{}}],OT={current:{}},ol={draggable:{measure:tv},droppable:{measure:tv,strategy:Uo.WhileDragging,frequency:nd.Optimized},dragOverlay:{measure:Ti}};class go extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,n;return(r=(n=this.get(t))==null?void 0:n.node.current)!=null?r:void 0}}const BT={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new go,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Vl},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:ol,measureDroppableContainers:Vl,windowRect:null,measuringScheduled:!1},NT={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Vl,draggableNodes:new Map,over:null,measureDroppableContainers:Vl},bc=E.createContext(NT),rw=E.createContext(BT);function jT(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new go}}}function FT(e,t){switch(t.type){case xt.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case xt.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 xt.DragEnd:case xt.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case xt.RegisterDroppable:{const{element:r}=t,{id:n}=r,i=new go(e.droppable.containers);return i.set(n,r),{...e,droppable:{...e.droppable,containers:i}}}case xt.SetDroppableDisabled:{const{id:r,key:n,disabled:i}=t,a=e.droppable.containers.get(r);if(!a||n!==a.key)return e;const l=new go(e.droppable.containers);return l.set(r,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:l}}}case xt.UnregisterDroppable:{const{id:r,key:n}=t,i=e.droppable.containers.get(r);if(!i||n!==i.key)return e;const a=new go(e.droppable.containers);return a.delete(r),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function HT(e){let{disabled:t}=e;const{active:r,activatorEvent:n,draggableNodes:i}=E.useContext(bc),a=Zh(n),l=Zh(r==null?void 0:r.id);return E.useEffect(()=>{if(!t&&!n&&a&&l!=null){if(!Qf(a)||document.activeElement===a.target)return;const s=i.get(l);if(!s)return;const{activatorNode:o,node:c}=s;if(!o.current&&!c.current)return;requestAnimationFrame(()=>{for(const f of[o.current,c.current]){if(!f)continue;const u=RL(f);if(u){u.focus();break}}})}},[n,t,i,l,a]),null}function $T(e,t){let{transform:r,...n}=t;return e!=null&&e.length?e.reduce((i,a)=>a({transform:i,...n}),r):r}function zT(e){return E.useMemo(()=>({draggable:{...ol.draggable,...e==null?void 0:e.draggable},droppable:{...ol.droppable,...e==null?void 0:e.droppable},dragOverlay:{...ol.dragOverlay,...e==null?void 0:e.dragOverlay}}),[e==null?void 0:e.draggable,e==null?void 0:e.droppable,e==null?void 0:e.dragOverlay])}function UT(e){let{activeNode:t,measure:r,initialRect:n,config:i=!0}=e;const a=E.useRef(!1),{x:l,y:s}=typeof i=="boolean"?{x:i,y:i}:i;Gr(()=>{if(!l&&!s||!t){a.current=!1;return}if(a.current||!n)return;const c=t==null?void 0:t.node.current;if(!c||c.isConnected===!1)return;const f=r(c),u=V1(f,n);if(l||(u.x=0),s||(u.y=0),a.current=!0,Math.abs(u.x)>0||Math.abs(u.y)>0){const p=K1(c);p&&p.scrollBy({top:u.y,left:u.x})}},[t,l,s,n,r])}const nw=E.createContext({...jr,scaleX:1,scaleY:1});var Rn;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Rn||(Rn={}));const WT=E.memo(function(t){var r,n,i,a;let{id:l,accessibility:s,autoScroll:o=!0,children:c,sensors:f=IT,collisionDetection:u=GL,measuring:p,modifiers:_,...y}=t;const v=E.useReducer(FT,void 0,jT),[h,m]=v,[d,g]=OL(),[w,b]=E.useState(Rn.Uninitialized),x=w===Rn.Initialized,{draggable:{active:C,nodes:S,translate:k},droppable:{containers:L}}=h,A=C!=null?S.get(C):null,M=E.useRef({initial:null,translated:null}),D=E.useMemo(()=>{var he;return C!=null?{id:C,data:(he=A==null?void 0:A.data)!=null?he:OT,rect:M}:null},[C,A]),O=E.useRef(null),[z,F]=E.useState(null),[H,I]=E.useState(null),R=$o(y,Object.values(y)),P=aa("DndDescribedBy",l),N=E.useMemo(()=>L.getEnabled(),[L]),j=zT(p),{droppableRects:W,measureDroppableContainers:V,measuringScheduled:Z}=xT(N,{dragging:x,dependencies:[k.x,k.y],config:j.droppable}),Q=wT(S,C),$=E.useMemo(()=>H?ed(H):null,[H]),B=ie(),K=bT(Q,j.draggable.measure);UT({activeNode:C!=null?S.get(C):null,config:B.layoutShiftCompensation,initialRect:K,measure:j.draggable.measure});const U=ov(Q,j.draggable.measure,K),te=ov(Q?Q.parentElement:null),Y=E.useRef({activatorEvent:null,active:null,activeNode:Q,collisionRect:null,collisions:null,droppableRects:W,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:L,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),_e=L.getNodeFor((r=Y.current.over)==null?void 0:r.id),de=PT({measure:j.dragOverlay.measure}),re=(n=de.nodeRef.current)!=null?n:Q,le=x?(i=de.rect)!=null?i:U:null,ne=!!(de.nodeRef.current&&de.rect),fe=kT(ne?null:U),ge=tw(re?lr(re):null),se=LT(x?_e??Q:null),oe=MT(se),ue=$T(_,{transform:{x:k.x-fe.x,y:k.y-fe.y,scaleX:1,scaleY:1},activatorEvent:H,active:D,activeNodeRect:U,containerNodeRect:te,draggingNodeRect:le,over:Y.current.over,overlayNodeRect:de.rect,scrollableAncestors:se,scrollableAncestorRects:oe,windowRect:ge}),ae=$?ai($,k):null,ve=TT(se),Ce=lv(ve),Le=lv(ve,[U]),je=ai(ue,Ce),Fe=le?YL(le,ue):null,Pe=D&&Fe?u({active:D,collisionRect:Fe,droppableRects:W,droppableContainers:N,pointerCoordinates:ae}):null,Oe=WL(Pe,"id"),[Ee,q]=E.useState(null),ee=ne?ue:ai(ue,Le),Ne=qL(ee,(a=Ee==null?void 0:Ee.rect)!=null?a:null,U),qe=E.useRef(null),Ae=E.useCallback((he,ke)=>{let{sensor:Re,options:$e}=ke;if(O.current==null)return;const Ue=S.get(O.current);if(!Ue)return;const Ie=he.nativeEvent,De=new Re({active:O.current,activeNode:Ue,event:Ie,options:$e,context:Y,onAbort(ze){if(!S.get(ze))return;const{onDragAbort:Me}=R.current,We={id:ze};Me==null||Me(We),d({type:"onDragAbort",event:We})},onPending(ze,Te,Me,We){if(!S.get(ze))return;const{onDragPending:$t}=R.current,_t={id:ze,constraint:Te,initialCoordinates:Me,offset:We};$t==null||$t(_t),d({type:"onDragPending",event:_t})},onStart(ze){const Te=O.current;if(Te==null)return;const Me=S.get(Te);if(!Me)return;const{onDragStart:We}=R.current,Ye={activatorEvent:Ie,active:{id:Te,data:Me.data,rect:M}};hn.unstable_batchedUpdates(()=>{We==null||We(Ye),b(Rn.Initializing),m({type:xt.DragStart,initialCoordinates:ze,active:Te}),d({type:"onDragStart",event:Ye}),F(qe.current),I(Ie)})},onMove(ze){m({type:xt.DragMove,coordinates:ze})},onEnd:et(xt.DragEnd),onCancel:et(xt.DragCancel)});qe.current=De;function et(ze){return async function(){const{active:Me,collisions:We,over:Ye,scrollAdjustedTranslate:$t}=Y.current;let _t=null;if(Me&&$t){const{cancelDrop:zt}=R.current;_t={activatorEvent:Ie,active:Me,collisions:We,delta:$t,over:Ye},ze===xt.DragEnd&&typeof zt=="function"&&await Promise.resolve(zt(_t))&&(ze=xt.DragCancel)}O.current=null,hn.unstable_batchedUpdates(()=>{m({type:ze}),b(Rn.Uninitialized),q(null),F(null),I(null),qe.current=null;const zt=ze===xt.DragEnd?"onDragEnd":"onDragCancel";if(_t){const It=R.current[zt];It==null||It(_t),d({type:zt,event:_t})}})}}},[S]),G=E.useCallback((he,ke)=>(Re,$e)=>{const Ue=Re.nativeEvent,Ie=S.get($e);if(O.current!==null||!Ie||Ue.dndKit||Ue.defaultPrevented)return;const De={active:Ie};he(Re,ke.options,De)===!0&&(Ue.dndKit={capturedBy:ke.sensor},O.current=$e,Ae(Re,ke))},[S,Ae]),me=ST(f,G);RT(f),Gr(()=>{U&&w===Rn.Initializing&&b(Rn.Initialized)},[U,w]),E.useEffect(()=>{const{onDragMove:he}=R.current,{active:ke,activatorEvent:Re,collisions:$e,over:Ue}=Y.current;if(!ke||!Re)return;const Ie={active:ke,activatorEvent:Re,collisions:$e,delta:{x:je.x,y:je.y},over:Ue};hn.unstable_batchedUpdates(()=>{he==null||he(Ie),d({type:"onDragMove",event:Ie})})},[je.x,je.y]),E.useEffect(()=>{const{active:he,activatorEvent:ke,collisions:Re,droppableContainers:$e,scrollAdjustedTranslate:Ue}=Y.current;if(!he||O.current==null||!ke||!Ue)return;const{onDragOver:Ie}=R.current,De=$e.get(Oe),et=De&&De.rect.current?{id:De.id,rect:De.rect.current,data:De.data,disabled:De.disabled}:null,ze={active:he,activatorEvent:ke,collisions:Re,delta:{x:Ue.x,y:Ue.y},over:et};hn.unstable_batchedUpdates(()=>{q(et),Ie==null||Ie(ze),d({type:"onDragOver",event:ze})})},[Oe]),Gr(()=>{Y.current={activatorEvent:H,active:D,activeNode:Q,collisionRect:Fe,collisions:Pe,droppableRects:W,draggableNodes:S,draggingNode:re,draggingNodeRect:le,droppableContainers:L,over:Ee,scrollableAncestors:se,scrollAdjustedTranslate:je},M.current={initial:le,translated:Fe}},[D,Q,Pe,Fe,S,re,le,W,L,Ee,se,je]),vT({...B,delta:k,draggingRect:Fe,pointerCoordinates:ae,scrollableAncestors:se,scrollableAncestorRects:oe});const J=E.useMemo(()=>({active:D,activeNode:Q,activeNodeRect:U,activatorEvent:H,collisions:Pe,containerNodeRect:te,dragOverlay:de,draggableNodes:S,droppableContainers:L,droppableRects:W,over:Ee,measureDroppableContainers:V,scrollableAncestors:se,scrollableAncestorRects:oe,measuringConfiguration:j,measuringScheduled:Z,windowRect:ge}),[D,Q,U,H,Pe,te,de,S,L,W,Ee,V,se,oe,j,Z,ge]),Se=E.useMemo(()=>({activatorEvent:H,activators:me,active:D,activeNodeRect:U,ariaDescribedById:{draggable:P},dispatch:m,draggableNodes:S,over:Ee,measureDroppableContainers:V}),[H,me,D,U,m,P,S,Ee,V]);return gt.createElement(W1.Provider,{value:g},gt.createElement(bc.Provider,{value:Se},gt.createElement(rw.Provider,{value:J},gt.createElement(nw.Provider,{value:Ne},c)),gt.createElement(HT,{disabled:(s==null?void 0:s.restoreFocus)===!1})),gt.createElement(jL,{...s,hiddenTextDescribedById:P}));function ie(){const he=(z==null?void 0:z.autoScrollEnabled)===!1,ke=typeof o=="object"?o.enabled===!1:o===!1,Re=x&&!he&&!ke;return typeof o=="object"?{...o,enabled:Re}:{enabled:Re}}}),VT=E.createContext(null),uv="button",KT="Draggable";function GT(e){let{id:t,data:r,disabled:n=!1,attributes:i}=e;const a=aa(KT),{activators:l,activatorEvent:s,active:o,activeNodeRect:c,ariaDescribedById:f,draggableNodes:u,over:p}=E.useContext(bc),{role:_=uv,roleDescription:y="draggable",tabIndex:v=0}=i??{},h=(o==null?void 0:o.id)===t,m=E.useContext(h?nw:VT),[d,g]=Ul(),[w,b]=Ul(),x=DT(l,t),C=$o(r);Gr(()=>(u.set(t,{id:t,key:a,node:d,activatorNode:w,data:C}),()=>{const k=u.get(t);k&&k.key===a&&u.delete(t)}),[u,t]);const S=E.useMemo(()=>({role:_,tabIndex:v,"aria-disabled":n,"aria-pressed":h&&_===uv?!0:void 0,"aria-roledescription":y,"aria-describedby":f.draggable}),[n,_,v,h,y,f.draggable]);return{active:o,activatorEvent:s,activeNodeRect:c,attributes:S,isDragging:h,listeners:n?void 0:x,node:d,over:p,setNodeRef:g,setActivatorNodeRef:b,transform:m}}function qT(){return E.useContext(rw)}const XT="Droppable",YT={timeout:25};function JT(e){let{data:t,disabled:r=!1,id:n,resizeObserverConfig:i}=e;const a=aa(XT),{active:l,dispatch:s,over:o,measureDroppableContainers:c}=E.useContext(bc),f=E.useRef({disabled:r}),u=E.useRef(!1),p=E.useRef(null),_=E.useRef(null),{disabled:y,updateMeasurementsFor:v,timeout:h}={...YT,...i},m=$o(v??n),d=E.useCallback(()=>{if(!u.current){u.current=!0;return}_.current!=null&&clearTimeout(_.current),_.current=setTimeout(()=>{c(Array.isArray(m.current)?m.current:[m.current]),_.current=null},h)},[h]),g=xc({callback:d,disabled:y||!l}),w=E.useCallback((S,k)=>{g&&(k&&(g.unobserve(k),u.current=!1),S&&g.observe(S))},[g]),[b,x]=Ul(w),C=$o(t);return E.useEffect(()=>{!g||!b.current||(g.disconnect(),u.current=!1,g.observe(b.current))},[b,g]),E.useEffect(()=>(s({type:xt.RegisterDroppable,element:{id:n,key:a,disabled:r,node:b,rect:p,data:C}}),()=>s({type:xt.UnregisterDroppable,key:a,id:n})),[n]),E.useEffect(()=>{r!==f.current.disabled&&(s({type:xt.SetDroppableDisabled,id:n,key:a,disabled:r}),f.current.disabled=r)},[n,a,r,s]),{active:l,rect:p,isOver:(o==null?void 0:o.id)===n,node:b,over:o,setNodeRef:x}}function sw(e,t,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function QT(e,t){return e.reduce((r,n,i)=>{const a=t.get(n);return a&&(r[i]=a),r},Array(e.length))}function Aa(e){return e!==null&&e>=0}function ZT(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function eR(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const iw=e=>{let{rects:t,activeIndex:r,overIndex:n,index:i}=e;const a=sw(t,n,r),l=t[i],s=a[i];return!s||!l?null:{x:s.left-l.left,y:s.top-l.top,scaleX:s.width/l.width,scaleY:s.height/l.height}},Pa={scaleX:1,scaleY:1},tR=e=>{var t;let{activeIndex:r,activeNodeRect:n,index:i,rects:a,overIndex:l}=e;const s=(t=a[r])!=null?t:n;if(!s)return null;if(i===r){const c=a[l];return c?{x:0,y:r<l?c.top+c.height-(s.top+s.height):c.top-s.top,...Pa}:null}const o=rR(a,i,r);return i>r&&i<=l?{x:0,y:-s.height-o,...Pa}:i<r&&i>=l?{x:0,y:s.height+o,...Pa}:{x:0,y:0,...Pa}};function rR(e,t,r){const n=e[t],i=e[t-1],a=e[t+1];return n?r<t?i?n.top-(i.top+i.height):a?a.top-(n.top+n.height):0:a?a.top-(n.top+n.height):i?n.top-(i.top+i.height):0:0}const ow="Sortable",aw=gt.createContext({activeIndex:-1,containerId:ow,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:iw,disabled:{draggable:!1,droppable:!1}});function nR(e){let{children:t,id:r,items:n,strategy:i=iw,disabled:a=!1}=e;const{active:l,dragOverlay:s,droppableRects:o,over:c,measureDroppableContainers:f}=qT(),u=aa(ow,r),p=s.rect!==null,_=E.useMemo(()=>n.map(x=>typeof x=="object"&&"id"in x?x.id:x),[n]),y=l!=null,v=l?_.indexOf(l.id):-1,h=c?_.indexOf(c.id):-1,m=E.useRef(_),d=!ZT(_,m.current),g=h!==-1&&v===-1||d,w=eR(a);Gr(()=>{d&&y&&f(_)},[d,_,y,f]),E.useEffect(()=>{m.current=_},[_]);const b=E.useMemo(()=>({activeIndex:v,containerId:u,disabled:w,disableTransforms:g,items:_,overIndex:h,useDragOverlay:p,sortedRects:QT(_,o),strategy:i}),[v,u,w.draggable,w.droppable,g,_,h,o,p,i]);return gt.createElement(aw.Provider,{value:b},t)}const sR=e=>{let{id:t,items:r,activeIndex:n,overIndex:i}=e;return sw(r,n,i).indexOf(t)},iR=e=>{let{containerId:t,isSorting:r,wasDragging:n,index:i,items:a,newIndex:l,previousItems:s,previousContainerId:o,transition:c}=e;return!c||!n||s!==a&&i===l?!1:r?!0:l!==i&&t===o},oR={duration:200,easing:"ease"},lw="transform",aR=zo.Transition.toString({property:lw,duration:0,easing:"linear"}),lR={roleDescription:"sortable"};function cR(e){let{disabled:t,index:r,node:n,rect:i}=e;const[a,l]=E.useState(null),s=E.useRef(r);return Gr(()=>{if(!t&&r!==s.current&&n.current){const o=i.current;if(o){const c=Ti(n.current,{ignoreTransform:!0}),f={x:o.left-c.left,y:o.top-c.top,scaleX:o.width/c.width,scaleY:o.height/c.height};(f.x||f.y)&&l(f)}}r!==s.current&&(s.current=r)},[t,r,n,i]),E.useEffect(()=>{a&&l(null)},[a]),a}function uR(e){let{animateLayoutChanges:t=iR,attributes:r,disabled:n,data:i,getNewIndex:a=sR,id:l,strategy:s,resizeObserverConfig:o,transition:c=oR}=e;const{items:f,containerId:u,activeIndex:p,disabled:_,disableTransforms:y,sortedRects:v,overIndex:h,useDragOverlay:m,strategy:d}=E.useContext(aw),g=hR(n,_),w=f.indexOf(l),b=E.useMemo(()=>({sortable:{containerId:u,index:w,items:f},...i}),[u,i,w,f]),x=E.useMemo(()=>f.slice(f.indexOf(l)),[f,l]),{rect:C,node:S,isOver:k,setNodeRef:L}=JT({id:l,data:b,disabled:g.droppable,resizeObserverConfig:{updateMeasurementsFor:x,...o}}),{active:A,activatorEvent:M,activeNodeRect:D,attributes:O,setNodeRef:z,listeners:F,isDragging:H,over:I,setActivatorNodeRef:R,transform:P}=GT({id:l,data:b,attributes:{...lR,...r},disabled:g.draggable}),N=EL(L,z),j=!!A,W=j&&!y&&Aa(p)&&Aa(h),V=!m&&H,Z=V&&W?P:null,$=W?Z??(s??d)({rects:v,activeNodeRect:D,activeIndex:p,overIndex:h,index:w}):null,B=Aa(p)&&Aa(h)?a({id:l,items:f,activeIndex:p,overIndex:h}):w,K=A==null?void 0:A.id,U=E.useRef({activeId:K,items:f,newIndex:B,containerId:u}),te=f!==U.current.items,Y=t({active:A,containerId:u,isDragging:H,isSorting:j,id:l,index:w,items:f,newIndex:U.current.newIndex,previousItems:U.current.items,previousContainerId:U.current.containerId,transition:c,wasDragging:U.current.activeId!=null}),_e=cR({disabled:!Y,index:w,node:S,rect:C});return E.useEffect(()=>{j&&U.current.newIndex!==B&&(U.current.newIndex=B),u!==U.current.containerId&&(U.current.containerId=u),f!==U.current.items&&(U.current.items=f)},[j,B,u,f]),E.useEffect(()=>{if(K===U.current.activeId)return;if(K!=null&&U.current.activeId==null){U.current.activeId=K;return}const re=setTimeout(()=>{U.current.activeId=K},50);return()=>clearTimeout(re)},[K]),{active:A,activeIndex:p,attributes:O,data:b,rect:C,index:w,newIndex:B,items:f,isOver:k,isSorting:j,isDragging:H,listeners:F,node:S,overIndex:h,over:I,setNodeRef:N,setActivatorNodeRef:R,setDroppableNodeRef:L,setDraggableNodeRef:z,transform:_e??$,transition:de()};function de(){if(_e||te&&U.current.newIndex===w)return aR;if(!(V&&!Qf(M)||!c)&&(j||Y))return zo.Transition.toString({...c,property:lw})}}function hR(e,t){var r,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e==null?void 0:e.draggable)!=null?r:t.draggable,droppable:(n=e==null?void 0:e.droppable)!=null?n:t.droppable}}Je.Down,Je.Right,Je.Up,Je.Left;const Ia={permission:0,waiting:1,working:2,unknown:3};function vo(e){var r;const t=(r=e.agentSessionId)==null?void 0:r.trim();return t&&t.length>0?t:e.id}const dR={mode:"created",direction:"desc"};function np(e,t=dR){const{mode:r,direction:n,manualOrder:i}=t;if(r==="manual"&&i&&i.length>0){const a=new Map(i.map((l,s)=>[l,s]));return e.toSorted((l,s)=>{const o=vo(l),c=vo(s),f=a.get(o)??a.get(l.id)??1/0,u=a.get(c)??a.get(s.id)??1/0;return f===1/0&&u===1/0?Date.parse(s.createdAt)-Date.parse(l.createdAt):f-u})}return e.toSorted((a,l)=>{if(r==="status"){const c=Ia[a.status]??Ia.unknown,f=Ia[l.status]??Ia.unknown;return c!==f?c-f:Date.parse(l.lastActivity)-Date.parse(a.lastActivity)}const s=Date.parse(a.createdAt),o=Date.parse(l.createdAt);return n==="desc"?o-s:s-o})}function fR(e,t){var n,i;const r=new Map;for(const a of e){const l=(n=a.projectPath)==null?void 0:n.trim();if(l){const s=Date.parse(a.lastActivity)||0,o=r.get(l)||0;s>o&&r.set(l,s)}}for(const a of t){const l=(i=a.projectPath)==null?void 0:i.trim();if(l){const s=Date.parse(a.lastActivityAt)||0,o=r.get(l)||0;s>o&&r.set(l,s)}}return Array.from(r.keys()).toSorted((a,l)=>{const s=r.get(a)||0;return(r.get(l)||0)-s})}function pR(e,t){var n,i;const r=new Map;for(const a of e){const l=(n=a.host)==null?void 0:n.trim();if(l){const s=Date.parse(a.lastActivity)||0,o=r.get(l)||0;s>o&&r.set(l,s)}}for(const a of t){const l=(i=a.host)==null?void 0:i.trim();if(l){const s=Date.parse(a.lastActivityAt)||0,o=r.get(l)||0;s>o&&r.set(l,s)}}return Array.from(r.keys()).toSorted((a,l)=>{const s=r.get(a)||0;return(r.get(l)||0)-s})}function sp(e){const t=Date.parse(e);if(Number.isNaN(t))return"";const r=Date.now()-t,n=Math.floor(r/6e4);if(n<1)return"now";if(n<60)return`${n}m`;const i=Math.floor(n/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function _s(e){const t=e.trim();if(!t)return null;const r=t.replace(/[\\/]+$/,"");if(!r)return null;const n=r.split(/[\\/]/);return n[n.length-1]||null}function mR(e){const t=e.map(s=>{const o=s.trim(),c=o.replace(/[\\/]+$/,""),f=c.split(/[\\/]/).filter(Boolean);return{path:s,parts:f,fallback:c||o||s}}),r=new Map;for(const s of t)r.set(s.path,1);let n=!0;for(;n;){n=!1;const s=new Map;for(const o of t){if(o.parts.length===0)continue;const c=r.get(o.path)??1,f=o.parts.slice(-c).join("/");s.set(f,(s.get(f)??0)+1)}for(const o of t){if(o.parts.length===0)continue;const c=r.get(o.path)??1,f=o.parts.slice(-c).join("/");(s.get(f)??0)>1&&c<o.parts.length&&(r.set(o.path,c+1),n=!0)}}const i=new Map,a=new Map;for(const s of t){let o=s.fallback;if(s.parts.length>0){const c=r.get(s.path)??1;o=s.parts.slice(-c).join("/")}i.set(s.path,o),a.set(o,(a.get(o)??0)+1)}const l=new Map;for(const s of t){let o=i.get(s.path)??s.fallback;(a.get(o)??0)>1&&(o=s.fallback),l.set(s.path,o)}return l}function cw(e){const t=e.trim();return!t||t.length<=6?t:`${t.slice(0,3)}…${t.slice(-3)}`}function uw(e){var r;const 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{(r=navigator.clipboard)==null||r.writeText(e).catch(()=>{})}document.body.removeChild(t)}function gR({useSafariLayoutFallback:e,isDragging:t,dndTransform:r,generatedTransform:n}){return e&&!t&&!r||!r?n:!n||n==="none"?r:`${r} ${n}`}const vR="agentboard-session",_R=sC();function yR(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 wR(e,t){if(e.length!==t.length)return!1;const r=new Map(e.map(n=>[n.id,n]));for(const n of t){const i=r.get(n.id);if(!i||!yR(i,n))return!1}return!0}const Ke=df()(ff((e,t)=>({sessions:[],agentSessions:{active:[],inactive:[]},hostStatuses:[],exitingSessions:new Map,selectedSessionId:null,hasLoaded:!1,connectionStatus:"connecting",connectionError:null,remoteAllowControl:!1,remoteAllowAttach:!1,hostLabel:null,setSessions:r=>{var f;const n=t(),i=n.selectedSessionId,a=n.sessions,l=n.exitingSessions;if(n.hasLoaded&&wR(a,r))return;const s=new Set(r.map(u=>u.id)),o=a.filter(u=>!s.has(u.id)&&!l.has(u.id));let c=i;if(i!==null&&!r.some(u=>u.id===i)){const{sessionSortMode:u,sessionSortDirection:p}=pe.getState();c=((f=np(r,{mode:u,direction:p})[0])==null?void 0:f.id)??null}if(o.length>0){const u=new Map(l);for(const p of o)u.set(p.id,p);e({sessions:r,hasLoaded:!0,selectedSessionId:c,exitingSessions:u})}else e({sessions:r,hasLoaded:!0,selectedSessionId:c})},setAgentSessions:(r,n)=>e({agentSessions:{active:r,inactive:n}}),setHostStatuses:r=>e({hostStatuses:r}),updateSession:r=>e(n=>({sessions:n.sessions.map(i=>i.id===r.id?r:i)})),setSelectedSessionId:r=>e({selectedSessionId:r}),setConnectionStatus:r=>e({connectionStatus:r}),setConnectionError:r=>e({connectionError:r}),setRemoteAllowControl:r=>e({remoteAllowControl:r}),setRemoteAllowAttach:r=>e({remoteAllowAttach:r}),setHostLabel:r=>e({hostLabel:r}),markSessionExiting:r=>{const n=t().sessions.find(i=>i.id===r);if(n){const i=new Map(t().exitingSessions);i.set(r,n),e({exitingSessions:i})}},clearExitingSession:r=>{const n=new Map(t().exitingSessions);n.delete(r),e({exitingSessions:n})}}),{name:vR,storage:gc(()=>_R),partialize:e=>({selectedSessionId:e.selectedSessionId})}));function hv(e,t,r=!1){const[n,i]=E.useState(!1),a=E.useRef(e),l=E.useRef(!1);return E.useEffect(()=>{const o=a.current;if(r?e>o:e!==o){l.current=!0;const f=setTimeout(()=>{l.current&&(i(!0),l.current=!1)},t);return a.current=e,()=>clearTimeout(f)}a.current=e},[e,t,r]),[n,()=>i(!1)]}function SR(e,t,r,n){const i=E.useRef(new Map);E.useEffect(()=>{const a=new Set(e.map(l=>l.id));for(const l of t.keys())if(a.has(l)){const s=i.current.get(l);s&&(clearTimeout(s),i.current.delete(l)),r(l)}else if(!i.current.has(l)){const s=setTimeout(()=>{i.current.delete(l),r(l)},n+100);i.current.set(l,s)}},[e,t,r,n]),E.useEffect(()=>()=>{for(const a of i.current.values())clearTimeout(a);i.current.clear()},[])}function xR({className:e}){return T.jsx("svg",{viewBox:"0 0 92.2 92.2",fill:"currentColor",className:e,"aria-label":"Anthropic",children:T.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 bR({className:e}){return T.jsx("svg",{viewBox:"-1 -1 26 26",fill:"currentColor",className:e,"aria-label":"OpenAI",children:T.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 CR({className:e}){return T.jsx("svg",{viewBox:"0 0 588.42 568.88",fill:"currentColor",className:e,"aria-label":"Pi",children:T.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"})})}const ER=[["claude",xR],["codex",bR],["pi",CR]];function Cc({agentType:e,command:t,className:r=""}){const n=(e||(t==null?void 0:t.split(" ")[0])||"").toLowerCase();for(const[i,a]of ER)if(n.startsWith(i))return T.jsx(a,{className:r});return T.jsx(FC,{className:r})}const kR=360;function LR(e){let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);t=(t<<5)-t+n,t=t&t}return Math.abs(t)}function hw(e){return{"--badge-hue":`${LR(e)%kR}`}}function dw({name:e,fullPath:t,className:r=""}){const n=hw(e);return T.jsx("span",{className:`project-badge inline-flex items-center rounded-full px-1.5 py-0.5 text-[10px] font-medium leading-none ${r}`,style:n,title:t,children:e})}const TR=E.memo(function({session:t,showSessionIdPrefix:r,showProjectName:n,showLastUserMessage:i,onResume:a,onPreview:l,onSetPinned:s}){const o=sp(t.lastActivityAt),c=_s(t.projectPath),f=t.displayName||c||t.sessionId.slice(0,8),u=n&&!!c,p=i&&!!t.lastUserMessage,_=r?cw(t.sessionId):"",y=E.useRef(null),[v,h]=E.useState(null);E.useEffect(()=>{if(!v)return;const d=w=>{y.current&&!y.current.contains(w.target)&&h(null)},g=w=>{w.key==="Escape"&&h(null)};return document.addEventListener("mousedown",d),document.addEventListener("touchstart",d),document.addEventListener("keydown",g),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("touchstart",d),document.removeEventListener("keydown",g)}},[v]);const m=d=>{d.preventDefault(),d.stopPropagation(),h({x:d.clientX,y:d.clientY})};return T.jsxs("div",{className:"group relative cursor-pointer px-3 py-2 hover:bg-hover",role:"button",tabIndex:0,title:"Click to preview",onClick:()=>l(t),onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),l(t))},onContextMenu:m,children:[T.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:"Resume directly",onClick:d=>{d.stopPropagation(),a(t.sessionId)},children:"▶"}),T.jsxs("div",{className:"flex flex-col gap-0.5 pl-2.5 group-hover:pr-4",children:[T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx(Cc,{agentType:t.agentType,className:"h-3.5 w-3.5 shrink-0 text-muted"}),T.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-primary",children:f}),t.lastResumeError&&T.jsx(fC,{className:"h-3 w-3 shrink-0 text-amber-500","aria-label":"Resume failed",title:`Last resume failed: ${t.lastResumeError}`}),t.isPinned&&T.jsx(Ol,{className:"h-3 w-3 shrink-0 text-muted","aria-label":"Pinned",title:"Pinned - will auto-resume on server restart"}),_&&T.jsx("span",{className:"shrink-0 text-[11px] font-mono text-muted",title:t.sessionId,children:_}),T.jsx("span",{className:"ml-1 w-8 shrink-0 text-right text-xs tabular-nums text-muted",children:o})]}),(u||p)&&T.jsxs("div",{className:"flex flex-wrap items-center gap-1 pl-[1.375rem]",children:[u&&T.jsx(dw,{name:c,fullPath:t.projectPath}),p&&T.jsxs("span",{className:"truncate text-xs italic text-muted",children:['"',t.lastUserMessage.length>200?t.lastUserMessage.slice(0,200)+"…":t.lastUserMessage,'"']})]})]}),v&&T.jsxs("div",{ref:y,className:"fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1",style:{left:v.x,top:v.y},role:"menu",children:[s&&T.jsxs("button",{onClick:d=>{d.stopPropagation(),h(null),s(t.sessionId,!t.isPinned)},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:t.isPinned?"Remove from auto-resume list":"Auto-resume on server restart",children:[T.jsx(Ol,{width:14,height:14}),t.isPinned?"Unpin":"Pin"]}),t.logFilePath&&T.jsxs("button",{onClick:d=>{d.stopPropagation(),h(null),t.logFilePath&&uw(t.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:t.logFilePath,children:[T.jsx(iy,{width:14,height:14}),"Copy Log Path"]})]})]})});function RR({name:e,className:t=""}){const r=hw(`host:${e}`);return T.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:r,title:e,children:e})}function DR({hosts:e,selectedHosts:t,onSelect:r,statuses:n=[]}){const[i,a]=E.useState(!1),l=E.useId(),s=E.useRef(null),o=E.useMemo(()=>new Set(t),[t]),c=E.useMemo(()=>new Map(n.map(_=>[_.host,_])),[n]),f=E.useMemo(()=>t.length===0?"All Hosts":t.join(", "),[t]),u=E.useMemo(()=>t.length===0?"All Hosts":t.length===1?t[0]:`${t.length} hosts`,[t]);E.useEffect(()=>{if(!i||typeof document>"u"||!document.addEventListener||!document.removeEventListener)return;const _=v=>{var m;const h=v.target;h&&((m=s.current)!=null&&m.contains(h))||a(!1)},y=v=>{v.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",_),document.addEventListener("touchstart",_,{passive:!0}),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",_),document.removeEventListener("touchstart",_),document.removeEventListener("keydown",y)}},[i]);const p=_=>{const y=new Set(o);y.has(_)?y.delete(_):y.add(_);const v=e.filter(h=>y.has(h));r(v)};return T.jsxs("div",{ref:s,className:"relative",children:[T.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":i,"aria-controls":l,"aria-label":"Filter by host",onClick:()=>a(_=>!_),className:"flex h-6 max-w-[9rem] items-center gap-1 rounded border border-border bg-base px-2 text-[11px] text-primary hover:bg-hover focus:border-accent focus:outline-none",title:f,children:[T.jsx("span",{className:"truncate",children:u}),T.jsx(pf,{className:"h-3 w-3 shrink-0 text-muted"})]}),i&&T.jsxs("div",{id:l,role:"menu",className:"absolute right-0 z-20 mt-1 w-48 rounded border border-border bg-surface p-2 text-xs shadow-lg",children:[T.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:[T.jsx("input",{type:"checkbox",checked:t.length===0,onChange:()=>r([]),className:"h-3.5 w-3.5 accent-approval"}),T.jsx("span",{children:"All Hosts"})]}),T.jsx("div",{className:"my-2 h-px bg-border"}),e.length===0?T.jsx("div",{className:"px-2 py-1 text-muted",children:"No hosts"}):T.jsx("div",{className:"max-h-48 overflow-y-auto pr-1",children:e.map(_=>{const y=c.get(_),v=y?!y.ok:!1;return T.jsxs("label",{role:"menuitemcheckbox","aria-checked":o.has(_),className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover",title:y!=null&&y.error?`${_}: ${y.error}`:_,children:[T.jsx("input",{type:"checkbox",checked:o.has(_),onChange:()=>p(_),className:"h-3.5 w-3.5 accent-approval"}),T.jsx("span",{className:"truncate",children:_}),v&&T.jsx("span",{className:"ml-auto text-[10px] uppercase text-danger",children:"offline"})]},_)})})]})]})}function MR({projects:e,selectedProjects:t,onSelect:r,hasHiddenPermissions:n}){const[i,a]=E.useState(!1),l=E.useId(),s=E.useRef(null),o=E.useMemo(()=>mR(e),[e]),c=E.useMemo(()=>new Set(t),[t]),f=n&&t.length>0,u=E.useMemo(()=>t.length===0?"All Projects":t.map(y=>o.get(y)??_s(y)??y).join(", "),[o,t]),p=E.useMemo(()=>{if(t.length===0)return"All Projects";if(t.length===1){const y=t[0];return o.get(y)??_s(y)??y}return`${t.length} projects`},[o,t]);E.useEffect(()=>{if(!i||typeof document>"u"||!document.addEventListener||!document.removeEventListener)return;const y=h=>{var d;const m=h.target;m&&((d=s.current)!=null&&d.contains(m))||a(!1)},v=h=>{h.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",y),document.addEventListener("touchstart",y,{passive:!0}),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("touchstart",y),document.removeEventListener("keydown",v)}},[i]);const _=y=>{const v=new Set(c);v.has(y)?v.delete(y):v.add(y);const h=e.filter(m=>v.has(m));r(h)};return T.jsxs("div",{ref:s,className:"relative",children:[T.jsxs("button",{type:"button","aria-haspopup":"menu","aria-expanded":i,"aria-controls":l,"aria-label":"Filter by project",onClick:()=>a(y=>!y),className:"flex h-6 max-w-[11rem] items-center gap-1 rounded border border-border bg-base px-2 text-[11px] text-primary hover:bg-hover focus:border-accent focus:outline-none",title:u,children:[T.jsx("span",{className:"truncate",children:p}),T.jsx(pf,{className:"h-3 w-3 shrink-0 text-muted"})]}),i&&T.jsxs("div",{id:l,role:"menu",className:"absolute right-0 z-20 mt-1 w-60 rounded border border-border bg-surface p-2 text-xs shadow-lg",children:[T.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover",children:[T.jsx("input",{type:"checkbox",checked:t.length===0,onChange:()=>r([]),className:"h-3.5 w-3.5 accent-approval"}),T.jsx("span",{children:"All Projects"})]}),T.jsx("div",{className:"my-2 h-px bg-border"}),e.length===0?T.jsx("div",{className:"px-2 py-1 text-muted",children:"No projects"}):T.jsx("div",{className:"max-h-48 overflow-y-auto pr-1",children:e.map(y=>{const v=o.get(y)??_s(y)??y;return T.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-primary hover:bg-hover",title:y,children:[T.jsx("input",{type:"checkbox",checked:c.has(y),onChange:()=>_(y),className:"h-3.5 w-3.5 accent-approval"}),T.jsx("span",{className:"truncate",children:v})]},y)})})]}),f&&T.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:y=>{y.stopPropagation(),r([])},children:T.jsx("span",{className:"sr-only",children:"Clear project filters"})})]})}const Gl=new Set(["tool_result","custom_tool_call_output"]),AR=new Set(["text","input_text","output_text"]);function qr(e){return!e||typeof e!="object"?null:e}function At(e){return typeof e=="string"?e:null}function Wo(e){return e==="user"?"user":e==="assistant"?"assistant":e==="system"||e==="developer"?"system":e==="tool"?"tool":"other"}function PR(e){const t=At(e.type)??"",r=qr(e.payload),n=At(r==null?void 0:r.type)??"",i=At(e.source)??At(r==null?void 0:r.source)??"",a=At(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":n==="user_message"||n==="assistant_message"?"codex":"unknown"}function IR(e){const t=qr(e.payload),r=At(t==null?void 0:t.type);return{family:PR(e),rawType:At(e.type)??"unknown",...r?{payloadType:r}:{}}}function bt(e){if(!e)return[];if(typeof e=="string")return e.trim()?[e]:[];if(Array.isArray(e)){const r=[];for(const n of e){if(typeof n=="string"){n.trim()&&r.push(n);continue}const i=qr(n);if(!i)continue;const a=At(i.type);if(a&&Gl.has(a)||a&&!AR.has(a))continue;const l=At(i.text);l&&l.trim()&&r.push(l)}return r}const t=qr(e);if(t){const r=At(t.type);if(r&&Gl.has(r))return[];const n=At(t.text);return n&&n.trim()?[n]:[...bt(t.content),...bt(t.message)]}return[]}function OR(e,t){if(e.type!=="response_item")return[];const r=qr(e.payload);if(!r||r.type!=="message")return[];const n=Wo(r.role);return bt(r.content).map(i=>({kind:"message",role:n,text:i,source:t}))}function BR(e,t){if(e.type!=="event_msg")return[];const r=qr(e.payload);if(!r)return[];const n=At(r.type);let i=null;if(n==="user_message"?i="user":n==="assistant_message"?i="assistant":n==="system_message"?i="system":n==="message"&&(i=Wo(r.role)),!i||!["user","assistant","system"].includes(i))return[];const a=Array.from(new Set([...bt(r.message),...bt(r.content),...bt(r.text)]));return a.length===0?[]:a.map(l=>({kind:"message",role:i,text:l,source:t}))}function NR(e,t){const r=Wo(e.type),n=qr(e.message);if(n){const a=Wo(n.role??e.type);return[...bt(n.content),...bt(n.text),...bt(n.message)].map(s=>({kind:"message",role:a,text:s,source:t}))}return["user","assistant","system"].includes(r)?[...bt(e.content),...bt(e.text)].map(a=>({kind:"message",role:r,text:a,source:t})):[]}function jR(e,t){const r=Wo(e.role);return["user","assistant","system"].includes(r)?[...bt(e.content),...bt(e.message),...bt(e.text)].map(i=>({kind:"message",role:r,text:i,source:t})):[]}function FR(e,t){const r=At(e.type),n=At(e.event);return r!=="tool_use"&&n!=="tool_use"?[]:[{kind:"tool_call",role:"assistant",text:`[Tool: ${At(e.name)??"tool"}]`,source:t}]}function HR(e,t){if(e.type!=="result")return[];const r=At(e.result);return!r||!r.trim()?[]:[{kind:"result",role:"system",text:r,source:t}]}function $R(e,t){const r=qr(e.payload),n=[...bt(e.message),...bt(e.content),...bt(e.text),...bt(r==null?void 0:r.message),...bt(r==null?void 0:r.content)];return n.length===0?[]:n.map(i=>({kind:"unknown",role:"other",text:i,source:t}))}function zR(e,t){const r=At(e.type),n=qr(e.payload),i=At(n==null?void 0:n.type);return r&&Gl.has(r)||i&&Gl.has(i)?[{kind:"tool_result",role:"tool",text:"",source:t}]:[]}function UR(e){const t=qr(e);if(!t)return[];const r=IR(t),n=[...OR(t,r),...BR(t,r),...NR(t,r),...FR(t,r),...HR(t,r),...zR(t,r)];if(n.length>0)return n;const i=jR(t,r);return i.length>0?i:$R(t,r)}function WR(e){const t=e.trim();if(!t)return null;try{const r=JSON.parse(t);return{parsed:!0,events:UR(r),raw:r}}catch{return{parsed:!1,events:[{kind:"unknown",role:"other",text:t,source:{family:"unknown",rawType:"raw_text"}}],raw:e}}}function VR(e){return e==="user"?"user":e==="assistant"?"assistant":e==="system"?"system":"other"}function KR(e){const t=WR(e);if(!t)return[];const r=t.events.map(n=>({type:VR(n.role),content:n.text.trim(),raw:e})).filter(n=>n.content.length>0);return r.length>0?r:!t.parsed&&e.trim()?[{type:"other",content:e.trim(),raw:e}]:[]}function GR({session:e,onClose:t,onResume:r}){const[n,i]=E.useState(!0),[a,l]=E.useState(null),[s,o]=E.useState(null),[c,f]=E.useState(!1),u=E.useRef(null),p=E.useRef(null);E.useEffect(()=>{(async()=>{try{const m=await fetch(`/api/session-preview/${e.sessionId}`);if(!m.ok){const g=await m.json();throw new Error(g.error||"Failed to load preview")}const d=await m.json();o(d)}catch(m){l(m instanceof Error?m.message:"Failed to load preview")}finally{i(!1)}})()},[e.sessionId]),E.useEffect(()=>{u.current&&s&&(u.current.scrollTop=u.current.scrollHeight)},[s,c]),E.useEffect(()=>{const h=m=>{m.key==="Escape"?(m.stopPropagation(),t()):m.key==="Enter"&&!n&&!a&&(m.preventDefault(),r(e.sessionId))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[t,r,e.sessionId,n,a]),E.useEffect(()=>{var h;(h=p.current)==null||h.focus()},[]);const _=e.displayName||_s(e.projectPath)||e.sessionId.slice(0,8),y=sp(e.lastActivityAt),v=(s==null?void 0:s.lines.flatMap(KR).slice(-30))??[];return T.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:h=>{h.target===h.currentTarget&&t()},children:T.jsxs("div",{ref:p,tabIndex:-1,className:"flex max-h-[80vh] w-full max-w-2xl flex-col border border-border bg-elevated",children:[T.jsxs("div",{className:"flex items-center gap-3 border-b border-border px-4 py-3",children:[T.jsx(Cc,{agentType:e.agentType,className:"h-5 w-5 shrink-0 text-muted"}),T.jsxs("div",{className:"min-w-0 flex-1",children:[T.jsx("h2",{id:"preview-title",className:"truncate text-sm font-semibold text-primary",children:_}),T.jsxs("p",{className:"truncate text-xs text-muted",title:e.projectPath,children:[_s(e.projectPath)," · ",y]})]}),T.jsx("button",{type:"button",onClick:()=>f(h=>!h),className:`btn text-xs ${c?"btn-primary":""}`,children:c?"Parsed":"Raw"})]}),T.jsxs("div",{ref:u,className:"flex-1 overflow-y-auto p-4 font-mono text-xs",children:[n&&T.jsx("div",{className:"flex items-center justify-center py-8 text-muted",children:"Loading preview..."}),a&&T.jsx("div",{className:"flex items-center justify-center py-8 text-danger",children:a}),s&&!c&&T.jsx("div",{className:"space-y-2",children:v.length===0?T.jsx("div",{className:"py-8 text-center text-muted",children:"No readable content found. Try raw view."}):v.map((h,m)=>T.jsx("div",{className:`rounded px-2 py-1 ${h.type==="user"?"bg-blue-500/10 text-blue-400":h.type==="assistant"?"bg-emerald-500/10 text-emerald-400":h.type==="system"?"bg-yellow-500/10 text-yellow-400":"text-muted"}`,children:T.jsx("span",{className:"whitespace-pre-wrap break-words",children:h.content.length>500?`${h.content.slice(0,500)}...`:h.content})},m))}),s&&c&&T.jsx("div",{className:"space-y-1",children:s.lines.slice(-50).map((h,m)=>T.jsx("div",{className:"whitespace-pre-wrap break-all text-muted",children:h||" "},m))})]}),T.jsxs("div",{className:"flex items-center justify-end gap-2 border-t border-border px-4 py-3",children:[T.jsx("button",{type:"button",onClick:t,className:"btn",children:"Cancel"}),T.jsx("button",{type:"button",onClick:()=>r(e.sessionId),disabled:n||!!a,className:"btn btn-primary",children:"Resume"})]})]})})}const dv={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 qR(){const[,e]=E.useState(0);E.useEffect(()=>{const t=setInterval(()=>e(r=>r+1),3e4);return()=>clearInterval(t)},[])}function fw({sessions:e,inactiveSessions:t=[],selectedSessionId:r,loading:n,error:i,onSelect:a,onRename:l,onResume:s,onKill:o,onDuplicate:c,onSetPinned:f}){qR();const u=E.useMemo(()=>typeof navigator>"u"?!1:/^((?!chrome|android).)*safari/i.test(navigator.userAgent),[]),[p,_]=E.useState(null),y=pe(G=>G.inactiveSessionsExpanded),v=pe(G=>G.setInactiveSessionsExpanded),[h,m]=E.useState(null),[d,g]=E.useState(20),w=$1(),b=u&&!w;E.useEffect(()=>{y||g(20)},[y]);const x=200,[C,S]=hv(e.length,x),[k,L]=hv(t.length,x,!0),A=E.useRef(new Set(e.map(G=>G.id))),M=E.useRef(new Set(t.map(G=>G.sessionId))),[D,O]=E.useState(new Set);E.useEffect(()=>{var Se;const G=new Set(e.map(ie=>ie.id)),me=new Set(t.map(ie=>ie.sessionId)),J=new Set;for(const ie of G)A.current.has(ie)||J.add(ie);for(const ie of e){const he=(Se=ie.agentSessionId)==null?void 0:Se.trim();he&&M.current.has(he)&&!me.has(he)&&J.add(ie.id)}A.current=G,M.current=me,J.size>0&&O(J)},[e,t]),E.useEffect(()=>{if(D.size===0)return;const G=setTimeout(()=>O(new Set),500);return()=>clearTimeout(G)},[D]);const z=pe(G=>G.shortcutModifier),F=ii(ea(z)),H=pe(G=>G.sessionSortMode),I=pe(G=>G.setSessionSortMode),R=pe(G=>G.sessionSortDirection),P=pe(G=>G.manualSessionOrder),N=pe(G=>G.setManualSessionOrder),j=pe(G=>G.showProjectName),W=pe(G=>G.showLastUserMessage),V=pe(G=>G.showSessionIdPrefix),Z=pe(G=>G.projectFilters),Q=pe(G=>G.setProjectFilters),$=pe(G=>G.hostFilters),B=pe(G=>G.setHostFilters),K=Ke(G=>G.exitingSessions),U=Ke(G=>G.clearExitingSession),te=Ke(G=>G.hostStatuses),Y=Ke(G=>G.remoteAllowControl);SR(e,K,U,x),E.useEffect(()=>{if(P.length===0)return;const G=new Set;for(const J of e)G.add(vo(J)),G.add(J.id);for(const J of t)G.add(J.sessionId);const me=P.filter(J=>G.has(J));me.length!==P.length&&N(me)},[e,t,P,N]);const de=E.useMemo(()=>np(e,{mode:H,direction:R,manualOrder:P}),[e,H,R,P]),re=E.useMemo(()=>fR(e,t),[e,t]),le=E.useMemo(()=>{const G=pR(e,t),me=te.map(ie=>ie.host),J=new Set,Se=[];for(const ie of me)!ie||J.has(ie)||(J.add(ie),Se.push(ie));for(const ie of G)!ie||J.has(ie)||(J.add(ie),Se.push(ie));return Se},[e,t,te]),ne=E.useMemo(()=>le.length>1,[le]),fe=E.useMemo(()=>{let G=de;return Z.length>0&&(G=G.filter(me=>Z.includes(me.projectPath))),$.length>0&&(G=G.filter(me=>$.includes(me.host??""))),G},[de,Z,$]),ge=E.useMemo(()=>{const G=Z.length===0?"all-projects":Z.join("|"),me=$.length===0?"all-hosts":$.join("|");return`${G}::${me}`},[Z,$]),se=E.useRef(new Set(fe.map(G=>G.id))),[oe,ue]=E.useState(new Set);E.useEffect(()=>{const G=new Set(fe.map(J=>J.id)),me=new Set;for(const J of G)se.current.has(J)||D.has(J)||me.add(J);se.current=G,me.size>0&&ue(me)},[fe,D]),E.useEffect(()=>{if(oe.size===0)return;const G=setTimeout(()=>ue(new Set),500);return()=>clearTimeout(G)},[oe]);const ae=E.useMemo(()=>{let G=t;return Z.length>0&&(G=G.filter(me=>Z.includes(me.projectPath))),$.length>0&&(G=G.filter(me=>$.includes(me.host??""))),G},[t,Z,$]),ve=E.useMemo(()=>{if(Z.length===0)return 0;const G=new Set(Z);return e.filter(me=>!G.has(me.projectPath)&&me.status==="permission").length},[e,Z]);E.useEffect(()=>{if(Z.length===0||re.length===0)return;const G=new Set(re),me=Z.filter(J=>G.has(J));me.length!==Z.length&&Q(me)},[Z,re,Q]),E.useEffect(()=>{if($.length===0||le.length===0)return;const G=new Set(le),me=$.filter(J=>G.has(J));me.length!==$.length&&B(me)},[$,le,B]);const Ce=HL(FL(rp,{activationConstraint:{distance:8}})),[Le,je]=E.useState(null),[Fe,Pe]=E.useState(null),[Oe,Ee]=E.useState(!1),q=E.useCallback(G=>{je(G.active.id),Ee(!0)},[]),ee=E.useCallback(G=>{var me;Pe((me=G.over)==null?void 0:me.id)},[]),Ne=E.useCallback(G=>{const{active:me,over:J}=G;if(je(null),Pe(null),!J||me.id===J.id){setTimeout(()=>Ee(!1),100);return}const Se=fe.findIndex(De=>De.id===me.id),ie=fe.findIndex(De=>De.id===J.id);if(Se===-1||ie===-1){setTimeout(()=>Ee(!1),100);return}const he=fe.map(De=>vo(De)),[ke]=he.splice(Se,1);he.splice(ie,0,ke);const Re=de.map(De=>vo(De)),$e=new Set(he);let Ue=0;const Ie=Re.map(De=>{if(!$e.has(De))return De;const et=he[Ue];return Ue+=1,et});H!=="manual"&&I("manual"),N(Ie),setTimeout(()=>Ee(!1),100)},[fe,de,H,I,N]),qe=E.useCallback(()=>{je(null),Pe(null),setTimeout(()=>Ee(!1),100)},[]);E.useEffect(()=>{if(!Le&&!Fe)return;const G=new Set(fe.map(J=>J.id));let me=!1;Le&&!G.has(Le)&&(je(null),me=!0),Fe&&!G.has(Fe)&&(Pe(null),me=!0),me&&Ee(!1)},[fe,Le,Fe]);const Ae=(G,me)=>{l(G,me),_(null)};return T.jsxs("aside",{className:"flex min-h-0 flex-1 flex-col border-r border-border bg-elevated",children:[i&&T.jsx("div",{className:"shrink-0 border-b border-danger/30 bg-danger/10 px-3 py-2 text-xs text-danger",children:i}),T.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[T.jsxs("div",{className:"sticky top-0 z-10 flex h-10 items-center justify-between border-b border-border bg-elevated px-3",children:[T.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted",children:"Sessions"}),T.jsxs("div",{className:"flex items-center gap-4",children:[ne&&T.jsx(DR,{hosts:le,selectedHosts:$,onSelect:B,statuses:te}),T.jsx(MR,{projects:re,selectedProjects:Z,onSelect:Q,hasHiddenPermissions:ve>0}),T.jsx(Qh.span,{className:"w-8 text-right text-xs text-muted",animate:C&&!w?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:S,children:fe.length})]})]}),n?T.jsx("div",{className:"space-y-1 p-2",children:[0,1,2].map(G=>T.jsx("div",{className:"h-14 animate-pulse rounded bg-surface"},G))}):fe.length===0?T.jsx("div",{className:"px-3 py-6 text-center text-xs text-muted",children:"No sessions"}):T.jsx(WT,{sensors:Ce,collisionDetection:VL,onDragStart:q,onDragOver:ee,onDragEnd:Ne,onDragCancel:qe,children:T.jsx(nR,{items:fe.map(G=>G.id),strategy:tR,children:T.jsx("div",{children:T.jsx(q5,{initial:!1,mode:b?"sync":"popLayout",children:fe.map((G,me)=>{const J=D.has(G.id),Se=oe.has(G.id),ie=G.remote===!0,he=G.source==="managed",ke=!ie||Y&&he,Re=Le?fe.findIndex(De=>De.id===Le):-1,Ue=Fe===G.id&&Le!==G.id?Re>me?"above":"below":null,Ie=J||Se;return T.jsx(pw,{session:G,isNew:Ie,exitDuration:x,prefersReducedMotion:w,useSafariLayoutFallback:b,layoutAnimationsDisabled:Oe,isSelected:G.id===r,isEditing:G.id===p,showSessionIdPrefix:V,showProjectName:j,showLastUserMessage:W,showHostInfo:ne,dropIndicator:Ue,onSelect:()=>a(G.id),onStartEdit:ke?()=>_(G.id):void 0,onCancelEdit:()=>_(null),onRename:De=>Ae(G.id,De),onKill:o&&ke?()=>o(G.id):void 0,onDuplicate:c&&ke?()=>c(G.id):void 0,onSetPinned:f&&G.agentSessionId?De=>f(G.agentSessionId.trim(),De):void 0},G.id)})})},ge)})}),ae.length>0&&T.jsxs("div",{className:"border-t border-border",children:[T.jsxs("button",{type:"button",onClick:()=>v(!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:[T.jsxs("span",{className:"flex items-center gap-2",children:[y?T.jsx(pf,{className:"h-4 w-4"}):T.jsx(gC,{className:"h-4 w-4"}),"Inactive Sessions"]}),T.jsx(Qh.span,{className:"w-8 text-right text-xs",animate:k&&!w?{scale:[1,1.3,1]}:{},transition:{duration:.3},onAnimationComplete:L,children:ae.length})]}),y&&T.jsxs("div",{className:"py-1",children:[ae.slice(0,d).map(G=>T.jsx(TR,{session:G,showSessionIdPrefix:V,showProjectName:j,showLastUserMessage:W,onResume:me=>s==null?void 0:s(me),onPreview:m,onSetPinned:f},G.sessionId)),ae.length>d&&T.jsxs("button",{type:"button",onClick:()=>g(G=>G+20),className:"w-full px-3 py-2 text-center text-xs text-muted hover:text-primary hover:bg-hover",children:["Show more (",ae.length-d," remaining)"]})]})]})]}),T.jsx("div",{className:"hidden shrink-0 border-t border-border px-3 py-2 md:block",children:T.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 text-[10px] text-muted",children:[T.jsxs("span",{children:[F,"[ ] nav"]}),T.jsxs("span",{children:[F,"N new"]}),T.jsxs("span",{children:[F,"X kill"]})]})}),h&&T.jsx(GR,{session:h,onClose:()=>m(null),onResume:G=>{m(null),s==null||s(G)}})]})}const pw=E.forwardRef(function({session:t,isNew:r,exitDuration:n,prefersReducedMotion:i,useSafariLayoutFallback:a,layoutAnimationsDisabled:l,isSelected:s,isEditing:o,showSessionIdPrefix:c,showProjectName:f,showLastUserMessage:u,showHostInfo:p,dropIndicator:_,onSelect:y,onStartEdit:v,onCancelEdit:h,onRename:m,onKill:d,onDuplicate:g,onSetPinned:w},b){const{attributes:x,listeners:C,setNodeRef:S,transform:k,transition:L,isDragging:A}=uR({id:t.id,animateLayoutChanges:({isSorting:F,wasDragging:H})=>F||H}),M=zo.Transform.toString(k),O={...!!(i&&M)?{transform:M,transition:L}:{},zIndex:A?10:void 0,opacity:A?.9:void 0},z=E.useCallback(F=>{S(F),typeof b=="function"?b(F):b&&(b.current=F)},[S,b]);return T.jsxs(Qh.div,{ref:z,style:{...O,overflow:"hidden"},className:"relative",layout:!i&&!A&&!l&&!r?!a:!1,transformTemplate:(F,H)=>gR({useSafariLayoutFallback:a,isDragging:A,dndTransform:M,generatedTransform:H}),initial:i||!r?!1:a?{opacity:0}:{opacity:0,scale:.97},animate:i?{opacity:1}:r?a?{opacity:1}:{opacity:1,scale:[1.02,.99,1]}:{opacity:1,scale:1},exit:i?{opacity:0}:a?{opacity:0,height:0}:{opacity:0,height:0,scale:.97},transition:i?{duration:0}:a?{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"}},...x,...C,children:[_==="above"&&T.jsx("div",{className:"absolute -top-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent"}),T.jsx(XR,{session:t,isSelected:s,isEditing:o,showSessionIdPrefix:c,showProjectName:f,showLastUserMessage:u,showHostInfo:p,isDragging:A,onSelect:y,onStartEdit:v,onCancelEdit:h,onRename:m,onKill:d,onDuplicate:g,onSetPinned:w}),_==="below"&&T.jsx("div",{className:"absolute -bottom-px left-3 right-3 h-0.5 border-t-2 border-dashed border-accent"})]})});pw.displayName="SortableSessionItem";function XR({session:e,isSelected:t,isEditing:r,showSessionIdPrefix:n,showProjectName:i,showLastUserMessage:a,showHostInfo:l,isDragging:s=!1,onSelect:o,onStartEdit:c,onCancelEdit:f,onRename:u,onKill:p,onDuplicate:_,onSetPinned:y}){var Q,$,B,K;const v=sp(e.lastActivity),h=E.useRef(null),m=E.useRef(null),d=((Q=e.agentSessionName)==null?void 0:Q.trim())||(($=e.name)==null?void 0:$.trim())||e.id,[g,w]=E.useState(d),b=E.useRef(null),[x,C]=E.useState(null),S=_s(e.projectPath),k=(B=e.host)==null?void 0:B.trim(),L=e.status==="permission",A=(K=e.agentSessionId)==null?void 0:K.trim(),M=n&&A?cw(A):"",D=i&&!!S,O=l&&!!k,z=a&&!!e.lastUserMessage,F=E.useRef(e.status),[H,I]=E.useState(!1);E.useEffect(()=>{const U=F.current,te=e.status;U==="working"&&te==="waiting"?I(!0):F.current=te},[e.status]);const R=()=>{I(!1),F.current=e.status};E.useEffect(()=>{r&&h.current&&(h.current.focus(),h.current.select())},[r]),E.useEffect(()=>{w(d)},[d]);const P=()=>{const U=g.trim();U&&U!==d?u(U):f()},N=U=>{U.key==="Enter"?(U.preventDefault(),P()):U.key==="Escape"&&(U.preventDefault(),w(d),f())},j=E.useRef(null),W=U=>{if(s)return;const te=U.touches[0];j.current={x:te.clientX,y:te.clientY},b.current=setTimeout(()=>{j.current&&C(j.current)},500)},V=()=>{b.current&&(clearTimeout(b.current),b.current=null)};E.useEffect(()=>{if(!x)return;const U=Y=>{m.current&&!m.current.contains(Y.target)&&C(null)},te=Y=>{Y.key==="Escape"&&C(null)};return document.addEventListener("mousedown",U),document.addEventListener("touchstart",U),document.addEventListener("keydown",te),()=>{document.removeEventListener("mousedown",U),document.removeEventListener("touchstart",U),document.removeEventListener("keydown",te)}},[x]);const Z=U=>{U.preventDefault(),U.stopPropagation(),C({x:U.clientX,y:U.clientY})};return T.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:o,onKeyDown:U=>{(U.key==="Enter"||U.key===" ")&&o()},onContextMenu:Z,onTouchStart:W,onTouchEnd:V,onTouchCancel:V,children:[T.jsxs("div",{className:"flex flex-col gap-0.5 pl-0.5",children:[T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx(Cc,{agentType:e.agentType,command:e.command,className:"h-3.5 w-3.5 shrink-0 text-muted"}),r?T.jsx("input",{ref:h,type:"text",value:g,onChange:U=>w(U.target.value),onBlur:P,onKeyDown:N,onClick:U=>U.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"}):T.jsx("span",{className:"min-w-0 flex-1 truncate text-sm font-medium text-primary",children:d}),e.isPinned&&T.jsx(Ol,{className:"h-3 w-3 shrink-0 text-primary","aria-label":"Pinned",title:"Pinned - will auto-resume on server restart"}),M&&T.jsx("span",{className:"shrink-0 text-[11px] font-mono text-muted",title:A,children:M}),L?T.jsx("span",{className:`ml-1 flex shrink-0 items-center justify-center rounded-full px-1.5 py-0.5 ${dv[e.status]} pulse-approval`,onAnimationEnd:R,children:T.jsx(LC,{className:"h-3 w-3","aria-label":"Needs input"})}):T.jsx("span",{className:`ml-1 shrink-0 rounded-full px-1.5 py-0.5 text-right text-xs tabular-nums ${dv[e.status]}${H?" pulse-complete":""}`,onAnimationEnd:R,children:v})]}),(D||O||z)&&T.jsxs("div",{className:"flex flex-wrap items-center gap-1 pl-[1.375rem]",children:[O&&T.jsx(RR,{name:k}),D&&T.jsx(dw,{name:S,fullPath:e.projectPath}),z&&T.jsxs("span",{className:"line-clamp-2 text-xs italic text-muted",children:['"',e.lastUserMessage.length>200?e.lastUserMessage.slice(0,200)+"…":e.lastUserMessage,'"']})]})]}),x&&T.jsxs("div",{ref:m,className:"fixed z-50 min-w-[160px] rounded-md border border-border bg-elevated shadow-lg py-1",style:{left:x.x,top:x.y},role:"menu",children:[c&&T.jsxs("button",{onClick:U=>{U.stopPropagation(),C(null),c()},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:[T.jsx(sy,{width:14,height:14}),"Rename"]}),_&&T.jsxs("button",{onClick:U=>{U.stopPropagation(),C(null),_()},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:[T.jsx(ny,{width:14,height:14}),"Duplicate"]}),y&&T.jsxs("button",{onClick:U=>{U.stopPropagation(),C(null),y(!e.isPinned)},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.isPinned?"Remove from auto-resume list":"Auto-resume on server restart",children:[T.jsx(Ol,{width:14,height:14}),e.isPinned?"Unpin":"Pin"]}),e.logFilePath&&T.jsxs("button",{onClick:U=>{U.stopPropagation(),C(null),e.logFilePath&&uw(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:[T.jsx(iy,{width:14,height:14}),"Copy Log Path"]}),p&&T.jsxs(T.Fragment,{children:[T.jsx("div",{className:"my-1 border-t border-border"}),T.jsxs("button",{onClick:U=>{U.stopPropagation(),C(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:[T.jsx(Dh,{width:14,height:14}),"Kill Session"]})]})]})]})}const sd={debug:0,info:1,warn:2,error:3};let mw="info";function YR(e){const t=e.toLowerCase();t in sd&&(mw=t)}function Ge(e,t,r="debug"){if(!(sd[r]<sd[mw]))try{fetch("/api/client-log",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:e,data:t,level:r})}).catch(()=>{})}catch{}}var gw={exports:{}};(function(e,t){(function(r,n){e.exports=n()})(globalThis,()=>(()=>{var r={4567:function(l,s,o){var c=this&&this.__decorate||function(d,g,w,b){var x,C=arguments.length,S=C<3?g:b===null?b=Object.getOwnPropertyDescriptor(g,w):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(d,g,w,b);else for(var k=d.length-1;k>=0;k--)(x=d[k])&&(S=(C<3?x(S):C>3?x(g,w,S):x(g,w))||S);return C>3&&S&&Object.defineProperty(g,w,S),S},f=this&&this.__param||function(d,g){return function(w,b){g(w,b,d)}};Object.defineProperty(s,"__esModule",{value:!0}),s.AccessibilityManager=void 0;const u=o(9042),p=o(9924),_=o(844),y=o(4725),v=o(2585),h=o(3656);let m=s.AccessibilityManager=class extends _.Disposable{constructor(d,g,w,b){super(),this._terminal=d,this._coreBrowserService=w,this._renderService=b,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 x=0;x<this._terminal.rows;x++)this._rowElements[x]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[x]);if(this._topBoundaryFocusListener=x=>this._handleBoundaryFocus(x,0),this._bottomBoundaryFocusListener=x=>this._handleBoundaryFocus(x,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 p.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize(x=>this._handleResize(x.rows))),this.register(this._terminal.onRender(x=>this._refreshRows(x.start,x.end))),this.register(this._terminal.onScroll(()=>this._refreshRows())),this.register(this._terminal.onA11yChar(x=>this._handleChar(x))),this.register(this._terminal.onLineFeed(()=>this._handleChar(`
53
53
  `))),this.register(this._terminal.onA11yTab(x=>this._handleTab(x))),this.register(this._terminal.onKey(x=>this._handleKey(x.key))),this.register(this._terminal.onBlur(()=>this._clearLiveRegion())),this.register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this.register((0,h.addDisposableDomListener)(document,"selectionchange",()=>this._handleSelectionChange())),this.register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRows(),this.register((0,_.toDisposable)(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(d){for(let g=0;g<d;g++)this._handleChar(" ")}_handleChar(d){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==d&&(this._charsToAnnounce+=d):this._charsToAnnounce+=d,d===`
54
54
  `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=u.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(d){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(d)||this._charsToConsume.push(d)}_refreshRows(d,g){this._liveRegionDebouncer.refresh(d,g,this._terminal.rows)}_renderRows(d,g){const w=this._terminal.buffer,b=w.lines.length.toString();for(let x=d;x<=g;x++){const C=w.lines.get(w.ydisp+x),S=[],k=(C==null?void 0:C.translateToString(!0,void 0,void 0,S))||"",L=(w.ydisp+x+1).toString(),A=this._rowElements[x];A&&(k.length===0?(A.innerText=" ",this._rowColumns.set(A,[0,1])):(A.textContent=k,this._rowColumns.set(A,S)),A.setAttribute("aria-posinset",L),A.setAttribute("aria-setsize",b))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(d,g){const w=d.target,b=this._rowElements[g===0?1:this._rowElements.length-2];if(w.getAttribute("aria-posinset")===(g===0?"1":`${this._terminal.buffer.lines.length}`)||d.relatedTarget!==b)return;let x,C;if(g===0?(x=w,C=this._rowElements.pop(),this._rowContainer.removeChild(C)):(x=this._rowElements.shift(),C=w,this._rowContainer.removeChild(x)),x.removeEventListener("focus",this._topBoundaryFocusListener),C.removeEventListener("focus",this._bottomBoundaryFocusListener),g===0){const S=this._createAccessibilityTreeNode();this._rowElements.unshift(S),this._rowContainer.insertAdjacentElement("afterbegin",S)}else{const S=this._createAccessibilityTreeNode();this._rowElements.push(S),this._rowContainer.appendChild(S)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(g===0?-1:1),this._rowElements[g===0?1:this._rowElements.length-2].focus(),d.preventDefault(),d.stopImmediatePropagation()}_handleSelectionChange(){var k;if(this._rowElements.length===0)return;const d=document.getSelection();if(!d)return;if(d.isCollapsed)return void(this._rowContainer.contains(d.anchorNode)&&this._terminal.clearSelection());if(!d.anchorNode||!d.focusNode)return void console.error("anchorNode and/or focusNode are null");let g={node:d.anchorNode,offset:d.anchorOffset},w={node:d.focusNode,offset:d.focusOffset};if((g.node.compareDocumentPosition(w.node)&Node.DOCUMENT_POSITION_PRECEDING||g.node===w.node&&g.offset>w.offset)&&([g,w]=[w,g]),g.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(g={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(g.node))return;const b=this._rowElements.slice(-1)[0];if(w.node.compareDocumentPosition(b)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(w={node:b,offset:((k=b.textContent)==null?void 0:k.length)??0}),!this._rowContainer.contains(w.node))return;const x=({node:L,offset:A})=>{const M=L instanceof Text?L.parentNode:L;let D=parseInt(M==null?void 0:M.getAttribute("aria-posinset"),10)-1;if(isNaN(D))return console.warn("row is invalid. Race condition?"),null;const O=this._rowColumns.get(M);if(!O)return console.warn("columns is null. Race condition?"),null;let z=A<O.length?O[A]:O.slice(-1)[0]+1;return z>=this._terminal.cols&&(++D,z=0),{row:D,column:z}},C=x(g),S=x(w);if(C&&S){if(C.row>S.row||C.row===S.row&&C.column>=S.column)throw new Error("invalid range");this._terminal.select(C.column,C.row,(S.row-C.row)*this._terminal.cols-C.column+S.column)}}_handleResize(d){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let g=this._rowContainer.children.length;g<this._terminal.rows;g++)this._rowElements[g]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[g]);for(;this._rowElements.length>d;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const d=this._coreBrowserService.mainDocument.createElement("div");return d.setAttribute("role","listitem"),d.tabIndex=-1,this._refreshRowDimensions(d),d}_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 d=0;d<this._terminal.rows;d++)this._refreshRowDimensions(this._rowElements[d])}}_refreshRowDimensions(d){d.style.height=`${this._renderService.dimensions.css.cell.height}px`}};s.AccessibilityManager=m=c([f(1,v.IInstantiationService),f(2,y.ICoreBrowserService),f(3,y.IRenderService)],m)},3614:(l,s)=>{function o(p){return p.replace(/\r?\n/g,"\r")}function c(p,_){return _?"\x1B[200~"+p+"\x1B[201~":p}function f(p,_,y,v){p=c(p=o(p),y.decPrivateModes.bracketedPasteMode&&v.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(p,!0),_.value=""}function u(p,_,y){const v=y.getBoundingClientRect(),h=p.clientX-v.left-10,m=p.clientY-v.top-10;_.style.width="20px",_.style.height="20px",_.style.left=`${h}px`,_.style.top=`${m}px`,_.style.zIndex="1000",_.focus()}Object.defineProperty(s,"__esModule",{value:!0}),s.rightClickHandler=s.moveTextAreaUnderMouseCursor=s.paste=s.handlePasteEvent=s.copyHandler=s.bracketTextForPaste=s.prepareTextForTerminal=void 0,s.prepareTextForTerminal=o,s.bracketTextForPaste=c,s.copyHandler=function(p,_){p.clipboardData&&p.clipboardData.setData("text/plain",_.selectionText),p.preventDefault()},s.handlePasteEvent=function(p,_,y,v){p.stopPropagation(),p.clipboardData&&f(p.clipboardData.getData("text/plain"),_,y,v)},s.paste=f,s.moveTextAreaUnderMouseCursor=u,s.rightClickHandler=function(p,_,y,v,h){u(p,_,y),h&&v.rightClickSelect(p),_.value=v.selectionText,_.select()}},7239:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ColorContrastCache=void 0;const c=o(1505);s.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(f,u,p){this._css.set(f,u,p)}getCss(f,u){return this._css.get(f,u)}setColor(f,u,p){this._color.set(f,u,p)}getColor(f,u){return this._color.get(f,u)}clear(){this._color.clear(),this._css.clear()}}},3656:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.addDisposableDomListener=void 0,s.addDisposableDomListener=function(o,c,f,u){o.addEventListener(c,f,u);let p=!1;return{dispose:()=>{p||(p=!0,o.removeEventListener(c,f,u))}}}},3551:function(l,s,o){var c=this&&this.__decorate||function(m,d,g,w){var b,x=arguments.length,C=x<3?d:w===null?w=Object.getOwnPropertyDescriptor(d,g):w;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(m,d,g,w);else for(var S=m.length-1;S>=0;S--)(b=m[S])&&(C=(x<3?b(C):x>3?b(d,g,C):b(d,g))||C);return x>3&&C&&Object.defineProperty(d,g,C),C},f=this&&this.__param||function(m,d){return function(g,w){d(g,w,m)}};Object.defineProperty(s,"__esModule",{value:!0}),s.Linkifier=void 0;const u=o(3656),p=o(8460),_=o(844),y=o(2585),v=o(4725);let h=s.Linkifier=class extends _.Disposable{get currentLink(){return this._currentLink}constructor(m,d,g,w,b){super(),this._element=m,this._mouseService=d,this._renderService=g,this._bufferService=w,this._linkProviderService=b,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,_.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,_.toDisposable)(()=>{var x;this._lastMouseEvent=void 0,(x=this._activeProviderReplies)==null||x.clear()})),this.register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this.register((0,u.addDisposableDomListener)(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this.register((0,u.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,u.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(m){this._lastMouseEvent=m;const d=this._positionFromMouseEvent(m,this._element,this._mouseService);if(!d)return;this._isMouseOut=!1;const g=m.composedPath();for(let w=0;w<g.length;w++){const b=g[w];if(b.classList.contains("xterm"))break;if(b.classList.contains("xterm-hover"))return}this._lastBufferCell&&d.x===this._lastBufferCell.x&&d.y===this._lastBufferCell.y||(this._handleHover(d),this._lastBufferCell=d)}_handleHover(m){if(this._activeLine!==m.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(m,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,m)||(this._clearCurrentLink(),this._askForLink(m,!0))}_askForLink(m,d){var w,b;this._activeProviderReplies&&d||((w=this._activeProviderReplies)==null||w.forEach(x=>{x==null||x.forEach(C=>{C.link.dispose&&C.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=m.y);let g=!1;for(const[x,C]of this._linkProviderService.linkProviders.entries())d?(b=this._activeProviderReplies)!=null&&b.get(x)&&(g=this._checkLinkProviderResult(x,m,g)):C.provideLinks(m.y,S=>{var L,A;if(this._isMouseOut)return;const k=S==null?void 0:S.map(M=>({link:M}));(L=this._activeProviderReplies)==null||L.set(x,k),g=this._checkLinkProviderResult(x,m,g),((A=this._activeProviderReplies)==null?void 0:A.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(m.y,this._activeProviderReplies)})}_removeIntersectingLinks(m,d){const g=new Set;for(let w=0;w<d.size;w++){const b=d.get(w);if(b)for(let x=0;x<b.length;x++){const C=b[x],S=C.link.range.start.y<m?0:C.link.range.start.x,k=C.link.range.end.y>m?this._bufferService.cols:C.link.range.end.x;for(let L=S;L<=k;L++){if(g.has(L)){b.splice(x--,1);break}g.add(L)}}}}_checkLinkProviderResult(m,d,g){var x;if(!this._activeProviderReplies)return g;const w=this._activeProviderReplies.get(m);let b=!1;for(let C=0;C<m;C++)this._activeProviderReplies.has(C)&&!this._activeProviderReplies.get(C)||(b=!0);if(!b&&w){const C=w.find(S=>this._linkAtPosition(S.link,d));C&&(g=!0,this._handleNewLink(C))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!g)for(let C=0;C<this._activeProviderReplies.size;C++){const S=(x=this._activeProviderReplies.get(C))==null?void 0:x.find(k=>this._linkAtPosition(k.link,d));if(S){g=!0,this._handleNewLink(S);break}}return g}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(m){if(!this._currentLink)return;const d=this._positionFromMouseEvent(m,this._element,this._mouseService);d&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,d)&&this._currentLink.link.activate(m,this._currentLink.link.text)}_clearCurrentLink(m,d){this._currentLink&&this._lastMouseEvent&&(!m||!d||this._currentLink.link.range.start.y>=m&&this._currentLink.link.range.end.y<=d)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,_.disposeArray)(this._linkCacheDisposables))}_handleNewLink(m){if(!this._lastMouseEvent)return;const d=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);d&&this._linkAtPosition(m.link,d)&&(this._currentLink=m,this._currentLink.state={decorations:{underline:m.link.decorations===void 0||m.link.decorations.underline,pointerCursor:m.link.decorations===void 0||m.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,m.link,this._lastMouseEvent),m.link.decorations={},Object.defineProperties(m.link.decorations,{pointerCursor:{get:()=>{var g,w;return(w=(g=this._currentLink)==null?void 0:g.state)==null?void 0:w.decorations.pointerCursor},set:g=>{var w;(w=this._currentLink)!=null&&w.state&&this._currentLink.state.decorations.pointerCursor!==g&&(this._currentLink.state.decorations.pointerCursor=g,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",g))}},underline:{get:()=>{var g,w;return(w=(g=this._currentLink)==null?void 0:g.state)==null?void 0:w.decorations.underline},set:g=>{var w,b,x;(w=this._currentLink)!=null&&w.state&&((x=(b=this._currentLink)==null?void 0:b.state)==null?void 0:x.decorations.underline)!==g&&(this._currentLink.state.decorations.underline=g,this._currentLink.state.isHovered&&this._fireUnderlineEvent(m.link,g))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(g=>{if(!this._currentLink)return;const w=g.start===0?0:g.start+1+this._bufferService.buffer.ydisp,b=this._bufferService.buffer.ydisp+1+g.end;if(this._currentLink.link.range.start.y>=w&&this._currentLink.link.range.end.y<=b&&(this._clearCurrentLink(w,b),this._lastMouseEvent)){const x=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);x&&this._askForLink(x,!1)}})))}_linkHover(m,d,g){var w;(w=this._currentLink)!=null&&w.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!0),this._currentLink.state.decorations.pointerCursor&&m.classList.add("xterm-cursor-pointer")),d.hover&&d.hover(g,d.text)}_fireUnderlineEvent(m,d){const g=m.range,w=this._bufferService.buffer.ydisp,b=this._createLinkUnderlineEvent(g.start.x-1,g.start.y-w-1,g.end.x,g.end.y-w-1,void 0);(d?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(b)}_linkLeave(m,d,g){var w;(w=this._currentLink)!=null&&w.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(d,!1),this._currentLink.state.decorations.pointerCursor&&m.classList.remove("xterm-cursor-pointer")),d.leave&&d.leave(g,d.text)}_linkAtPosition(m,d){const g=m.range.start.y*this._bufferService.cols+m.range.start.x,w=m.range.end.y*this._bufferService.cols+m.range.end.x,b=d.y*this._bufferService.cols+d.x;return g<=b&&b<=w}_positionFromMouseEvent(m,d,g){const w=g.getCoords(m,d,this._bufferService.cols,this._bufferService.rows);if(w)return{x:w[0],y:w[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(m,d,g,w,b){return{x1:m,y1:d,x2:g,y2:w,cols:this._bufferService.cols,fg:b}}};s.Linkifier=h=c([f(1,v.IMouseService),f(2,v.IRenderService),f(3,y.IBufferService),f(4,v.ILinkProviderService)],h)},9042:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.tooMuchOutput=s.promptLabel=void 0,s.promptLabel="Terminal input",s.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(l,s,o){var c=this&&this.__decorate||function(v,h,m,d){var g,w=arguments.length,b=w<3?h:d===null?d=Object.getOwnPropertyDescriptor(h,m):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")b=Reflect.decorate(v,h,m,d);else for(var x=v.length-1;x>=0;x--)(g=v[x])&&(b=(w<3?g(b):w>3?g(h,m,b):g(h,m))||b);return w>3&&b&&Object.defineProperty(h,m,b),b},f=this&&this.__param||function(v,h){return function(m,d){h(m,d,v)}};Object.defineProperty(s,"__esModule",{value:!0}),s.OscLinkProvider=void 0;const u=o(511),p=o(2585);let _=s.OscLinkProvider=class{constructor(v,h,m){this._bufferService=v,this._optionsService=h,this._oscLinkService=m}provideLinks(v,h){var k;const m=this._bufferService.buffer.lines.get(v-1);if(!m)return void h(void 0);const d=[],g=this._optionsService.rawOptions.linkHandler,w=new u.CellData,b=m.getTrimmedLength();let x=-1,C=-1,S=!1;for(let L=0;L<b;L++)if(C!==-1||m.hasContent(L)){if(m.loadCell(L,w),w.hasExtendedAttrs()&&w.extended.urlId){if(C===-1){C=L,x=w.extended.urlId;continue}S=w.extended.urlId!==x}else C!==-1&&(S=!0);if(S||C!==-1&&L===b-1){const A=(k=this._oscLinkService.getLinkData(x))==null?void 0:k.uri;if(A){const M={start:{x:C+1,y:v},end:{x:L+(S||L!==b-1?0:1),y:v}};let D=!1;if(!(g!=null&&g.allowNonHttpProtocols))try{const O=new URL(A);["http:","https:"].includes(O.protocol)||(D=!0)}catch{D=!0}D||d.push({text:A,range:M,activate:(O,z)=>g?g.activate(O,z,M):y(0,z),hover:(O,z)=>{var F;return(F=g==null?void 0:g.hover)==null?void 0:F.call(g,O,z,M)},leave:(O,z)=>{var F;return(F=g==null?void 0:g.leave)==null?void 0:F.call(g,O,z,M)}})}S=!1,w.hasExtendedAttrs()&&w.extended.urlId?(C=L,x=w.extended.urlId):(C=-1,x=-1)}}h(d)}};function y(v,h){if(confirm(`Do you want to navigate to ${h}?
55
55
 
@@ -125,7 +125,7 @@ out vec4 outColor;
125
125
 
126
126
  void main() {
127
127
  outColor = v_color;
128
- }`)),this.register((0,f.toDisposable)(()=>M.deleteProgram(this._program))),this._projectionLocation=(0,c.throwIfFalsy)(M.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=M.createVertexArray(),M.bindVertexArray(this._vertexArrayObject);const D=new Float32Array([0,0,1,0,0,1,1,1]),O=M.createBuffer();this.register((0,f.toDisposable)(()=>M.deleteBuffer(O))),M.bindBuffer(M.ARRAY_BUFFER,O),M.bufferData(M.ARRAY_BUFFER,D,M.STATIC_DRAW),M.enableVertexAttribArray(3),M.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);const z=new Uint8Array([0,1,2,3]),F=M.createBuffer();this.register((0,f.toDisposable)(()=>M.deleteBuffer(F))),M.bindBuffer(M.ELEMENT_ARRAY_BUFFER,F),M.bufferData(M.ELEMENT_ARRAY_BUFFER,z,M.STATIC_DRAW),this._attributesBuffer=(0,c.throwIfFalsy)(M.createBuffer()),this.register((0,f.toDisposable)(()=>M.deleteBuffer(this._attributesBuffer))),M.bindBuffer(M.ARRAY_BUFFER,this._attributesBuffer),M.enableVertexAttribArray(0),M.vertexAttribPointer(0,2,M.FLOAT,!1,_,0),M.vertexAttribDivisor(0,1),M.enableVertexAttribArray(1),M.vertexAttribPointer(1,2,M.FLOAT,!1,_,2*Float32Array.BYTES_PER_ELEMENT),M.vertexAttribDivisor(1,1),M.enableVertexAttribArray(2),M.vertexAttribPointer(2,4,M.FLOAT,!1,_,4*Float32Array.BYTES_PER_ELEMENT),M.vertexAttribDivisor(2,1),this._updateCachedColors(A.colors),this.register(this._themeService.onChangeColors(H=>{this._updateCachedColors(H),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(S){const k=this._gl;k.useProgram(this._program),k.bindVertexArray(this._vertexArrayObject),k.uniformMatrix4fv(this._projectionLocation,!1,p.PROJECTION_MATRIX),k.bindBuffer(k.ARRAY_BUFFER,this._attributesBuffer),k.bufferData(k.ARRAY_BUFFER,S.attributes,k.DYNAMIC_DRAW),k.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,k.UNSIGNED_BYTE,0,S.count)}handleResize(){this._updateViewportRectangle()}setDimensions(S){this._dimensions=S}_updateCachedColors(S){this._bgFloat=this._colorToFloat32Array(S.background),this._cursorFloat=this._colorToFloat32Array(S.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(S){const k=this._terminal,L=this._vertices;let A,M,D,O,z,F,H,I,R,P,N,j=1;for(A=0;A<k.rows;A++){for(D=-1,O=0,z=0,F=!1,M=0;M<k.cols;M++)H=(A*k.cols+M)*u.RENDER_MODEL_INDICIES_PER_CELL,I=S.cells[H+u.RENDER_MODEL_BG_OFFSET],R=S.cells[H+u.RENDER_MODEL_FG_OFFSET],P=!!(67108864&R),(I!==O||R!==z&&(F||P))&&((O!==0||F&&z!==0)&&(N=8*j++,this._updateRectangle(L,N,z,O,D,M,A)),D=M,O=I,z=R,F=P);(O!==0||F&&z!==0)&&(N=8*j++,this._updateRectangle(L,N,z,O,D,k.cols,A))}L.count=j}updateCursor(S){const k=this._verticesCursor,L=S.cursor;if(!L||L.style==="block")return void(k.count=0);let A,M=0;L.style!=="bar"&&L.style!=="outline"||(A=8*M++,this._addRectangleFloat(k.attributes,A,L.x*this._dimensions.device.cell.width,L.y*this._dimensions.device.cell.height,L.style==="bar"?L.dpr*L.cursorWidth:L.dpr,this._dimensions.device.cell.height,this._cursorFloat)),L.style!=="underline"&&L.style!=="outline"||(A=8*M++,this._addRectangleFloat(k.attributes,A,L.x*this._dimensions.device.cell.width,(L.y+1)*this._dimensions.device.cell.height-L.dpr,L.width*this._dimensions.device.cell.width,L.dpr,this._cursorFloat)),L.style==="outline"&&(A=8*M++,this._addRectangleFloat(k.attributes,A,L.x*this._dimensions.device.cell.width,L.y*this._dimensions.device.cell.height,L.width*this._dimensions.device.cell.width,L.dpr,this._cursorFloat),A=8*M++,this._addRectangleFloat(k.attributes,A,(L.x+L.width)*this._dimensions.device.cell.width-L.dpr,L.y*this._dimensions.device.cell.height,L.dpr,this._dimensions.device.cell.height,this._cursorFloat)),k.count=M}_updateRectangle(S,k,L,A,M,D,O){if(67108864&L)switch(50331648&L){case 16777216:case 33554432:v=this._themeService.colors.ansi[255&L].rgba;break;case 50331648:v=(16777215&L)<<8;break;default:v=this._themeService.colors.foreground.rgba}else switch(50331648&A){case 16777216:case 33554432:v=this._themeService.colors.ansi[255&A].rgba;break;case 50331648:v=(16777215&A)<<8;break;default:v=this._themeService.colors.background.rgba}S.attributes.length<k+4&&(S.attributes=(0,p.expandFloat32Array)(S.attributes,this._terminal.rows*this._terminal.cols*8)),h=M*this._dimensions.device.cell.width,m=O*this._dimensions.device.cell.height,d=(v>>24&255)/255,g=(v>>16&255)/255,w=(v>>8&255)/255,b=1,this._addRectangle(S.attributes,k,h,m,(D-M)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,d,g,w,b)}_addRectangle(S,k,L,A,M,D,O,z,F,H){S[k]=L/this._dimensions.device.canvas.width,S[k+1]=A/this._dimensions.device.canvas.height,S[k+2]=M/this._dimensions.device.canvas.width,S[k+3]=D/this._dimensions.device.canvas.height,S[k+4]=O,S[k+5]=z,S[k+6]=F,S[k+7]=H}_addRectangleFloat(S,k,L,A,M,D,O){S[k]=L/this._dimensions.device.canvas.width,S[k+1]=A/this._dimensions.device.canvas.height,S[k+2]=M/this._dimensions.device.canvas.width,S[k+3]=D/this._dimensions.device.canvas.height,S[k+4]=O[0],S[k+5]=O[1],S[k+6]=O[2],S[k+7]=O[3]}_colorToFloat32Array(S){return new Float32Array([(S.rgba>>24&255)/255,(S.rgba>>16&255)/255,(S.rgba>>8&255)/255,(255&S.rgba)/255])}}s.RectangleRenderer=x},310:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.RenderModel=s.COMBINED_CHAR_BIT_MASK=s.RENDER_MODEL_EXT_OFFSET=s.RENDER_MODEL_FG_OFFSET=s.RENDER_MODEL_BG_OFFSET=s.RENDER_MODEL_INDICIES_PER_CELL=void 0;const c=o(296);s.RENDER_MODEL_INDICIES_PER_CELL=4,s.RENDER_MODEL_BG_OFFSET=1,s.RENDER_MODEL_FG_OFFSET=2,s.RENDER_MODEL_EXT_OFFSET=3,s.COMBINED_CHAR_BIT_MASK=2147483648,s.RenderModel=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=(0,c.createSelectionRenderModel)()}resize(f,u){const p=f*u*s.RENDER_MODEL_INDICIES_PER_CELL;p!==this.cells.length&&(this.cells=new Uint32Array(p),this.lineLengths=new Uint32Array(u))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}}},666:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.JoinedCellData=s.WebglRenderer=void 0;const c=o(820),f=o(274),u=o(627),p=o(457),_=o(56),y=o(374),v=o(345),h=o(859),m=o(147),d=o(782),g=o(855),w=o(965),b=o(742),x=o(310),C=o(733);class S extends h.Disposable{constructor(M,D,O,z,F,H,I,R,P){super(),this._terminal=M,this._characterJoinerService=D,this._charSizeService=O,this._coreBrowserService=z,this._coreService=F,this._decorationService=H,this._optionsService=I,this._themeService=R,this._cursorBlinkStateManager=new h.MutableDisposable,this._charAtlasDisposable=this.register(new h.MutableDisposable),this._observerDisposable=this.register(new h.MutableDisposable),this._model=new x.RenderModel,this._workCell=new d.CellData,this._workCell2=new d.CellData,this._rectangleRenderer=this.register(new h.MutableDisposable),this._glyphRenderer=this.register(new h.MutableDisposable),this._onChangeTextureAtlas=this.register(new v.EventEmitter),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this.register(new v.EventEmitter),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this.register(new v.EventEmitter),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this.register(new v.EventEmitter),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this.register(new v.EventEmitter),this.onContextLoss=this._onContextLoss.event,this.register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new f.CellColorResolver(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new C.LinkRenderLayer(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,I,this._themeService)],this.dimensions=(0,y.createRenderDimensions)(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this.register(I.onOptionChange(()=>this._handleOptionsChanged())),this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");const N={antialias:!1,depth:!1,preserveDrawingBuffer:P};if(this._gl=this._canvas.getContext("webgl2",N),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this.register((0,c.addDisposableDomListener)(this._canvas,"webglcontextlost",j=>{console.log("webglcontextlost event received"),j.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(j)},3e3)})),this.register((0,c.addDisposableDomListener)(this._canvas,"webglcontextrestored",j=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,(0,u.removeTerminalFromCache)(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=(0,_.observeDevicePixelDimensions)(this._canvas,this._coreBrowserService.window,(j,W)=>this._setCanvasDevicePixelDimensions(j,W)),this.register(this._coreBrowserService.onWindowChange(j=>{this._observerDisposable.value=(0,_.observeDevicePixelDimensions)(this._canvas,j,(W,V)=>this._setCanvasDevicePixelDimensions(W,V))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._coreBrowserService.window.document.body.contains(this._core.screenElement),this.register((0,h.toDisposable)(()=>{var j;for(const W of this._renderLayers)W.dispose();(j=this._canvas.parentElement)==null||j.removeChild(this._canvas),(0,u.removeTerminalFromCache)(this._terminal)}))}get textureAtlas(){var M;return(M=this._charAtlas)==null?void 0:M.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(M,D){var O,z,F,H;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(const I of this._renderLayers)I.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,(O=this._rectangleRenderer.value)==null||O.setDimensions(this.dimensions),(z=this._rectangleRenderer.value)==null||z.handleResize(),(F=this._glyphRenderer.value)==null||F.setDimensions(this.dimensions),(H=this._glyphRenderer.value)==null||H.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){var M;for(const D of this._renderLayers)D.handleBlur(this._terminal);(M=this._cursorBlinkStateManager.value)==null||M.pause(),this._requestRedrawViewport()}handleFocus(){var M;for(const D of this._renderLayers)D.handleFocus(this._terminal);(M=this._cursorBlinkStateManager.value)==null||M.resume(),this._requestRedrawViewport()}handleSelectionChanged(M,D,O){for(const z of this._renderLayers)z.handleSelectionChanged(this._terminal,M,D,O);this._model.selection.update(this._core,M,D,O),this._requestRedrawViewport()}handleCursorMove(){var M;for(const D of this._renderLayers)D.handleCursorMove(this._terminal);(M=this._cursorBlinkStateManager.value)==null||M.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new b.RectangleRenderer(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new w.GlyphRenderer(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){var D;if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0)return void(this._isAttached=!1);const M=(0,u.acquireTextureAtlas)(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr);this._charAtlas!==M&&(this._onChangeTextureAtlas.fire(M.pages[0].canvas),this._charAtlasDisposable.value=(0,h.getDisposeArrayDisposable)([(0,v.forwardEvent)(M.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),(0,v.forwardEvent)(M.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)])),this._charAtlas=M,this._charAtlas.warmUp(),(D=this._glyphRenderer.value)==null||D.setAtlas(this._charAtlas)}_clearModel(M){var D;this._model.clear(),M&&((D=this._glyphRenderer.value)==null||D.clear())}clearTextureAtlas(){var M;(M=this._charAtlas)==null||M.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){var M;this._clearModel(!0);for(const D of this._renderLayers)D.reset(this._terminal);(M=this._cursorBlinkStateManager.value)==null||M.restartBlinkAnimation(),this._updateCursorBlink()}registerCharacterJoiner(M){return-1}deregisterCharacterJoiner(M){return!1}renderRows(M,D){if(!this._isAttached){if(!(this._coreBrowserService.window.document.body.contains(this._core.screenElement)&&this._charSizeService.width&&this._charSizeService.height))return;this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0}for(const O of this._renderLayers)O.handleGridChanged(this._terminal,M,D);this._glyphRenderer.value&&this._rectangleRenderer.value&&(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(M,D),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),this._cursorBlinkStateManager.value&&!this._cursorBlinkStateManager.value.isCursorVisible||this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new p.CursorBlinkStateManager(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(M,D){const O=this._core;let z,F,H,I,R,P,N,j,W,V,Z,Q,$,B,K=this._workCell;M=L(M,O.rows-1,0),D=L(D,O.rows-1,0);const U=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,te=U-O.buffer.ydisp,Y=Math.min(this._terminal.buffer.active.cursorX,O.cols-1);let _e=-1;const de=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let re=!1;for(F=M;F<=D;F++)for(H=F+O.buffer.ydisp,I=O.buffer.lines.get(H),this._model.lineLengths[F]=0,R=this._characterJoinerService.getJoinedCharacters(H),$=0;$<O.cols;$++)if(z=this._cellColorResolver.result.bg,I.loadCell($,K),$===0&&(z=this._cellColorResolver.result.bg),P=!1,N=$,R.length>0&&$===R[0][0]&&(P=!0,j=R.shift(),K=new k(K,I.translateToString(!0,j[0],j[1]),j[1]-j[0]),N=j[1]-1),W=K.getChars(),V=K.getCode(),Q=(F*O.cols+$)*x.RENDER_MODEL_INDICIES_PER_CELL,this._cellColorResolver.resolve(K,$,H,this.dimensions.device.cell.width),de&&H===U&&($===Y&&(this._model.cursor={x:Y,y:te,width:K.getWidth(),style:this._coreBrowserService.isFocused?O.options.cursorStyle||"block":O.options.cursorInactiveStyle,cursorWidth:O.options.cursorWidth,dpr:this._devicePixelRatio},_e=Y+K.getWidth()-1),$>=Y&&$<=_e&&(this._coreBrowserService.isFocused&&(O.options.cursorStyle||"block")==="block"||this._coreBrowserService.isFocused===!1&&O.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),V!==g.NULL_CELL_CODE&&(this._model.lineLengths[F]=$+1),(this._model.cells[Q]!==V||this._model.cells[Q+x.RENDER_MODEL_BG_OFFSET]!==this._cellColorResolver.result.bg||this._model.cells[Q+x.RENDER_MODEL_FG_OFFSET]!==this._cellColorResolver.result.fg||this._model.cells[Q+x.RENDER_MODEL_EXT_OFFSET]!==this._cellColorResolver.result.ext)&&(re=!0,W.length>1&&(V|=x.COMBINED_CHAR_BIT_MASK),this._model.cells[Q]=V,this._model.cells[Q+x.RENDER_MODEL_BG_OFFSET]=this._cellColorResolver.result.bg,this._model.cells[Q+x.RENDER_MODEL_FG_OFFSET]=this._cellColorResolver.result.fg,this._model.cells[Q+x.RENDER_MODEL_EXT_OFFSET]=this._cellColorResolver.result.ext,Z=K.getWidth(),this._glyphRenderer.value.updateCell($,F,V,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,W,Z,z),P))for(K=this._workCell,$++;$<N;$++)B=(F*O.cols+$)*x.RENDER_MODEL_INDICIES_PER_CELL,this._glyphRenderer.value.updateCell($,F,g.NULL_CELL_CODE,0,0,0,g.NULL_CELL_CHAR,0,0),this._model.cells[B]=g.NULL_CELL_CODE,this._model.cells[B+x.RENDER_MODEL_BG_OFFSET]=this._cellColorResolver.result.bg,this._model.cells[B+x.RENDER_MODEL_FG_OFFSET]=this._cellColorResolver.result.fg,this._model.cells[B+x.RENDER_MODEL_EXT_OFFSET]=this._cellColorResolver.result.ext;re&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){this._charSizeService.width&&this._charSizeService.height&&(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(M,D){this._canvas.width===M&&this._canvas.height===D||(this._canvas.width=M,this._canvas.height=D,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){const M=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:M,end:M})}}s.WebglRenderer=S;class k extends m.AttributeData{constructor(M,D,O){super(),this.content=0,this.combinedData="",this.fg=M.fg,this.bg=M.bg,this.combinedData=D,this._width=O}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(M){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}function L(A,M,D=0){return Math.max(Math.min(A,M),D)}s.JoinedCellData=k},381:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.GLTexture=s.expandFloat32Array=s.createShader=s.createProgram=s.PROJECTION_MATRIX=void 0;const c=o(374);function f(u,p,_){const y=(0,c.throwIfFalsy)(u.createShader(p));if(u.shaderSource(y,_),u.compileShader(y),u.getShaderParameter(y,u.COMPILE_STATUS))return y;console.error(u.getShaderInfoLog(y)),u.deleteShader(y)}s.PROJECTION_MATRIX=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]),s.createProgram=function(u,p,_){const y=(0,c.throwIfFalsy)(u.createProgram());if(u.attachShader(y,(0,c.throwIfFalsy)(f(u,u.VERTEX_SHADER,p))),u.attachShader(y,(0,c.throwIfFalsy)(f(u,u.FRAGMENT_SHADER,_))),u.linkProgram(y),u.getProgramParameter(y,u.LINK_STATUS))return y;console.error(u.getProgramInfoLog(y)),u.deleteProgram(y)},s.createShader=f,s.expandFloat32Array=function(u,p){const _=Math.min(2*u.length,p),y=new Float32Array(_);for(let v=0;v<u.length;v++)y[v]=u[v];return y},s.GLTexture=class{constructor(u){this.texture=u,this.version=-1}}},592:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BaseRenderLayer=void 0;const c=o(627),f=o(237),u=o(374),p=o(859);class _ extends p.Disposable{constructor(v,h,m,d,g,w,b,x){super(),this._container=h,this._alpha=g,this._coreBrowserService=w,this._optionsService=b,this._themeService=x,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${m}-layer`),this._canvas.style.zIndex=d.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this.register(this._themeService.onChangeColors(C=>{this._refreshCharAtlas(v,C),this.reset(v)})),this.register((0,p.toDisposable)(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=(0,u.throwIfFalsy)(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(v){}handleFocus(v){}handleCursorMove(v){}handleGridChanged(v,h,m){}handleSelectionChanged(v,h,m,d=!1){}_setTransparency(v,h){if(h===this._alpha)return;const m=this._canvas;this._alpha=h,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,m),this._refreshCharAtlas(v,this._themeService.colors),this.handleGridChanged(v,0,v.rows-1)}_refreshCharAtlas(v,h){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=(0,c.acquireTextureAtlas)(v,this._optionsService.rawOptions,h,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr),this._charAtlas.warmUp())}resize(v,h){this._deviceCellWidth=h.device.cell.width,this._deviceCellHeight=h.device.cell.height,this._deviceCharWidth=h.device.char.width,this._deviceCharHeight=h.device.char.height,this._deviceCharLeft=h.device.char.left,this._deviceCharTop=h.device.char.top,this._canvas.width=h.device.canvas.width,this._canvas.height=h.device.canvas.height,this._canvas.style.width=`${h.css.canvas.width}px`,this._canvas.style.height=`${h.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(v,this._themeService.colors)}_fillBottomLineAtCells(v,h,m=1){this._ctx.fillRect(v*this._deviceCellWidth,(h+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,m*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(v,h,m,d){this._alpha?this._ctx.clearRect(v*this._deviceCellWidth,h*this._deviceCellHeight,m*this._deviceCellWidth,d*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(v*this._deviceCellWidth,h*this._deviceCellHeight,m*this._deviceCellWidth,d*this._deviceCellHeight))}_fillCharTrueColor(v,h,m,d){this._ctx.font=this._getFont(v,!1,!1),this._ctx.textBaseline=f.TEXT_BASELINE,this._clipCell(m,d,h.getWidth()),this._ctx.fillText(h.getChars(),m*this._deviceCellWidth+this._deviceCharLeft,d*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(v,h,m){this._ctx.beginPath(),this._ctx.rect(v*this._deviceCellWidth,h*this._deviceCellHeight,m*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(v,h,m){return`${m?"italic":""} ${h?v.options.fontWeightBold:v.options.fontWeight} ${v.options.fontSize*this._coreBrowserService.dpr}px ${v.options.fontFamily}`}}s.BaseRenderLayer=_},733:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.LinkRenderLayer=void 0;const c=o(197),f=o(237),u=o(592);class p extends u.BaseRenderLayer{constructor(y,v,h,m,d,g,w){super(h,y,"link",v,!0,d,g,w),this.register(m.onShowLinkUnderline(b=>this._handleShowLinkUnderline(b))),this.register(m.onHideLinkUnderline(b=>this._handleHideLinkUnderline(b)))}resize(y,v){super.resize(y,v),this._state=void 0}reset(y){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);const y=this._state.y2-this._state.y1-1;y>0&&this._clearCells(0,this._state.y1+1,this._state.cols,y),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(y){if(y.fg===f.INVERTED_DEFAULT_COLOR?this._ctx.fillStyle=this._themeService.colors.background.css:y.fg!==void 0&&(0,c.is256Color)(y.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[y.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,y.y1===y.y2)this._fillBottomLineAtCells(y.x1,y.y1,y.x2-y.x1);else{this._fillBottomLineAtCells(y.x1,y.y1,y.cols-y.x1);for(let v=y.y1+1;v<y.y2;v++)this._fillBottomLineAtCells(0,v,y.cols);this._fillBottomLineAtCells(0,y.y2,y.x2)}this._state=y}_handleHideLinkUnderline(y){this._clearCurrentLink()}}s.LinkRenderLayer=p},820:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.addDisposableDomListener=void 0,s.addDisposableDomListener=function(o,c,f,u){o.addEventListener(c,f,u);let p=!1;return{dispose:()=>{p||(p=!0,o.removeEventListener(c,f,u))}}}},274:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CellColorResolver=void 0;const c=o(855),f=o(160),u=o(374);let p,_=0,y=0,v=!1,h=!1,m=!1,d=0;s.CellColorResolver=class{constructor(g,w,b,x,C,S){this._terminal=g,this._optionService=w,this._selectionRenderModel=b,this._decorationService=x,this._coreBrowserService=C,this._themeService=S,this.result={fg:0,bg:0,ext:0}}resolve(g,w,b,x){if(this.result.bg=g.bg,this.result.fg=g.fg,this.result.ext=268435456&g.bg?g.extended.ext:0,y=0,_=0,h=!1,v=!1,m=!1,p=this._themeService.colors,d=0,g.getCode()!==c.NULL_CELL_CODE&&g.extended.underlineStyle===4){const C=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));d=w*x%(2*Math.round(C))}if(this._decorationService.forEachDecorationAtCell(w,b,"bottom",C=>{C.backgroundColorRGB&&(y=C.backgroundColorRGB.rgba>>8&16777215,h=!0),C.foregroundColorRGB&&(_=C.foregroundColorRGB.rgba>>8&16777215,v=!0)}),m=this._selectionRenderModel.isCellSelected(this._terminal,w,b),m){if(67108864&this.result.fg||50331648&this.result.bg){if(67108864&this.result.fg)switch(50331648&this.result.fg){case 16777216:case 33554432:y=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:y=(16777215&this.result.fg)<<8|255;break;default:y=this._themeService.colors.foreground.rgba}else switch(50331648&this.result.bg){case 16777216:case 33554432:y=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:y=(16777215&this.result.bg)<<8|255}y=f.rgba.blend(y,4294967040&(this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}else y=(this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(h=!0,p.selectionForeground&&(_=p.selectionForeground.rgba>>8&16777215,v=!0),(0,u.treatGlyphAsBackgroundColor)(g.getCode())){if(67108864&this.result.fg&&!(50331648&this.result.bg))_=(this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(67108864&this.result.fg)switch(50331648&this.result.bg){case 16777216:case 33554432:_=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:_=(16777215&this.result.bg)<<8|255}else switch(50331648&this.result.fg){case 16777216:case 33554432:_=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:_=(16777215&this.result.fg)<<8|255;break;default:_=this._themeService.colors.foreground.rgba}_=f.rgba.blend(_,4294967040&(this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}v=!0}}this._decorationService.forEachDecorationAtCell(w,b,"top",C=>{C.backgroundColorRGB&&(y=C.backgroundColorRGB.rgba>>8&16777215,h=!0),C.foregroundColorRGB&&(_=C.foregroundColorRGB.rgba>>8&16777215,v=!0)}),h&&(y=m?-16777216&g.bg&-134217729|y|50331648:-16777216&g.bg|y|50331648),v&&(_=-16777216&g.fg&-67108865|_|50331648),67108864&this.result.fg&&(h&&!v&&(_=50331648&this.result.bg?-134217728&this.result.fg|67108863&this.result.bg:-134217728&this.result.fg|16777215&p.background.rgba>>8|50331648,v=!0),!h&&v&&(y=50331648&this.result.fg?-67108864&this.result.bg|67108863&this.result.fg:-67108864&this.result.bg|16777215&p.foreground.rgba>>8|50331648,h=!0)),p=void 0,this.result.bg=h?y:this.result.bg,this.result.fg=v?_:this.result.fg,this.result.ext&=536870911,this.result.ext|=d<<29&3758096384}}},627:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.removeTerminalFromCache=s.acquireTextureAtlas=void 0;const c=o(509),f=o(197),u=[];s.acquireTextureAtlas=function(p,_,y,v,h,m,d,g){const w=(0,f.generateConfig)(v,h,m,d,_,y,g);for(let C=0;C<u.length;C++){const S=u[C],k=S.ownedBy.indexOf(p);if(k>=0){if((0,f.configEquals)(S.config,w))return S.atlas;S.ownedBy.length===1?(S.atlas.dispose(),u.splice(C,1)):S.ownedBy.splice(k,1);break}}for(let C=0;C<u.length;C++){const S=u[C];if((0,f.configEquals)(S.config,w))return S.ownedBy.push(p),S.atlas}const b=p._core,x={atlas:new c.TextureAtlas(document,w,b.unicodeService),config:w,ownedBy:[p]};return u.push(x),x.atlas},s.removeTerminalFromCache=function(p){for(let _=0;_<u.length;_++){const y=u[_].ownedBy.indexOf(p);if(y!==-1){u[_].ownedBy.length===1?(u[_].atlas.dispose(),u.splice(_,1)):u[_].ownedBy.splice(y,1);break}}}},197:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.is256Color=s.configEquals=s.generateConfig=void 0;const c=o(160);s.generateConfig=function(f,u,p,_,y,v,h){const m={foreground:v.foreground,background:v.background,cursor:c.NULL_COLOR,cursorAccent:c.NULL_COLOR,selectionForeground:c.NULL_COLOR,selectionBackgroundTransparent:c.NULL_COLOR,selectionBackgroundOpaque:c.NULL_COLOR,selectionInactiveBackgroundTransparent:c.NULL_COLOR,selectionInactiveBackgroundOpaque:c.NULL_COLOR,ansi:v.ansi.slice(),contrastCache:v.contrastCache,halfContrastCache:v.halfContrastCache};return{customGlyphs:y.customGlyphs,devicePixelRatio:h,letterSpacing:y.letterSpacing,lineHeight:y.lineHeight,deviceCellWidth:f,deviceCellHeight:u,deviceCharWidth:p,deviceCharHeight:_,fontFamily:y.fontFamily,fontSize:y.fontSize,fontWeight:y.fontWeight,fontWeightBold:y.fontWeightBold,allowTransparency:y.allowTransparency,drawBoldTextInBrightColors:y.drawBoldTextInBrightColors,minimumContrastRatio:y.minimumContrastRatio,colors:m}},s.configEquals=function(f,u){for(let p=0;p<f.colors.ansi.length;p++)if(f.colors.ansi[p].rgba!==u.colors.ansi[p].rgba)return!1;return f.devicePixelRatio===u.devicePixelRatio&&f.customGlyphs===u.customGlyphs&&f.lineHeight===u.lineHeight&&f.letterSpacing===u.letterSpacing&&f.fontFamily===u.fontFamily&&f.fontSize===u.fontSize&&f.fontWeight===u.fontWeight&&f.fontWeightBold===u.fontWeightBold&&f.allowTransparency===u.allowTransparency&&f.deviceCharWidth===u.deviceCharWidth&&f.deviceCharHeight===u.deviceCharHeight&&f.drawBoldTextInBrightColors===u.drawBoldTextInBrightColors&&f.minimumContrastRatio===u.minimumContrastRatio&&f.colors.foreground.rgba===u.colors.foreground.rgba&&f.colors.background.rgba===u.colors.background.rgba},s.is256Color=function(f){return(50331648&f)==16777216||(50331648&f)==33554432}},237:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TEXT_BASELINE=s.DIM_OPACITY=s.INVERTED_DEFAULT_COLOR=void 0;const c=o(399);s.INVERTED_DEFAULT_COLOR=257,s.DIM_OPACITY=.5,s.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},457:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CursorBlinkStateManager=void 0,s.CursorBlinkStateManager=class{constructor(o,c){this._renderCallback=o,this._coreBrowserService=c,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(o=600){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){const c=600-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,c>0)return void this._restartInterval(c)}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){const c=600-(Date.now()-this._animationTimeRestarted);return this._animationTimeRestarted=void 0,void this._restartInterval(c)}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},600)},o)}pause(){this.isCursorVisible=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}}},860:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.tryDrawCustomChar=s.powerlineDefinitions=s.boxDrawingDefinitions=s.blockElementDefinitions=void 0;const c=o(374);s.blockElementDefinitions={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]};const f={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]};s.boxDrawingDefinitions={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(v,h)=>`M0,${.5-h} L1,${.5-h} M0,${.5+h} L1,${.5+h}`},"║":{1:(v,h)=>`M${.5-v},0 L${.5-v},1 M${.5+v},0 L${.5+v},1`},"╒":{1:(v,h)=>`M.5,1 L.5,${.5-h} L1,${.5-h} M.5,${.5+h} L1,${.5+h}`},"╓":{1:(v,h)=>`M${.5-v},1 L${.5-v},.5 L1,.5 M${.5+v},.5 L${.5+v},1`},"╔":{1:(v,h)=>`M1,${.5-h} L${.5-v},${.5-h} L${.5-v},1 M1,${.5+h} L${.5+v},${.5+h} L${.5+v},1`},"╕":{1:(v,h)=>`M0,${.5-h} L.5,${.5-h} L.5,1 M0,${.5+h} L.5,${.5+h}`},"╖":{1:(v,h)=>`M${.5+v},1 L${.5+v},.5 L0,.5 M${.5-v},.5 L${.5-v},1`},"╗":{1:(v,h)=>`M0,${.5+h} L${.5-v},${.5+h} L${.5-v},1 M0,${.5-h} L${.5+v},${.5-h} L${.5+v},1`},"╘":{1:(v,h)=>`M.5,0 L.5,${.5+h} L1,${.5+h} M.5,${.5-h} L1,${.5-h}`},"╙":{1:(v,h)=>`M1,.5 L${.5-v},.5 L${.5-v},0 M${.5+v},.5 L${.5+v},0`},"╚":{1:(v,h)=>`M1,${.5-h} L${.5+v},${.5-h} L${.5+v},0 M1,${.5+h} L${.5-v},${.5+h} L${.5-v},0`},"╛":{1:(v,h)=>`M0,${.5+h} L.5,${.5+h} L.5,0 M0,${.5-h} L.5,${.5-h}`},"╜":{1:(v,h)=>`M0,.5 L${.5+v},.5 L${.5+v},0 M${.5-v},.5 L${.5-v},0`},"╝":{1:(v,h)=>`M0,${.5-h} L${.5-v},${.5-h} L${.5-v},0 M0,${.5+h} L${.5+v},${.5+h} L${.5+v},0`},"╞":{1:(v,h)=>`M.5,0 L.5,1 M.5,${.5-h} L1,${.5-h} M.5,${.5+h} L1,${.5+h}`},"╟":{1:(v,h)=>`M${.5-v},0 L${.5-v},1 M${.5+v},0 L${.5+v},1 M${.5+v},.5 L1,.5`},"╠":{1:(v,h)=>`M${.5-v},0 L${.5-v},1 M1,${.5+h} L${.5+v},${.5+h} L${.5+v},1 M1,${.5-h} L${.5+v},${.5-h} L${.5+v},0`},"╡":{1:(v,h)=>`M.5,0 L.5,1 M0,${.5-h} L.5,${.5-h} M0,${.5+h} L.5,${.5+h}`},"╢":{1:(v,h)=>`M0,.5 L${.5-v},.5 M${.5-v},0 L${.5-v},1 M${.5+v},0 L${.5+v},1`},"╣":{1:(v,h)=>`M${.5+v},0 L${.5+v},1 M0,${.5+h} L${.5-v},${.5+h} L${.5-v},1 M0,${.5-h} L${.5-v},${.5-h} L${.5-v},0`},"╤":{1:(v,h)=>`M0,${.5-h} L1,${.5-h} M0,${.5+h} L1,${.5+h} M.5,${.5+h} L.5,1`},"╥":{1:(v,h)=>`M0,.5 L1,.5 M${.5-v},.5 L${.5-v},1 M${.5+v},.5 L${.5+v},1`},"╦":{1:(v,h)=>`M0,${.5-h} L1,${.5-h} M0,${.5+h} L${.5-v},${.5+h} L${.5-v},1 M1,${.5+h} L${.5+v},${.5+h} L${.5+v},1`},"╧":{1:(v,h)=>`M.5,0 L.5,${.5-h} M0,${.5-h} L1,${.5-h} M0,${.5+h} L1,${.5+h}`},"╨":{1:(v,h)=>`M0,.5 L1,.5 M${.5-v},.5 L${.5-v},0 M${.5+v},.5 L${.5+v},0`},"╩":{1:(v,h)=>`M0,${.5+h} L1,${.5+h} M0,${.5-h} L${.5-v},${.5-h} L${.5-v},0 M1,${.5-h} L${.5+v},${.5-h} L${.5+v},0`},"╪":{1:(v,h)=>`M.5,0 L.5,1 M0,${.5-h} L1,${.5-h} M0,${.5+h} L1,${.5+h}`},"╫":{1:(v,h)=>`M0,.5 L1,.5 M${.5-v},0 L${.5-v},1 M${.5+v},0 L${.5+v},1`},"╬":{1:(v,h)=>`M0,${.5+h} L${.5-v},${.5+h} L${.5-v},1 M1,${.5+h} L${.5+v},${.5+h} L${.5+v},1 M0,${.5-h} L${.5-v},${.5-h} L${.5-v},0 M1,${.5-h} L${.5+v},${.5-h} L${.5+v},0`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"┉":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(v,h)=>`M.5,1 L.5,${.5+h/.15*.5} C.5,${.5+h/.15*.5},.5,.5,1,.5`},"╮":{1:(v,h)=>`M.5,1 L.5,${.5+h/.15*.5} C.5,${.5+h/.15*.5},.5,.5,0,.5`},"╯":{1:(v,h)=>`M.5,0 L.5,${.5-h/.15*.5} C.5,${.5-h/.15*.5},.5,.5,0,.5`},"╰":{1:(v,h)=>`M.5,0 L.5,${.5-h/.15*.5} C.5,${.5-h/.15*.5},.5,.5,1,.5`}},s.powerlineDefinitions={"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}},s.powerlineDefinitions[""]=s.powerlineDefinitions[""],s.powerlineDefinitions[""]=s.powerlineDefinitions[""],s.tryDrawCustomChar=function(v,h,m,d,g,w,b,x){const C=s.blockElementDefinitions[h];if(C)return function(A,M,D,O,z,F){for(let H=0;H<M.length;H++){const I=M[H],R=z/8,P=F/8;A.fillRect(D+I.x*R,O+I.y*P,I.w*R,I.h*P)}}(v,C,m,d,g,w),!0;const S=f[h];if(S)return function(A,M,D,O,z,F){let H=u.get(M);H||(H=new Map,u.set(M,H));const I=A.fillStyle;if(typeof I!="string")throw new Error(`Unexpected fillStyle type "${I}"`);let R=H.get(I);if(!R){const P=M[0].length,N=M.length,j=A.canvas.ownerDocument.createElement("canvas");j.width=P,j.height=N;const W=(0,c.throwIfFalsy)(j.getContext("2d")),V=new ImageData(P,N);let Z,Q,$,B;if(I.startsWith("#"))Z=parseInt(I.slice(1,3),16),Q=parseInt(I.slice(3,5),16),$=parseInt(I.slice(5,7),16),B=I.length>7&&parseInt(I.slice(7,9),16)||1;else{if(!I.startsWith("rgba"))throw new Error(`Unexpected fillStyle color format "${I}" when drawing pattern glyph`);[Z,Q,$,B]=I.substring(5,I.length-1).split(",").map(K=>parseFloat(K))}for(let K=0;K<N;K++)for(let U=0;U<P;U++)V.data[4*(K*P+U)]=Z,V.data[4*(K*P+U)+1]=Q,V.data[4*(K*P+U)+2]=$,V.data[4*(K*P+U)+3]=M[K][U]*(255*B);W.putImageData(V,0,0),R=(0,c.throwIfFalsy)(A.createPattern(j,null)),H.set(I,R)}A.fillStyle=R,A.fillRect(D,O,z,F)}(v,S,m,d,g,w),!0;const k=s.boxDrawingDefinitions[h];if(k)return function(A,M,D,O,z,F,H){A.strokeStyle=A.fillStyle;for(const[I,R]of Object.entries(M)){let P;A.beginPath(),A.lineWidth=H*Number.parseInt(I),P=typeof R=="function"?R(.15,.15/F*z):R;for(const N of P.split(" ")){const j=N[0],W=_[j];if(!W){console.error(`Could not find drawing instructions for "${j}"`);continue}const V=N.substring(1).split(",");V[0]&&V[1]&&W(A,y(V,z,F,D,O,!0,H))}A.stroke(),A.closePath()}}(v,k,m,d,g,w,x),!0;const L=s.powerlineDefinitions[h];return!!L&&(function(A,M,D,O,z,F,H,I){const R=new Path2D;R.rect(D,O,z,F),A.clip(R),A.beginPath();const P=H/12;A.lineWidth=I*P;for(const N of M.d.split(" ")){const j=N[0],W=_[j];if(!W){console.error(`Could not find drawing instructions for "${j}"`);continue}const V=N.substring(1).split(",");V[0]&&V[1]&&W(A,y(V,z,F,D,O,!1,I,(M.leftPadding??0)*(P/2),(M.rightPadding??0)*(P/2)))}M.type===1?(A.strokeStyle=A.fillStyle,A.stroke()):A.fill(),A.closePath()}(v,L,m,d,g,w,b,x),!0)};const u=new Map;function p(v,h,m=0){return Math.max(Math.min(v,h),m)}const _={C:(v,h)=>v.bezierCurveTo(h[0],h[1],h[2],h[3],h[4],h[5]),L:(v,h)=>v.lineTo(h[0],h[1]),M:(v,h)=>v.moveTo(h[0],h[1])};function y(v,h,m,d,g,w,b,x=0,C=0){const S=v.map(k=>parseFloat(k)||parseInt(k));if(S.length<2)throw new Error("Too few arguments for instruction");for(let k=0;k<S.length;k+=2)S[k]*=h-x*b-C*b,w&&S[k]!==0&&(S[k]=p(Math.round(S[k]+.5)-.5,h,0)),S[k]+=d+x*b;for(let k=1;k<S.length;k+=2)S[k]*=m,w&&S[k]!==0&&(S[k]=p(Math.round(S[k]+.5)-.5,m,0)),S[k]+=g;return S}},56:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.observeDevicePixelDimensions=void 0;const c=o(859);s.observeDevicePixelDimensions=function(f,u,p){let _=new u.ResizeObserver(y=>{const v=y.find(d=>d.target===f);if(!v)return;if(!("devicePixelContentBoxSize"in v))return _==null||_.disconnect(),void(_=void 0);const h=v.devicePixelContentBoxSize[0].inlineSize,m=v.devicePixelContentBoxSize[0].blockSize;h>0&&m>0&&p(h,m)});try{_.observe(f,{box:["device-pixel-content-box"]})}catch{_.disconnect(),_=void 0}return(0,c.toDisposable)(()=>_==null?void 0:_.disconnect())}},374:(l,s)=>{function o(f){return 57508<=f&&f<=57558}function c(f){return f>=128512&&f<=128591||f>=127744&&f<=128511||f>=128640&&f<=128767||f>=9728&&f<=9983||f>=9984&&f<=10175||f>=65024&&f<=65039||f>=129280&&f<=129535||f>=127462&&f<=127487}Object.defineProperty(s,"__esModule",{value:!0}),s.computeNextVariantOffset=s.createRenderDimensions=s.treatGlyphAsBackgroundColor=s.allowRescaling=s.isEmoji=s.isRestrictedPowerlineGlyph=s.isPowerlineGlyph=s.throwIfFalsy=void 0,s.throwIfFalsy=function(f){if(!f)throw new Error("value must not be falsy");return f},s.isPowerlineGlyph=o,s.isRestrictedPowerlineGlyph=function(f){return 57520<=f&&f<=57527},s.isEmoji=c,s.allowRescaling=function(f,u,p,_){return u===1&&p>Math.ceil(1.5*_)&&f!==void 0&&f>255&&!c(f)&&!o(f)&&!function(y){return 57344<=y&&y<=63743}(f)},s.treatGlyphAsBackgroundColor=function(f){return o(f)||function(u){return 9472<=u&&u<=9631}(f)},s.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}}}},s.computeNextVariantOffset=function(f,u,p=0){return(f-(2*Math.round(u)-p))%(2*Math.round(u))}},296:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.createSelectionRenderModel=void 0;class o{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(f,u,p,_=!1){if(this.selectionStart=u,this.selectionEnd=p,!u||!p||u[0]===p[0]&&u[1]===p[1])return void this.clear();const y=f.buffers.active.ydisp,v=u[1]-y,h=p[1]-y,m=Math.max(v,0),d=Math.min(h,f.rows-1);m>=f.rows||d<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=_,this.viewportStartRow=v,this.viewportEndRow=h,this.viewportCappedStartRow=m,this.viewportCappedEndRow=d,this.startCol=u[0],this.endCol=p[0])}isCellSelected(f,u,p){return!!this.hasSelection&&(p-=f.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?u>=this.startCol&&p>=this.viewportCappedStartRow&&u<this.endCol&&p<=this.viewportCappedEndRow:u<this.startCol&&p>=this.viewportCappedStartRow&&u>=this.endCol&&p<=this.viewportCappedEndRow:p>this.viewportStartRow&&p<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&p===this.viewportStartRow&&u>=this.startCol&&u<this.endCol||this.viewportStartRow<this.viewportEndRow&&p===this.viewportEndRow&&u<this.endCol||this.viewportStartRow<this.viewportEndRow&&p===this.viewportStartRow&&u>=this.startCol)}}s.createSelectionRenderModel=function(){return new o}},509:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TextureAtlas=void 0;const c=o(237),f=o(860),u=o(374),p=o(160),_=o(345),y=o(485),v=o(385),h=o(147),m=o(855),d={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}};let g;class w{get pages(){return this._pages}constructor(k,L,A){this._document=k,this._config=L,this._unicodeService=A,this._didWarmUp=!1,this._cacheMap=new y.FourKeyMap,this._cacheMapCombined=new y.FourKeyMap,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new h.AttributeData,this._textureSize=512,this._onAddTextureAtlasCanvas=new _.EventEmitter,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new _.EventEmitter,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=C(k,4*this._config.deviceCellWidth+4,this._config.deviceCellHeight+4),this._tmpCtx=(0,u.throwIfFalsy)(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}dispose(){for(const k of this.pages)k.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){const k=new v.IdleTaskQueue;for(let L=33;L<126;L++)k.enqueue(()=>{if(!this._cacheMap.get(L,m.DEFAULT_COLOR,m.DEFAULT_COLOR,m.DEFAULT_EXT)){const A=this._drawToCache(L,m.DEFAULT_COLOR,m.DEFAULT_COLOR,m.DEFAULT_EXT);this._cacheMap.set(L,m.DEFAULT_COLOR,m.DEFAULT_COLOR,m.DEFAULT_EXT,A)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(this._pages[0].currentRow.x!==0||this._pages[0].currentRow.y!==0){for(const k of this._pages)k.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(w.maxAtlasPages&&this._pages.length>=Math.max(4,w.maxAtlasPages)){const L=this._pages.filter(H=>2*H.canvas.width<=(w.maxTextureSize||4096)).sort((H,I)=>I.canvas.width!==H.canvas.width?I.canvas.width-H.canvas.width:I.percentageUsed-H.percentageUsed);let A=-1,M=0;for(let H=0;H<L.length;H++)if(L[H].canvas.width!==M)A=H,M=L[H].canvas.width;else if(H-A==3)break;const D=L.slice(A,A+4),O=D.map(H=>H.glyphs[0].texturePage).sort((H,I)=>H>I?1:-1),z=this.pages.length-D.length,F=this._mergePages(D,z);F.version++;for(let H=O.length-1;H>=0;H--)this._deletePage(O[H]);this.pages.push(F),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(F.canvas)}const k=new b(this._document,this._textureSize);return this._pages.push(k),this._activePages.push(k),this._onAddTextureAtlasCanvas.fire(k.canvas),k}_mergePages(k,L){const A=2*k[0].canvas.width,M=new b(this._document,A,k);for(const[D,O]of k.entries()){const z=D*O.canvas.width%A,F=Math.floor(D/2)*O.canvas.height;M.ctx.drawImage(O.canvas,z,F);for(const I of O.glyphs)I.texturePage=L,I.sizeClipSpace.x=I.size.x/A,I.sizeClipSpace.y=I.size.y/A,I.texturePosition.x+=z,I.texturePosition.y+=F,I.texturePositionClipSpace.x=I.texturePosition.x/A,I.texturePositionClipSpace.y=I.texturePosition.y/A;this._onRemoveTextureAtlasCanvas.fire(O.canvas);const H=this._activePages.indexOf(O);H!==-1&&this._activePages.splice(H,1)}return M}_deletePage(k){this._pages.splice(k,1);for(let L=k;L<this._pages.length;L++){const A=this._pages[L];for(const M of A.glyphs)M.texturePage--;A.version++}}getRasterizedGlyphCombinedChar(k,L,A,M,D){return this._getFromCacheMap(this._cacheMapCombined,k,L,A,M,D)}getRasterizedGlyph(k,L,A,M,D){return this._getFromCacheMap(this._cacheMap,k,L,A,M,D)}_getFromCacheMap(k,L,A,M,D,O=!1){return g=k.get(L,A,M,D),g||(g=this._drawToCache(L,A,M,D,O),k.set(L,A,M,D,g)),g}_getColorFromAnsiIndex(k){if(k>=this._config.colors.ansi.length)throw new Error("No color found for idx "+k);return this._config.colors.ansi[k]}_getBackgroundColor(k,L,A,M){if(this._config.allowTransparency)return p.NULL_COLOR;let D;switch(k){case 16777216:case 33554432:D=this._getColorFromAnsiIndex(L);break;case 50331648:const O=h.AttributeData.toColorRGB(L);D=p.channels.toColor(O[0],O[1],O[2]);break;default:D=A?p.color.opaque(this._config.colors.foreground):this._config.colors.background}return D}_getForegroundColor(k,L,A,M,D,O,z,F,H,I){const R=this._getMinimumContrastColor(k,L,A,M,D,O,z,H,F,I);if(R)return R;let P;switch(D){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&H&&O<8&&(O+=8),P=this._getColorFromAnsiIndex(O);break;case 50331648:const N=h.AttributeData.toColorRGB(O);P=p.channels.toColor(N[0],N[1],N[2]);break;default:P=z?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(P=p.color.opaque(P)),F&&(P=p.color.multiplyOpacity(P,c.DIM_OPACITY)),P}_resolveBackgroundRgba(k,L,A){switch(k){case 16777216:case 33554432:return this._getColorFromAnsiIndex(L).rgba;case 50331648:return L<<8;default:return A?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(k,L,A,M){switch(k){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&M&&L<8&&(L+=8),this._getColorFromAnsiIndex(L).rgba;case 50331648:return L<<8;default:return A?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(k,L,A,M,D,O,z,F,H,I){if(this._config.minimumContrastRatio===1||I)return;const R=this._getContrastCache(H),P=R.getColor(k,M);if(P!==void 0)return P||void 0;const N=this._resolveBackgroundRgba(L,A,z),j=this._resolveForegroundRgba(D,O,z,F),W=p.rgba.ensureContrastRatio(N,j,this._config.minimumContrastRatio/(H?2:1));if(!W)return void R.setColor(k,M,null);const V=p.channels.toColor(W>>24&255,W>>16&255,W>>8&255);return R.setColor(k,M,V),V}_getContrastCache(k){return k?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(k,L,A,M,D=!1){const O=typeof k=="number"?String.fromCharCode(k):k,z=Math.min(this._config.deviceCellWidth*Math.max(O.length,2)+4,this._textureSize);this._tmpCanvas.width<z&&(this._tmpCanvas.width=z);const F=Math.min(this._config.deviceCellHeight+8,this._textureSize);if(this._tmpCanvas.height<F&&(this._tmpCanvas.height=F),this._tmpCtx.save(),this._workAttributeData.fg=A,this._workAttributeData.bg=L,this._workAttributeData.extended.ext=M,this._workAttributeData.isInvisible())return d;const H=!!this._workAttributeData.isBold(),I=!!this._workAttributeData.isInverse(),R=!!this._workAttributeData.isDim(),P=!!this._workAttributeData.isItalic(),N=!!this._workAttributeData.isUnderline(),j=!!this._workAttributeData.isStrikethrough(),W=!!this._workAttributeData.isOverline();let V=this._workAttributeData.getFgColor(),Z=this._workAttributeData.getFgColorMode(),Q=this._workAttributeData.getBgColor(),$=this._workAttributeData.getBgColorMode();if(I){const ae=V;V=Q,Q=ae;const ve=Z;Z=$,$=ve}const B=this._getBackgroundColor($,Q,I,R);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=B.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";const K=H?this._config.fontWeightBold:this._config.fontWeight,U=P?"italic":"";this._tmpCtx.font=`${U} ${K} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=c.TEXT_BASELINE;const te=O.length===1&&(0,u.isPowerlineGlyph)(O.charCodeAt(0)),Y=O.length===1&&(0,u.isRestrictedPowerlineGlyph)(O.charCodeAt(0)),_e=this._getForegroundColor(L,$,Q,A,Z,V,I,R,H,(0,u.treatGlyphAsBackgroundColor)(O.charCodeAt(0)));this._tmpCtx.fillStyle=_e.css;const de=Y?0:4;let re=!1;this._config.customGlyphs!==!1&&(re=(0,f.tryDrawCustomChar)(this._tmpCtx,O,de,de,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let le,ne=!te;if(le=typeof k=="number"?this._unicodeService.wcwidth(k):this._unicodeService.getStringCellWidth(k),N){this._tmpCtx.save();const ae=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),ve=ae%2==1?.5:0;if(this._tmpCtx.lineWidth=ae,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())ne=!1,this._tmpCtx.strokeStyle=`rgb(${h.AttributeData.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{ne=!1;let Oe=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&Oe<8&&(Oe+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(Oe).css}this._tmpCtx.beginPath();const Ce=de,Le=Math.ceil(de+this._config.deviceCharHeight)-ve-(D?2*ae:0),je=Le+ae,Fe=Le+2*ae;let Pe=this._workAttributeData.getUnderlineVariantOffset();for(let Oe=0;Oe<le;Oe++){this._tmpCtx.save();const Ee=Ce+Oe*this._config.deviceCellWidth,q=Ce+(Oe+1)*this._config.deviceCellWidth,ee=Ee+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(Ee,Le),this._tmpCtx.lineTo(q,Le),this._tmpCtx.moveTo(Ee,Fe),this._tmpCtx.lineTo(q,Fe);break;case 3:const Ne=ae<=1?Fe:Math.ceil(de+this._config.deviceCharHeight-ae/2)-ve,Ge=ae<=1?Le:Math.ceil(de+this._config.deviceCharHeight+ae/2)-ve,Ae=new Path2D;Ae.rect(Ee,Le,this._config.deviceCellWidth,Fe-Le),this._tmpCtx.clip(Ae),this._tmpCtx.moveTo(Ee-this._config.deviceCellWidth/2,je),this._tmpCtx.bezierCurveTo(Ee-this._config.deviceCellWidth/2,Ge,Ee,Ge,Ee,je),this._tmpCtx.bezierCurveTo(Ee,Ne,ee,Ne,ee,je),this._tmpCtx.bezierCurveTo(ee,Ge,q,Ge,q,je),this._tmpCtx.bezierCurveTo(q,Ne,q+this._config.deviceCellWidth/2,Ne,q+this._config.deviceCellWidth/2,je);break;case 4:const G=Pe===0?0:Pe>=ae?2*ae-Pe:ae-Pe;Pe>=ae||G===0?(this._tmpCtx.setLineDash([Math.round(ae),Math.round(ae)]),this._tmpCtx.moveTo(Ee+G,Le),this._tmpCtx.lineTo(q,Le)):(this._tmpCtx.setLineDash([Math.round(ae),Math.round(ae)]),this._tmpCtx.moveTo(Ee,Le),this._tmpCtx.lineTo(Ee+G,Le),this._tmpCtx.moveTo(Ee+G+ae,Le),this._tmpCtx.lineTo(q,Le)),Pe=(0,u.computeNextVariantOffset)(q-Ee,ae,Pe);break;case 5:const me=.6,J=.3,Se=q-Ee,ie=Math.floor(me*Se),he=Math.floor(J*Se),ke=Se-ie-he;this._tmpCtx.setLineDash([ie,he,ke]),this._tmpCtx.moveTo(Ee,Le),this._tmpCtx.lineTo(q,Le);break;default:this._tmpCtx.moveTo(Ee,Le),this._tmpCtx.lineTo(q,Le)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!re&&this._config.fontSize>=12&&!this._config.allowTransparency&&O!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";const Oe=this._tmpCtx.measureText(O);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in Oe&&Oe.actualBoundingBoxDescent>0){this._tmpCtx.save();const Ee=new Path2D;Ee.rect(Ce,Le-Math.ceil(ae/2),this._config.deviceCellWidth*le,Fe-Le+Math.ceil(ae/2)),this._tmpCtx.clip(Ee),this._tmpCtx.lineWidth=3*this._config.devicePixelRatio,this._tmpCtx.strokeStyle=B.css,this._tmpCtx.strokeText(O,de,de+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(W){const ae=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),ve=ae%2==1?.5:0;this._tmpCtx.lineWidth=ae,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(de,de+ve),this._tmpCtx.lineTo(de+this._config.deviceCharWidth*le,de+ve),this._tmpCtx.stroke()}if(re||this._tmpCtx.fillText(O,de,de+this._config.deviceCharHeight),O==="_"&&!this._config.allowTransparency){let ae=x(this._tmpCtx.getImageData(de,de,this._config.deviceCellWidth,this._config.deviceCellHeight),B,_e,ne);if(ae)for(let ve=1;ve<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=B.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(O,de,de+this._config.deviceCharHeight-ve),ae=x(this._tmpCtx.getImageData(de,de,this._config.deviceCellWidth,this._config.deviceCellHeight),B,_e,ne),ae);ve++);}if(j){const ae=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),ve=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=ae,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(de,de+Math.floor(this._config.deviceCharHeight/2)-ve),this._tmpCtx.lineTo(de+this._config.deviceCharWidth*le,de+Math.floor(this._config.deviceCharHeight/2)-ve),this._tmpCtx.stroke()}this._tmpCtx.restore();const fe=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height);let ge;if(ge=this._config.allowTransparency?function(ae){for(let ve=0;ve<ae.data.length;ve+=4)if(ae.data[ve+3]>0)return!1;return!0}(fe):x(fe,B,_e,ne),ge)return d;const se=this._findGlyphBoundingBox(fe,this._workBoundingBox,z,Y,re,de);let oe,ue;for(;;){if(this._activePages.length===0){const ae=this._createNewPage();oe=ae,ue=ae.currentRow,ue.height=se.size.y;break}oe=this._activePages[this._activePages.length-1],ue=oe.currentRow;for(const ae of this._activePages)se.size.y<=ae.currentRow.height&&(oe=ae,ue=ae.currentRow);for(let ae=this._activePages.length-1;ae>=0;ae--)for(const ve of this._activePages[ae].fixedRows)ve.height<=ue.height&&se.size.y<=ve.height&&(oe=this._activePages[ae],ue=ve);if(ue.y+se.size.y>=oe.canvas.height||ue.height>se.size.y+2){let ae=!1;if(oe.currentRow.y+oe.currentRow.height+se.size.y>=oe.canvas.height){let ve;for(const Ce of this._activePages)if(Ce.currentRow.y+Ce.currentRow.height+se.size.y<Ce.canvas.height){ve=Ce;break}if(ve)oe=ve;else if(w.maxAtlasPages&&this._pages.length>=w.maxAtlasPages&&ue.y+se.size.y<=oe.canvas.height&&ue.height>=se.size.y&&ue.x+se.size.x<=oe.canvas.width)ae=!0;else{const Ce=this._createNewPage();oe=Ce,ue=Ce.currentRow,ue.height=se.size.y,ae=!0}}ae||(oe.currentRow.height>0&&oe.fixedRows.push(oe.currentRow),ue={x:0,y:oe.currentRow.y+oe.currentRow.height,height:se.size.y},oe.fixedRows.push(ue),oe.currentRow={x:0,y:ue.y+ue.height,height:0})}if(ue.x+se.size.x<=oe.canvas.width)break;ue===oe.currentRow?(ue.x=0,ue.y+=ue.height,ue.height=0):oe.fixedRows.splice(oe.fixedRows.indexOf(ue),1)}return se.texturePage=this._pages.indexOf(oe),se.texturePosition.x=ue.x,se.texturePosition.y=ue.y,se.texturePositionClipSpace.x=ue.x/oe.canvas.width,se.texturePositionClipSpace.y=ue.y/oe.canvas.height,se.sizeClipSpace.x/=oe.canvas.width,se.sizeClipSpace.y/=oe.canvas.height,ue.height=Math.max(ue.height,se.size.y),ue.x+=se.size.x,oe.ctx.putImageData(fe,se.texturePosition.x-this._workBoundingBox.left,se.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,se.size.x,se.size.y),oe.addGlyph(se),oe.version++,se}_findGlyphBoundingBox(k,L,A,M,D,O){L.top=0;const z=M?this._config.deviceCellHeight:this._tmpCanvas.height,F=M?this._config.deviceCellWidth:A;let H=!1;for(let I=0;I<z;I++){for(let R=0;R<F;R++){const P=I*this._tmpCanvas.width*4+4*R+3;if(k.data[P]!==0){L.top=I,H=!0;break}}if(H)break}L.left=0,H=!1;for(let I=0;I<O+F;I++){for(let R=0;R<z;R++){const P=R*this._tmpCanvas.width*4+4*I+3;if(k.data[P]!==0){L.left=I,H=!0;break}}if(H)break}L.right=F,H=!1;for(let I=O+F-1;I>=O;I--){for(let R=0;R<z;R++){const P=R*this._tmpCanvas.width*4+4*I+3;if(k.data[P]!==0){L.right=I,H=!0;break}}if(H)break}L.bottom=z,H=!1;for(let I=z-1;I>=0;I--){for(let R=0;R<F;R++){const P=I*this._tmpCanvas.width*4+4*R+3;if(k.data[P]!==0){L.bottom=I,H=!0;break}}if(H)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:L.right-L.left+1,y:L.bottom-L.top+1},sizeClipSpace:{x:L.right-L.left+1,y:L.bottom-L.top+1},offset:{x:-L.left+O+(M||D?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-L.top+O+(M||D?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}}s.TextureAtlas=w;class b{get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(k){this._glyphs.push(k),this._usedPixels+=k.size.x*k.size.y}constructor(k,L,A){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],A)for(const M of A)this._glyphs.push(...M.glyphs),this._usedPixels+=M._usedPixels;this.canvas=C(k,L,L),this.ctx=(0,u.throwIfFalsy)(this.canvas.getContext("2d",{alpha:!0}))}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}}function x(S,k,L,A){const M=k.rgba>>>24,D=k.rgba>>>16&255,O=k.rgba>>>8&255,z=L.rgba>>>24,F=L.rgba>>>16&255,H=L.rgba>>>8&255,I=Math.floor((Math.abs(M-z)+Math.abs(D-F)+Math.abs(O-H))/12);let R=!0;for(let P=0;P<S.data.length;P+=4)S.data[P]===M&&S.data[P+1]===D&&S.data[P+2]===O||A&&Math.abs(S.data[P]-M)+Math.abs(S.data[P+1]-D)+Math.abs(S.data[P+2]-O)<I?S.data[P+3]=0:R=!1;return R}function C(S,k,L){const A=S.createElement("canvas");return A.width=k,A.height=L,A}},160:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.contrastRatio=s.toPaddedHex=s.rgba=s.rgb=s.css=s.color=s.channels=s.NULL_COLOR=void 0;let o=0,c=0,f=0,u=0;var p,_,y,v,h;function m(g){const w=g.toString(16);return w.length<2?"0"+w:w}function d(g,w){return g<w?(w+.05)/(g+.05):(g+.05)/(w+.05)}s.NULL_COLOR={css:"#00000000",rgba:0},function(g){g.toCss=function(w,b,x,C){return C!==void 0?`#${m(w)}${m(b)}${m(x)}${m(C)}`:`#${m(w)}${m(b)}${m(x)}`},g.toRgba=function(w,b,x,C=255){return(w<<24|b<<16|x<<8|C)>>>0},g.toColor=function(w,b,x,C){return{css:g.toCss(w,b,x,C),rgba:g.toRgba(w,b,x,C)}}}(p||(s.channels=p={})),function(g){function w(b,x){return u=Math.round(255*x),[o,c,f]=h.toChannels(b.rgba),{css:p.toCss(o,c,f,u),rgba:p.toRgba(o,c,f,u)}}g.blend=function(b,x){if(u=(255&x.rgba)/255,u===1)return{css:x.css,rgba:x.rgba};const C=x.rgba>>24&255,S=x.rgba>>16&255,k=x.rgba>>8&255,L=b.rgba>>24&255,A=b.rgba>>16&255,M=b.rgba>>8&255;return o=L+Math.round((C-L)*u),c=A+Math.round((S-A)*u),f=M+Math.round((k-M)*u),{css:p.toCss(o,c,f),rgba:p.toRgba(o,c,f)}},g.isOpaque=function(b){return(255&b.rgba)==255},g.ensureContrastRatio=function(b,x,C){const S=h.ensureContrastRatio(b.rgba,x.rgba,C);if(S)return p.toColor(S>>24&255,S>>16&255,S>>8&255)},g.opaque=function(b){const x=(255|b.rgba)>>>0;return[o,c,f]=h.toChannels(x),{css:p.toCss(o,c,f),rgba:x}},g.opacity=w,g.multiplyOpacity=function(b,x){return u=255&b.rgba,w(b,u*x/255)},g.toColorRGB=function(b){return[b.rgba>>24&255,b.rgba>>16&255,b.rgba>>8&255]}}(_||(s.color=_={})),function(g){let w,b;try{const x=document.createElement("canvas");x.width=1,x.height=1;const C=x.getContext("2d",{willReadFrequently:!0});C&&(w=C,w.globalCompositeOperation="copy",b=w.createLinearGradient(0,0,1,1))}catch{}g.toColor=function(x){if(x.match(/#[\da-f]{3,8}/i))switch(x.length){case 4:return o=parseInt(x.slice(1,2).repeat(2),16),c=parseInt(x.slice(2,3).repeat(2),16),f=parseInt(x.slice(3,4).repeat(2),16),p.toColor(o,c,f);case 5:return o=parseInt(x.slice(1,2).repeat(2),16),c=parseInt(x.slice(2,3).repeat(2),16),f=parseInt(x.slice(3,4).repeat(2),16),u=parseInt(x.slice(4,5).repeat(2),16),p.toColor(o,c,f,u);case 7:return{css:x,rgba:(parseInt(x.slice(1),16)<<8|255)>>>0};case 9:return{css:x,rgba:parseInt(x.slice(1),16)>>>0}}const C=x.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(C)return o=parseInt(C[1]),c=parseInt(C[2]),f=parseInt(C[3]),u=Math.round(255*(C[5]===void 0?1:parseFloat(C[5]))),p.toColor(o,c,f,u);if(!w||!b)throw new Error("css.toColor: Unsupported css format");if(w.fillStyle=b,w.fillStyle=x,typeof w.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(w.fillRect(0,0,1,1),[o,c,f,u]=w.getImageData(0,0,1,1).data,u!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:p.toRgba(o,c,f,u),css:x}}}(y||(s.css=y={})),function(g){function w(b,x,C){const S=b/255,k=x/255,L=C/255;return .2126*(S<=.03928?S/12.92:Math.pow((S+.055)/1.055,2.4))+.7152*(k<=.03928?k/12.92:Math.pow((k+.055)/1.055,2.4))+.0722*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))}g.relativeLuminance=function(b){return w(b>>16&255,b>>8&255,255&b)},g.relativeLuminance2=w}(v||(s.rgb=v={})),function(g){function w(x,C,S){const k=x>>24&255,L=x>>16&255,A=x>>8&255;let M=C>>24&255,D=C>>16&255,O=C>>8&255,z=d(v.relativeLuminance2(M,D,O),v.relativeLuminance2(k,L,A));for(;z<S&&(M>0||D>0||O>0);)M-=Math.max(0,Math.ceil(.1*M)),D-=Math.max(0,Math.ceil(.1*D)),O-=Math.max(0,Math.ceil(.1*O)),z=d(v.relativeLuminance2(M,D,O),v.relativeLuminance2(k,L,A));return(M<<24|D<<16|O<<8|255)>>>0}function b(x,C,S){const k=x>>24&255,L=x>>16&255,A=x>>8&255;let M=C>>24&255,D=C>>16&255,O=C>>8&255,z=d(v.relativeLuminance2(M,D,O),v.relativeLuminance2(k,L,A));for(;z<S&&(M<255||D<255||O<255);)M=Math.min(255,M+Math.ceil(.1*(255-M))),D=Math.min(255,D+Math.ceil(.1*(255-D))),O=Math.min(255,O+Math.ceil(.1*(255-O))),z=d(v.relativeLuminance2(M,D,O),v.relativeLuminance2(k,L,A));return(M<<24|D<<16|O<<8|255)>>>0}g.blend=function(x,C){if(u=(255&C)/255,u===1)return C;const S=C>>24&255,k=C>>16&255,L=C>>8&255,A=x>>24&255,M=x>>16&255,D=x>>8&255;return o=A+Math.round((S-A)*u),c=M+Math.round((k-M)*u),f=D+Math.round((L-D)*u),p.toRgba(o,c,f)},g.ensureContrastRatio=function(x,C,S){const k=v.relativeLuminance(x>>8),L=v.relativeLuminance(C>>8);if(d(k,L)<S){if(L<k){const D=w(x,C,S),O=d(k,v.relativeLuminance(D>>8));if(O<S){const z=b(x,C,S);return O>d(k,v.relativeLuminance(z>>8))?D:z}return D}const A=b(x,C,S),M=d(k,v.relativeLuminance(A>>8));if(M<S){const D=w(x,C,S);return M>d(k,v.relativeLuminance(D>>8))?A:D}return A}},g.reduceLuminance=w,g.increaseLuminance=b,g.toChannels=function(x){return[x>>24&255,x>>16&255,x>>8&255,255&x]}}(h||(s.rgba=h={})),s.toPaddedHex=m,s.contrastRatio=d},345:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.runAndSubscribe=s.forwardEvent=s.EventEmitter=void 0,s.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=o=>(this._listeners.push(o),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===o)return void this._listeners.splice(c,1)}}})),this._event}fire(o,c){const f=[];for(let u=0;u<this._listeners.length;u++)f.push(this._listeners[u]);for(let u=0;u<f.length;u++)f[u].call(void 0,o,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},s.forwardEvent=function(o,c){return o(f=>c.fire(f))},s.runAndSubscribe=function(o,c){return c(void 0),o(f=>c(f))}},859:(l,s)=>{function o(c){for(const f of c)f.dispose();c.length=0}Object.defineProperty(s,"__esModule",{value:!0}),s.getDisposeArrayDisposable=s.disposeArray=s.toDisposable=s.MutableDisposable=s.Disposable=void 0,s.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const c of this._disposables)c.dispose();this._disposables.length=0}register(c){return this._disposables.push(c),c}unregister(c){const f=this._disposables.indexOf(c);f!==-1&&this._disposables.splice(f,1)}},s.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var f;this._isDisposed||c===this._value||((f=this._value)==null||f.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){var c;this._isDisposed=!0,(c=this._value)==null||c.dispose(),this._value=void 0}},s.toDisposable=function(c){return{dispose:c}},s.disposeArray=o,s.getDisposeArrayDisposable=function(c){return{dispose:()=>o(c)}}},485:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.FourKeyMap=s.TwoKeyMap=void 0;class o{constructor(){this._data={}}set(f,u,p){this._data[f]||(this._data[f]={}),this._data[f][u]=p}get(f,u){return this._data[f]?this._data[f][u]:void 0}clear(){this._data={}}}s.TwoKeyMap=o,s.FourKeyMap=class{constructor(){this._data=new o}set(c,f,u,p,_){this._data.get(c,f)||this._data.set(c,f,new o),this._data.get(c,f).set(u,p,_)}get(c,f,u,p){var _;return(_=this._data.get(c,f))==null?void 0:_.get(u,p)}clear(){this._data.clear()}}},399:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.isChromeOS=s.isLinux=s.isWindows=s.isIphone=s.isIpad=s.isMac=s.getSafariVersion=s.isSafari=s.isLegacyEdge=s.isFirefox=s.isNode=void 0,s.isNode=typeof process<"u"&&"title"in process;const o=s.isNode?"node":navigator.userAgent,c=s.isNode?"node":navigator.platform;s.isFirefox=o.includes("Firefox"),s.isLegacyEdge=o.includes("Edge"),s.isSafari=/^((?!chrome|android).)*safari/i.test(o),s.getSafariVersion=function(){if(!s.isSafari)return 0;const f=o.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[1])},s.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),s.isIpad=c==="iPad",s.isIphone=c==="iPhone",s.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),s.isLinux=c.indexOf("Linux")>=0,s.isChromeOS=/\bCrOS\b/.test(o)},385:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DebouncedIdleTask=s.IdleTaskQueue=s.PriorityTaskQueue=void 0;const c=o(399);class f{constructor(){this._tasks=[],this._i=0}enqueue(_){this._tasks.push(_),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(_){this._idleCallback=void 0;let y=0,v=0,h=_.timeRemaining(),m=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),v=Math.max(y,v),m=_.timeRemaining(),1.5*v>m)return h-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(h-y))}ms`),void this._start();h=m}this.clear()}}class u extends f{_requestCallback(_){return setTimeout(()=>_(this._createDeadline(16)))}_cancelCallback(_){clearTimeout(_)}_createDeadline(_){const y=Date.now()+_;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}s.PriorityTaskQueue=u,s.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(p){return requestIdleCallback(p)}_cancelCallback(p){cancelIdleCallback(p)}}:u,s.DebouncedIdleTask=class{constructor(){this._queue=new s.IdleTaskQueue}set(p){this._queue.clear(),this._queue.enqueue(p)}flush(){this._queue.flush()}}},147:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ExtendedAttrs=s.AttributeData=void 0;class o{constructor(){this.fg=0,this.bg=0,this.extended=new c}static toColorRGB(u){return[u>>>16&255,u>>>8&255,255&u]}static fromColorRGB(u){return(255&u[0])<<16|(255&u[1])<<8|255&u[2]}clone(){const u=new o;return u.fg=this.fg,u.bg=this.bg,u.extended=this.extended.clone(),u}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}s.AttributeData=o;class c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(u){this._ext=u}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(u){this._ext&=-469762049,this._ext|=u<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(u){this._ext&=-67108864,this._ext|=67108863&u}get urlId(){return this._urlId}set urlId(u){this._urlId=u}get underlineVariantOffset(){const u=(3758096384&this._ext)>>29;return u<0?4294967288^u:u}set underlineVariantOffset(u){this._ext&=536870911,this._ext|=u<<29&3758096384}constructor(u=0,p=0){this._ext=0,this._urlId=0,this._ext=u,this._urlId=p}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}s.ExtendedAttrs=c},782:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CellData=void 0;const c=o(133),f=o(855),u=o(147);class p extends u.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new u.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const v=new p;return v.setFromCharData(y),v}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,c.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let v=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)v=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const h=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=h&&h<=56319){const m=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=m&&m<=57343?this.content=1024*(h-55296)+m-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:v=!0}else v=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;v&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}s.CellData=p},855:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.WHITESPACE_CELL_CODE=s.WHITESPACE_CELL_WIDTH=s.WHITESPACE_CELL_CHAR=s.NULL_CELL_CODE=s.NULL_CELL_WIDTH=s.NULL_CELL_CHAR=s.CHAR_DATA_CODE_INDEX=s.CHAR_DATA_WIDTH_INDEX=s.CHAR_DATA_CHAR_INDEX=s.CHAR_DATA_ATTR_INDEX=s.DEFAULT_EXT=s.DEFAULT_ATTR=s.DEFAULT_COLOR=void 0,s.DEFAULT_COLOR=0,s.DEFAULT_ATTR=256|s.DEFAULT_COLOR<<9,s.DEFAULT_EXT=0,s.CHAR_DATA_ATTR_INDEX=0,s.CHAR_DATA_CHAR_INDEX=1,s.CHAR_DATA_WIDTH_INDEX=2,s.CHAR_DATA_CODE_INDEX=3,s.NULL_CELL_CHAR="",s.NULL_CELL_WIDTH=1,s.NULL_CELL_CODE=0,s.WHITESPACE_CELL_CHAR=" ",s.WHITESPACE_CELL_WIDTH=1,s.WHITESPACE_CELL_CODE=32},133:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Utf8ToUtf32=s.StringToUtf32=s.utf32ToString=s.stringFromCodePoint=void 0,s.stringFromCodePoint=function(o){return o>65535?(o-=65536,String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):String.fromCharCode(o)},s.utf32ToString=function(o,c=0,f=o.length){let u="";for(let p=c;p<f;++p){let _=o[p];_>65535?(_-=65536,u+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):u+=String.fromCharCode(_)}return u},s.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(o,c){const f=o.length;if(!f)return 0;let u=0,p=0;if(this._interim){const _=o.charCodeAt(p++);56320<=_&&_<=57343?c[u++]=1024*(this._interim-55296)+_-56320+65536:(c[u++]=this._interim,c[u++]=_),this._interim=0}for(let _=p;_<f;++_){const y=o.charCodeAt(_);if(55296<=y&&y<=56319){if(++_>=f)return this._interim=y,u;const v=o.charCodeAt(_);56320<=v&&v<=57343?c[u++]=1024*(y-55296)+v-56320+65536:(c[u++]=y,c[u++]=v)}else y!==65279&&(c[u++]=y)}return u}},s.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(o,c){const f=o.length;if(!f)return 0;let u,p,_,y,v=0,h=0,m=0;if(this.interim[0]){let w=!1,b=this.interim[0];b&=(224&b)==192?31:(240&b)==224?15:7;let x,C=0;for(;(x=63&this.interim[++C])&&C<4;)b<<=6,b|=x;const S=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,k=S-C;for(;m<k;){if(m>=f)return 0;if(x=o[m++],(192&x)!=128){m--,w=!0;break}this.interim[C++]=x,b<<=6,b|=63&x}w||(S===2?b<128?m--:c[v++]=b:S===3?b<2048||b>=55296&&b<=57343||b===65279||(c[v++]=b):b<65536||b>1114111||(c[v++]=b)),this.interim.fill(0)}const d=f-4;let g=m;for(;g<f;){for(;!(!(g<d)||128&(u=o[g])||128&(p=o[g+1])||128&(_=o[g+2])||128&(y=o[g+3]));)c[v++]=u,c[v++]=p,c[v++]=_,c[v++]=y,g+=4;if(u=o[g++],u<128)c[v++]=u;else if((224&u)==192){if(g>=f)return this.interim[0]=u,v;if(p=o[g++],(192&p)!=128){g--;continue}if(h=(31&u)<<6|63&p,h<128){g--;continue}c[v++]=h}else if((240&u)==224){if(g>=f)return this.interim[0]=u,v;if(p=o[g++],(192&p)!=128){g--;continue}if(g>=f)return this.interim[0]=u,this.interim[1]=p,v;if(_=o[g++],(192&_)!=128){g--;continue}if(h=(15&u)<<12|(63&p)<<6|63&_,h<2048||h>=55296&&h<=57343||h===65279)continue;c[v++]=h}else if((248&u)==240){if(g>=f)return this.interim[0]=u,v;if(p=o[g++],(192&p)!=128){g--;continue}if(g>=f)return this.interim[0]=u,this.interim[1]=p,v;if(_=o[g++],(192&_)!=128){g--;continue}if(g>=f)return this.interim[0]=u,this.interim[1]=p,this.interim[2]=_,v;if(y=o[g++],(192&y)!=128){g--;continue}if(h=(7&u)<<18|(63&p)<<12|(63&_)<<6|63&y,h<65536||h>1114111)continue;c[v++]=h}}return v}}},776:function(l,s,o){var c=this&&this.__decorate||function(h,m,d,g){var w,b=arguments.length,x=b<3?m:g===null?g=Object.getOwnPropertyDescriptor(m,d):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(h,m,d,g);else for(var C=h.length-1;C>=0;C--)(w=h[C])&&(x=(b<3?w(x):b>3?w(m,d,x):w(m,d))||x);return b>3&&x&&Object.defineProperty(m,d,x),x},f=this&&this.__param||function(h,m){return function(d,g){m(d,g,h)}};Object.defineProperty(s,"__esModule",{value:!0}),s.traceCall=s.setTraceLogger=s.LogService=void 0;const u=o(859),p=o(97),_={trace:p.LogLevelEnum.TRACE,debug:p.LogLevelEnum.DEBUG,info:p.LogLevelEnum.INFO,warn:p.LogLevelEnum.WARN,error:p.LogLevelEnum.ERROR,off:p.LogLevelEnum.OFF};let y,v=s.LogService=class extends u.Disposable{get logLevel(){return this._logLevel}constructor(h){super(),this._optionsService=h,this._logLevel=p.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),y=this}_updateLogLevel(){this._logLevel=_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(h){for(let m=0;m<h.length;m++)typeof h[m]=="function"&&(h[m]=h[m]())}_log(h,m,d){this._evalLazyOptionalParams(d),h.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+m,...d)}trace(h,...m){var d;this._logLevel<=p.LogLevelEnum.TRACE&&this._log(((d=this._optionsService.options.logger)==null?void 0:d.trace.bind(this._optionsService.options.logger))??console.log,h,m)}debug(h,...m){var d;this._logLevel<=p.LogLevelEnum.DEBUG&&this._log(((d=this._optionsService.options.logger)==null?void 0:d.debug.bind(this._optionsService.options.logger))??console.log,h,m)}info(h,...m){var d;this._logLevel<=p.LogLevelEnum.INFO&&this._log(((d=this._optionsService.options.logger)==null?void 0:d.info.bind(this._optionsService.options.logger))??console.info,h,m)}warn(h,...m){var d;this._logLevel<=p.LogLevelEnum.WARN&&this._log(((d=this._optionsService.options.logger)==null?void 0:d.warn.bind(this._optionsService.options.logger))??console.warn,h,m)}error(h,...m){var d;this._logLevel<=p.LogLevelEnum.ERROR&&this._log(((d=this._optionsService.options.logger)==null?void 0:d.error.bind(this._optionsService.options.logger))??console.error,h,m)}};s.LogService=v=c([f(0,p.IOptionsService)],v),s.setTraceLogger=function(h){y=h},s.traceCall=function(h,m,d){if(typeof d.value!="function")throw new Error("not supported");const g=d.value;d.value=function(...w){if(y.logLevel!==p.LogLevelEnum.TRACE)return g.apply(this,w);y.trace(`GlyphRenderer#${g.name}(${w.map(x=>JSON.stringify(x)).join(", ")})`);const b=g.apply(this,w);return y.trace(`GlyphRenderer#${g.name} return`,b),b}}},726:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.createDecorator=s.getServiceDependencies=s.serviceRegistry=void 0;const o="di$target",c="di$dependencies";s.serviceRegistry=new Map,s.getServiceDependencies=function(f){return f[c]||[]},s.createDecorator=function(f){if(s.serviceRegistry.has(f))return s.serviceRegistry.get(f);const u=function(p,_,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(v,h,m){h[o]===h?h[c].push({id:v,index:m}):(h[c]=[{id:v,index:m}],h[o]=h)})(u,p,y)};return u.toString=()=>f,s.serviceRegistry.set(f,u),u}},97:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.IDecorationService=s.IUnicodeService=s.IOscLinkService=s.IOptionsService=s.ILogService=s.LogLevelEnum=s.IInstantiationService=s.ICharsetService=s.ICoreService=s.ICoreMouseService=s.IBufferService=void 0;const c=o(726);var f;s.IBufferService=(0,c.createDecorator)("BufferService"),s.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),s.ICoreService=(0,c.createDecorator)("CoreService"),s.ICharsetService=(0,c.createDecorator)("CharsetService"),s.IInstantiationService=(0,c.createDecorator)("InstantiationService"),function(u){u[u.TRACE=0]="TRACE",u[u.DEBUG=1]="DEBUG",u[u.INFO=2]="INFO",u[u.WARN=3]="WARN",u[u.ERROR=4]="ERROR",u[u.OFF=5]="OFF"}(f||(s.LogLevelEnum=f={})),s.ILogService=(0,c.createDecorator)("LogService"),s.IOptionsService=(0,c.createDecorator)("OptionsService"),s.IOscLinkService=(0,c.createDecorator)("OscLinkService"),s.IUnicodeService=(0,c.createDecorator)("UnicodeService"),s.IDecorationService=(0,c.createDecorator)("DecorationService")}},n={};function i(l){var s=n[l];if(s!==void 0)return s.exports;var o=n[l]={exports:{}};return r[l].call(o.exports,o,o.exports,i),o.exports}var a={};return(()=>{var l=a;Object.defineProperty(l,"__esModule",{value:!0}),l.WebglAddon=void 0;const s=i(345),o=i(859),c=i(399),f=i(666),u=i(776);class p extends o.Disposable{constructor(y){if(c.isSafari&&(0,c.getSafariVersion)()<16){const v={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",v))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=y,this._onChangeTextureAtlas=this.register(new s.EventEmitter),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this.register(new s.EventEmitter),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this.register(new s.EventEmitter),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this.register(new s.EventEmitter),this.onContextLoss=this._onContextLoss.event}activate(y){const v=y._core;if(!y.element)return void this.register(v.onWillOpen(()=>this.activate(y)));this._terminal=y;const h=v.coreService,m=v.optionsService,d=v,g=d._renderService,w=d._characterJoinerService,b=d._charSizeService,x=d._coreBrowserService,C=d._decorationService,S=d._logService,k=d._themeService;(0,u.setTraceLogger)(S),this._renderer=this.register(new f.WebglRenderer(y,w,b,x,h,C,m,k,this._preserveDrawingBuffer)),this.register((0,s.forwardEvent)(this._renderer.onContextLoss,this._onContextLoss)),this.register((0,s.forwardEvent)(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this.register((0,s.forwardEvent)(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this.register((0,s.forwardEvent)(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),g.setRenderer(this._renderer),this.register((0,o.toDisposable)(()=>{const L=this._terminal._core._renderService;L.setRenderer(this._terminal._core._createRenderer()),L.handleResize(y.cols,y.rows)}))}get textureAtlas(){var y;return(y=this._renderer)==null?void 0:y.textureAtlas}clearTextureAtlas(){var y;(y=this._renderer)==null||y.clearTextureAtlas()}}l.WebglAddon=p})(),a})())})(_w);var fv=_w.exports;/**
128
+ }`)),this.register((0,f.toDisposable)(()=>M.deleteProgram(this._program))),this._projectionLocation=(0,c.throwIfFalsy)(M.getUniformLocation(this._program,"u_projection")),this._vertexArrayObject=M.createVertexArray(),M.bindVertexArray(this._vertexArrayObject);const D=new Float32Array([0,0,1,0,0,1,1,1]),O=M.createBuffer();this.register((0,f.toDisposable)(()=>M.deleteBuffer(O))),M.bindBuffer(M.ARRAY_BUFFER,O),M.bufferData(M.ARRAY_BUFFER,D,M.STATIC_DRAW),M.enableVertexAttribArray(3),M.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);const z=new Uint8Array([0,1,2,3]),F=M.createBuffer();this.register((0,f.toDisposable)(()=>M.deleteBuffer(F))),M.bindBuffer(M.ELEMENT_ARRAY_BUFFER,F),M.bufferData(M.ELEMENT_ARRAY_BUFFER,z,M.STATIC_DRAW),this._attributesBuffer=(0,c.throwIfFalsy)(M.createBuffer()),this.register((0,f.toDisposable)(()=>M.deleteBuffer(this._attributesBuffer))),M.bindBuffer(M.ARRAY_BUFFER,this._attributesBuffer),M.enableVertexAttribArray(0),M.vertexAttribPointer(0,2,M.FLOAT,!1,_,0),M.vertexAttribDivisor(0,1),M.enableVertexAttribArray(1),M.vertexAttribPointer(1,2,M.FLOAT,!1,_,2*Float32Array.BYTES_PER_ELEMENT),M.vertexAttribDivisor(1,1),M.enableVertexAttribArray(2),M.vertexAttribPointer(2,4,M.FLOAT,!1,_,4*Float32Array.BYTES_PER_ELEMENT),M.vertexAttribDivisor(2,1),this._updateCachedColors(A.colors),this.register(this._themeService.onChangeColors(H=>{this._updateCachedColors(H),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(S){const k=this._gl;k.useProgram(this._program),k.bindVertexArray(this._vertexArrayObject),k.uniformMatrix4fv(this._projectionLocation,!1,p.PROJECTION_MATRIX),k.bindBuffer(k.ARRAY_BUFFER,this._attributesBuffer),k.bufferData(k.ARRAY_BUFFER,S.attributes,k.DYNAMIC_DRAW),k.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,k.UNSIGNED_BYTE,0,S.count)}handleResize(){this._updateViewportRectangle()}setDimensions(S){this._dimensions=S}_updateCachedColors(S){this._bgFloat=this._colorToFloat32Array(S.background),this._cursorFloat=this._colorToFloat32Array(S.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(S){const k=this._terminal,L=this._vertices;let A,M,D,O,z,F,H,I,R,P,N,j=1;for(A=0;A<k.rows;A++){for(D=-1,O=0,z=0,F=!1,M=0;M<k.cols;M++)H=(A*k.cols+M)*u.RENDER_MODEL_INDICIES_PER_CELL,I=S.cells[H+u.RENDER_MODEL_BG_OFFSET],R=S.cells[H+u.RENDER_MODEL_FG_OFFSET],P=!!(67108864&R),(I!==O||R!==z&&(F||P))&&((O!==0||F&&z!==0)&&(N=8*j++,this._updateRectangle(L,N,z,O,D,M,A)),D=M,O=I,z=R,F=P);(O!==0||F&&z!==0)&&(N=8*j++,this._updateRectangle(L,N,z,O,D,k.cols,A))}L.count=j}updateCursor(S){const k=this._verticesCursor,L=S.cursor;if(!L||L.style==="block")return void(k.count=0);let A,M=0;L.style!=="bar"&&L.style!=="outline"||(A=8*M++,this._addRectangleFloat(k.attributes,A,L.x*this._dimensions.device.cell.width,L.y*this._dimensions.device.cell.height,L.style==="bar"?L.dpr*L.cursorWidth:L.dpr,this._dimensions.device.cell.height,this._cursorFloat)),L.style!=="underline"&&L.style!=="outline"||(A=8*M++,this._addRectangleFloat(k.attributes,A,L.x*this._dimensions.device.cell.width,(L.y+1)*this._dimensions.device.cell.height-L.dpr,L.width*this._dimensions.device.cell.width,L.dpr,this._cursorFloat)),L.style==="outline"&&(A=8*M++,this._addRectangleFloat(k.attributes,A,L.x*this._dimensions.device.cell.width,L.y*this._dimensions.device.cell.height,L.width*this._dimensions.device.cell.width,L.dpr,this._cursorFloat),A=8*M++,this._addRectangleFloat(k.attributes,A,(L.x+L.width)*this._dimensions.device.cell.width-L.dpr,L.y*this._dimensions.device.cell.height,L.dpr,this._dimensions.device.cell.height,this._cursorFloat)),k.count=M}_updateRectangle(S,k,L,A,M,D,O){if(67108864&L)switch(50331648&L){case 16777216:case 33554432:v=this._themeService.colors.ansi[255&L].rgba;break;case 50331648:v=(16777215&L)<<8;break;default:v=this._themeService.colors.foreground.rgba}else switch(50331648&A){case 16777216:case 33554432:v=this._themeService.colors.ansi[255&A].rgba;break;case 50331648:v=(16777215&A)<<8;break;default:v=this._themeService.colors.background.rgba}S.attributes.length<k+4&&(S.attributes=(0,p.expandFloat32Array)(S.attributes,this._terminal.rows*this._terminal.cols*8)),h=M*this._dimensions.device.cell.width,m=O*this._dimensions.device.cell.height,d=(v>>24&255)/255,g=(v>>16&255)/255,w=(v>>8&255)/255,b=1,this._addRectangle(S.attributes,k,h,m,(D-M)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,d,g,w,b)}_addRectangle(S,k,L,A,M,D,O,z,F,H){S[k]=L/this._dimensions.device.canvas.width,S[k+1]=A/this._dimensions.device.canvas.height,S[k+2]=M/this._dimensions.device.canvas.width,S[k+3]=D/this._dimensions.device.canvas.height,S[k+4]=O,S[k+5]=z,S[k+6]=F,S[k+7]=H}_addRectangleFloat(S,k,L,A,M,D,O){S[k]=L/this._dimensions.device.canvas.width,S[k+1]=A/this._dimensions.device.canvas.height,S[k+2]=M/this._dimensions.device.canvas.width,S[k+3]=D/this._dimensions.device.canvas.height,S[k+4]=O[0],S[k+5]=O[1],S[k+6]=O[2],S[k+7]=O[3]}_colorToFloat32Array(S){return new Float32Array([(S.rgba>>24&255)/255,(S.rgba>>16&255)/255,(S.rgba>>8&255)/255,(255&S.rgba)/255])}}s.RectangleRenderer=x},310:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.RenderModel=s.COMBINED_CHAR_BIT_MASK=s.RENDER_MODEL_EXT_OFFSET=s.RENDER_MODEL_FG_OFFSET=s.RENDER_MODEL_BG_OFFSET=s.RENDER_MODEL_INDICIES_PER_CELL=void 0;const c=o(296);s.RENDER_MODEL_INDICIES_PER_CELL=4,s.RENDER_MODEL_BG_OFFSET=1,s.RENDER_MODEL_FG_OFFSET=2,s.RENDER_MODEL_EXT_OFFSET=3,s.COMBINED_CHAR_BIT_MASK=2147483648,s.RenderModel=class{constructor(){this.cells=new Uint32Array(0),this.lineLengths=new Uint32Array(0),this.selection=(0,c.createSelectionRenderModel)()}resize(f,u){const p=f*u*s.RENDER_MODEL_INDICIES_PER_CELL;p!==this.cells.length&&(this.cells=new Uint32Array(p),this.lineLengths=new Uint32Array(u))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}}},666:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.JoinedCellData=s.WebglRenderer=void 0;const c=o(820),f=o(274),u=o(627),p=o(457),_=o(56),y=o(374),v=o(345),h=o(859),m=o(147),d=o(782),g=o(855),w=o(965),b=o(742),x=o(310),C=o(733);class S extends h.Disposable{constructor(M,D,O,z,F,H,I,R,P){super(),this._terminal=M,this._characterJoinerService=D,this._charSizeService=O,this._coreBrowserService=z,this._coreService=F,this._decorationService=H,this._optionsService=I,this._themeService=R,this._cursorBlinkStateManager=new h.MutableDisposable,this._charAtlasDisposable=this.register(new h.MutableDisposable),this._observerDisposable=this.register(new h.MutableDisposable),this._model=new x.RenderModel,this._workCell=new d.CellData,this._workCell2=new d.CellData,this._rectangleRenderer=this.register(new h.MutableDisposable),this._glyphRenderer=this.register(new h.MutableDisposable),this._onChangeTextureAtlas=this.register(new v.EventEmitter),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this.register(new v.EventEmitter),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this.register(new v.EventEmitter),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this.register(new v.EventEmitter),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this.register(new v.EventEmitter),this.onContextLoss=this._onContextLoss.event,this.register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new f.CellColorResolver(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new C.LinkRenderLayer(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,I,this._themeService)],this.dimensions=(0,y.createRenderDimensions)(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this.register(I.onOptionChange(()=>this._handleOptionsChanged())),this._canvas=this._coreBrowserService.mainDocument.createElement("canvas");const N={antialias:!1,depth:!1,preserveDrawingBuffer:P};if(this._gl=this._canvas.getContext("webgl2",N),!this._gl)throw new Error("WebGL2 not supported "+this._gl);this.register((0,c.addDisposableDomListener)(this._canvas,"webglcontextlost",j=>{console.log("webglcontextlost event received"),j.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn("webgl context not restored; firing onContextLoss"),this._onContextLoss.fire(j)},3e3)})),this.register((0,c.addDisposableDomListener)(this._canvas,"webglcontextrestored",j=>{console.warn("webglcontextrestored event received"),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,(0,u.removeTerminalFromCache)(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=(0,_.observeDevicePixelDimensions)(this._canvas,this._coreBrowserService.window,(j,W)=>this._setCanvasDevicePixelDimensions(j,W)),this.register(this._coreBrowserService.onWindowChange(j=>{this._observerDisposable.value=(0,_.observeDevicePixelDimensions)(this._canvas,j,(W,V)=>this._setCanvasDevicePixelDimensions(W,V))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._coreBrowserService.window.document.body.contains(this._core.screenElement),this.register((0,h.toDisposable)(()=>{var j;for(const W of this._renderLayers)W.dispose();(j=this._canvas.parentElement)==null||j.removeChild(this._canvas),(0,u.removeTerminalFromCache)(this._terminal)}))}get textureAtlas(){var M;return(M=this._charAtlas)==null?void 0:M.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(M,D){var O,z,F,H;this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(const I of this._renderLayers)I.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,(O=this._rectangleRenderer.value)==null||O.setDimensions(this.dimensions),(z=this._rectangleRenderer.value)==null||z.handleResize(),(F=this._glyphRenderer.value)==null||F.setDimensions(this.dimensions),(H=this._glyphRenderer.value)==null||H.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){var M;for(const D of this._renderLayers)D.handleBlur(this._terminal);(M=this._cursorBlinkStateManager.value)==null||M.pause(),this._requestRedrawViewport()}handleFocus(){var M;for(const D of this._renderLayers)D.handleFocus(this._terminal);(M=this._cursorBlinkStateManager.value)==null||M.resume(),this._requestRedrawViewport()}handleSelectionChanged(M,D,O){for(const z of this._renderLayers)z.handleSelectionChanged(this._terminal,M,D,O);this._model.selection.update(this._core,M,D,O),this._requestRedrawViewport()}handleCursorMove(){var M;for(const D of this._renderLayers)D.handleCursorMove(this._terminal);(M=this._cursorBlinkStateManager.value)==null||M.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new b.RectangleRenderer(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new w.GlyphRenderer(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){var D;if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0)return void(this._isAttached=!1);const M=(0,u.acquireTextureAtlas)(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr);this._charAtlas!==M&&(this._onChangeTextureAtlas.fire(M.pages[0].canvas),this._charAtlasDisposable.value=(0,h.getDisposeArrayDisposable)([(0,v.forwardEvent)(M.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),(0,v.forwardEvent)(M.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)])),this._charAtlas=M,this._charAtlas.warmUp(),(D=this._glyphRenderer.value)==null||D.setAtlas(this._charAtlas)}_clearModel(M){var D;this._model.clear(),M&&((D=this._glyphRenderer.value)==null||D.clear())}clearTextureAtlas(){var M;(M=this._charAtlas)==null||M.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){var M;this._clearModel(!0);for(const D of this._renderLayers)D.reset(this._terminal);(M=this._cursorBlinkStateManager.value)==null||M.restartBlinkAnimation(),this._updateCursorBlink()}registerCharacterJoiner(M){return-1}deregisterCharacterJoiner(M){return!1}renderRows(M,D){if(!this._isAttached){if(!(this._coreBrowserService.window.document.body.contains(this._core.screenElement)&&this._charSizeService.width&&this._charSizeService.height))return;this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0}for(const O of this._renderLayers)O.handleGridChanged(this._terminal,M,D);this._glyphRenderer.value&&this._rectangleRenderer.value&&(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(M,D),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),this._cursorBlinkStateManager.value&&!this._cursorBlinkStateManager.value.isCursorVisible||this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new p.CursorBlinkStateManager(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(M,D){const O=this._core;let z,F,H,I,R,P,N,j,W,V,Z,Q,$,B,K=this._workCell;M=L(M,O.rows-1,0),D=L(D,O.rows-1,0);const U=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,te=U-O.buffer.ydisp,Y=Math.min(this._terminal.buffer.active.cursorX,O.cols-1);let _e=-1;const de=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let re=!1;for(F=M;F<=D;F++)for(H=F+O.buffer.ydisp,I=O.buffer.lines.get(H),this._model.lineLengths[F]=0,R=this._characterJoinerService.getJoinedCharacters(H),$=0;$<O.cols;$++)if(z=this._cellColorResolver.result.bg,I.loadCell($,K),$===0&&(z=this._cellColorResolver.result.bg),P=!1,N=$,R.length>0&&$===R[0][0]&&(P=!0,j=R.shift(),K=new k(K,I.translateToString(!0,j[0],j[1]),j[1]-j[0]),N=j[1]-1),W=K.getChars(),V=K.getCode(),Q=(F*O.cols+$)*x.RENDER_MODEL_INDICIES_PER_CELL,this._cellColorResolver.resolve(K,$,H,this.dimensions.device.cell.width),de&&H===U&&($===Y&&(this._model.cursor={x:Y,y:te,width:K.getWidth(),style:this._coreBrowserService.isFocused?O.options.cursorStyle||"block":O.options.cursorInactiveStyle,cursorWidth:O.options.cursorWidth,dpr:this._devicePixelRatio},_e=Y+K.getWidth()-1),$>=Y&&$<=_e&&(this._coreBrowserService.isFocused&&(O.options.cursorStyle||"block")==="block"||this._coreBrowserService.isFocused===!1&&O.options.cursorInactiveStyle==="block")&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),V!==g.NULL_CELL_CODE&&(this._model.lineLengths[F]=$+1),(this._model.cells[Q]!==V||this._model.cells[Q+x.RENDER_MODEL_BG_OFFSET]!==this._cellColorResolver.result.bg||this._model.cells[Q+x.RENDER_MODEL_FG_OFFSET]!==this._cellColorResolver.result.fg||this._model.cells[Q+x.RENDER_MODEL_EXT_OFFSET]!==this._cellColorResolver.result.ext)&&(re=!0,W.length>1&&(V|=x.COMBINED_CHAR_BIT_MASK),this._model.cells[Q]=V,this._model.cells[Q+x.RENDER_MODEL_BG_OFFSET]=this._cellColorResolver.result.bg,this._model.cells[Q+x.RENDER_MODEL_FG_OFFSET]=this._cellColorResolver.result.fg,this._model.cells[Q+x.RENDER_MODEL_EXT_OFFSET]=this._cellColorResolver.result.ext,Z=K.getWidth(),this._glyphRenderer.value.updateCell($,F,V,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,W,Z,z),P))for(K=this._workCell,$++;$<N;$++)B=(F*O.cols+$)*x.RENDER_MODEL_INDICIES_PER_CELL,this._glyphRenderer.value.updateCell($,F,g.NULL_CELL_CODE,0,0,0,g.NULL_CELL_CHAR,0,0),this._model.cells[B]=g.NULL_CELL_CODE,this._model.cells[B+x.RENDER_MODEL_BG_OFFSET]=this._cellColorResolver.result.bg,this._model.cells[B+x.RENDER_MODEL_FG_OFFSET]=this._cellColorResolver.result.fg,this._model.cells[B+x.RENDER_MODEL_EXT_OFFSET]=this._cellColorResolver.result.ext;re&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){this._charSizeService.width&&this._charSizeService.height&&(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(M,D){this._canvas.width===M&&this._canvas.height===D||(this._canvas.width=M,this._canvas.height=D,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){const M=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:M,end:M})}}s.WebglRenderer=S;class k extends m.AttributeData{constructor(M,D,O){super(),this.content=0,this.combinedData="",this.fg=M.fg,this.bg=M.bg,this.combinedData=D,this._width=O}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(M){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}function L(A,M,D=0){return Math.max(Math.min(A,M),D)}s.JoinedCellData=k},381:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.GLTexture=s.expandFloat32Array=s.createShader=s.createProgram=s.PROJECTION_MATRIX=void 0;const c=o(374);function f(u,p,_){const y=(0,c.throwIfFalsy)(u.createShader(p));if(u.shaderSource(y,_),u.compileShader(y),u.getShaderParameter(y,u.COMPILE_STATUS))return y;console.error(u.getShaderInfoLog(y)),u.deleteShader(y)}s.PROJECTION_MATRIX=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]),s.createProgram=function(u,p,_){const y=(0,c.throwIfFalsy)(u.createProgram());if(u.attachShader(y,(0,c.throwIfFalsy)(f(u,u.VERTEX_SHADER,p))),u.attachShader(y,(0,c.throwIfFalsy)(f(u,u.FRAGMENT_SHADER,_))),u.linkProgram(y),u.getProgramParameter(y,u.LINK_STATUS))return y;console.error(u.getProgramInfoLog(y)),u.deleteProgram(y)},s.createShader=f,s.expandFloat32Array=function(u,p){const _=Math.min(2*u.length,p),y=new Float32Array(_);for(let v=0;v<u.length;v++)y[v]=u[v];return y},s.GLTexture=class{constructor(u){this.texture=u,this.version=-1}}},592:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BaseRenderLayer=void 0;const c=o(627),f=o(237),u=o(374),p=o(859);class _ extends p.Disposable{constructor(v,h,m,d,g,w,b,x){super(),this._container=h,this._alpha=g,this._coreBrowserService=w,this._optionsService=b,this._themeService=x,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add(`xterm-${m}-layer`),this._canvas.style.zIndex=d.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this.register(this._themeService.onChangeColors(C=>{this._refreshCharAtlas(v,C),this.reset(v)})),this.register((0,p.toDisposable)(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=(0,u.throwIfFalsy)(this._canvas.getContext("2d",{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(v){}handleFocus(v){}handleCursorMove(v){}handleGridChanged(v,h,m){}handleSelectionChanged(v,h,m,d=!1){}_setTransparency(v,h){if(h===this._alpha)return;const m=this._canvas;this._alpha=h,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,m),this._refreshCharAtlas(v,this._themeService.colors),this.handleGridChanged(v,0,v.rows-1)}_refreshCharAtlas(v,h){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=(0,c.acquireTextureAtlas)(v,this._optionsService.rawOptions,h,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr),this._charAtlas.warmUp())}resize(v,h){this._deviceCellWidth=h.device.cell.width,this._deviceCellHeight=h.device.cell.height,this._deviceCharWidth=h.device.char.width,this._deviceCharHeight=h.device.char.height,this._deviceCharLeft=h.device.char.left,this._deviceCharTop=h.device.char.top,this._canvas.width=h.device.canvas.width,this._canvas.height=h.device.canvas.height,this._canvas.style.width=`${h.css.canvas.width}px`,this._canvas.style.height=`${h.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(v,this._themeService.colors)}_fillBottomLineAtCells(v,h,m=1){this._ctx.fillRect(v*this._deviceCellWidth,(h+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,m*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(v,h,m,d){this._alpha?this._ctx.clearRect(v*this._deviceCellWidth,h*this._deviceCellHeight,m*this._deviceCellWidth,d*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(v*this._deviceCellWidth,h*this._deviceCellHeight,m*this._deviceCellWidth,d*this._deviceCellHeight))}_fillCharTrueColor(v,h,m,d){this._ctx.font=this._getFont(v,!1,!1),this._ctx.textBaseline=f.TEXT_BASELINE,this._clipCell(m,d,h.getWidth()),this._ctx.fillText(h.getChars(),m*this._deviceCellWidth+this._deviceCharLeft,d*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(v,h,m){this._ctx.beginPath(),this._ctx.rect(v*this._deviceCellWidth,h*this._deviceCellHeight,m*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(v,h,m){return`${m?"italic":""} ${h?v.options.fontWeightBold:v.options.fontWeight} ${v.options.fontSize*this._coreBrowserService.dpr}px ${v.options.fontFamily}`}}s.BaseRenderLayer=_},733:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.LinkRenderLayer=void 0;const c=o(197),f=o(237),u=o(592);class p extends u.BaseRenderLayer{constructor(y,v,h,m,d,g,w){super(h,y,"link",v,!0,d,g,w),this.register(m.onShowLinkUnderline(b=>this._handleShowLinkUnderline(b))),this.register(m.onHideLinkUnderline(b=>this._handleHideLinkUnderline(b)))}resize(y,v){super.resize(y,v),this._state=void 0}reset(y){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);const y=this._state.y2-this._state.y1-1;y>0&&this._clearCells(0,this._state.y1+1,this._state.cols,y),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(y){if(y.fg===f.INVERTED_DEFAULT_COLOR?this._ctx.fillStyle=this._themeService.colors.background.css:y.fg!==void 0&&(0,c.is256Color)(y.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[y.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,y.y1===y.y2)this._fillBottomLineAtCells(y.x1,y.y1,y.x2-y.x1);else{this._fillBottomLineAtCells(y.x1,y.y1,y.cols-y.x1);for(let v=y.y1+1;v<y.y2;v++)this._fillBottomLineAtCells(0,v,y.cols);this._fillBottomLineAtCells(0,y.y2,y.x2)}this._state=y}_handleHideLinkUnderline(y){this._clearCurrentLink()}}s.LinkRenderLayer=p},820:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.addDisposableDomListener=void 0,s.addDisposableDomListener=function(o,c,f,u){o.addEventListener(c,f,u);let p=!1;return{dispose:()=>{p||(p=!0,o.removeEventListener(c,f,u))}}}},274:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CellColorResolver=void 0;const c=o(855),f=o(160),u=o(374);let p,_=0,y=0,v=!1,h=!1,m=!1,d=0;s.CellColorResolver=class{constructor(g,w,b,x,C,S){this._terminal=g,this._optionService=w,this._selectionRenderModel=b,this._decorationService=x,this._coreBrowserService=C,this._themeService=S,this.result={fg:0,bg:0,ext:0}}resolve(g,w,b,x){if(this.result.bg=g.bg,this.result.fg=g.fg,this.result.ext=268435456&g.bg?g.extended.ext:0,y=0,_=0,h=!1,v=!1,m=!1,p=this._themeService.colors,d=0,g.getCode()!==c.NULL_CELL_CODE&&g.extended.underlineStyle===4){const C=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));d=w*x%(2*Math.round(C))}if(this._decorationService.forEachDecorationAtCell(w,b,"bottom",C=>{C.backgroundColorRGB&&(y=C.backgroundColorRGB.rgba>>8&16777215,h=!0),C.foregroundColorRGB&&(_=C.foregroundColorRGB.rgba>>8&16777215,v=!0)}),m=this._selectionRenderModel.isCellSelected(this._terminal,w,b),m){if(67108864&this.result.fg||50331648&this.result.bg){if(67108864&this.result.fg)switch(50331648&this.result.fg){case 16777216:case 33554432:y=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:y=(16777215&this.result.fg)<<8|255;break;default:y=this._themeService.colors.foreground.rgba}else switch(50331648&this.result.bg){case 16777216:case 33554432:y=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:y=(16777215&this.result.bg)<<8|255}y=f.rgba.blend(y,4294967040&(this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}else y=(this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(h=!0,p.selectionForeground&&(_=p.selectionForeground.rgba>>8&16777215,v=!0),(0,u.treatGlyphAsBackgroundColor)(g.getCode())){if(67108864&this.result.fg&&!(50331648&this.result.bg))_=(this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(67108864&this.result.fg)switch(50331648&this.result.bg){case 16777216:case 33554432:_=this._themeService.colors.ansi[255&this.result.bg].rgba;break;case 50331648:_=(16777215&this.result.bg)<<8|255}else switch(50331648&this.result.fg){case 16777216:case 33554432:_=this._themeService.colors.ansi[255&this.result.fg].rgba;break;case 50331648:_=(16777215&this.result.fg)<<8|255;break;default:_=this._themeService.colors.foreground.rgba}_=f.rgba.blend(_,4294967040&(this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque).rgba|128)>>8&16777215}v=!0}}this._decorationService.forEachDecorationAtCell(w,b,"top",C=>{C.backgroundColorRGB&&(y=C.backgroundColorRGB.rgba>>8&16777215,h=!0),C.foregroundColorRGB&&(_=C.foregroundColorRGB.rgba>>8&16777215,v=!0)}),h&&(y=m?-16777216&g.bg&-134217729|y|50331648:-16777216&g.bg|y|50331648),v&&(_=-16777216&g.fg&-67108865|_|50331648),67108864&this.result.fg&&(h&&!v&&(_=50331648&this.result.bg?-134217728&this.result.fg|67108863&this.result.bg:-134217728&this.result.fg|16777215&p.background.rgba>>8|50331648,v=!0),!h&&v&&(y=50331648&this.result.fg?-67108864&this.result.bg|67108863&this.result.fg:-67108864&this.result.bg|16777215&p.foreground.rgba>>8|50331648,h=!0)),p=void 0,this.result.bg=h?y:this.result.bg,this.result.fg=v?_:this.result.fg,this.result.ext&=536870911,this.result.ext|=d<<29&3758096384}}},627:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.removeTerminalFromCache=s.acquireTextureAtlas=void 0;const c=o(509),f=o(197),u=[];s.acquireTextureAtlas=function(p,_,y,v,h,m,d,g){const w=(0,f.generateConfig)(v,h,m,d,_,y,g);for(let C=0;C<u.length;C++){const S=u[C],k=S.ownedBy.indexOf(p);if(k>=0){if((0,f.configEquals)(S.config,w))return S.atlas;S.ownedBy.length===1?(S.atlas.dispose(),u.splice(C,1)):S.ownedBy.splice(k,1);break}}for(let C=0;C<u.length;C++){const S=u[C];if((0,f.configEquals)(S.config,w))return S.ownedBy.push(p),S.atlas}const b=p._core,x={atlas:new c.TextureAtlas(document,w,b.unicodeService),config:w,ownedBy:[p]};return u.push(x),x.atlas},s.removeTerminalFromCache=function(p){for(let _=0;_<u.length;_++){const y=u[_].ownedBy.indexOf(p);if(y!==-1){u[_].ownedBy.length===1?(u[_].atlas.dispose(),u.splice(_,1)):u[_].ownedBy.splice(y,1);break}}}},197:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.is256Color=s.configEquals=s.generateConfig=void 0;const c=o(160);s.generateConfig=function(f,u,p,_,y,v,h){const m={foreground:v.foreground,background:v.background,cursor:c.NULL_COLOR,cursorAccent:c.NULL_COLOR,selectionForeground:c.NULL_COLOR,selectionBackgroundTransparent:c.NULL_COLOR,selectionBackgroundOpaque:c.NULL_COLOR,selectionInactiveBackgroundTransparent:c.NULL_COLOR,selectionInactiveBackgroundOpaque:c.NULL_COLOR,ansi:v.ansi.slice(),contrastCache:v.contrastCache,halfContrastCache:v.halfContrastCache};return{customGlyphs:y.customGlyphs,devicePixelRatio:h,letterSpacing:y.letterSpacing,lineHeight:y.lineHeight,deviceCellWidth:f,deviceCellHeight:u,deviceCharWidth:p,deviceCharHeight:_,fontFamily:y.fontFamily,fontSize:y.fontSize,fontWeight:y.fontWeight,fontWeightBold:y.fontWeightBold,allowTransparency:y.allowTransparency,drawBoldTextInBrightColors:y.drawBoldTextInBrightColors,minimumContrastRatio:y.minimumContrastRatio,colors:m}},s.configEquals=function(f,u){for(let p=0;p<f.colors.ansi.length;p++)if(f.colors.ansi[p].rgba!==u.colors.ansi[p].rgba)return!1;return f.devicePixelRatio===u.devicePixelRatio&&f.customGlyphs===u.customGlyphs&&f.lineHeight===u.lineHeight&&f.letterSpacing===u.letterSpacing&&f.fontFamily===u.fontFamily&&f.fontSize===u.fontSize&&f.fontWeight===u.fontWeight&&f.fontWeightBold===u.fontWeightBold&&f.allowTransparency===u.allowTransparency&&f.deviceCharWidth===u.deviceCharWidth&&f.deviceCharHeight===u.deviceCharHeight&&f.drawBoldTextInBrightColors===u.drawBoldTextInBrightColors&&f.minimumContrastRatio===u.minimumContrastRatio&&f.colors.foreground.rgba===u.colors.foreground.rgba&&f.colors.background.rgba===u.colors.background.rgba},s.is256Color=function(f){return(50331648&f)==16777216||(50331648&f)==33554432}},237:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TEXT_BASELINE=s.DIM_OPACITY=s.INVERTED_DEFAULT_COLOR=void 0;const c=o(399);s.INVERTED_DEFAULT_COLOR=257,s.DIM_OPACITY=.5,s.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},457:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CursorBlinkStateManager=void 0,s.CursorBlinkStateManager=class{constructor(o,c){this._renderCallback=o,this._coreBrowserService=c,this.isCursorVisible=!0,this._coreBrowserService.isFocused&&this._restartInterval()}get isPaused(){return!(this._blinkStartTimeout||this._blinkInterval)}dispose(){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}restartBlinkAnimation(){this.isPaused||(this._animationTimeRestarted=Date.now(),this.isCursorVisible=!0,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})))}_restartInterval(o=600){this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){const c=600-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,c>0)return void this._restartInterval(c)}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){const c=600-(Date.now()-this._animationTimeRestarted);return this._animationTimeRestarted=void 0,void this._restartInterval(c)}this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},600)},o)}pause(){this.isCursorVisible=!0,this._blinkInterval&&(this._coreBrowserService.window.clearInterval(this._blinkInterval),this._blinkInterval=void 0),this._blinkStartTimeout&&(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),this._blinkStartTimeout=void 0),this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}}},860:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.tryDrawCustomChar=s.powerlineDefinitions=s.boxDrawingDefinitions=s.blockElementDefinitions=void 0;const c=o(374);s.blockElementDefinitions={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]};const f={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]};s.boxDrawingDefinitions={"─":{1:"M0,.5 L1,.5"},"━":{3:"M0,.5 L1,.5"},"│":{1:"M.5,0 L.5,1"},"┃":{3:"M.5,0 L.5,1"},"┌":{1:"M0.5,1 L.5,.5 L1,.5"},"┏":{3:"M0.5,1 L.5,.5 L1,.5"},"┐":{1:"M0,.5 L.5,.5 L.5,1"},"┓":{3:"M0,.5 L.5,.5 L.5,1"},"└":{1:"M.5,0 L.5,.5 L1,.5"},"┗":{3:"M.5,0 L.5,.5 L1,.5"},"┘":{1:"M.5,0 L.5,.5 L0,.5"},"┛":{3:"M.5,0 L.5,.5 L0,.5"},"├":{1:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┣":{3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"┤":{1:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┫":{3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"┬":{1:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┳":{3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"┴":{1:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┻":{3:"M0,.5 L1,.5 M.5,.5 L.5,0"},"┼":{1:"M0,.5 L1,.5 M.5,0 L.5,1"},"╋":{3:"M0,.5 L1,.5 M.5,0 L.5,1"},"╴":{1:"M.5,.5 L0,.5"},"╸":{3:"M.5,.5 L0,.5"},"╵":{1:"M.5,.5 L.5,0"},"╹":{3:"M.5,.5 L.5,0"},"╶":{1:"M.5,.5 L1,.5"},"╺":{3:"M.5,.5 L1,.5"},"╷":{1:"M.5,.5 L.5,1"},"╻":{3:"M.5,.5 L.5,1"},"═":{1:(v,h)=>`M0,${.5-h} L1,${.5-h} M0,${.5+h} L1,${.5+h}`},"║":{1:(v,h)=>`M${.5-v},0 L${.5-v},1 M${.5+v},0 L${.5+v},1`},"╒":{1:(v,h)=>`M.5,1 L.5,${.5-h} L1,${.5-h} M.5,${.5+h} L1,${.5+h}`},"╓":{1:(v,h)=>`M${.5-v},1 L${.5-v},.5 L1,.5 M${.5+v},.5 L${.5+v},1`},"╔":{1:(v,h)=>`M1,${.5-h} L${.5-v},${.5-h} L${.5-v},1 M1,${.5+h} L${.5+v},${.5+h} L${.5+v},1`},"╕":{1:(v,h)=>`M0,${.5-h} L.5,${.5-h} L.5,1 M0,${.5+h} L.5,${.5+h}`},"╖":{1:(v,h)=>`M${.5+v},1 L${.5+v},.5 L0,.5 M${.5-v},.5 L${.5-v},1`},"╗":{1:(v,h)=>`M0,${.5+h} L${.5-v},${.5+h} L${.5-v},1 M0,${.5-h} L${.5+v},${.5-h} L${.5+v},1`},"╘":{1:(v,h)=>`M.5,0 L.5,${.5+h} L1,${.5+h} M.5,${.5-h} L1,${.5-h}`},"╙":{1:(v,h)=>`M1,.5 L${.5-v},.5 L${.5-v},0 M${.5+v},.5 L${.5+v},0`},"╚":{1:(v,h)=>`M1,${.5-h} L${.5+v},${.5-h} L${.5+v},0 M1,${.5+h} L${.5-v},${.5+h} L${.5-v},0`},"╛":{1:(v,h)=>`M0,${.5+h} L.5,${.5+h} L.5,0 M0,${.5-h} L.5,${.5-h}`},"╜":{1:(v,h)=>`M0,.5 L${.5+v},.5 L${.5+v},0 M${.5-v},.5 L${.5-v},0`},"╝":{1:(v,h)=>`M0,${.5-h} L${.5-v},${.5-h} L${.5-v},0 M0,${.5+h} L${.5+v},${.5+h} L${.5+v},0`},"╞":{1:(v,h)=>`M.5,0 L.5,1 M.5,${.5-h} L1,${.5-h} M.5,${.5+h} L1,${.5+h}`},"╟":{1:(v,h)=>`M${.5-v},0 L${.5-v},1 M${.5+v},0 L${.5+v},1 M${.5+v},.5 L1,.5`},"╠":{1:(v,h)=>`M${.5-v},0 L${.5-v},1 M1,${.5+h} L${.5+v},${.5+h} L${.5+v},1 M1,${.5-h} L${.5+v},${.5-h} L${.5+v},0`},"╡":{1:(v,h)=>`M.5,0 L.5,1 M0,${.5-h} L.5,${.5-h} M0,${.5+h} L.5,${.5+h}`},"╢":{1:(v,h)=>`M0,.5 L${.5-v},.5 M${.5-v},0 L${.5-v},1 M${.5+v},0 L${.5+v},1`},"╣":{1:(v,h)=>`M${.5+v},0 L${.5+v},1 M0,${.5+h} L${.5-v},${.5+h} L${.5-v},1 M0,${.5-h} L${.5-v},${.5-h} L${.5-v},0`},"╤":{1:(v,h)=>`M0,${.5-h} L1,${.5-h} M0,${.5+h} L1,${.5+h} M.5,${.5+h} L.5,1`},"╥":{1:(v,h)=>`M0,.5 L1,.5 M${.5-v},.5 L${.5-v},1 M${.5+v},.5 L${.5+v},1`},"╦":{1:(v,h)=>`M0,${.5-h} L1,${.5-h} M0,${.5+h} L${.5-v},${.5+h} L${.5-v},1 M1,${.5+h} L${.5+v},${.5+h} L${.5+v},1`},"╧":{1:(v,h)=>`M.5,0 L.5,${.5-h} M0,${.5-h} L1,${.5-h} M0,${.5+h} L1,${.5+h}`},"╨":{1:(v,h)=>`M0,.5 L1,.5 M${.5-v},.5 L${.5-v},0 M${.5+v},.5 L${.5+v},0`},"╩":{1:(v,h)=>`M0,${.5+h} L1,${.5+h} M0,${.5-h} L${.5-v},${.5-h} L${.5-v},0 M1,${.5-h} L${.5+v},${.5-h} L${.5+v},0`},"╪":{1:(v,h)=>`M.5,0 L.5,1 M0,${.5-h} L1,${.5-h} M0,${.5+h} L1,${.5+h}`},"╫":{1:(v,h)=>`M0,.5 L1,.5 M${.5-v},0 L${.5-v},1 M${.5+v},0 L${.5+v},1`},"╬":{1:(v,h)=>`M0,${.5+h} L${.5-v},${.5+h} L${.5-v},1 M1,${.5+h} L${.5+v},${.5+h} L${.5+v},1 M0,${.5-h} L${.5-v},${.5-h} L${.5-v},0 M1,${.5-h} L${.5+v},${.5-h} L${.5+v},0`},"╱":{1:"M1,0 L0,1"},"╲":{1:"M0,0 L1,1"},"╳":{1:"M1,0 L0,1 M0,0 L1,1"},"╼":{1:"M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"╽":{1:"M.5,.5 L.5,0",3:"M.5,.5 L.5,1"},"╾":{1:"M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"╿":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┍":{1:"M.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┎":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┑":{1:"M.5,.5 L.5,1",3:"M.5,.5 L0,.5"},"┒":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┕":{1:"M.5,.5 L.5,0",3:"M.5,.5 L1,.5"},"┖":{1:"M.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┙":{1:"M.5,.5 L.5,0",3:"M.5,.5 L0,.5"},"┚":{1:"M.5,.5 L0,.5",3:"M.5,.5 L.5,0"},"┝":{1:"M.5,0 L.5,1",3:"M.5,.5 L1,.5"},"┞":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L.5,0"},"┟":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L.5,1"},"┠":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1"},"┡":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"┢":{1:"M.5,.5 L.5,0",3:"M0.5,1 L.5,.5 L1,.5"},"┥":{1:"M.5,0 L.5,1",3:"M.5,.5 L0,.5"},"┦":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"┧":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L.5,1"},"┨":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1"},"┩":{1:"M.5,.5 L.5,1",3:"M.5,0 L.5,.5 L0,.5"},"┪":{1:"M.5,.5 L.5,0",3:"M0,.5 L.5,.5 L.5,1"},"┭":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┮":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,.5 L1,.5"},"┯":{1:"M.5,.5 L.5,1",3:"M0,.5 L1,.5"},"┰":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"┱":{1:"M.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"┲":{1:"M.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"┵":{1:"M.5,0 L.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┶":{1:"M.5,0 L.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┷":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5"},"┸":{1:"M0,.5 L1,.5",3:"M.5,.5 L.5,0"},"┹":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"┺":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,.5 L1,.5"},"┽":{1:"M.5,0 L.5,1 M.5,.5 L1,.5",3:"M.5,.5 L0,.5"},"┾":{1:"M.5,0 L.5,1 M.5,.5 L0,.5",3:"M.5,.5 L1,.5"},"┿":{1:"M.5,0 L.5,1",3:"M0,.5 L1,.5"},"╀":{1:"M0,.5 L1,.5 M.5,.5 L.5,1",3:"M.5,.5 L.5,0"},"╁":{1:"M.5,.5 L.5,0 M0,.5 L1,.5",3:"M.5,.5 L.5,1"},"╂":{1:"M0,.5 L1,.5",3:"M.5,0 L.5,1"},"╃":{1:"M0.5,1 L.5,.5 L1,.5",3:"M.5,0 L.5,.5 L0,.5"},"╄":{1:"M0,.5 L.5,.5 L.5,1",3:"M.5,0 L.5,.5 L1,.5"},"╅":{1:"M.5,0 L.5,.5 L1,.5",3:"M0,.5 L.5,.5 L.5,1"},"╆":{1:"M.5,0 L.5,.5 L0,.5",3:"M0.5,1 L.5,.5 L1,.5"},"╇":{1:"M.5,.5 L.5,1",3:"M.5,.5 L.5,0 M0,.5 L1,.5"},"╈":{1:"M.5,.5 L.5,0",3:"M0,.5 L1,.5 M.5,.5 L.5,1"},"╉":{1:"M.5,.5 L1,.5",3:"M.5,0 L.5,1 M.5,.5 L0,.5"},"╊":{1:"M.5,.5 L0,.5",3:"M.5,0 L.5,1 M.5,.5 L1,.5"},"╌":{1:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"╍":{3:"M.1,.5 L.4,.5 M.6,.5 L.9,.5"},"┄":{1:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┅":{3:"M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5"},"┈":{1:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"┉":{3:"M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5"},"╎":{1:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"╏":{3:"M.5,.1 L.5,.4 M.5,.6 L.5,.9"},"┆":{1:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┇":{3:"M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333"},"┊":{1:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"┋":{3:"M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95"},"╭":{1:(v,h)=>`M.5,1 L.5,${.5+h/.15*.5} C.5,${.5+h/.15*.5},.5,.5,1,.5`},"╮":{1:(v,h)=>`M.5,1 L.5,${.5+h/.15*.5} C.5,${.5+h/.15*.5},.5,.5,0,.5`},"╯":{1:(v,h)=>`M.5,0 L.5,${.5-h/.15*.5} C.5,${.5-h/.15*.5},.5,.5,0,.5`},"╰":{1:(v,h)=>`M.5,0 L.5,${.5-h/.15*.5} C.5,${.5-h/.15*.5},.5,.5,1,.5`}},s.powerlineDefinitions={"":{d:"M0,0 L1,.5 L0,1",type:0,rightPadding:2},"":{d:"M-1,-.5 L1,.5 L-1,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1,0 L0,.5 L1,1",type:0,leftPadding:2},"":{d:"M2,-.5 L0,.5 L2,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0",type:0,rightPadding:1},"":{d:"M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0",type:1,rightPadding:1},"":{d:"M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0",type:0,leftPadding:1},"":{d:"M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0",type:1,leftPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L-.5,1.5",type:0},"":{d:"M-.5,-.5 L1.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M1.5,-.5 L-.5,1.5 L1.5,1.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5 L-.5,-.5",type:0},"":{d:"M1.5,-.5 L-.5,1.5",type:1,leftPadding:1,rightPadding:1},"":{d:"M-.5,-.5 L1.5,1.5 L1.5,-.5",type:0}},s.powerlineDefinitions[""]=s.powerlineDefinitions[""],s.powerlineDefinitions[""]=s.powerlineDefinitions[""],s.tryDrawCustomChar=function(v,h,m,d,g,w,b,x){const C=s.blockElementDefinitions[h];if(C)return function(A,M,D,O,z,F){for(let H=0;H<M.length;H++){const I=M[H],R=z/8,P=F/8;A.fillRect(D+I.x*R,O+I.y*P,I.w*R,I.h*P)}}(v,C,m,d,g,w),!0;const S=f[h];if(S)return function(A,M,D,O,z,F){let H=u.get(M);H||(H=new Map,u.set(M,H));const I=A.fillStyle;if(typeof I!="string")throw new Error(`Unexpected fillStyle type "${I}"`);let R=H.get(I);if(!R){const P=M[0].length,N=M.length,j=A.canvas.ownerDocument.createElement("canvas");j.width=P,j.height=N;const W=(0,c.throwIfFalsy)(j.getContext("2d")),V=new ImageData(P,N);let Z,Q,$,B;if(I.startsWith("#"))Z=parseInt(I.slice(1,3),16),Q=parseInt(I.slice(3,5),16),$=parseInt(I.slice(5,7),16),B=I.length>7&&parseInt(I.slice(7,9),16)||1;else{if(!I.startsWith("rgba"))throw new Error(`Unexpected fillStyle color format "${I}" when drawing pattern glyph`);[Z,Q,$,B]=I.substring(5,I.length-1).split(",").map(K=>parseFloat(K))}for(let K=0;K<N;K++)for(let U=0;U<P;U++)V.data[4*(K*P+U)]=Z,V.data[4*(K*P+U)+1]=Q,V.data[4*(K*P+U)+2]=$,V.data[4*(K*P+U)+3]=M[K][U]*(255*B);W.putImageData(V,0,0),R=(0,c.throwIfFalsy)(A.createPattern(j,null)),H.set(I,R)}A.fillStyle=R,A.fillRect(D,O,z,F)}(v,S,m,d,g,w),!0;const k=s.boxDrawingDefinitions[h];if(k)return function(A,M,D,O,z,F,H){A.strokeStyle=A.fillStyle;for(const[I,R]of Object.entries(M)){let P;A.beginPath(),A.lineWidth=H*Number.parseInt(I),P=typeof R=="function"?R(.15,.15/F*z):R;for(const N of P.split(" ")){const j=N[0],W=_[j];if(!W){console.error(`Could not find drawing instructions for "${j}"`);continue}const V=N.substring(1).split(",");V[0]&&V[1]&&W(A,y(V,z,F,D,O,!0,H))}A.stroke(),A.closePath()}}(v,k,m,d,g,w,x),!0;const L=s.powerlineDefinitions[h];return!!L&&(function(A,M,D,O,z,F,H,I){const R=new Path2D;R.rect(D,O,z,F),A.clip(R),A.beginPath();const P=H/12;A.lineWidth=I*P;for(const N of M.d.split(" ")){const j=N[0],W=_[j];if(!W){console.error(`Could not find drawing instructions for "${j}"`);continue}const V=N.substring(1).split(",");V[0]&&V[1]&&W(A,y(V,z,F,D,O,!1,I,(M.leftPadding??0)*(P/2),(M.rightPadding??0)*(P/2)))}M.type===1?(A.strokeStyle=A.fillStyle,A.stroke()):A.fill(),A.closePath()}(v,L,m,d,g,w,b,x),!0)};const u=new Map;function p(v,h,m=0){return Math.max(Math.min(v,h),m)}const _={C:(v,h)=>v.bezierCurveTo(h[0],h[1],h[2],h[3],h[4],h[5]),L:(v,h)=>v.lineTo(h[0],h[1]),M:(v,h)=>v.moveTo(h[0],h[1])};function y(v,h,m,d,g,w,b,x=0,C=0){const S=v.map(k=>parseFloat(k)||parseInt(k));if(S.length<2)throw new Error("Too few arguments for instruction");for(let k=0;k<S.length;k+=2)S[k]*=h-x*b-C*b,w&&S[k]!==0&&(S[k]=p(Math.round(S[k]+.5)-.5,h,0)),S[k]+=d+x*b;for(let k=1;k<S.length;k+=2)S[k]*=m,w&&S[k]!==0&&(S[k]=p(Math.round(S[k]+.5)-.5,m,0)),S[k]+=g;return S}},56:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.observeDevicePixelDimensions=void 0;const c=o(859);s.observeDevicePixelDimensions=function(f,u,p){let _=new u.ResizeObserver(y=>{const v=y.find(d=>d.target===f);if(!v)return;if(!("devicePixelContentBoxSize"in v))return _==null||_.disconnect(),void(_=void 0);const h=v.devicePixelContentBoxSize[0].inlineSize,m=v.devicePixelContentBoxSize[0].blockSize;h>0&&m>0&&p(h,m)});try{_.observe(f,{box:["device-pixel-content-box"]})}catch{_.disconnect(),_=void 0}return(0,c.toDisposable)(()=>_==null?void 0:_.disconnect())}},374:(l,s)=>{function o(f){return 57508<=f&&f<=57558}function c(f){return f>=128512&&f<=128591||f>=127744&&f<=128511||f>=128640&&f<=128767||f>=9728&&f<=9983||f>=9984&&f<=10175||f>=65024&&f<=65039||f>=129280&&f<=129535||f>=127462&&f<=127487}Object.defineProperty(s,"__esModule",{value:!0}),s.computeNextVariantOffset=s.createRenderDimensions=s.treatGlyphAsBackgroundColor=s.allowRescaling=s.isEmoji=s.isRestrictedPowerlineGlyph=s.isPowerlineGlyph=s.throwIfFalsy=void 0,s.throwIfFalsy=function(f){if(!f)throw new Error("value must not be falsy");return f},s.isPowerlineGlyph=o,s.isRestrictedPowerlineGlyph=function(f){return 57520<=f&&f<=57527},s.isEmoji=c,s.allowRescaling=function(f,u,p,_){return u===1&&p>Math.ceil(1.5*_)&&f!==void 0&&f>255&&!c(f)&&!o(f)&&!function(y){return 57344<=y&&y<=63743}(f)},s.treatGlyphAsBackgroundColor=function(f){return o(f)||function(u){return 9472<=u&&u<=9631}(f)},s.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}}}},s.computeNextVariantOffset=function(f,u,p=0){return(f-(2*Math.round(u)-p))%(2*Math.round(u))}},296:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.createSelectionRenderModel=void 0;class o{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(f,u,p,_=!1){if(this.selectionStart=u,this.selectionEnd=p,!u||!p||u[0]===p[0]&&u[1]===p[1])return void this.clear();const y=f.buffers.active.ydisp,v=u[1]-y,h=p[1]-y,m=Math.max(v,0),d=Math.min(h,f.rows-1);m>=f.rows||d<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=_,this.viewportStartRow=v,this.viewportEndRow=h,this.viewportCappedStartRow=m,this.viewportCappedEndRow=d,this.startCol=u[0],this.endCol=p[0])}isCellSelected(f,u,p){return!!this.hasSelection&&(p-=f.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?u>=this.startCol&&p>=this.viewportCappedStartRow&&u<this.endCol&&p<=this.viewportCappedEndRow:u<this.startCol&&p>=this.viewportCappedStartRow&&u>=this.endCol&&p<=this.viewportCappedEndRow:p>this.viewportStartRow&&p<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&p===this.viewportStartRow&&u>=this.startCol&&u<this.endCol||this.viewportStartRow<this.viewportEndRow&&p===this.viewportEndRow&&u<this.endCol||this.viewportStartRow<this.viewportEndRow&&p===this.viewportStartRow&&u>=this.startCol)}}s.createSelectionRenderModel=function(){return new o}},509:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TextureAtlas=void 0;const c=o(237),f=o(860),u=o(374),p=o(160),_=o(345),y=o(485),v=o(385),h=o(147),m=o(855),d={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}};let g;class w{get pages(){return this._pages}constructor(k,L,A){this._document=k,this._config=L,this._unicodeService=A,this._didWarmUp=!1,this._cacheMap=new y.FourKeyMap,this._cacheMapCombined=new y.FourKeyMap,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new h.AttributeData,this._textureSize=512,this._onAddTextureAtlasCanvas=new _.EventEmitter,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new _.EventEmitter,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=C(k,4*this._config.deviceCellWidth+4,this._config.deviceCellHeight+4),this._tmpCtx=(0,u.throwIfFalsy)(this._tmpCanvas.getContext("2d",{alpha:this._config.allowTransparency,willReadFrequently:!0}))}dispose(){for(const k of this.pages)k.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||(this._doWarmUp(),this._didWarmUp=!0)}_doWarmUp(){const k=new v.IdleTaskQueue;for(let L=33;L<126;L++)k.enqueue(()=>{if(!this._cacheMap.get(L,m.DEFAULT_COLOR,m.DEFAULT_COLOR,m.DEFAULT_EXT)){const A=this._drawToCache(L,m.DEFAULT_COLOR,m.DEFAULT_COLOR,m.DEFAULT_EXT);this._cacheMap.set(L,m.DEFAULT_COLOR,m.DEFAULT_COLOR,m.DEFAULT_EXT,A)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(this._pages[0].currentRow.x!==0||this._pages[0].currentRow.y!==0){for(const k of this._pages)k.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(w.maxAtlasPages&&this._pages.length>=Math.max(4,w.maxAtlasPages)){const L=this._pages.filter(H=>2*H.canvas.width<=(w.maxTextureSize||4096)).sort((H,I)=>I.canvas.width!==H.canvas.width?I.canvas.width-H.canvas.width:I.percentageUsed-H.percentageUsed);let A=-1,M=0;for(let H=0;H<L.length;H++)if(L[H].canvas.width!==M)A=H,M=L[H].canvas.width;else if(H-A==3)break;const D=L.slice(A,A+4),O=D.map(H=>H.glyphs[0].texturePage).sort((H,I)=>H>I?1:-1),z=this.pages.length-D.length,F=this._mergePages(D,z);F.version++;for(let H=O.length-1;H>=0;H--)this._deletePage(O[H]);this.pages.push(F),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(F.canvas)}const k=new b(this._document,this._textureSize);return this._pages.push(k),this._activePages.push(k),this._onAddTextureAtlasCanvas.fire(k.canvas),k}_mergePages(k,L){const A=2*k[0].canvas.width,M=new b(this._document,A,k);for(const[D,O]of k.entries()){const z=D*O.canvas.width%A,F=Math.floor(D/2)*O.canvas.height;M.ctx.drawImage(O.canvas,z,F);for(const I of O.glyphs)I.texturePage=L,I.sizeClipSpace.x=I.size.x/A,I.sizeClipSpace.y=I.size.y/A,I.texturePosition.x+=z,I.texturePosition.y+=F,I.texturePositionClipSpace.x=I.texturePosition.x/A,I.texturePositionClipSpace.y=I.texturePosition.y/A;this._onRemoveTextureAtlasCanvas.fire(O.canvas);const H=this._activePages.indexOf(O);H!==-1&&this._activePages.splice(H,1)}return M}_deletePage(k){this._pages.splice(k,1);for(let L=k;L<this._pages.length;L++){const A=this._pages[L];for(const M of A.glyphs)M.texturePage--;A.version++}}getRasterizedGlyphCombinedChar(k,L,A,M,D){return this._getFromCacheMap(this._cacheMapCombined,k,L,A,M,D)}getRasterizedGlyph(k,L,A,M,D){return this._getFromCacheMap(this._cacheMap,k,L,A,M,D)}_getFromCacheMap(k,L,A,M,D,O=!1){return g=k.get(L,A,M,D),g||(g=this._drawToCache(L,A,M,D,O),k.set(L,A,M,D,g)),g}_getColorFromAnsiIndex(k){if(k>=this._config.colors.ansi.length)throw new Error("No color found for idx "+k);return this._config.colors.ansi[k]}_getBackgroundColor(k,L,A,M){if(this._config.allowTransparency)return p.NULL_COLOR;let D;switch(k){case 16777216:case 33554432:D=this._getColorFromAnsiIndex(L);break;case 50331648:const O=h.AttributeData.toColorRGB(L);D=p.channels.toColor(O[0],O[1],O[2]);break;default:D=A?p.color.opaque(this._config.colors.foreground):this._config.colors.background}return D}_getForegroundColor(k,L,A,M,D,O,z,F,H,I){const R=this._getMinimumContrastColor(k,L,A,M,D,O,z,H,F,I);if(R)return R;let P;switch(D){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&H&&O<8&&(O+=8),P=this._getColorFromAnsiIndex(O);break;case 50331648:const N=h.AttributeData.toColorRGB(O);P=p.channels.toColor(N[0],N[1],N[2]);break;default:P=z?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(P=p.color.opaque(P)),F&&(P=p.color.multiplyOpacity(P,c.DIM_OPACITY)),P}_resolveBackgroundRgba(k,L,A){switch(k){case 16777216:case 33554432:return this._getColorFromAnsiIndex(L).rgba;case 50331648:return L<<8;default:return A?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(k,L,A,M){switch(k){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&M&&L<8&&(L+=8),this._getColorFromAnsiIndex(L).rgba;case 50331648:return L<<8;default:return A?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(k,L,A,M,D,O,z,F,H,I){if(this._config.minimumContrastRatio===1||I)return;const R=this._getContrastCache(H),P=R.getColor(k,M);if(P!==void 0)return P||void 0;const N=this._resolveBackgroundRgba(L,A,z),j=this._resolveForegroundRgba(D,O,z,F),W=p.rgba.ensureContrastRatio(N,j,this._config.minimumContrastRatio/(H?2:1));if(!W)return void R.setColor(k,M,null);const V=p.channels.toColor(W>>24&255,W>>16&255,W>>8&255);return R.setColor(k,M,V),V}_getContrastCache(k){return k?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(k,L,A,M,D=!1){const O=typeof k=="number"?String.fromCharCode(k):k,z=Math.min(this._config.deviceCellWidth*Math.max(O.length,2)+4,this._textureSize);this._tmpCanvas.width<z&&(this._tmpCanvas.width=z);const F=Math.min(this._config.deviceCellHeight+8,this._textureSize);if(this._tmpCanvas.height<F&&(this._tmpCanvas.height=F),this._tmpCtx.save(),this._workAttributeData.fg=A,this._workAttributeData.bg=L,this._workAttributeData.extended.ext=M,this._workAttributeData.isInvisible())return d;const H=!!this._workAttributeData.isBold(),I=!!this._workAttributeData.isInverse(),R=!!this._workAttributeData.isDim(),P=!!this._workAttributeData.isItalic(),N=!!this._workAttributeData.isUnderline(),j=!!this._workAttributeData.isStrikethrough(),W=!!this._workAttributeData.isOverline();let V=this._workAttributeData.getFgColor(),Z=this._workAttributeData.getFgColorMode(),Q=this._workAttributeData.getBgColor(),$=this._workAttributeData.getBgColorMode();if(I){const ae=V;V=Q,Q=ae;const ve=Z;Z=$,$=ve}const B=this._getBackgroundColor($,Q,I,R);this._tmpCtx.globalCompositeOperation="copy",this._tmpCtx.fillStyle=B.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.globalCompositeOperation="source-over";const K=H?this._config.fontWeightBold:this._config.fontWeight,U=P?"italic":"";this._tmpCtx.font=`${U} ${K} ${this._config.fontSize*this._config.devicePixelRatio}px ${this._config.fontFamily}`,this._tmpCtx.textBaseline=c.TEXT_BASELINE;const te=O.length===1&&(0,u.isPowerlineGlyph)(O.charCodeAt(0)),Y=O.length===1&&(0,u.isRestrictedPowerlineGlyph)(O.charCodeAt(0)),_e=this._getForegroundColor(L,$,Q,A,Z,V,I,R,H,(0,u.treatGlyphAsBackgroundColor)(O.charCodeAt(0)));this._tmpCtx.fillStyle=_e.css;const de=Y?0:4;let re=!1;this._config.customGlyphs!==!1&&(re=(0,f.tryDrawCustomChar)(this._tmpCtx,O,de,de,this._config.deviceCellWidth,this._config.deviceCellHeight,this._config.fontSize,this._config.devicePixelRatio));let le,ne=!te;if(le=typeof k=="number"?this._unicodeService.wcwidth(k):this._unicodeService.getStringCellWidth(k),N){this._tmpCtx.save();const ae=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),ve=ae%2==1?.5:0;if(this._tmpCtx.lineWidth=ae,this._workAttributeData.isUnderlineColorDefault())this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle;else if(this._workAttributeData.isUnderlineColorRGB())ne=!1,this._tmpCtx.strokeStyle=`rgb(${h.AttributeData.toColorRGB(this._workAttributeData.getUnderlineColor()).join(",")})`;else{ne=!1;let Oe=this._workAttributeData.getUnderlineColor();this._config.drawBoldTextInBrightColors&&this._workAttributeData.isBold()&&Oe<8&&(Oe+=8),this._tmpCtx.strokeStyle=this._getColorFromAnsiIndex(Oe).css}this._tmpCtx.beginPath();const Ce=de,Le=Math.ceil(de+this._config.deviceCharHeight)-ve-(D?2*ae:0),je=Le+ae,Fe=Le+2*ae;let Pe=this._workAttributeData.getUnderlineVariantOffset();for(let Oe=0;Oe<le;Oe++){this._tmpCtx.save();const Ee=Ce+Oe*this._config.deviceCellWidth,q=Ce+(Oe+1)*this._config.deviceCellWidth,ee=Ee+this._config.deviceCellWidth/2;switch(this._workAttributeData.extended.underlineStyle){case 2:this._tmpCtx.moveTo(Ee,Le),this._tmpCtx.lineTo(q,Le),this._tmpCtx.moveTo(Ee,Fe),this._tmpCtx.lineTo(q,Fe);break;case 3:const Ne=ae<=1?Fe:Math.ceil(de+this._config.deviceCharHeight-ae/2)-ve,qe=ae<=1?Le:Math.ceil(de+this._config.deviceCharHeight+ae/2)-ve,Ae=new Path2D;Ae.rect(Ee,Le,this._config.deviceCellWidth,Fe-Le),this._tmpCtx.clip(Ae),this._tmpCtx.moveTo(Ee-this._config.deviceCellWidth/2,je),this._tmpCtx.bezierCurveTo(Ee-this._config.deviceCellWidth/2,qe,Ee,qe,Ee,je),this._tmpCtx.bezierCurveTo(Ee,Ne,ee,Ne,ee,je),this._tmpCtx.bezierCurveTo(ee,qe,q,qe,q,je),this._tmpCtx.bezierCurveTo(q,Ne,q+this._config.deviceCellWidth/2,Ne,q+this._config.deviceCellWidth/2,je);break;case 4:const G=Pe===0?0:Pe>=ae?2*ae-Pe:ae-Pe;Pe>=ae||G===0?(this._tmpCtx.setLineDash([Math.round(ae),Math.round(ae)]),this._tmpCtx.moveTo(Ee+G,Le),this._tmpCtx.lineTo(q,Le)):(this._tmpCtx.setLineDash([Math.round(ae),Math.round(ae)]),this._tmpCtx.moveTo(Ee,Le),this._tmpCtx.lineTo(Ee+G,Le),this._tmpCtx.moveTo(Ee+G+ae,Le),this._tmpCtx.lineTo(q,Le)),Pe=(0,u.computeNextVariantOffset)(q-Ee,ae,Pe);break;case 5:const me=.6,J=.3,Se=q-Ee,ie=Math.floor(me*Se),he=Math.floor(J*Se),ke=Se-ie-he;this._tmpCtx.setLineDash([ie,he,ke]),this._tmpCtx.moveTo(Ee,Le),this._tmpCtx.lineTo(q,Le);break;default:this._tmpCtx.moveTo(Ee,Le),this._tmpCtx.lineTo(q,Le)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!re&&this._config.fontSize>=12&&!this._config.allowTransparency&&O!==" "){this._tmpCtx.save(),this._tmpCtx.textBaseline="alphabetic";const Oe=this._tmpCtx.measureText(O);if(this._tmpCtx.restore(),"actualBoundingBoxDescent"in Oe&&Oe.actualBoundingBoxDescent>0){this._tmpCtx.save();const Ee=new Path2D;Ee.rect(Ce,Le-Math.ceil(ae/2),this._config.deviceCellWidth*le,Fe-Le+Math.ceil(ae/2)),this._tmpCtx.clip(Ee),this._tmpCtx.lineWidth=3*this._config.devicePixelRatio,this._tmpCtx.strokeStyle=B.css,this._tmpCtx.strokeText(O,de,de+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(W){const ae=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),ve=ae%2==1?.5:0;this._tmpCtx.lineWidth=ae,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(de,de+ve),this._tmpCtx.lineTo(de+this._config.deviceCharWidth*le,de+ve),this._tmpCtx.stroke()}if(re||this._tmpCtx.fillText(O,de,de+this._config.deviceCharHeight),O==="_"&&!this._config.allowTransparency){let ae=x(this._tmpCtx.getImageData(de,de,this._config.deviceCellWidth,this._config.deviceCellHeight),B,_e,ne);if(ae)for(let ve=1;ve<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=B.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(O,de,de+this._config.deviceCharHeight-ve),ae=x(this._tmpCtx.getImageData(de,de,this._config.deviceCellWidth,this._config.deviceCellHeight),B,_e,ne),ae);ve++);}if(j){const ae=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),ve=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=ae,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(de,de+Math.floor(this._config.deviceCharHeight/2)-ve),this._tmpCtx.lineTo(de+this._config.deviceCharWidth*le,de+Math.floor(this._config.deviceCharHeight/2)-ve),this._tmpCtx.stroke()}this._tmpCtx.restore();const fe=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height);let ge;if(ge=this._config.allowTransparency?function(ae){for(let ve=0;ve<ae.data.length;ve+=4)if(ae.data[ve+3]>0)return!1;return!0}(fe):x(fe,B,_e,ne),ge)return d;const se=this._findGlyphBoundingBox(fe,this._workBoundingBox,z,Y,re,de);let oe,ue;for(;;){if(this._activePages.length===0){const ae=this._createNewPage();oe=ae,ue=ae.currentRow,ue.height=se.size.y;break}oe=this._activePages[this._activePages.length-1],ue=oe.currentRow;for(const ae of this._activePages)se.size.y<=ae.currentRow.height&&(oe=ae,ue=ae.currentRow);for(let ae=this._activePages.length-1;ae>=0;ae--)for(const ve of this._activePages[ae].fixedRows)ve.height<=ue.height&&se.size.y<=ve.height&&(oe=this._activePages[ae],ue=ve);if(ue.y+se.size.y>=oe.canvas.height||ue.height>se.size.y+2){let ae=!1;if(oe.currentRow.y+oe.currentRow.height+se.size.y>=oe.canvas.height){let ve;for(const Ce of this._activePages)if(Ce.currentRow.y+Ce.currentRow.height+se.size.y<Ce.canvas.height){ve=Ce;break}if(ve)oe=ve;else if(w.maxAtlasPages&&this._pages.length>=w.maxAtlasPages&&ue.y+se.size.y<=oe.canvas.height&&ue.height>=se.size.y&&ue.x+se.size.x<=oe.canvas.width)ae=!0;else{const Ce=this._createNewPage();oe=Ce,ue=Ce.currentRow,ue.height=se.size.y,ae=!0}}ae||(oe.currentRow.height>0&&oe.fixedRows.push(oe.currentRow),ue={x:0,y:oe.currentRow.y+oe.currentRow.height,height:se.size.y},oe.fixedRows.push(ue),oe.currentRow={x:0,y:ue.y+ue.height,height:0})}if(ue.x+se.size.x<=oe.canvas.width)break;ue===oe.currentRow?(ue.x=0,ue.y+=ue.height,ue.height=0):oe.fixedRows.splice(oe.fixedRows.indexOf(ue),1)}return se.texturePage=this._pages.indexOf(oe),se.texturePosition.x=ue.x,se.texturePosition.y=ue.y,se.texturePositionClipSpace.x=ue.x/oe.canvas.width,se.texturePositionClipSpace.y=ue.y/oe.canvas.height,se.sizeClipSpace.x/=oe.canvas.width,se.sizeClipSpace.y/=oe.canvas.height,ue.height=Math.max(ue.height,se.size.y),ue.x+=se.size.x,oe.ctx.putImageData(fe,se.texturePosition.x-this._workBoundingBox.left,se.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,se.size.x,se.size.y),oe.addGlyph(se),oe.version++,se}_findGlyphBoundingBox(k,L,A,M,D,O){L.top=0;const z=M?this._config.deviceCellHeight:this._tmpCanvas.height,F=M?this._config.deviceCellWidth:A;let H=!1;for(let I=0;I<z;I++){for(let R=0;R<F;R++){const P=I*this._tmpCanvas.width*4+4*R+3;if(k.data[P]!==0){L.top=I,H=!0;break}}if(H)break}L.left=0,H=!1;for(let I=0;I<O+F;I++){for(let R=0;R<z;R++){const P=R*this._tmpCanvas.width*4+4*I+3;if(k.data[P]!==0){L.left=I,H=!0;break}}if(H)break}L.right=F,H=!1;for(let I=O+F-1;I>=O;I--){for(let R=0;R<z;R++){const P=R*this._tmpCanvas.width*4+4*I+3;if(k.data[P]!==0){L.right=I,H=!0;break}}if(H)break}L.bottom=z,H=!1;for(let I=z-1;I>=0;I--){for(let R=0;R<F;R++){const P=I*this._tmpCanvas.width*4+4*R+3;if(k.data[P]!==0){L.bottom=I,H=!0;break}}if(H)break}return{texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},size:{x:L.right-L.left+1,y:L.bottom-L.top+1},sizeClipSpace:{x:L.right-L.left+1,y:L.bottom-L.top+1},offset:{x:-L.left+O+(M||D?Math.floor((this._config.deviceCellWidth-this._config.deviceCharWidth)/2):0),y:-L.top+O+(M||D?this._config.lineHeight===1?0:Math.round((this._config.deviceCellHeight-this._config.deviceCharHeight)/2):0)}}}}s.TextureAtlas=w;class b{get percentageUsed(){return this._usedPixels/(this.canvas.width*this.canvas.height)}get glyphs(){return this._glyphs}addGlyph(k){this._glyphs.push(k),this._usedPixels+=k.size.x*k.size.y}constructor(k,L,A){if(this._usedPixels=0,this._glyphs=[],this.version=0,this.currentRow={x:0,y:0,height:0},this.fixedRows=[],A)for(const M of A)this._glyphs.push(...M.glyphs),this._usedPixels+=M._usedPixels;this.canvas=C(k,L,L),this.ctx=(0,u.throwIfFalsy)(this.canvas.getContext("2d",{alpha:!0}))}clear(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.currentRow.x=0,this.currentRow.y=0,this.currentRow.height=0,this.fixedRows.length=0,this.version++}}function x(S,k,L,A){const M=k.rgba>>>24,D=k.rgba>>>16&255,O=k.rgba>>>8&255,z=L.rgba>>>24,F=L.rgba>>>16&255,H=L.rgba>>>8&255,I=Math.floor((Math.abs(M-z)+Math.abs(D-F)+Math.abs(O-H))/12);let R=!0;for(let P=0;P<S.data.length;P+=4)S.data[P]===M&&S.data[P+1]===D&&S.data[P+2]===O||A&&Math.abs(S.data[P]-M)+Math.abs(S.data[P+1]-D)+Math.abs(S.data[P+2]-O)<I?S.data[P+3]=0:R=!1;return R}function C(S,k,L){const A=S.createElement("canvas");return A.width=k,A.height=L,A}},160:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.contrastRatio=s.toPaddedHex=s.rgba=s.rgb=s.css=s.color=s.channels=s.NULL_COLOR=void 0;let o=0,c=0,f=0,u=0;var p,_,y,v,h;function m(g){const w=g.toString(16);return w.length<2?"0"+w:w}function d(g,w){return g<w?(w+.05)/(g+.05):(g+.05)/(w+.05)}s.NULL_COLOR={css:"#00000000",rgba:0},function(g){g.toCss=function(w,b,x,C){return C!==void 0?`#${m(w)}${m(b)}${m(x)}${m(C)}`:`#${m(w)}${m(b)}${m(x)}`},g.toRgba=function(w,b,x,C=255){return(w<<24|b<<16|x<<8|C)>>>0},g.toColor=function(w,b,x,C){return{css:g.toCss(w,b,x,C),rgba:g.toRgba(w,b,x,C)}}}(p||(s.channels=p={})),function(g){function w(b,x){return u=Math.round(255*x),[o,c,f]=h.toChannels(b.rgba),{css:p.toCss(o,c,f,u),rgba:p.toRgba(o,c,f,u)}}g.blend=function(b,x){if(u=(255&x.rgba)/255,u===1)return{css:x.css,rgba:x.rgba};const C=x.rgba>>24&255,S=x.rgba>>16&255,k=x.rgba>>8&255,L=b.rgba>>24&255,A=b.rgba>>16&255,M=b.rgba>>8&255;return o=L+Math.round((C-L)*u),c=A+Math.round((S-A)*u),f=M+Math.round((k-M)*u),{css:p.toCss(o,c,f),rgba:p.toRgba(o,c,f)}},g.isOpaque=function(b){return(255&b.rgba)==255},g.ensureContrastRatio=function(b,x,C){const S=h.ensureContrastRatio(b.rgba,x.rgba,C);if(S)return p.toColor(S>>24&255,S>>16&255,S>>8&255)},g.opaque=function(b){const x=(255|b.rgba)>>>0;return[o,c,f]=h.toChannels(x),{css:p.toCss(o,c,f),rgba:x}},g.opacity=w,g.multiplyOpacity=function(b,x){return u=255&b.rgba,w(b,u*x/255)},g.toColorRGB=function(b){return[b.rgba>>24&255,b.rgba>>16&255,b.rgba>>8&255]}}(_||(s.color=_={})),function(g){let w,b;try{const x=document.createElement("canvas");x.width=1,x.height=1;const C=x.getContext("2d",{willReadFrequently:!0});C&&(w=C,w.globalCompositeOperation="copy",b=w.createLinearGradient(0,0,1,1))}catch{}g.toColor=function(x){if(x.match(/#[\da-f]{3,8}/i))switch(x.length){case 4:return o=parseInt(x.slice(1,2).repeat(2),16),c=parseInt(x.slice(2,3).repeat(2),16),f=parseInt(x.slice(3,4).repeat(2),16),p.toColor(o,c,f);case 5:return o=parseInt(x.slice(1,2).repeat(2),16),c=parseInt(x.slice(2,3).repeat(2),16),f=parseInt(x.slice(3,4).repeat(2),16),u=parseInt(x.slice(4,5).repeat(2),16),p.toColor(o,c,f,u);case 7:return{css:x,rgba:(parseInt(x.slice(1),16)<<8|255)>>>0};case 9:return{css:x,rgba:parseInt(x.slice(1),16)>>>0}}const C=x.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(C)return o=parseInt(C[1]),c=parseInt(C[2]),f=parseInt(C[3]),u=Math.round(255*(C[5]===void 0?1:parseFloat(C[5]))),p.toColor(o,c,f,u);if(!w||!b)throw new Error("css.toColor: Unsupported css format");if(w.fillStyle=b,w.fillStyle=x,typeof w.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(w.fillRect(0,0,1,1),[o,c,f,u]=w.getImageData(0,0,1,1).data,u!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:p.toRgba(o,c,f,u),css:x}}}(y||(s.css=y={})),function(g){function w(b,x,C){const S=b/255,k=x/255,L=C/255;return .2126*(S<=.03928?S/12.92:Math.pow((S+.055)/1.055,2.4))+.7152*(k<=.03928?k/12.92:Math.pow((k+.055)/1.055,2.4))+.0722*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))}g.relativeLuminance=function(b){return w(b>>16&255,b>>8&255,255&b)},g.relativeLuminance2=w}(v||(s.rgb=v={})),function(g){function w(x,C,S){const k=x>>24&255,L=x>>16&255,A=x>>8&255;let M=C>>24&255,D=C>>16&255,O=C>>8&255,z=d(v.relativeLuminance2(M,D,O),v.relativeLuminance2(k,L,A));for(;z<S&&(M>0||D>0||O>0);)M-=Math.max(0,Math.ceil(.1*M)),D-=Math.max(0,Math.ceil(.1*D)),O-=Math.max(0,Math.ceil(.1*O)),z=d(v.relativeLuminance2(M,D,O),v.relativeLuminance2(k,L,A));return(M<<24|D<<16|O<<8|255)>>>0}function b(x,C,S){const k=x>>24&255,L=x>>16&255,A=x>>8&255;let M=C>>24&255,D=C>>16&255,O=C>>8&255,z=d(v.relativeLuminance2(M,D,O),v.relativeLuminance2(k,L,A));for(;z<S&&(M<255||D<255||O<255);)M=Math.min(255,M+Math.ceil(.1*(255-M))),D=Math.min(255,D+Math.ceil(.1*(255-D))),O=Math.min(255,O+Math.ceil(.1*(255-O))),z=d(v.relativeLuminance2(M,D,O),v.relativeLuminance2(k,L,A));return(M<<24|D<<16|O<<8|255)>>>0}g.blend=function(x,C){if(u=(255&C)/255,u===1)return C;const S=C>>24&255,k=C>>16&255,L=C>>8&255,A=x>>24&255,M=x>>16&255,D=x>>8&255;return o=A+Math.round((S-A)*u),c=M+Math.round((k-M)*u),f=D+Math.round((L-D)*u),p.toRgba(o,c,f)},g.ensureContrastRatio=function(x,C,S){const k=v.relativeLuminance(x>>8),L=v.relativeLuminance(C>>8);if(d(k,L)<S){if(L<k){const D=w(x,C,S),O=d(k,v.relativeLuminance(D>>8));if(O<S){const z=b(x,C,S);return O>d(k,v.relativeLuminance(z>>8))?D:z}return D}const A=b(x,C,S),M=d(k,v.relativeLuminance(A>>8));if(M<S){const D=w(x,C,S);return M>d(k,v.relativeLuminance(D>>8))?A:D}return A}},g.reduceLuminance=w,g.increaseLuminance=b,g.toChannels=function(x){return[x>>24&255,x>>16&255,x>>8&255,255&x]}}(h||(s.rgba=h={})),s.toPaddedHex=m,s.contrastRatio=d},345:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.runAndSubscribe=s.forwardEvent=s.EventEmitter=void 0,s.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=o=>(this._listeners.push(o),{dispose:()=>{if(!this._disposed){for(let c=0;c<this._listeners.length;c++)if(this._listeners[c]===o)return void this._listeners.splice(c,1)}}})),this._event}fire(o,c){const f=[];for(let u=0;u<this._listeners.length;u++)f.push(this._listeners[u]);for(let u=0;u<f.length;u++)f[u].call(void 0,o,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},s.forwardEvent=function(o,c){return o(f=>c.fire(f))},s.runAndSubscribe=function(o,c){return c(void 0),o(f=>c(f))}},859:(l,s)=>{function o(c){for(const f of c)f.dispose();c.length=0}Object.defineProperty(s,"__esModule",{value:!0}),s.getDisposeArrayDisposable=s.disposeArray=s.toDisposable=s.MutableDisposable=s.Disposable=void 0,s.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const c of this._disposables)c.dispose();this._disposables.length=0}register(c){return this._disposables.push(c),c}unregister(c){const f=this._disposables.indexOf(c);f!==-1&&this._disposables.splice(f,1)}},s.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var f;this._isDisposed||c===this._value||((f=this._value)==null||f.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){var c;this._isDisposed=!0,(c=this._value)==null||c.dispose(),this._value=void 0}},s.toDisposable=function(c){return{dispose:c}},s.disposeArray=o,s.getDisposeArrayDisposable=function(c){return{dispose:()=>o(c)}}},485:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.FourKeyMap=s.TwoKeyMap=void 0;class o{constructor(){this._data={}}set(f,u,p){this._data[f]||(this._data[f]={}),this._data[f][u]=p}get(f,u){return this._data[f]?this._data[f][u]:void 0}clear(){this._data={}}}s.TwoKeyMap=o,s.FourKeyMap=class{constructor(){this._data=new o}set(c,f,u,p,_){this._data.get(c,f)||this._data.set(c,f,new o),this._data.get(c,f).set(u,p,_)}get(c,f,u,p){var _;return(_=this._data.get(c,f))==null?void 0:_.get(u,p)}clear(){this._data.clear()}}},399:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.isChromeOS=s.isLinux=s.isWindows=s.isIphone=s.isIpad=s.isMac=s.getSafariVersion=s.isSafari=s.isLegacyEdge=s.isFirefox=s.isNode=void 0,s.isNode=typeof process<"u"&&"title"in process;const o=s.isNode?"node":navigator.userAgent,c=s.isNode?"node":navigator.platform;s.isFirefox=o.includes("Firefox"),s.isLegacyEdge=o.includes("Edge"),s.isSafari=/^((?!chrome|android).)*safari/i.test(o),s.getSafariVersion=function(){if(!s.isSafari)return 0;const f=o.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[1])},s.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),s.isIpad=c==="iPad",s.isIphone=c==="iPhone",s.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),s.isLinux=c.indexOf("Linux")>=0,s.isChromeOS=/\bCrOS\b/.test(o)},385:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DebouncedIdleTask=s.IdleTaskQueue=s.PriorityTaskQueue=void 0;const c=o(399);class f{constructor(){this._tasks=[],this._i=0}enqueue(_){this._tasks.push(_),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(_){this._idleCallback=void 0;let y=0,v=0,h=_.timeRemaining(),m=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),v=Math.max(y,v),m=_.timeRemaining(),1.5*v>m)return h-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(h-y))}ms`),void this._start();h=m}this.clear()}}class u extends f{_requestCallback(_){return setTimeout(()=>_(this._createDeadline(16)))}_cancelCallback(_){clearTimeout(_)}_createDeadline(_){const y=Date.now()+_;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}s.PriorityTaskQueue=u,s.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(p){return requestIdleCallback(p)}_cancelCallback(p){cancelIdleCallback(p)}}:u,s.DebouncedIdleTask=class{constructor(){this._queue=new s.IdleTaskQueue}set(p){this._queue.clear(),this._queue.enqueue(p)}flush(){this._queue.flush()}}},147:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ExtendedAttrs=s.AttributeData=void 0;class o{constructor(){this.fg=0,this.bg=0,this.extended=new c}static toColorRGB(u){return[u>>>16&255,u>>>8&255,255&u]}static fromColorRGB(u){return(255&u[0])<<16|(255&u[1])<<8|255&u[2]}clone(){const u=new o;return u.fg=this.fg,u.bg=this.bg,u.extended=this.extended.clone(),u}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}s.AttributeData=o;class c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(u){this._ext=u}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(u){this._ext&=-469762049,this._ext|=u<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(u){this._ext&=-67108864,this._ext|=67108863&u}get urlId(){return this._urlId}set urlId(u){this._urlId=u}get underlineVariantOffset(){const u=(3758096384&this._ext)>>29;return u<0?4294967288^u:u}set underlineVariantOffset(u){this._ext&=536870911,this._ext|=u<<29&3758096384}constructor(u=0,p=0){this._ext=0,this._urlId=0,this._ext=u,this._urlId=p}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}s.ExtendedAttrs=c},782:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CellData=void 0;const c=o(133),f=o(855),u=o(147);class p extends u.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new u.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const v=new p;return v.setFromCharData(y),v}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,c.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let v=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)v=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const h=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=h&&h<=56319){const m=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=m&&m<=57343?this.content=1024*(h-55296)+m-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:v=!0}else v=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;v&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}s.CellData=p},855:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.WHITESPACE_CELL_CODE=s.WHITESPACE_CELL_WIDTH=s.WHITESPACE_CELL_CHAR=s.NULL_CELL_CODE=s.NULL_CELL_WIDTH=s.NULL_CELL_CHAR=s.CHAR_DATA_CODE_INDEX=s.CHAR_DATA_WIDTH_INDEX=s.CHAR_DATA_CHAR_INDEX=s.CHAR_DATA_ATTR_INDEX=s.DEFAULT_EXT=s.DEFAULT_ATTR=s.DEFAULT_COLOR=void 0,s.DEFAULT_COLOR=0,s.DEFAULT_ATTR=256|s.DEFAULT_COLOR<<9,s.DEFAULT_EXT=0,s.CHAR_DATA_ATTR_INDEX=0,s.CHAR_DATA_CHAR_INDEX=1,s.CHAR_DATA_WIDTH_INDEX=2,s.CHAR_DATA_CODE_INDEX=3,s.NULL_CELL_CHAR="",s.NULL_CELL_WIDTH=1,s.NULL_CELL_CODE=0,s.WHITESPACE_CELL_CHAR=" ",s.WHITESPACE_CELL_WIDTH=1,s.WHITESPACE_CELL_CODE=32},133:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Utf8ToUtf32=s.StringToUtf32=s.utf32ToString=s.stringFromCodePoint=void 0,s.stringFromCodePoint=function(o){return o>65535?(o-=65536,String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):String.fromCharCode(o)},s.utf32ToString=function(o,c=0,f=o.length){let u="";for(let p=c;p<f;++p){let _=o[p];_>65535?(_-=65536,u+=String.fromCharCode(55296+(_>>10))+String.fromCharCode(_%1024+56320)):u+=String.fromCharCode(_)}return u},s.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(o,c){const f=o.length;if(!f)return 0;let u=0,p=0;if(this._interim){const _=o.charCodeAt(p++);56320<=_&&_<=57343?c[u++]=1024*(this._interim-55296)+_-56320+65536:(c[u++]=this._interim,c[u++]=_),this._interim=0}for(let _=p;_<f;++_){const y=o.charCodeAt(_);if(55296<=y&&y<=56319){if(++_>=f)return this._interim=y,u;const v=o.charCodeAt(_);56320<=v&&v<=57343?c[u++]=1024*(y-55296)+v-56320+65536:(c[u++]=y,c[u++]=v)}else y!==65279&&(c[u++]=y)}return u}},s.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(o,c){const f=o.length;if(!f)return 0;let u,p,_,y,v=0,h=0,m=0;if(this.interim[0]){let w=!1,b=this.interim[0];b&=(224&b)==192?31:(240&b)==224?15:7;let x,C=0;for(;(x=63&this.interim[++C])&&C<4;)b<<=6,b|=x;const S=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,k=S-C;for(;m<k;){if(m>=f)return 0;if(x=o[m++],(192&x)!=128){m--,w=!0;break}this.interim[C++]=x,b<<=6,b|=63&x}w||(S===2?b<128?m--:c[v++]=b:S===3?b<2048||b>=55296&&b<=57343||b===65279||(c[v++]=b):b<65536||b>1114111||(c[v++]=b)),this.interim.fill(0)}const d=f-4;let g=m;for(;g<f;){for(;!(!(g<d)||128&(u=o[g])||128&(p=o[g+1])||128&(_=o[g+2])||128&(y=o[g+3]));)c[v++]=u,c[v++]=p,c[v++]=_,c[v++]=y,g+=4;if(u=o[g++],u<128)c[v++]=u;else if((224&u)==192){if(g>=f)return this.interim[0]=u,v;if(p=o[g++],(192&p)!=128){g--;continue}if(h=(31&u)<<6|63&p,h<128){g--;continue}c[v++]=h}else if((240&u)==224){if(g>=f)return this.interim[0]=u,v;if(p=o[g++],(192&p)!=128){g--;continue}if(g>=f)return this.interim[0]=u,this.interim[1]=p,v;if(_=o[g++],(192&_)!=128){g--;continue}if(h=(15&u)<<12|(63&p)<<6|63&_,h<2048||h>=55296&&h<=57343||h===65279)continue;c[v++]=h}else if((248&u)==240){if(g>=f)return this.interim[0]=u,v;if(p=o[g++],(192&p)!=128){g--;continue}if(g>=f)return this.interim[0]=u,this.interim[1]=p,v;if(_=o[g++],(192&_)!=128){g--;continue}if(g>=f)return this.interim[0]=u,this.interim[1]=p,this.interim[2]=_,v;if(y=o[g++],(192&y)!=128){g--;continue}if(h=(7&u)<<18|(63&p)<<12|(63&_)<<6|63&y,h<65536||h>1114111)continue;c[v++]=h}}return v}}},776:function(l,s,o){var c=this&&this.__decorate||function(h,m,d,g){var w,b=arguments.length,x=b<3?m:g===null?g=Object.getOwnPropertyDescriptor(m,d):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(h,m,d,g);else for(var C=h.length-1;C>=0;C--)(w=h[C])&&(x=(b<3?w(x):b>3?w(m,d,x):w(m,d))||x);return b>3&&x&&Object.defineProperty(m,d,x),x},f=this&&this.__param||function(h,m){return function(d,g){m(d,g,h)}};Object.defineProperty(s,"__esModule",{value:!0}),s.traceCall=s.setTraceLogger=s.LogService=void 0;const u=o(859),p=o(97),_={trace:p.LogLevelEnum.TRACE,debug:p.LogLevelEnum.DEBUG,info:p.LogLevelEnum.INFO,warn:p.LogLevelEnum.WARN,error:p.LogLevelEnum.ERROR,off:p.LogLevelEnum.OFF};let y,v=s.LogService=class extends u.Disposable{get logLevel(){return this._logLevel}constructor(h){super(),this._optionsService=h,this._logLevel=p.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel())),y=this}_updateLogLevel(){this._logLevel=_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(h){for(let m=0;m<h.length;m++)typeof h[m]=="function"&&(h[m]=h[m]())}_log(h,m,d){this._evalLazyOptionalParams(d),h.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+m,...d)}trace(h,...m){var d;this._logLevel<=p.LogLevelEnum.TRACE&&this._log(((d=this._optionsService.options.logger)==null?void 0:d.trace.bind(this._optionsService.options.logger))??console.log,h,m)}debug(h,...m){var d;this._logLevel<=p.LogLevelEnum.DEBUG&&this._log(((d=this._optionsService.options.logger)==null?void 0:d.debug.bind(this._optionsService.options.logger))??console.log,h,m)}info(h,...m){var d;this._logLevel<=p.LogLevelEnum.INFO&&this._log(((d=this._optionsService.options.logger)==null?void 0:d.info.bind(this._optionsService.options.logger))??console.info,h,m)}warn(h,...m){var d;this._logLevel<=p.LogLevelEnum.WARN&&this._log(((d=this._optionsService.options.logger)==null?void 0:d.warn.bind(this._optionsService.options.logger))??console.warn,h,m)}error(h,...m){var d;this._logLevel<=p.LogLevelEnum.ERROR&&this._log(((d=this._optionsService.options.logger)==null?void 0:d.error.bind(this._optionsService.options.logger))??console.error,h,m)}};s.LogService=v=c([f(0,p.IOptionsService)],v),s.setTraceLogger=function(h){y=h},s.traceCall=function(h,m,d){if(typeof d.value!="function")throw new Error("not supported");const g=d.value;d.value=function(...w){if(y.logLevel!==p.LogLevelEnum.TRACE)return g.apply(this,w);y.trace(`GlyphRenderer#${g.name}(${w.map(x=>JSON.stringify(x)).join(", ")})`);const b=g.apply(this,w);return y.trace(`GlyphRenderer#${g.name} return`,b),b}}},726:(l,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.createDecorator=s.getServiceDependencies=s.serviceRegistry=void 0;const o="di$target",c="di$dependencies";s.serviceRegistry=new Map,s.getServiceDependencies=function(f){return f[c]||[]},s.createDecorator=function(f){if(s.serviceRegistry.has(f))return s.serviceRegistry.get(f);const u=function(p,_,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(v,h,m){h[o]===h?h[c].push({id:v,index:m}):(h[c]=[{id:v,index:m}],h[o]=h)})(u,p,y)};return u.toString=()=>f,s.serviceRegistry.set(f,u),u}},97:(l,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.IDecorationService=s.IUnicodeService=s.IOscLinkService=s.IOptionsService=s.ILogService=s.LogLevelEnum=s.IInstantiationService=s.ICharsetService=s.ICoreService=s.ICoreMouseService=s.IBufferService=void 0;const c=o(726);var f;s.IBufferService=(0,c.createDecorator)("BufferService"),s.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),s.ICoreService=(0,c.createDecorator)("CoreService"),s.ICharsetService=(0,c.createDecorator)("CharsetService"),s.IInstantiationService=(0,c.createDecorator)("InstantiationService"),function(u){u[u.TRACE=0]="TRACE",u[u.DEBUG=1]="DEBUG",u[u.INFO=2]="INFO",u[u.WARN=3]="WARN",u[u.ERROR=4]="ERROR",u[u.OFF=5]="OFF"}(f||(s.LogLevelEnum=f={})),s.ILogService=(0,c.createDecorator)("LogService"),s.IOptionsService=(0,c.createDecorator)("OptionsService"),s.IOscLinkService=(0,c.createDecorator)("OscLinkService"),s.IUnicodeService=(0,c.createDecorator)("UnicodeService"),s.IDecorationService=(0,c.createDecorator)("DecorationService")}},n={};function i(l){var s=n[l];if(s!==void 0)return s.exports;var o=n[l]={exports:{}};return r[l].call(o.exports,o,o.exports,i),o.exports}var a={};return(()=>{var l=a;Object.defineProperty(l,"__esModule",{value:!0}),l.WebglAddon=void 0;const s=i(345),o=i(859),c=i(399),f=i(666),u=i(776);class p extends o.Disposable{constructor(y){if(c.isSafari&&(0,c.getSafariVersion)()<16){const v={antialias:!1,depth:!1,preserveDrawingBuffer:!0};if(!document.createElement("canvas").getContext("webgl2",v))throw new Error("Webgl2 is only supported on Safari 16 and above")}super(),this._preserveDrawingBuffer=y,this._onChangeTextureAtlas=this.register(new s.EventEmitter),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this.register(new s.EventEmitter),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this.register(new s.EventEmitter),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this.register(new s.EventEmitter),this.onContextLoss=this._onContextLoss.event}activate(y){const v=y._core;if(!y.element)return void this.register(v.onWillOpen(()=>this.activate(y)));this._terminal=y;const h=v.coreService,m=v.optionsService,d=v,g=d._renderService,w=d._characterJoinerService,b=d._charSizeService,x=d._coreBrowserService,C=d._decorationService,S=d._logService,k=d._themeService;(0,u.setTraceLogger)(S),this._renderer=this.register(new f.WebglRenderer(y,w,b,x,h,C,m,k,this._preserveDrawingBuffer)),this.register((0,s.forwardEvent)(this._renderer.onContextLoss,this._onContextLoss)),this.register((0,s.forwardEvent)(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this.register((0,s.forwardEvent)(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this.register((0,s.forwardEvent)(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),g.setRenderer(this._renderer),this.register((0,o.toDisposable)(()=>{const L=this._terminal._core._renderService;L.setRenderer(this._terminal._core._createRenderer()),L.handleResize(y.cols,y.rows)}))}get textureAtlas(){var y;return(y=this._renderer)==null?void 0:y.textureAtlas}clearTextureAtlas(){var y;(y=this._renderer)==null||y.clearTextureAtlas()}}l.WebglAddon=p})(),a})())})(_w);var fv=_w.exports;/**
129
129
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
130
130
  * @license MIT
131
131
  *
@@ -184,7 +184,7 @@ void main() {
184
184
  pointer-events: none;
185
185
  max-width: 400px;
186
186
  word-break: break-all;
187
- `,Le=document.createElement("div"),Ce.appendChild(Le),je=document.createElement("div"),je.style.color="var(--text-muted)",je.style.marginTop="2px",je.style.fontSize="11px",Ce.appendChild(je),w.current=Ce);const Fe=(ie,he)=>{if(!ge.element||!Ce||!Le||!je)return;const ke=wu(he);if(!ke)return;const Re=ge.element.getBoundingClientRect(),$e=ke.length>60?ke.slice(0,57)+"...":ke;Le.textContent=$e,je.textContent=`${Na()?"⌘":"Ctrl"}+click to open`,Ce.style.left=`${ie.clientX-Re.left+10}px`,Ce.style.top=`${ie.clientY-Re.top+10}px`,Ce.style.display="block"},Pe=()=>{Ce&&(Ce.style.display="none")};let Oe=null,Ee=!1,q=null;const ee={activate:(ie,he)=>{if(!Ee&&(ie.metaKey||ie.ctrlKey)){const ke=wu(he);if(!ke)return;window.open(ke,"_blank","noopener")}},hover:(ie,he)=>{Oe=wu(he)||null,Fe(ie,he)},leave:()=>{Oe=null,Pe()}},Ne=ie=>{Oe&&(ie.metaKey||ie.ctrlKey)&&(ie.preventDefault(),ie.stopPropagation(),Ee=!0,window.open(Oe,"_blank","noopener"),q&&clearTimeout(q),q=setTimeout(()=>{Ee=!1},100))};re.addEventListener("mousedown",Ne,!0),ge.options.linkHandler=ee;const Ge=new oD((ie,he)=>ee.activate(ie,he),{urlRegex:TD,hover:(ie,he)=>ee.hover(ie,he),leave:()=>ee.leave()});ge.loadAddon(Ge),g.current=Ge;let Ae=null,G=null;const me=Na()?"metaKey":"ctrlKey";ge.attachCustomKeyEventHandler(ie=>{if((ie.ctrlKey||ie.metaKey)&&ie.key.toLowerCase()==="c"&&ge.hasSelection()){const he=ge.getSelection();return he!=null&&he.trim()&&navigator.clipboard&&navigator.clipboard.writeText(he),!1}if(Na()&&!y&&ie.ctrlKey&&!ie.metaKey&&ie.key.toLowerCase()==="v"&&ie.type==="keydown")return O.current&&(M.current&&(I.current({type:"tmux-cancel-copy-mode",sessionId:O.current}),Y(!1)),I.current({type:"terminal-input",sessionId:O.current,data:MD})),!O.current;if(ie[me]&&ie.key.toLowerCase()==="v"&&ie.type==="keydown"){G!==null&&(clearTimeout(G),G=null),Ae=null;const he=new Promise(ke=>{G=setTimeout(()=>{G=null,Ae=null,ke(null)},100),Ae=Re=>{G!==null&&(clearTimeout(G),G=null),ke(Re)}});return(async()=>{try{const ke=O.current;if(!ke)return;let Re=await he;if(Re==null)try{Re=await navigator.clipboard.readText()}catch{Re=""}if(!Re&&Na()&&!y)try{const $e=await fetch("/api/clipboard-file-path");if($e.ok){const{path:Ue}=await $e.json();if(Ue){I.current({type:"terminal-input",sessionId:ke,data:Ue});return}}}catch{}Re&&ge.paste(Re)}finally{Ae=null}})(),!1}if(ie.ctrlKey&&ie.key==="Backspace"&&ie.type==="keydown"){const he=O.current;return he&&I.current({type:"terminal-input",sessionId:he,data:""}),!1}return!0});const J=ie=>{var Re;if(!Ae)return;ie.preventDefault(),ie.stopPropagation();const he=((Re=ie.clipboardData)==null?void 0:Re.getData("text/plain"))??"",ke=Ae;Ae=null,ke(he)};return re.addEventListener("paste",J,{capture:!0}),ge.onData(ie=>{const he=O.current;if(he){const ke=/^\x1b\[(<[\d;]+[Mm]|[\d;]+M|M[\x20-\xff]{3})$/.test(ie);if(M.current&&ke)return;M.current&&(I.current({type:"tmux-cancel-copy-mode",sessionId:he}),Y(!1)),I.current({type:"terminal-input",sessionId:he,data:ie})}}),ge.attachCustomWheelEventHandler(ie=>{const he=O.current;if(!he)return!0;const ke=ie.target;if(ke!=null&&ke.closest('input, textarea, [contenteditable="true"], .xterm-hover')||ge.hasSelection()||ie.shiftKey)return!0;const Re=30;A.current+=ie.deltaY;const $e=ge.cols,Ue=ge.rows,Ie=Math.floor($e/2),De=Math.floor(Ue/2);let et=!1,ze=!1;for(;Math.abs(A.current)>=Re;){ze=!0;const Te=A.current>0;A.current+=Te?-Re:Re;const Me=Te?65:64;Te||(et=!0),I.current({type:"terminal-input",sessionId:he,data:`\x1B[<${Me};${Ie};${De}M`})}return et&&Y(!0),ze&&_e(),!1}),h.current=ge,m.current=se,()=>{if(le=!0,q&&clearTimeout(q),Oe=null,re.removeEventListener("mousedown",Ne,!0),re.removeEventListener("paste",J,!0),G!==null&&(clearTimeout(G),G=null),Ae=null,w.current&&(w.current.remove(),w.current=null),g.current){try{g.current.dispose()}catch{}g.current=null}if(d.current){try{d.current.dispose()}catch{}d.current=null}try{ge.dispose()}catch{}re&&(re.innerHTML=""),h.current=null,m.current=null,b.current=null,x.current=null,C.current=null,L.current&&window.clearTimeout(L.current),D.current!==null&&window.clearTimeout(D.current)}},[de]),E.useEffect(()=>{h.current&&(h.current.options.theme=s)},[s]),E.useEffect(()=>{const re=h.current,le=m.current;if(re&&le){re.options.fontFamily=u,re.options.fontSize=o,re.options.lineHeight=Math.round(o*c)/o,re.options.letterSpacing=f,le.fit();const ne=O.current;ne&&I.current({type:"terminal-resize",sessionId:ne,cols:re.cols,rows:re.rows})}},[o,c,f,u]),E.useEffect(()=>{const re=h.current;if(!re)return;const le=P.current;if(P.current=p,le!==p){if(p){if(!d.current)try{const ne=new fv.WebglAddon;ne.onContextLoss(()=>{try{ne.dispose()}catch{}d.current=null}),re.loadAddon(ne),d.current=ne}catch{}}else if(d.current){try{d.current.dispose()}catch{}d.current=null}}},[p]),E.useEffect(()=>{const re=h.current;if(!re)return;const le=O.current,ne=z.current;if(!r){le&&(I.current({type:"terminal-detach",sessionId:le}),O.current=null,z.current=null,F.current=-1,M.current=!1),re.reset();return}if(n!=="connected"){le&&(Ke("terminal_detach_on_disconnect",{connectionStatus:n,prevAttached:le}),O.current=null,z.current=null,F.current=-1,M.current=!1);return}le&&le!==e&&(I.current({type:"terminal-detach",sessionId:le}),O.current=null,z.current=null,F.current=-1,M.current=!1);const fe=F.current,ge=i!==fe;if(e&&(e!==le||t!==ne||ge)){Ke("terminal_attach",{sessionId:e,tmuxTarget:t,prevAttached:le,prevTarget:ne,connectionStatus:n,connectionEpoch:i,attachedEpoch:fe});const se=performance.now();re.reset();const oe=performance.now(),ue=m.current;ue&&ue.fit();const ae=performance.now();I.current({type:"terminal-attach",sessionId:e,tmuxTarget:t??void 0,cols:re.cols,rows:re.rows}),O.current=e,z.current=t??null,F.current=i,I.current({type:"tmux-check-copy-mode",sessionId:e}),Ke("switch_attach_sent",{sessionId:e,resetMs:Math.round(oe-se),fitMs:Math.round(ae-oe),totalMs:Math.round(performance.now()-se),from:le??null}),H.current=se,k.current&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{re.scrollToBottom(),te(),re.focus()},300)}e&&e===le&&t===ne&&!ge&&Ke("terminal_attach_skip",{sessionId:e,prevAttached:le,connectionStatus:n,connectionEpoch:i,attachedEpoch:fe}),!e&&le&&(O.current=null,z.current=null,F.current=-1)},[e,t,r,n,i,te]),E.useEffect(()=>{const re=()=>{j.current!==null&&(window.clearTimeout(j.current),j.current=null),W.current!==null&&(window.clearTimeout(W.current),W.current=null);const fe=h.current,ge=N.current;if(!fe||!ge)return;N.current="";const se=performance.now(),oe=ge.length;fe.write(ge,()=>{const ue=Math.round(performance.now()-se);ue>50&&Ke("switch_write_slow",{sessionId:O.current,writeMs:ue,bytes:oe}),te()})},le=()=>{j.current!==null&&window.clearTimeout(j.current),j.current=window.setTimeout(re,V),W.current===null&&(W.current=window.setTimeout(re,Z))},ne=l(fe=>{const ge=O.current;if(fe.type==="terminal-output"&&ge&&fe.sessionId===ge){const se=H.current;se&&(Ke("switch_first_output",{sessionId:fe.sessionId,serverRoundtripMs:Math.round(performance.now()-se),bytes:fe.data.length,parseMs:fe._parseMs??-1,rawLength:fe._rawLength??-1}),H.current=null),N.current+=y?BD(fe.data):fe.data,le()}if(fe.type==="terminal-ready"&&ge&&fe.sessionId===ge){const se=H.current;se&&(Ke("switch_ready",{sessionId:fe.sessionId,totalMs:Math.round(performance.now()-se)}),H.current=null),y&&(re(),U(50))}fe.type==="tmux-copy-mode-status"&&ge&&fe.sessionId===ge&&Y(fe.inCopyMode)});return()=>{ne(),re(),K()}},[l,te,Y]),E.useEffect(()=>{const re=v.current,le=h.current,ne=m.current;if(!re||!le||!ne)return;const fe=()=>{S.current&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{de()},150)},ge=new ResizeObserver(fe);return ge.observe(re),fe(),()=>{ge.disconnect(),S.current&&window.clearTimeout(S.current)}},[]),E.useEffect(()=>{if(!y)return;const re=()=>{document.visibilityState!=="hidden"&&U(200)},le=fe=>{fe.persisted&&U(200)},ne=()=>{U(200)};return document.addEventListener("visibilitychange",re),window.addEventListener("pageshow",le),window.addEventListener("focus",ne),()=>{document.removeEventListener("visibilitychange",re),window.removeEventListener("pageshow",le),window.removeEventListener("focus",ne),K()}},[]),{containerRef:v,terminalRef:h,searchAddonRef:b,serializeAddonRef:x,progressAddonRef:C,inTmuxCopyModeRef:M,setTmuxCopyMode:Y}}function jD(e="(max-width: 767px)"){const[t,r]=E.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return E.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const n=window.matchMedia(e),i=()=>r(n.matches);return i(),typeof n.addEventListener=="function"?(n.addEventListener("change",i),()=>n.removeEventListener("change",i)):(n.addListener(i),()=>n.removeListener(i))},[e]),t}function FD(e,t,r){E.useEffect(()=>{if(!t)return;const n=i=>{e.current&&!e.current.contains(i.target)&&r()};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}},[e,t,r])}function HD(e,t){E.useEffect(()=>{if(!e)return;const r=n=>{n.key==="Escape"&&(n.preventDefault(),t())};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t])}function $D({enabled:e,isOpen:t,onOpen:r,edgeThresholdPx:n=30,swipeDistancePx:i=50,swipeRatio:a=1.5}){const l=E.useRef(!1);return E.useEffect(()=>{if(!e)return;let s=0,o=0,c=!1;const f=p=>{if(t)return;const _=p.touches[0];_.clientX<=n?(s=_.clientX,o=_.clientY,c=!0,l.current=!0):c=!1},u=p=>{if(l.current=!1,!c||t)return;const _=p.changedTouches[0],y=_.clientX-s,v=Math.abs(_.clientY-o);y>=i&&y>v*a&&r(),c=!1};return document.addEventListener("touchstart",f,{passive:!0}),document.addEventListener("touchend",u,{passive:!0}),()=>{l.current=!1,document.removeEventListener("touchstart",f),document.removeEventListener("touchend",u)}},[e,t,r,n,i,a]),l}const ql=df()(ff(e=>({theme:"dark",setTheme:t=>e({theme:t}),toggleTheme:()=>e(t=>({theme:t.theme==="dark"?"light":"dark"}))}),{name:"agentboard-theme",storage:gc(()=>lo)})),zD={dark:{background:"#2d2d2d",foreground:"#d4d4d4",cursor:"#3b82f6",cursorAccent:"#2d2d2d",selectionBackground:"rgba(59, 130, 246, 0.35)",selectionForeground:"#ffffff",black:"#808080",red:"#f87171",green:"#4ade80",yellow:"#fbbf24",blue:"#60a5fa",magenta:"#c084fc",cyan:"#22d3ee",white:"#d4d4d4",brightBlack:"#a0a0a0",brightRed:"#fca5a5",brightGreen:"#86efac",brightYellow:"#fde047",brightBlue:"#93c5fd",brightMagenta:"#d8b4fe",brightCyan:"#67e8f9",brightWhite:"#ffffff"},light:{background:"#fafafa",foreground:"#171717",cursor:"#2563eb",cursorAccent:"#fafafa",selectionBackground:"rgba(37, 99, 235, 0.2)",selectionForeground:"#000000",black:"#171717",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#9333ea",cyan:"#0891b2",white:"#f5f5f5",brightBlack:"#737373",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#eab308",brightBlue:"#3b82f6",brightMagenta:"#a855f7",brightCyan:"#06b6d4",brightWhite:"#ffffff"}},UD={up:"\x1B[A",down:"\x1B[B",left:"\x1B[D",right:"\x1B[C"},WD=150,VD=250,KD=400,xv=1500,GD=15,Qi=70;function Su(e=10){"vibrate"in navigator&&navigator.vibrate(e)}function qD(e,t){const r=Math.sqrt(e*e+t*t);if(r<GD)return{direction:null,distance:0};const n=Math.atan2(t,e)*(180/Math.PI);let i;return n>=-45&&n<45?i="right":n>=45&&n<135?i="down":n>=-135&&n<-45?i="up":i="left",{direction:i,distance:r}}function XD(e){const t=Qi-20,r=Math.min(e/t,1);return xv-r*(xv-KD)}function YD({onSendKey:e,disabled:t=!1,onRefocus:r,isKeyboardVisible:n}){const[i,a]=E.useState(!1),[l,s]=E.useState(null),[o,c]=E.useState({x:0,y:0}),[f,u]=E.useState({x:0,y:0}),p=E.useRef(null),_=E.useRef(null),y=E.useRef(null),v=E.useRef(!1),h=E.useRef(null),m=E.useRef(0),d=E.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null),_.current&&(clearTimeout(_.current),_.current=null),y.current&&(clearInterval(y.current),y.current=null)},[]),g=E.useCallback(()=>{_.current&&(clearTimeout(_.current),_.current=null),y.current&&(clearInterval(y.current),y.current=null)},[]),w=E.useCallback(D=>{const O=XD(m.current);y.current=setTimeout(()=>{h.current&&(Su(5),e(D),w(D))},O)},[e]),b=E.useCallback((D,O)=>{if(!D||t)return;const z=UD[D];m.current=O,Su(8),e(z),g(),_.current=setTimeout(()=>{w(z)},VD)},[t,e,g,w]),x=E.useCallback((D,O)=>{const z=D-o.x,F=O-o.y,H=Math.sqrt(z*z+F*F),I=Math.min(H,Qi-20),R=H>0?I/H:0;u({x:z*R,y:F*R});const{direction:P,distance:N}=qD(z,F);m.current=N,P!==h.current&&(h.current=P,s(P),g(),P&&b(P,N))},[o,g,b]),C=E.useCallback(()=>{a(!1),s(null),u({x:0,y:0}),g(),h.current=null,v.current&&(r==null||r())},[g,r]),S=E.useCallback(D=>{if(t)return;D.preventDefault(),D.stopPropagation();const O=D.touches[0];v.current=(n==null?void 0:n())??!1,p.current=setTimeout(()=>{Su(15),c({x:O.clientX,y:O.clientY-80}),u({x:0,y:0}),a(!0)},WD)},[t,n]),k=E.useCallback(D=>{if(D.preventDefault(),D.stopPropagation(),!i)return;const O=D.touches[0];x(O.clientX,O.clientY)},[i,x]),L=E.useCallback(D=>{D.preventDefault(),D.stopPropagation(),p.current&&(clearTimeout(p.current),p.current=null),i&&C()},[i,C]),A=E.useCallback(D=>{D.preventDefault(),d(),C()},[d,C]);E.useEffect(()=>()=>{d()},[d]);const M=[{dir:"up",angle:-90,label:"↑"},{dir:"right",angle:0,label:"→"},{dir:"down",angle:90,label:"↓"},{dir:"left",angle:180,label:"←"}];return T.jsxs(T.Fragment,{children:[T.jsx("button",{type:"button","aria-label":"Arrow keys",className:`
187
+ `,Le=document.createElement("div"),Ce.appendChild(Le),je=document.createElement("div"),je.style.color="var(--text-muted)",je.style.marginTop="2px",je.style.fontSize="11px",Ce.appendChild(je),w.current=Ce);const Fe=(ie,he)=>{if(!ge.element||!Ce||!Le||!je)return;const ke=wu(he);if(!ke)return;const Re=ge.element.getBoundingClientRect(),$e=ke.length>60?ke.slice(0,57)+"...":ke;Le.textContent=$e,je.textContent=`${Na()?"⌘":"Ctrl"}+click to open`,Ce.style.left=`${ie.clientX-Re.left+10}px`,Ce.style.top=`${ie.clientY-Re.top+10}px`,Ce.style.display="block"},Pe=()=>{Ce&&(Ce.style.display="none")};let Oe=null,Ee=!1,q=null;const ee={activate:(ie,he)=>{if(!Ee&&(ie.metaKey||ie.ctrlKey)){const ke=wu(he);if(!ke)return;window.open(ke,"_blank","noopener")}},hover:(ie,he)=>{Oe=wu(he)||null,Fe(ie,he)},leave:()=>{Oe=null,Pe()}},Ne=ie=>{Oe&&(ie.metaKey||ie.ctrlKey)&&(ie.preventDefault(),ie.stopPropagation(),Ee=!0,window.open(Oe,"_blank","noopener"),q&&clearTimeout(q),q=setTimeout(()=>{Ee=!1},100))};re.addEventListener("mousedown",Ne,!0),ge.options.linkHandler=ee;const qe=new oD((ie,he)=>ee.activate(ie,he),{urlRegex:TD,hover:(ie,he)=>ee.hover(ie,he),leave:()=>ee.leave()});ge.loadAddon(qe),g.current=qe;let Ae=null,G=null;const me=Na()?"metaKey":"ctrlKey";ge.attachCustomKeyEventHandler(ie=>{if((ie.ctrlKey||ie.metaKey)&&ie.key.toLowerCase()==="c"&&ge.hasSelection()){const he=ge.getSelection();return he!=null&&he.trim()&&navigator.clipboard&&navigator.clipboard.writeText(he),!1}if(Na()&&!y&&ie.ctrlKey&&!ie.metaKey&&ie.key.toLowerCase()==="v"&&ie.type==="keydown")return O.current&&(M.current&&(I.current({type:"tmux-cancel-copy-mode",sessionId:O.current}),Y(!1)),I.current({type:"terminal-input",sessionId:O.current,data:MD})),!O.current;if(ie[me]&&ie.key.toLowerCase()==="v"&&ie.type==="keydown"){G!==null&&(clearTimeout(G),G=null),Ae=null;const he=new Promise(ke=>{G=setTimeout(()=>{G=null,Ae=null,ke(null)},100),Ae=Re=>{G!==null&&(clearTimeout(G),G=null),ke(Re)}});return(async()=>{try{const ke=O.current;if(!ke)return;let Re=await he;if(Re==null)try{Re=await navigator.clipboard.readText()}catch{Re=""}if(!Re&&Na()&&!y)try{const $e=await fetch("/api/clipboard-file-path");if($e.ok){const{path:Ue}=await $e.json();if(Ue){I.current({type:"terminal-input",sessionId:ke,data:Ue});return}}}catch{}Re&&ge.paste(Re)}finally{Ae=null}})(),!1}if(ie.ctrlKey&&ie.key==="Backspace"&&ie.type==="keydown"){const he=O.current;return he&&I.current({type:"terminal-input",sessionId:he,data:""}),!1}return!0});const J=ie=>{var Re;if(!Ae)return;ie.preventDefault(),ie.stopPropagation();const he=((Re=ie.clipboardData)==null?void 0:Re.getData("text/plain"))??"",ke=Ae;Ae=null,ke(he)};return re.addEventListener("paste",J,{capture:!0}),ge.onData(ie=>{const he=O.current;if(he){const ke=/^\x1b\[(<[\d;]+[Mm]|[\d;]+M|M[\x20-\xff]{3})$/.test(ie);if(M.current&&ke)return;M.current&&(I.current({type:"tmux-cancel-copy-mode",sessionId:he}),Y(!1)),I.current({type:"terminal-input",sessionId:he,data:ie})}}),ge.attachCustomWheelEventHandler(ie=>{const he=O.current;if(!he)return!0;const ke=ie.target;if(ke!=null&&ke.closest('input, textarea, [contenteditable="true"], .xterm-hover')||ge.hasSelection()||ie.shiftKey)return!0;const Re=30;A.current+=ie.deltaY;const $e=ge.cols,Ue=ge.rows,Ie=Math.floor($e/2),De=Math.floor(Ue/2);let et=!1,ze=!1;for(;Math.abs(A.current)>=Re;){ze=!0;const Te=A.current>0;A.current+=Te?-Re:Re;const Me=Te?65:64;Te||(et=!0),I.current({type:"terminal-input",sessionId:he,data:`\x1B[<${Me};${Ie};${De}M`})}return et&&Y(!0),ze&&_e(),!1}),h.current=ge,m.current=se,()=>{if(le=!0,q&&clearTimeout(q),Oe=null,re.removeEventListener("mousedown",Ne,!0),re.removeEventListener("paste",J,!0),G!==null&&(clearTimeout(G),G=null),Ae=null,w.current&&(w.current.remove(),w.current=null),g.current){try{g.current.dispose()}catch{}g.current=null}if(d.current){try{d.current.dispose()}catch{}d.current=null}try{ge.dispose()}catch{}re&&(re.innerHTML=""),h.current=null,m.current=null,b.current=null,x.current=null,C.current=null,L.current&&window.clearTimeout(L.current),D.current!==null&&window.clearTimeout(D.current)}},[de]),E.useEffect(()=>{h.current&&(h.current.options.theme=s)},[s]),E.useEffect(()=>{const re=h.current,le=m.current;if(re&&le){re.options.fontFamily=u,re.options.fontSize=o,re.options.lineHeight=Math.round(o*c)/o,re.options.letterSpacing=f,le.fit();const ne=O.current;ne&&I.current({type:"terminal-resize",sessionId:ne,cols:re.cols,rows:re.rows})}},[o,c,f,u]),E.useEffect(()=>{const re=h.current;if(!re)return;const le=P.current;if(P.current=p,le!==p){if(p){if(!d.current)try{const ne=new fv.WebglAddon;ne.onContextLoss(()=>{try{ne.dispose()}catch{}d.current=null}),re.loadAddon(ne),d.current=ne}catch{}}else if(d.current){try{d.current.dispose()}catch{}d.current=null}}},[p]),E.useEffect(()=>{const re=h.current;if(!re)return;const le=O.current,ne=z.current;if(!r){le&&(I.current({type:"terminal-detach",sessionId:le}),O.current=null,z.current=null,F.current=-1,M.current=!1),re.reset();return}if(n!=="connected"){le&&(Ge("terminal_detach_on_disconnect",{connectionStatus:n,prevAttached:le}),O.current=null,z.current=null,F.current=-1,M.current=!1);return}le&&le!==e&&(I.current({type:"terminal-detach",sessionId:le}),O.current=null,z.current=null,F.current=-1,M.current=!1);const fe=F.current,ge=i!==fe;if(e&&(e!==le||t!==ne||ge)){Ge("terminal_attach",{sessionId:e,tmuxTarget:t,prevAttached:le,prevTarget:ne,connectionStatus:n,connectionEpoch:i,attachedEpoch:fe});const se=performance.now();re.reset();const oe=performance.now(),ue=m.current;ue&&ue.fit();const ae=performance.now();I.current({type:"terminal-attach",sessionId:e,tmuxTarget:t??void 0,cols:re.cols,rows:re.rows}),O.current=e,z.current=t??null,F.current=i,I.current({type:"tmux-check-copy-mode",sessionId:e}),Ge("switch_attach_sent",{sessionId:e,resetMs:Math.round(oe-se),fitMs:Math.round(ae-oe),totalMs:Math.round(performance.now()-se),from:le??null}),H.current=se,k.current&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{re.scrollToBottom(),te(),re.focus()},300)}e&&e===le&&t===ne&&!ge&&Ge("terminal_attach_skip",{sessionId:e,prevAttached:le,connectionStatus:n,connectionEpoch:i,attachedEpoch:fe}),!e&&le&&(O.current=null,z.current=null,F.current=-1)},[e,t,r,n,i,te]),E.useEffect(()=>{const re=()=>{j.current!==null&&(window.clearTimeout(j.current),j.current=null),W.current!==null&&(window.clearTimeout(W.current),W.current=null);const fe=h.current,ge=N.current;if(!fe||!ge)return;N.current="";const se=performance.now(),oe=ge.length;fe.write(ge,()=>{const ue=Math.round(performance.now()-se);ue>50&&Ge("switch_write_slow",{sessionId:O.current,writeMs:ue,bytes:oe}),te()})},le=()=>{j.current!==null&&window.clearTimeout(j.current),j.current=window.setTimeout(re,V),W.current===null&&(W.current=window.setTimeout(re,Z))},ne=l(fe=>{const ge=O.current;if(fe.type==="terminal-output"&&ge&&fe.sessionId===ge){const se=H.current;se&&(Ge("switch_first_output",{sessionId:fe.sessionId,serverRoundtripMs:Math.round(performance.now()-se),bytes:fe.data.length,parseMs:fe._parseMs??-1,rawLength:fe._rawLength??-1}),H.current=null),N.current+=y?BD(fe.data):fe.data,le()}if(fe.type==="terminal-ready"&&ge&&fe.sessionId===ge){const se=H.current;se&&(Ge("switch_ready",{sessionId:fe.sessionId,totalMs:Math.round(performance.now()-se)}),H.current=null),y&&(re(),U(50))}fe.type==="tmux-copy-mode-status"&&ge&&fe.sessionId===ge&&Y(fe.inCopyMode)});return()=>{ne(),re(),K()}},[l,te,Y]),E.useEffect(()=>{const re=v.current,le=h.current,ne=m.current;if(!re||!le||!ne)return;const fe=()=>{S.current&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{de()},150)},ge=new ResizeObserver(fe);return ge.observe(re),fe(),()=>{ge.disconnect(),S.current&&window.clearTimeout(S.current)}},[]),E.useEffect(()=>{if(!y)return;const re=()=>{document.visibilityState!=="hidden"&&U(200)},le=fe=>{fe.persisted&&U(200)},ne=()=>{U(200)};return document.addEventListener("visibilitychange",re),window.addEventListener("pageshow",le),window.addEventListener("focus",ne),()=>{document.removeEventListener("visibilitychange",re),window.removeEventListener("pageshow",le),window.removeEventListener("focus",ne),K()}},[]),{containerRef:v,terminalRef:h,searchAddonRef:b,serializeAddonRef:x,progressAddonRef:C,inTmuxCopyModeRef:M,setTmuxCopyMode:Y}}function jD(e="(max-width: 767px)"){const[t,r]=E.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches);return E.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const n=window.matchMedia(e),i=()=>r(n.matches);return i(),typeof n.addEventListener=="function"?(n.addEventListener("change",i),()=>n.removeEventListener("change",i)):(n.addListener(i),()=>n.removeListener(i))},[e]),t}function FD(e,t,r){E.useEffect(()=>{if(!t)return;const n=i=>{e.current&&!e.current.contains(i.target)&&r()};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}},[e,t,r])}function HD(e,t){E.useEffect(()=>{if(!e)return;const r=n=>{n.key==="Escape"&&(n.preventDefault(),t())};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[e,t])}function $D({enabled:e,isOpen:t,onOpen:r,edgeThresholdPx:n=30,swipeDistancePx:i=50,swipeRatio:a=1.5}){const l=E.useRef(!1);return E.useEffect(()=>{if(!e)return;let s=0,o=0,c=!1;const f=p=>{if(t)return;const _=p.touches[0];_.clientX<=n?(s=_.clientX,o=_.clientY,c=!0,l.current=!0):c=!1},u=p=>{if(l.current=!1,!c||t)return;const _=p.changedTouches[0],y=_.clientX-s,v=Math.abs(_.clientY-o);y>=i&&y>v*a&&r(),c=!1};return document.addEventListener("touchstart",f,{passive:!0}),document.addEventListener("touchend",u,{passive:!0}),()=>{l.current=!1,document.removeEventListener("touchstart",f),document.removeEventListener("touchend",u)}},[e,t,r,n,i,a]),l}const ql=df()(ff(e=>({theme:"dark",setTheme:t=>e({theme:t}),toggleTheme:()=>e(t=>({theme:t.theme==="dark"?"light":"dark"}))}),{name:"agentboard-theme",storage:gc(()=>lo)})),zD={dark:{background:"#2d2d2d",foreground:"#d4d4d4",cursor:"#3b82f6",cursorAccent:"#2d2d2d",selectionBackground:"rgba(59, 130, 246, 0.35)",selectionForeground:"#ffffff",black:"#808080",red:"#f87171",green:"#4ade80",yellow:"#fbbf24",blue:"#60a5fa",magenta:"#c084fc",cyan:"#22d3ee",white:"#d4d4d4",brightBlack:"#a0a0a0",brightRed:"#fca5a5",brightGreen:"#86efac",brightYellow:"#fde047",brightBlue:"#93c5fd",brightMagenta:"#d8b4fe",brightCyan:"#67e8f9",brightWhite:"#ffffff"},light:{background:"#fafafa",foreground:"#171717",cursor:"#2563eb",cursorAccent:"#fafafa",selectionBackground:"rgba(37, 99, 235, 0.2)",selectionForeground:"#000000",black:"#171717",red:"#dc2626",green:"#16a34a",yellow:"#ca8a04",blue:"#2563eb",magenta:"#9333ea",cyan:"#0891b2",white:"#f5f5f5",brightBlack:"#737373",brightRed:"#ef4444",brightGreen:"#22c55e",brightYellow:"#eab308",brightBlue:"#3b82f6",brightMagenta:"#a855f7",brightCyan:"#06b6d4",brightWhite:"#ffffff"}},UD={up:"\x1B[A",down:"\x1B[B",left:"\x1B[D",right:"\x1B[C"},WD=150,VD=250,KD=400,xv=1500,GD=15,Qi=70;function Su(e=10){"vibrate"in navigator&&navigator.vibrate(e)}function qD(e,t){const r=Math.sqrt(e*e+t*t);if(r<GD)return{direction:null,distance:0};const n=Math.atan2(t,e)*(180/Math.PI);let i;return n>=-45&&n<45?i="right":n>=45&&n<135?i="down":n>=-135&&n<-45?i="up":i="left",{direction:i,distance:r}}function XD(e){const t=Qi-20,r=Math.min(e/t,1);return xv-r*(xv-KD)}function YD({onSendKey:e,disabled:t=!1,onRefocus:r,isKeyboardVisible:n}){const[i,a]=E.useState(!1),[l,s]=E.useState(null),[o,c]=E.useState({x:0,y:0}),[f,u]=E.useState({x:0,y:0}),p=E.useRef(null),_=E.useRef(null),y=E.useRef(null),v=E.useRef(!1),h=E.useRef(null),m=E.useRef(0),d=E.useCallback(()=>{p.current&&(clearTimeout(p.current),p.current=null),_.current&&(clearTimeout(_.current),_.current=null),y.current&&(clearInterval(y.current),y.current=null)},[]),g=E.useCallback(()=>{_.current&&(clearTimeout(_.current),_.current=null),y.current&&(clearInterval(y.current),y.current=null)},[]),w=E.useCallback(D=>{const O=XD(m.current);y.current=setTimeout(()=>{h.current&&(Su(5),e(D),w(D))},O)},[e]),b=E.useCallback((D,O)=>{if(!D||t)return;const z=UD[D];m.current=O,Su(8),e(z),g(),_.current=setTimeout(()=>{w(z)},VD)},[t,e,g,w]),x=E.useCallback((D,O)=>{const z=D-o.x,F=O-o.y,H=Math.sqrt(z*z+F*F),I=Math.min(H,Qi-20),R=H>0?I/H:0;u({x:z*R,y:F*R});const{direction:P,distance:N}=qD(z,F);m.current=N,P!==h.current&&(h.current=P,s(P),g(),P&&b(P,N))},[o,g,b]),C=E.useCallback(()=>{a(!1),s(null),u({x:0,y:0}),g(),h.current=null,v.current&&(r==null||r())},[g,r]),S=E.useCallback(D=>{if(t)return;D.preventDefault(),D.stopPropagation();const O=D.touches[0];v.current=(n==null?void 0:n())??!1,p.current=setTimeout(()=>{Su(15),c({x:O.clientX,y:O.clientY-80}),u({x:0,y:0}),a(!0)},WD)},[t,n]),k=E.useCallback(D=>{if(D.preventDefault(),D.stopPropagation(),!i)return;const O=D.touches[0];x(O.clientX,O.clientY)},[i,x]),L=E.useCallback(D=>{D.preventDefault(),D.stopPropagation(),p.current&&(clearTimeout(p.current),p.current=null),i&&C()},[i,C]),A=E.useCallback(D=>{D.preventDefault(),d(),C()},[d,C]);E.useEffect(()=>()=>{d()},[d]);const M=[{dir:"up",angle:-90,label:"↑"},{dir:"right",angle:0,label:"→"},{dir:"down",angle:90,label:"↓"},{dir:"left",angle:180,label:"←"}];return T.jsxs(T.Fragment,{children:[T.jsx("button",{type:"button","aria-label":"Arrow keys",className:`
188
188
  terminal-key
189
189
  flex items-center justify-center
190
190
  h-11 min-w-[2.75rem] px-2.5
@@ -291,13 +291,13 @@ void main() {
291
291
  select-none touch-manipulation
292
292
  text-secondary
293
293
  ${t?"opacity-50":""}
294
- `,onMouseDown:F=>F.preventDefault(),onTouchStart:O(M),onClick:z(M),disabled:t,children:nM})]}),c&&T.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:T.jsxs("div",{ref:d,className:"mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl",children:[T.jsx("h3",{className:"text-base font-medium text-primary mb-1 text-balance",children:"Paste"}),T.jsx("p",{className:"text-xs text-muted mb-3 text-pretty",children:"Text or image (long-press → Paste)"}),_?T.jsx("div",{className:"w-full h-11 flex items-center justify-center bg-surface border border-border rounded-md text-secondary",children:"Uploading image..."}):T.jsx("input",{ref:m,type:"text",value:u,onChange:F=>p(F.target.value),onKeyDown:F=>{F.key==="Enter"?(F.preventDefault(),k()):F.key==="Escape"&&(F.preventDefault(),L())},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"}}),T.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[T.jsx("button",{type:"button",onClick:L,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"}),T.jsx("button",{type:"button",onClick:k,disabled:_,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 lM({isOpen:e,onClose:t,sessions:r,inactiveSessions:n=[],selectedSessionId:i,onSelect:a,onRename:l,onResume:s,onSetPinned:o,onNewSession:c,loading:f,error:u}){const p=$1(),_=E.useRef(null),y=E.useRef(null);E.useEffect(()=>{if(!e)return;const m=d=>{d.key==="Escape"&&(d.preventDefault(),t())};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,t]),E.useEffect(()=>{var m;e?(y.current=document.activeElement,(m=_.current)==null||m.focus()):y.current&&(y.current.focus(),y.current=null)},[e]),E.useEffect(()=>{if(!e)return;const m=_.current;if(!m)return;const d=50,g=1.5;let w=0,b=0;const x=S=>{const k=S.touches[0];w=k.clientX,b=k.clientY},C=S=>{const k=S.changedTouches[0],L=w-k.clientX,A=Math.abs(k.clientY-b);L>=d&&L>A*g&&("vibrate"in navigator&&navigator.vibrate(10),t())};return m.addEventListener("touchstart",x,{passive:!0}),m.addEventListener("touchend",C,{passive:!0}),()=>{m.removeEventListener("touchstart",x),m.removeEventListener("touchend",C)}},[e,t]);const v=m=>{a(m),t()},h=p?{transition:"none"}:void 0;return T.jsxs(T.Fragment,{children:[T.jsx("div",{className:`session-drawer-backdrop ${e?"open":""}`,style:h,onClick:t,"aria-hidden":"true"}),T.jsxs("div",{ref:_,className:`session-drawer ${e?"open":""}`,style:h,role:"dialog","aria-modal":"true","aria-label":"Session list",tabIndex:-1,children:[T.jsx(fw,{sessions:r,inactiveSessions:n,selectedSessionId:i,onSelect:v,onRename:l,onResume:s,onSetPinned:o,loading:f,error:u}),T.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:T.jsx("button",{onClick:()=>{c()!==!1&&t()},className:"btn btn-primary w-full py-2 text-sm",children:"New Session"})})]})]})}const cM={working:"Working",waiting:"Waiting",permission:"Needs Input",unknown:"Unknown"},uM={working:"text-working",waiting:"text-waiting",permission:"text-approval",unknown:"text-muted"},hM={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"},dM={working:"bg-working text-white",waiting:"bg-waiting text-white",permission:"bg-approval text-white",unknown:"bg-muted text-white"};function bv(){"vibrate"in navigator&&navigator.vibrate(10)}function fM({session:e,sessions:t,inactiveSessions:r=[],connectionStatus:n,connectionEpoch:i=0,sendMessage:a,subscribe:l,onClose:s,onSelectSession:o,onNewSession:c,onKillSession:f,onRenameSession:u,onResumeSession:p,onSetPinned:_,onOpenSettings:y,loading:v=!1,error:h=null}){const m=ql(J=>J.theme),d=zD[m],g=pe(J=>J.useWebGL),w=pe(J=>J.fontSize),b=pe(J=>J.lineHeight),x=pe(J=>J.letterSpacing),C=pe(J=>J.fontOption),S=pe(J=>J.customFontFamily),k=lC(C,S),L=pe(J=>J.shortcutModifier),A=ii(ea(L)),M=Zo(),D=jD(),[O,z]=E.useState(!1),[F,H]=E.useState(!1),[I,R]=E.useState(!1),[P,N]=E.useState(!1),[j,W]=E.useState(!1),[V,Z]=E.useState(!1),[Q,$]=E.useState(""),B=E.useRef(!1),K=E.useRef(null),U=E.useRef(null),te=E.useRef(null),Y=E.useRef(null),_e=(e==null?void 0:e.remote)===!0,de=qe(J=>J.remoteAllowControl),re=qe(J=>J.remoteAllowAttach),le=_e&&!re,ne=!_e||de&&(e==null?void 0:e.source)==="managed",{containerRef:fe,terminalRef:ge,inTmuxCopyModeRef:se,setTmuxCopyMode:oe}=ND({sessionId:(e==null?void 0:e.id)??null,tmuxTarget:(e==null?void 0:e.tmuxWindow)??null,allowAttach:!le,connectionStatus:n,connectionEpoch:i,sendMessage:a,subscribe:l,theme:d,fontSize:w,lineHeight:b,letterSpacing:x,fontFamily:k,useWebGL:g,onScrollChange:J=>{z(!J)}}),ue=E.useCallback(()=>{var J;!e||le||(a({type:"tmux-cancel-copy-mode",sessionId:e.id}),oe(!1),(J=ge.current)==null||J.scrollToBottom())},[e,le,a,oe,ge]),ae=E.useCallback(()=>{W(!0),bv()},[]),ve=$D({enabled:D||M,isOpen:j,onOpen:ae});E.useEffect(()=>{!D&&!M&&j&&W(!1)},[j,D,M]);const Ce=E.useCallback(()=>N(!1),[]);FD(U,P,Ce),E.useEffect(()=>{V&&te.current&&(te.current.focus(),te.current.select())},[V]),E.useEffect(()=>{I&&Y.current&&Y.current.focus()},[I]);const Le=E.useCallback(()=>R(!1),[]);HD(I,Le);const je=()=>{e&&(f(e.id),R(!1))},Fe=()=>{e&&($(e.agentSessionName||e.name),Z(!0),N(!1))},Pe=()=>{if(!e)return;const J=Q.trim(),Se=e.agentSessionName||e.name;J&&J!==Se&&u(e.id,J),Z(!1)},Oe=J=>{J.key==="Enter"?(J.preventDefault(),Pe()):J.key==="Escape"&&(J.preventDefault(),Z(!1))};E.useEffect(()=>{if(!M||!e){H(!1);return}const J=fe.current;if(!J)return;const Se=Te=>{const Me=J.querySelector(".xterm-accessibility-tree");if(!Me)return!1;const We=Te.anchorNode,Ye=Te.focusNode;return!!We&&Me.contains(We)||!!Ye&&Me.contains(Ye)},ie=()=>{const Te=J.querySelector(".xterm-accessibility"),Me=J.querySelector(".xterm-accessibility-tree");!Te||!Me||(Te.style.setProperty("opacity","0"),Me.style.setProperty("opacity","0"),Te.style.setProperty("-webkit-user-select","none"),Te.style.setProperty("user-select","none"),Me.style.setProperty("-webkit-user-select","none"),Me.style.setProperty("user-select","none"),Te.offsetHeight,requestAnimationFrame(()=>{Te.style.removeProperty("opacity"),Me.style.removeProperty("opacity"),Te.style.removeProperty("-webkit-user-select"),Te.style.removeProperty("user-select"),Me.style.removeProperty("-webkit-user-select"),Me.style.removeProperty("user-select")}))},he=()=>{var Me;B.current=!1;const Te=window.getSelection();try{Te==null||Te.removeAllRanges()}catch{}(Me=ge.current)==null||Me.clearSelection(),ie(),H(!1)};K.current=he;const ke=()=>{const Te=window.getSelection();if(!Te||Te.rangeCount===0||Te.isCollapsed){B.current?he():H(Ye=>Ye&&!1);return}const Me=Se(Te);if(!Me&&B.current){he();return}B.current=Me;const We=Me;H(Ye=>Ye!==We?We:Ye)},Re=()=>{const Te=window.getSelection();!Te||Te.isCollapsed||Se(Te)&&setTimeout(he,0)},$e=10;let Ue=null,Ie=!1;const De=Te=>{if(Te.touches.length===1){const Me=Te.touches[0];Ue={x:Me.clientX,y:Me.clientY},Ie=!1}},et=Te=>{if(Ie||!Ue||Te.touches.length!==1)return;const Me=Te.touches[0],We=Math.abs(Me.clientX-Ue.x),Ye=Math.abs(Me.clientY-Ue.y);(We>$e||Ye>$e)&&(Ie=!0)},ze=Te=>{const Me=Ie;Ue=null,Ie=!1;const We=window.getSelection();if(!We||We.rangeCount===0||We.isCollapsed){H(!1);return}const Ye=J.querySelector(".xterm-accessibility-tree");if(!Ye)return;if(!Se(We)){H(!1);return}if(Me)return;const $t=Te.target,_t=$t?Ye.contains($t):!1;let zt=!1;if(_t&&$t)try{zt=We.containsNode($t,!0)}catch{zt=!1}(!_t||!zt)&&setTimeout(he,0)};return document.addEventListener("selectionchange",ke),document.addEventListener("copy",Re),document.addEventListener("touchstart",De,{passive:!0}),document.addEventListener("touchmove",et,{passive:!0}),document.addEventListener("touchend",ze,{passive:!0}),()=>{document.removeEventListener("selectionchange",ke),document.removeEventListener("copy",Re),document.removeEventListener("touchstart",De),document.removeEventListener("touchmove",et),document.removeEventListener("touchend",ze),K.current=null,B.current=!1}},[fe,M,e==null?void 0:e.id]),E.useEffect(()=>{var Ue;if(!M)return;const J=fe.current;if(!J)return;const Se=()=>{const Ie=ge.current,De=J.querySelector(".xterm");if(!Ie||!De)return;const et=De.querySelector(".xterm-screen"),ze=De.querySelector(".xterm-accessibility"),Te=De.querySelector(".xterm-accessibility-tree");if(!et||!ze||!Te)return;const Me=De.getBoundingClientRect(),We=et.getBoundingClientRect(),Ye=We.left-Me.left,$t=We.top-Me.top;Object.assign(ze.style,{left:`${Ye}px`,top:`${$t}px`,right:"auto",bottom:"auto",width:`${We.width}px`,height:`${We.height}px`});const _t=We.width/Ie.cols,zt=We.height/Ie.rows,It=document.createElement("span");It.textContent="0".repeat(200),It.style.cssText="position:absolute;visibility:hidden;white-space:pre;pointer-events:none;letter-spacing:0px",Te.appendChild(It);const wn=It.getBoundingClientRect().width/200;It.remove();const Ts=Math.max(-2,Math.min(2,_t-wn));J.style.setProperty("--xterm-font-size",`${Ie.options.fontSize}px`),J.style.setProperty("--xterm-cell-height",`${zt}px`),J.style.setProperty("--xterm-a11y-letter-spacing",`${Ts}px`)},ie=performance.now();Se();const he=Math.round(performance.now()-ie);he>10&&Ke("switch_a11y_overlay",{sessionId:e==null?void 0:e.id,a11yMs:he});const ke=window.requestAnimationFrame(Se),Re=window.setTimeout(Se,100),$e=()=>window.requestAnimationFrame(Se);return(Ue=window.visualViewport)==null||Ue.addEventListener("resize",$e),window.addEventListener("orientationchange",$e),()=>{var Ie;window.cancelAnimationFrame(ke),window.clearTimeout(Re),(Ie=window.visualViewport)==null||Ie.removeEventListener("resize",$e),window.removeEventListener("orientationchange",$e)}},[fe,w,M,e==null?void 0:e.id,ge]);const Ee=E.useRef(F);E.useEffect(()=>{Ee.current=F},[F]);const q=E.useRef(e==null?void 0:e.id);E.useEffect(()=>{q.current=e==null?void 0:e.id},[e==null?void 0:e.id]);const ee=E.useRef(a);E.useEffect(()=>{ee.current=a},[a]);const Ne=E.useRef(!1);E.useEffect(()=>{const J=fe.current;if(!J||!(e!=null&&e.id)||!D&&!M)return;const Se=6,ie=350;let he={x:0,y:0},ke=0,Re=!1,$e=null,Ue=0,Ie=0,De=0,et=Math.round(w*b),ze=null;const Te=()=>{const Et=window.getComputedStyle(J).getPropertyValue("--xterm-cell-height").trim(),kt=Number.parseFloat(Et);return!Number.isNaN(kt)&&kt>0?kt:Math.round(w*b)},Me=()=>J.querySelector(".xterm-helper-textarea"),We=()=>{const Be=Me();Be&&document.activeElement!==Be&&(Be.disabled=!0)},Ye=()=>{const Be=Me();Be&&(Be.disabled=!1)};We();const $t=()=>{if(se.current)return;const Be=Me();Be&&(Be.disabled=!1,Be.focus())},_t=()=>{ze!==null&&(cancelAnimationFrame(ze),ze=null),Ie=0},zt=Be=>{const Et=q.current;if(!Et||Be===0)return!1;const kt=ge.current,Zr=(kt==null?void 0:kt.cols)??80,Ds=(kt==null?void 0:kt.rows)??24,Ms=Math.floor(Zr/2),Jn=Math.floor(Ds/2),Qn=Be>0?65:64,Zn=Math.abs(Be),Sn=Be<0;for(let en=0;en<Zn;en++)ee.current({type:"terminal-input",sessionId:Et,data:`\x1B[<${Qn};${Ms};${Jn}M`});return Sn&&oe(!0),Sn},It=()=>{$e=null,Ie=0,De=0},wn=()=>{if(!M)return!1;const Be=window.getSelection();if(!Be||Be.isCollapsed)return!1;const Et=J.querySelector(".xterm-accessibility-tree");if(!Et)return!1;const kt=Be.anchorNode,Zr=Be.focusNode;return!!kt&&Et.contains(kt)||!!Zr&&Et.contains(Zr)},Ts=()=>{var Be;!M||!B.current||wn()||(Be=K.current)==null||Be.call(K)},ca=Be=>{if(_t(),Ts(),ve.current||j){It();return}if(Ee.current){It();return}if(Be.touches.length===1){const Et=Be.touches[0];he={x:Et.clientX,y:Et.clientY},ke=performance.now(),Re=!1,$e=Et.clientY,Ue=ke,Ie=0,De=0,et=Te(),Ye()}},X=Be=>{if(Be.touches.length!==1||$e===null)return;if(Ts(),ve.current||j){It();return}if(Ee.current||wn()){It();return}Be.preventDefault(),Be.stopPropagation();const Et=performance.now(),kt=Be.touches[0],Zr=kt.clientX,Ds=kt.clientY,Ms=Math.abs(Zr-he.x),Jn=Math.abs(Ds-he.y);!Re&&(Ms>Se||Jn>Se)&&(Re=!0,We());const Qn=$e-Ds,Zn=Et-Ue;if($e=Ds,Ue=Et,Zn>0){const kc=Qn/Zn;Ie=Ie*.7+kc*.3}De+=Qn;const Sn=Math.max(6,et*.6),en=Math.trunc(De/Sn);en!==0&&(zt(en),De-=en*Sn)},tt=Be=>{var Ms;const Et=Ie,kt=performance.now()-ke;if(It(),ve.current||j)return;const Zr=wn();if(Ee.current&&!Zr&&((Ms=K.current)==null||Ms.call(K)),Ee.current||Zr){se.current&&(Ne.current=!0);return}if(!Re){if(M&&kt>=ie)return;if(se.current){Be.preventDefault(),Be.stopPropagation(),Ne.current=!0;return}$t();return}if(Math.abs(Et)>.12){let Jn=Et,Qn=performance.now();const Zn=()=>{const Sn=performance.now(),en=Sn-Qn;Qn=Sn;const kc=Jn*en;De+=kc;const Ep=Math.max(6,et*.6),Lc=Math.trunc(De/Ep);Lc!==0&&(zt(Lc),De-=Lc*Ep),Jn*=Math.pow(.95,en/16.67),Math.abs(Jn)>.02?ze=requestAnimationFrame(Zn):ze=null};ze=requestAnimationFrame(Zn)}},Jr=Be=>{Ne.current&&(Be.preventDefault(),Be.stopPropagation(),Ne.current=!1)},Qr={passive:!0,capture:!0},Rs={passive:!1,capture:!0},bp={passive:!1,capture:!0},Cp={capture:!0};return J.addEventListener("touchstart",ca,Qr),J.addEventListener("touchmove",X,Rs),J.addEventListener("touchend",tt,bp),J.addEventListener("mousedown",Jr,Cp),()=>{J.removeEventListener("touchstart",ca,Qr),J.removeEventListener("touchmove",X,Rs),J.removeEventListener("touchend",tt,bp),J.removeEventListener("mousedown",Jr,Cp);const Be=Me();Be&&(Be.disabled=!1)}},[e==null?void 0:e.id,fe,ge,M,D,j,w,b]);const Ge=E.useCallback(J=>{!e||le||a({type:"terminal-input",sessionId:e.id,data:J})},[e,le,a]),Ae=E.useCallback(()=>{const J=fe.current;if(!J)return;const Se=J.querySelector(".xterm-helper-textarea");Se&&(Se.removeAttribute("disabled"),Se.focus())},[fe]),G=E.useCallback(()=>{if(!e||le)return;se.current&&(a({type:"tmux-cancel-copy-mode",sessionId:e.id}),oe(!1));const J=fe.current;if(!J)return;const Se=J.querySelector(".xterm-helper-textarea");Se&&(Se.removeAttribute("disabled"),Se.focus())},[e,le,a,fe,se,oe]),me=E.useCallback(()=>{var Re,$e;if(typeof document>"u")return!1;const J=fe.current;if(!J)return!1;const Se=J.querySelector(".xterm-helper-textarea");if(Se&&document.activeElement===Se)return!0;const ie=document.activeElement,he=typeof HTMLInputElement<"u"&&ie instanceof HTMLInputElement,ke=typeof HTMLTextAreaElement<"u"&&ie instanceof HTMLTextAreaElement;return he||ke||ie&&ie.isContentEditable?!1:!!(($e=(Re=document.documentElement)==null?void 0:Re.classList)!=null&&$e.contains("keyboard-visible"))},[fe]);return E.useEffect(()=>{if(!M)return;const J=fe.current;if(!J)return;const Se=J.querySelector(".xterm-accessibility"),ie=J.querySelector(".xterm-accessibility-tree");if(!Se||!ie)return;const he=()=>{const ke=J.querySelector(".xterm-helper-textarea");(ke?document.activeElement===ke:!1)&&!Ee.current?(Se.style.pointerEvents="none",ie.style.pointerEvents="none"):(Se.style.removeProperty("pointer-events"),ie.style.removeProperty("pointer-events"))};return he(),document.addEventListener("focusin",he),document.addEventListener("focusout",he),()=>{document.removeEventListener("focusin",he),document.removeEventListener("focusout",he)}},[fe,M,F]),T.jsxs("section",{className:`flex flex-1 flex-col bg-base terminal-mobile-overlay md:relative md:inset-auto ${M?"ios-native-term-selection":""}`,"data-testid":"terminal-panel",children:[T.jsxs("div",{className:`flex h-10 shrink-0 items-center justify-between border-b border-border bg-elevated px-3 ${e?"":"md:hidden"}`,children:[T.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[T.jsx("button",{onClick:()=>W(!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:T.jsx(RC,{width:16,height:16})}),e&&ne&&T.jsx("button",{onClick:()=>R(!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 (${A}X)`,"aria-label":"Kill session",children:T.jsx(Dh,{width:16,height:16})}),e?T.jsxs("div",{className:"flex items-baseline gap-3 min-w-0",children:[V?T.jsx("input",{ref:te,type:"text",value:Q,onChange:J=>$(J.target.value),onBlur:Pe,onKeyDown:Oe,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"}):T.jsx("span",{className:"text-sm font-medium text-primary truncate",children:e.agentSessionName||e.name}),T.jsx("span",{className:`text-xs shrink-0 ${uM[e.status]}`,children:cM[e.status]})]}):T.jsx("span",{className:"text-sm font-medium text-primary md:hidden",children:"Sessions"})]}),T.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[n!=="connected"&&T.jsx("span",{className:"text-xs text-approval",children:n}),T.jsx("button",{onClick:c,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 (${A}N)`,"aria-label":"New session",children:T.jsx(oy,{width:16,height:16})}),e&&ne&&T.jsx("button",{onClick:()=>R(!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 (${A}X)`,"aria-label":"Kill session",children:T.jsx(Dh,{width:16,height:16})}),e&&T.jsxs("div",{className:"relative md:hidden",ref:U,children:[T.jsx("button",{onClick:()=>N(!P),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:T.jsx(SC,{width:16,height:16})}),P&&T.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:[ne&&T.jsxs("button",{onClick:Fe,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:[T.jsx(sy,{width:14,height:14}),"Rename"]}),T.jsxs("button",{onClick:()=>{y(),N(!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:[T.jsx(OC,{width:14,height:14}),"Settings"]})]})]})]})]}),e&&t.length>1&&T.jsxs("div",{className:"relative overflow-hidden bg-elevated border-b border-border md:hidden",children:[T.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"}),T.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((J,Se)=>{const ie=J.id===e.id;return T.jsx("button",{type:"button",className:`
294
+ `,onMouseDown:F=>F.preventDefault(),onTouchStart:O(M),onClick:z(M),disabled:t,children:nM})]}),c&&T.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:T.jsxs("div",{ref:d,className:"mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl",children:[T.jsx("h3",{className:"text-base font-medium text-primary mb-1 text-balance",children:"Paste"}),T.jsx("p",{className:"text-xs text-muted mb-3 text-pretty",children:"Text or image (long-press → Paste)"}),_?T.jsx("div",{className:"w-full h-11 flex items-center justify-center bg-surface border border-border rounded-md text-secondary",children:"Uploading image..."}):T.jsx("input",{ref:m,type:"text",value:u,onChange:F=>p(F.target.value),onKeyDown:F=>{F.key==="Enter"?(F.preventDefault(),k()):F.key==="Escape"&&(F.preventDefault(),L())},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"}}),T.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[T.jsx("button",{type:"button",onClick:L,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"}),T.jsx("button",{type:"button",onClick:k,disabled:_,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 lM({isOpen:e,onClose:t,sessions:r,inactiveSessions:n=[],selectedSessionId:i,onSelect:a,onRename:l,onResume:s,onSetPinned:o,onNewSession:c,loading:f,error:u}){const p=$1(),_=E.useRef(null),y=E.useRef(null);E.useEffect(()=>{if(!e)return;const m=d=>{d.key==="Escape"&&(d.preventDefault(),t())};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,t]),E.useEffect(()=>{var m;e?(y.current=document.activeElement,(m=_.current)==null||m.focus()):y.current&&(y.current.focus(),y.current=null)},[e]),E.useEffect(()=>{if(!e)return;const m=_.current;if(!m)return;const d=50,g=1.5;let w=0,b=0;const x=S=>{const k=S.touches[0];w=k.clientX,b=k.clientY},C=S=>{const k=S.changedTouches[0],L=w-k.clientX,A=Math.abs(k.clientY-b);L>=d&&L>A*g&&("vibrate"in navigator&&navigator.vibrate(10),t())};return m.addEventListener("touchstart",x,{passive:!0}),m.addEventListener("touchend",C,{passive:!0}),()=>{m.removeEventListener("touchstart",x),m.removeEventListener("touchend",C)}},[e,t]);const v=m=>{a(m),t()},h=p?{transition:"none"}:void 0;return T.jsxs(T.Fragment,{children:[T.jsx("div",{className:`session-drawer-backdrop ${e?"open":""}`,style:h,onClick:t,"aria-hidden":"true"}),T.jsxs("div",{ref:_,className:`session-drawer ${e?"open":""}`,style:h,role:"dialog","aria-modal":"true","aria-label":"Session list",tabIndex:-1,children:[T.jsx(fw,{sessions:r,inactiveSessions:n,selectedSessionId:i,onSelect:v,onRename:l,onResume:s,onSetPinned:o,loading:f,error:u}),T.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:T.jsx("button",{onClick:()=>{c()!==!1&&t()},className:"btn btn-primary w-full py-2 text-sm",children:"New Session"})})]})]})}const cM={working:"Working",waiting:"Waiting",permission:"Needs Input",unknown:"Unknown"},uM={working:"text-working",waiting:"text-waiting",permission:"text-approval",unknown:"text-muted"},hM={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"},dM={working:"bg-working text-white",waiting:"bg-waiting text-white",permission:"bg-approval text-white",unknown:"bg-muted text-white"};function bv(){"vibrate"in navigator&&navigator.vibrate(10)}function fM({session:e,sessions:t,inactiveSessions:r=[],connectionStatus:n,connectionEpoch:i=0,sendMessage:a,subscribe:l,onClose:s,onSelectSession:o,onNewSession:c,onKillSession:f,onRenameSession:u,onResumeSession:p,onSetPinned:_,onOpenSettings:y,loading:v=!1,error:h=null}){const m=ql(J=>J.theme),d=zD[m],g=pe(J=>J.useWebGL),w=pe(J=>J.fontSize),b=pe(J=>J.lineHeight),x=pe(J=>J.letterSpacing),C=pe(J=>J.fontOption),S=pe(J=>J.customFontFamily),k=lC(C,S),L=pe(J=>J.shortcutModifier),A=ii(ea(L)),M=Zo(),D=jD(),[O,z]=E.useState(!1),[F,H]=E.useState(!1),[I,R]=E.useState(!1),[P,N]=E.useState(!1),[j,W]=E.useState(!1),[V,Z]=E.useState(!1),[Q,$]=E.useState(""),B=E.useRef(!1),K=E.useRef(null),U=E.useRef(null),te=E.useRef(null),Y=E.useRef(null),_e=(e==null?void 0:e.remote)===!0,de=Ke(J=>J.remoteAllowControl),re=Ke(J=>J.remoteAllowAttach),le=_e&&!re,ne=!_e||de&&(e==null?void 0:e.source)==="managed",{containerRef:fe,terminalRef:ge,inTmuxCopyModeRef:se,setTmuxCopyMode:oe}=ND({sessionId:(e==null?void 0:e.id)??null,tmuxTarget:(e==null?void 0:e.tmuxWindow)??null,allowAttach:!le,connectionStatus:n,connectionEpoch:i,sendMessage:a,subscribe:l,theme:d,fontSize:w,lineHeight:b,letterSpacing:x,fontFamily:k,useWebGL:g,onScrollChange:J=>{z(!J)}}),ue=E.useCallback(()=>{var J;!e||le||(a({type:"tmux-cancel-copy-mode",sessionId:e.id}),oe(!1),(J=ge.current)==null||J.scrollToBottom())},[e,le,a,oe,ge]),ae=E.useCallback(()=>{W(!0),bv()},[]),ve=$D({enabled:D||M,isOpen:j,onOpen:ae});E.useEffect(()=>{!D&&!M&&j&&W(!1)},[j,D,M]);const Ce=E.useCallback(()=>N(!1),[]);FD(U,P,Ce),E.useEffect(()=>{V&&te.current&&(te.current.focus(),te.current.select())},[V]),E.useEffect(()=>{I&&Y.current&&Y.current.focus()},[I]);const Le=E.useCallback(()=>R(!1),[]);HD(I,Le);const je=()=>{e&&(f(e.id),R(!1))},Fe=()=>{e&&($(e.agentSessionName||e.name),Z(!0),N(!1))},Pe=()=>{if(!e)return;const J=Q.trim(),Se=e.agentSessionName||e.name;J&&J!==Se&&u(e.id,J),Z(!1)},Oe=J=>{J.key==="Enter"?(J.preventDefault(),Pe()):J.key==="Escape"&&(J.preventDefault(),Z(!1))};E.useEffect(()=>{if(!M||!e){H(!1);return}const J=fe.current;if(!J)return;const Se=Te=>{const Me=J.querySelector(".xterm-accessibility-tree");if(!Me)return!1;const We=Te.anchorNode,Ye=Te.focusNode;return!!We&&Me.contains(We)||!!Ye&&Me.contains(Ye)},ie=()=>{const Te=J.querySelector(".xterm-accessibility"),Me=J.querySelector(".xterm-accessibility-tree");!Te||!Me||(Te.style.setProperty("opacity","0"),Me.style.setProperty("opacity","0"),Te.style.setProperty("-webkit-user-select","none"),Te.style.setProperty("user-select","none"),Me.style.setProperty("-webkit-user-select","none"),Me.style.setProperty("user-select","none"),Te.offsetHeight,requestAnimationFrame(()=>{Te.style.removeProperty("opacity"),Me.style.removeProperty("opacity"),Te.style.removeProperty("-webkit-user-select"),Te.style.removeProperty("user-select"),Me.style.removeProperty("-webkit-user-select"),Me.style.removeProperty("user-select")}))},he=()=>{var Me;B.current=!1;const Te=window.getSelection();try{Te==null||Te.removeAllRanges()}catch{}(Me=ge.current)==null||Me.clearSelection(),ie(),H(!1)};K.current=he;const ke=()=>{const Te=window.getSelection();if(!Te||Te.rangeCount===0||Te.isCollapsed){B.current?he():H(Ye=>Ye&&!1);return}const Me=Se(Te);if(!Me&&B.current){he();return}B.current=Me;const We=Me;H(Ye=>Ye!==We?We:Ye)},Re=()=>{const Te=window.getSelection();!Te||Te.isCollapsed||Se(Te)&&setTimeout(he,0)},$e=10;let Ue=null,Ie=!1;const De=Te=>{if(Te.touches.length===1){const Me=Te.touches[0];Ue={x:Me.clientX,y:Me.clientY},Ie=!1}},et=Te=>{if(Ie||!Ue||Te.touches.length!==1)return;const Me=Te.touches[0],We=Math.abs(Me.clientX-Ue.x),Ye=Math.abs(Me.clientY-Ue.y);(We>$e||Ye>$e)&&(Ie=!0)},ze=Te=>{const Me=Ie;Ue=null,Ie=!1;const We=window.getSelection();if(!We||We.rangeCount===0||We.isCollapsed){H(!1);return}const Ye=J.querySelector(".xterm-accessibility-tree");if(!Ye)return;if(!Se(We)){H(!1);return}if(Me)return;const $t=Te.target,_t=$t?Ye.contains($t):!1;let zt=!1;if(_t&&$t)try{zt=We.containsNode($t,!0)}catch{zt=!1}(!_t||!zt)&&setTimeout(he,0)};return document.addEventListener("selectionchange",ke),document.addEventListener("copy",Re),document.addEventListener("touchstart",De,{passive:!0}),document.addEventListener("touchmove",et,{passive:!0}),document.addEventListener("touchend",ze,{passive:!0}),()=>{document.removeEventListener("selectionchange",ke),document.removeEventListener("copy",Re),document.removeEventListener("touchstart",De),document.removeEventListener("touchmove",et),document.removeEventListener("touchend",ze),K.current=null,B.current=!1}},[fe,M,e==null?void 0:e.id]),E.useEffect(()=>{var Ue;if(!M)return;const J=fe.current;if(!J)return;const Se=()=>{const Ie=ge.current,De=J.querySelector(".xterm");if(!Ie||!De)return;const et=De.querySelector(".xterm-screen"),ze=De.querySelector(".xterm-accessibility"),Te=De.querySelector(".xterm-accessibility-tree");if(!et||!ze||!Te)return;const Me=De.getBoundingClientRect(),We=et.getBoundingClientRect(),Ye=We.left-Me.left,$t=We.top-Me.top;Object.assign(ze.style,{left:`${Ye}px`,top:`${$t}px`,right:"auto",bottom:"auto",width:`${We.width}px`,height:`${We.height}px`});const _t=We.width/Ie.cols,zt=We.height/Ie.rows,It=document.createElement("span");It.textContent="0".repeat(200),It.style.cssText="position:absolute;visibility:hidden;white-space:pre;pointer-events:none;letter-spacing:0px",Te.appendChild(It);const wn=It.getBoundingClientRect().width/200;It.remove();const Ts=Math.max(-2,Math.min(2,_t-wn));J.style.setProperty("--xterm-font-size",`${Ie.options.fontSize}px`),J.style.setProperty("--xterm-cell-height",`${zt}px`),J.style.setProperty("--xterm-a11y-letter-spacing",`${Ts}px`)},ie=performance.now();Se();const he=Math.round(performance.now()-ie);he>10&&Ge("switch_a11y_overlay",{sessionId:e==null?void 0:e.id,a11yMs:he});const ke=window.requestAnimationFrame(Se),Re=window.setTimeout(Se,100),$e=()=>window.requestAnimationFrame(Se);return(Ue=window.visualViewport)==null||Ue.addEventListener("resize",$e),window.addEventListener("orientationchange",$e),()=>{var Ie;window.cancelAnimationFrame(ke),window.clearTimeout(Re),(Ie=window.visualViewport)==null||Ie.removeEventListener("resize",$e),window.removeEventListener("orientationchange",$e)}},[fe,w,M,e==null?void 0:e.id,ge]);const Ee=E.useRef(F);E.useEffect(()=>{Ee.current=F},[F]);const q=E.useRef(e==null?void 0:e.id);E.useEffect(()=>{q.current=e==null?void 0:e.id},[e==null?void 0:e.id]);const ee=E.useRef(a);E.useEffect(()=>{ee.current=a},[a]);const Ne=E.useRef(!1);E.useEffect(()=>{const J=fe.current;if(!J||!(e!=null&&e.id)||!D&&!M)return;const Se=6,ie=350;let he={x:0,y:0},ke=0,Re=!1,$e=null,Ue=0,Ie=0,De=0,et=Math.round(w*b),ze=null;const Te=()=>{const Et=window.getComputedStyle(J).getPropertyValue("--xterm-cell-height").trim(),kt=Number.parseFloat(Et);return!Number.isNaN(kt)&&kt>0?kt:Math.round(w*b)},Me=()=>J.querySelector(".xterm-helper-textarea"),We=()=>{const Be=Me();Be&&document.activeElement!==Be&&(Be.disabled=!0)},Ye=()=>{const Be=Me();Be&&(Be.disabled=!1)};We();const $t=()=>{if(se.current)return;const Be=Me();Be&&(Be.disabled=!1,Be.focus())},_t=()=>{ze!==null&&(cancelAnimationFrame(ze),ze=null),Ie=0},zt=Be=>{const Et=q.current;if(!Et||Be===0)return!1;const kt=ge.current,Zr=(kt==null?void 0:kt.cols)??80,Ds=(kt==null?void 0:kt.rows)??24,Ms=Math.floor(Zr/2),Jn=Math.floor(Ds/2),Qn=Be>0?65:64,Zn=Math.abs(Be),Sn=Be<0;for(let en=0;en<Zn;en++)ee.current({type:"terminal-input",sessionId:Et,data:`\x1B[<${Qn};${Ms};${Jn}M`});return Sn&&oe(!0),Sn},It=()=>{$e=null,Ie=0,De=0},wn=()=>{if(!M)return!1;const Be=window.getSelection();if(!Be||Be.isCollapsed)return!1;const Et=J.querySelector(".xterm-accessibility-tree");if(!Et)return!1;const kt=Be.anchorNode,Zr=Be.focusNode;return!!kt&&Et.contains(kt)||!!Zr&&Et.contains(Zr)},Ts=()=>{var Be;!M||!B.current||wn()||(Be=K.current)==null||Be.call(K)},ca=Be=>{if(_t(),Ts(),ve.current||j){It();return}if(Ee.current){It();return}if(Be.touches.length===1){const Et=Be.touches[0];he={x:Et.clientX,y:Et.clientY},ke=performance.now(),Re=!1,$e=Et.clientY,Ue=ke,Ie=0,De=0,et=Te(),Ye()}},X=Be=>{if(Be.touches.length!==1||$e===null)return;if(Ts(),ve.current||j){It();return}if(Ee.current||wn()){It();return}Be.preventDefault(),Be.stopPropagation();const Et=performance.now(),kt=Be.touches[0],Zr=kt.clientX,Ds=kt.clientY,Ms=Math.abs(Zr-he.x),Jn=Math.abs(Ds-he.y);!Re&&(Ms>Se||Jn>Se)&&(Re=!0,We());const Qn=$e-Ds,Zn=Et-Ue;if($e=Ds,Ue=Et,Zn>0){const kc=Qn/Zn;Ie=Ie*.7+kc*.3}De+=Qn;const Sn=Math.max(6,et*.6),en=Math.trunc(De/Sn);en!==0&&(zt(en),De-=en*Sn)},tt=Be=>{var Ms;const Et=Ie,kt=performance.now()-ke;if(It(),ve.current||j)return;const Zr=wn();if(Ee.current&&!Zr&&((Ms=K.current)==null||Ms.call(K)),Ee.current||Zr){se.current&&(Ne.current=!0);return}if(!Re){if(M&&kt>=ie)return;if(se.current){Be.preventDefault(),Be.stopPropagation(),Ne.current=!0;return}$t();return}if(Math.abs(Et)>.12){let Jn=Et,Qn=performance.now();const Zn=()=>{const Sn=performance.now(),en=Sn-Qn;Qn=Sn;const kc=Jn*en;De+=kc;const Ep=Math.max(6,et*.6),Lc=Math.trunc(De/Ep);Lc!==0&&(zt(Lc),De-=Lc*Ep),Jn*=Math.pow(.95,en/16.67),Math.abs(Jn)>.02?ze=requestAnimationFrame(Zn):ze=null};ze=requestAnimationFrame(Zn)}},Jr=Be=>{Ne.current&&(Be.preventDefault(),Be.stopPropagation(),Ne.current=!1)},Qr={passive:!0,capture:!0},Rs={passive:!1,capture:!0},bp={passive:!1,capture:!0},Cp={capture:!0};return J.addEventListener("touchstart",ca,Qr),J.addEventListener("touchmove",X,Rs),J.addEventListener("touchend",tt,bp),J.addEventListener("mousedown",Jr,Cp),()=>{J.removeEventListener("touchstart",ca,Qr),J.removeEventListener("touchmove",X,Rs),J.removeEventListener("touchend",tt,bp),J.removeEventListener("mousedown",Jr,Cp);const Be=Me();Be&&(Be.disabled=!1)}},[e==null?void 0:e.id,fe,ge,M,D,j,w,b]);const qe=E.useCallback(J=>{!e||le||a({type:"terminal-input",sessionId:e.id,data:J})},[e,le,a]),Ae=E.useCallback(()=>{const J=fe.current;if(!J)return;const Se=J.querySelector(".xterm-helper-textarea");Se&&(Se.removeAttribute("disabled"),Se.focus())},[fe]),G=E.useCallback(()=>{if(!e||le)return;se.current&&(a({type:"tmux-cancel-copy-mode",sessionId:e.id}),oe(!1));const J=fe.current;if(!J)return;const Se=J.querySelector(".xterm-helper-textarea");Se&&(Se.removeAttribute("disabled"),Se.focus())},[e,le,a,fe,se,oe]),me=E.useCallback(()=>{var Re,$e;if(typeof document>"u")return!1;const J=fe.current;if(!J)return!1;const Se=J.querySelector(".xterm-helper-textarea");if(Se&&document.activeElement===Se)return!0;const ie=document.activeElement,he=typeof HTMLInputElement<"u"&&ie instanceof HTMLInputElement,ke=typeof HTMLTextAreaElement<"u"&&ie instanceof HTMLTextAreaElement;return he||ke||ie&&ie.isContentEditable?!1:!!(($e=(Re=document.documentElement)==null?void 0:Re.classList)!=null&&$e.contains("keyboard-visible"))},[fe]);return E.useEffect(()=>{if(!M)return;const J=fe.current;if(!J)return;const Se=J.querySelector(".xterm-accessibility"),ie=J.querySelector(".xterm-accessibility-tree");if(!Se||!ie)return;const he=()=>{const ke=J.querySelector(".xterm-helper-textarea");(ke?document.activeElement===ke:!1)&&!Ee.current?(Se.style.pointerEvents="none",ie.style.pointerEvents="none"):(Se.style.removeProperty("pointer-events"),ie.style.removeProperty("pointer-events"))};return he(),document.addEventListener("focusin",he),document.addEventListener("focusout",he),()=>{document.removeEventListener("focusin",he),document.removeEventListener("focusout",he)}},[fe,M,F]),T.jsxs("section",{className:`flex flex-1 flex-col bg-base terminal-mobile-overlay md:relative md:inset-auto ${M?"ios-native-term-selection":""}`,"data-testid":"terminal-panel",children:[T.jsxs("div",{className:`flex h-10 shrink-0 items-center justify-between border-b border-border bg-elevated px-3 ${e?"":"md:hidden"}`,children:[T.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[T.jsx("button",{onClick:()=>W(!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:T.jsx(RC,{width:16,height:16})}),e&&ne&&T.jsx("button",{onClick:()=>R(!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 (${A}X)`,"aria-label":"Kill session",children:T.jsx(Dh,{width:16,height:16})}),e?T.jsxs("div",{className:"flex items-baseline gap-3 min-w-0",children:[V?T.jsx("input",{ref:te,type:"text",value:Q,onChange:J=>$(J.target.value),onBlur:Pe,onKeyDown:Oe,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"}):T.jsx("span",{className:"text-sm font-medium text-primary truncate",children:e.agentSessionName||e.name}),T.jsx("span",{className:`text-xs shrink-0 ${uM[e.status]}`,children:cM[e.status]})]}):T.jsx("span",{className:"text-sm font-medium text-primary md:hidden",children:"Sessions"})]}),T.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[n!=="connected"&&T.jsx("span",{className:"text-xs text-approval",children:n}),T.jsx("button",{onClick:c,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 (${A}N)`,"aria-label":"New session",children:T.jsx(oy,{width:16,height:16})}),e&&ne&&T.jsx("button",{onClick:()=>R(!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 (${A}X)`,"aria-label":"Kill session",children:T.jsx(Dh,{width:16,height:16})}),e&&T.jsxs("div",{className:"relative md:hidden",ref:U,children:[T.jsx("button",{onClick:()=>N(!P),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:T.jsx(SC,{width:16,height:16})}),P&&T.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:[ne&&T.jsxs("button",{onClick:Fe,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:[T.jsx(sy,{width:14,height:14}),"Rename"]}),T.jsxs("button",{onClick:()=>{y(),N(!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:[T.jsx(OC,{width:14,height:14}),"Settings"]})]})]})]})]}),e&&t.length>1&&T.jsxs("div",{className:"relative overflow-hidden bg-elevated border-b border-border md:hidden",children:[T.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"}),T.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((J,Se)=>{const ie=J.id===e.id;return T.jsx("button",{type:"button",className:`
295
295
  flex items-center justify-center shrink-0 snap-start
296
296
  h-8 w-8 text-sm font-extrabold rounded-lg
297
297
  active:scale-95 transition-all duration-75
298
298
  select-none touch-manipulation
299
299
  ${ie?dM[J.status]:hM[J.status]}
300
- `,onClick:()=>{bv(),o(J.id)},children:Se+1},J.id)})})]}),T.jsxs("div",{className:"relative flex-1",children:[T.jsx("div",{ref:fe,className:"absolute inset-0"}),!e&&T.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-muted",children:"Select a session to view terminal"}),e&&le&&T.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."}),O&&e&&!F&&T.jsxs("button",{onClick:ue,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:[T.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:T.jsx("path",{d:"M12 5v14M5 12l7 7 7-7"})}),T.jsx("span",{className:"text-sm font-medium",children:"Jump to bottom"})]})]}),e&&T.jsx(aM,{onSendKey:Ge,disabled:n!=="connected"||le,sessions:t.map(J=>({id:J.id,name:J.name,status:J.status})),currentSessionId:e.id,onSelectSession:o,hideSessionSwitcher:!0,onRefocus:Ae,isKeyboardVisible:me,onEnterTextMode:G}),(D||M)&&T.jsx(lM,{isOpen:j,onClose:()=>W(!1),sessions:t,inactiveSessions:r,selectedSessionId:(e==null?void 0:e.id)??null,onSelect:o,onRename:u,onResume:p,onSetPinned:_,onNewSession:c,loading:v,error:h}),I&&e&&T.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:T.jsxs("div",{className:"mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl",children:[T.jsx("h3",{className:"text-base font-medium text-primary mb-2 text-balance",children:"Kill Session"}),T.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.']}),T.jsxs("div",{className:"flex justify-end gap-2",children:[T.jsx("button",{onClick:()=>R(!1),className:"btn py-1.5 px-3 text-sm",children:"Cancel"}),T.jsx("button",{ref:Y,onClick:je,className:"btn btn-danger py-1.5 px-3 text-sm",children:"Kill Session"})]})]})})]})}function pM({onSelect:e,onCancel:t,initialPath:r}){const[n,i]=E.useState(r||"~"),[a,l]=E.useState(null),[s,o]=E.useState(null),[c,f]=E.useState(!0),[u,p]=E.useState(-1),_=E.useRef(null),y=pe(g=>g.recentPaths),v=E.useCallback(async g=>{var x;(x=_.current)==null||x.abort();const w=new AbortController;_.current=w;const{signal:b}=w;f(!0),o(null),l(null),p(-1),i(g);try{const C=await fetch(`/api/directories?path=${encodeURIComponent(g)}`,{signal:b});if(!C.ok){const k=await C.json();throw new Error(k.message||"Failed to load directory")}const S=await C.json();if(_.current!==w)return;l(S),i(S.path)}catch(C){if(_.current!==w)return;const S=C;(S==null?void 0:S.name)!=="AbortError"&&o((S==null?void 0:S.message)||"Failed to load directory")}finally{_.current===w&&f(!1)}},[]);E.useEffect(()=>(v(r||"~"),()=>{var g;(g=_.current)==null||g.abort()}),[v,r]);const h=(a==null?void 0:a.directories)??[],m=(a==null?void 0:a.path)||n,d=a==null?void 0:a.parent;return E.useEffect(()=>{const g=w=>{if(w.key==="Escape"){w.preventDefault(),t();return}if(!c){if(w.key==="ArrowDown"){w.preventDefault(),p(b=>h.length===0?-1:b<0?0:Math.min(b+1,h.length-1));return}if(w.key==="ArrowUp"){w.preventDefault(),p(b=>h.length===0?-1:b<0?h.length-1:Math.max(b-1,0));return}if(w.key==="Enter"){w.preventDefault();const b=h[u];b?v(b.path):m&&e(m);return}w.key==="Backspace"&&d&&(w.preventDefault(),v(d))}};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[h,m,v,u,c,t,e,d]),T.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:g=>{g.target===g.currentTarget&&t()},"data-testid":"directory-browser",children:T.jsxs("div",{className:"w-full max-w-lg border border-border bg-elevated p-4",children:[T.jsxs("div",{className:"flex items-center gap-3 border-b border-border pb-2",children:[T.jsx("button",{type:"button",className:"btn",onClick:()=>{d&&v(d)},disabled:!d||c,children:"Up"}),T.jsx("div",{className:"min-w-0 flex-1 truncate text-xs font-mono text-secondary",title:m,"data-testid":"directory-current-path",children:m})]}),T.jsx("div",{className:"mt-3 max-h-60 overflow-y-auto border border-border bg-surface",children:c?T.jsx("div",{className:"px-3 py-4 text-xs text-muted","data-testid":"directory-loading",children:"Loading directories..."}):s?T.jsxs("div",{className:"px-3 py-4 text-xs","data-testid":"directory-error",children:[T.jsx("p",{className:"text-danger",children:s}),T.jsx("button",{type:"button",className:"btn mt-3",onClick:()=>v(n),children:"Retry"})]}):h.length===0?T.jsx("div",{className:"px-3 py-4 text-xs text-muted","data-testid":"directory-empty",children:"No subdirectories"}):T.jsx("div",{className:"py-1",children:h.map((g,w)=>T.jsxs("button",{type:"button",onClick:()=>v(g.path),onMouseEnter:()=>p(w),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-xs ${w===u?"bg-hover text-primary":"text-secondary"}`,"data-testid":"directory-entry","data-entry-name":g.name,"data-entry-path":g.path,children:[T.jsx(EC,{width:14,height:14,className:"shrink-0 text-muted","aria-hidden":"true"}),T.jsx("span",{className:"truncate",children:g.name})]},g.path))})}),a!=null&&a.truncated?T.jsx("p",{className:"mt-2 text-[10px] text-muted",children:"Showing first 200 directories."}):null,T.jsxs("div",{className:"mt-4 border-t border-border pt-3",children:[T.jsx("div",{className:"text-[10px] uppercase tracking-wider text-secondary",children:"Recent"}),y.length===0?T.jsx("p",{className:"mt-2 text-xs text-muted",children:"No recent paths yet."}):T.jsx("div",{className:"mt-2 space-y-1",children:y.map(g=>T.jsx("button",{type:"button",className:"block w-full truncate text-left text-xs text-secondary hover:text-primary",onClick:()=>v(g),title:g,"data-testid":"directory-recent","data-recent-path":g,children:g},g))})]}),T.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[T.jsx("button",{type:"button",onClick:t,className:"btn",children:"Cancel"}),T.jsx("button",{type:"button",onClick:()=>{m&&e(m)},className:"btn btn-primary",disabled:c||!m,children:"Select"})]})]})})}function mM({isOpen:e,onClose:t,onCreate:r,defaultProjectDir:n,commandPresets:i,defaultPresetId:a,lastProjectPath:l,activeProjectPath:s,remoteHosts:o=[],remoteAllowControl:c=!1,initialHost:f,initialPath:u,initialCommand:p}){const[_,y]=E.useState(""),[v,h]=E.useState(""),[m,d]=E.useState(null),[g,w]=E.useState(""),[b,x]=E.useState(!1),[C,S]=E.useState(""),k=E.useRef(null),L=E.useRef(null),A=E.useRef(null),M=c&&o.length>0;if(E.useEffect(()=>{if(!e){y(""),h(""),d(null),w(""),x(!1),S(f??""),setTimeout(()=>{if(typeof document>"u"||typeof document.querySelector!="function")return;const W=document.querySelector(".xterm-helper-textarea");W&&(W.removeAttribute("disabled"),W.focus())},300);return}if(typeof document<"u"&&typeof document.querySelector=="function"){const W=document.querySelector(".xterm-helper-textarea");W&&typeof W.setAttribute=="function"&&(typeof W.blur=="function"&&W.blur(),W.setAttribute("disabled","true"))}const N=(u==null?void 0:u.trim())||(s==null?void 0:s.trim())||l||n||"";y(N),h(""),S(f??"");const j=p==null?void 0:p.trim();if(j){const W=i.find(V=>Hi(V)===j);W?(d(W.id),w(Hi(W))):(d(null),w(j))}else{const W=i.find(V=>V.id===a);W?(d(a),w(Hi(W))):i.length>0?(d(i[0].id),w(Hi(i[0]))):(d(null),w(""))}setTimeout(()=>{var W;if((W=A.current)==null||W.focus(),L.current){const V=L.current;V.scrollLeft=V.scrollWidth}},50)},[s,i,a,n,e,l,f,u,p]),E.useEffect(()=>{if(!e||typeof window>"u"||typeof window.addEventListener!="function")return;const N=()=>k.current?Array.from(k.current.querySelectorAll('input:not([disabled]), select:not([disabled]), button:not([disabled]):not([tabindex="-1"]), [tabindex="0"]')):[],j=W=>{var V,Z;if(!b){if(W.key==="Escape"){typeof W.stopPropagation=="function"&&W.stopPropagation(),t();return}if(W.key==="Enter"){const Q=document.activeElement;if(!Q||Q.tagName==="INPUT"||Q.closest('[data-testid="host-select"]')||!Q.closest('[data-testid="command-select"]'))return;W.preventDefault(),typeof W.stopPropagation=="function"&&W.stopPropagation(),(V=k.current)==null||V.requestSubmit();return}if(W.key==="Tab"){W.preventDefault(),typeof W.stopPropagation=="function"&&W.stopPropagation();const Q=N();if(Q.length===0)return;const $=document.activeElement,B=Q.indexOf($);let K;B===-1?K=W.shiftKey?Q.length-1:0:W.shiftKey?K=B<=0?Q.length-1:B-1:K=B>=Q.length-1?0:B+1,(Z=Q[K])==null||Z.focus()}}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[e,t,b]),!e)return null;const D=N=>{const j=i.find(W=>W.id===N);j&&(d(N),w(Hi(j)))},O=()=>{d(null),w("")},z=m===null,F=C!=="",H=N=>{N.preventDefault();const j=_.trim();if(!j)return;const W=g.trim();r(j,v.trim()||void 0,W||void 0,F?C:void 0),t()},I=[...i.map(N=>({id:N.id,label:N.label,isCustom:!1,agentType:N.agentType,command:N.command})),{id:"custom",label:"Custom",isCustom:!0,agentType:void 0,command:void 0}],R=[{id:"",label:"Local",ok:!0,error:void 0},...o.map(N=>({id:N.host,label:N.host,ok:N.ok,error:N.error}))],P=_.trim()||"~";return T.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:N=>{N.target===N.currentTarget&&t()},children:[T.jsxs("form",{ref:k,onSubmit:H,className:"w-full max-w-md border border-border bg-elevated p-6",children:[T.jsx("h2",{id:"new-session-title",className:"text-sm font-semibold uppercase tracking-wider text-primary text-balance",children:"New Session"}),T.jsxs("div",{className:"mt-4 space-y-4",children:[M&&T.jsxs("div",{children:[T.jsx("label",{className:"mb-1.5 block text-xs text-secondary",children:"Host"}),T.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Host","data-testid":"host-select",children:R.map((N,j)=>{const W=C===N.id,V=!N.ok&&!W;return T.jsx("button",{type:"button",role:"radio","aria-checked":W,"aria-label":N.label,title:N.ok?void 0:N.error||"Unreachable",tabIndex:W?0:-1,onClick:()=>S(N.id),onKeyDown:Z=>{var U;let Q=j;if(Z.key==="ArrowRight"||Z.key==="ArrowDown")Z.preventDefault(),Q=(j+1)%R.length;else if(Z.key==="ArrowLeft"||Z.key==="ArrowUp")Z.preventDefault(),Q=(j-1+R.length)%R.length;else return;const $=R[Q];S($.id);const B=Z.currentTarget.parentElement,K=B==null?void 0:B.querySelectorAll('[role="radio"]');(U=K==null?void 0:K[Q])==null||U.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${W?"btn-primary":""} ${V?"opacity-60":""}`,children:N.label},N.id||"local")})})]}),T.jsxs("div",{children:[T.jsx("label",{className:"mb-1.5 block text-xs text-secondary",children:"Command"}),T.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Command preset","data-testid":"command-select",children:I.map((N,j)=>{const W=N.isCustom?z:m===N.id;return T.jsxs("button",{ref:W?A:void 0,type:"button",role:"radio","aria-checked":W,tabIndex:W?0:-1,onClick:()=>{N.isCustom?O():D(N.id)},onKeyDown:V=>{var K;let Z=j;if(V.key==="ArrowRight"||V.key==="ArrowDown")V.preventDefault(),Z=(j+1)%I.length;else if(V.key==="ArrowLeft"||V.key==="ArrowUp")V.preventDefault(),Z=(j-1+I.length)%I.length;else return;const Q=I[Z];Q.isCustom?O():D(Q.id);const $=V.currentTarget.parentElement,B=$==null?void 0:$.querySelectorAll('[role="radio"]');(K=B==null?void 0:B[Z])==null||K.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${W?"btn-primary":""}`,children:[T.jsx(Cc,{agentType:N.agentType,command:N.command,className:"inline-block h-3.5 w-3.5 shrink-0"}),N.label]},N.id)})}),T.jsx("input",{value:g,onChange:N=>w(N.target.value),placeholder:"Enter command...",className:"input mt-2 font-mono text-xs"})]}),T.jsxs("div",{children:[T.jsx("label",{className:"mb-1.5 block text-xs text-secondary",children:"Project Path"}),T.jsxs("div",{className:"flex gap-2",children:[T.jsx("input",{ref:L,value:_,onChange:N=>y(N.target.value),placeholder:F?"/home/user/project":s||l||n||"/Users/you/code/my-project",className:"input flex-1 text-sm"}),!F&&T.jsx("button",{type:"button",className:"btn",onClick:()=>x(!0),children:"Browse"})]})]}),T.jsxs("div",{children:[T.jsx("label",{className:"mb-1.5 block text-xs text-secondary",children:"Display Name"}),T.jsx("input",{value:v,onChange:N=>h(N.target.value),placeholder:"auto-generated",className:"input text-sm placeholder:italic"})]})]}),T.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[T.jsx("button",{type:"button",onClick:t,className:"btn",children:"Cancel"}),T.jsx("button",{type:"submit",className:"btn btn-primary",children:"Create"})]})]}),b&&!F&&T.jsx(pM,{initialPath:P,onSelect:N=>{y(N),x(!1)},onCancel:()=>x(!1)})]})}const Cu=1,Eu=168;function gM({controlled:e,default:t,name:r,state:n="value"}){const{current:i}=E.useRef(e!==void 0),[a,l]=E.useState(t),s=i?e:a,o=E.useCallback(c=>{i||l(c)},[]);return[s,o]}const Cv={};function ks(e,t){const r=E.useRef(Cv);return r.current===Cv&&(r.current=e(t)),r}const ku=Jv[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],vM=ku&&ku!==E.useLayoutEffect?ku:e=>e();function Xr(e){const t=ks(_M).current;return t.next=e,vM(t.effect),t.trampoline}function _M(){const e={next:void 0,callback:yM,trampoline:(...t)=>{var r;return(r=e.callback)==null?void 0:r.call(e,...t)},effect:()=>{e.callback=e.next}};return e}function yM(){}function ld(e,t,r,n){const i=ks(Fw).current;return SM(i,e,t,r,n)&&Hw(i,[e,t,r,n]),i.callback}function wM(e){const t=ks(Fw).current;return xM(t,e)&&Hw(t,e),t.callback}function Fw(){return{callback:null,cleanup:null,refs:[]}}function SM(e,t,r,n,i){return e.refs[0]!==t||e.refs[1]!==r||e.refs[2]!==n||e.refs[3]!==i}function xM(e,t){return e.refs.length!==t.length||e.refs.some((r,n)=>r!==t[n])}function Hw(e,t){if(e.refs=t,t.every(r=>r==null)){e.callback=null;return}e.callback=r=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),r!=null){const n=Array(t.length).fill(null);for(let i=0;i<t.length;i+=1){const a=t[i];if(a!=null)switch(typeof a){case"function":{const l=a(r);typeof l=="function"&&(n[i]=l);break}case"object":{a.current=r;break}}}e.cleanup=()=>{for(let i=0;i<t.length;i+=1){const a=t[i];if(a!=null)switch(typeof a){case"function":{const l=n[i];typeof l=="function"?l():a(null);break}case"object":{a.current=null;break}}}}}}}const bM=()=>{},qt=typeof document<"u"?E.useLayoutEffect:bM,$w={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},ap={...$w,position:"fixed",top:0,left:0},CM={...$w,position:"absolute"};function ur(){}const zr=Object.freeze({});function Yr(e,...t){const r=new URL("https://base-ui.com/production-error");return r.searchParams.set("code",e.toString()),t.forEach(n=>r.searchParams.append("args[]",n)),`Base UI error #${e}; visit ${r} for the full message.`}const EM=parseInt(E.version,10);function lp(e){return EM>=e}function Ev(e){if(!E.isValidElement(e))return null;const t=e,r=t.props;return(lp(19)?r==null?void 0:r.ref:t.ref)??null}function cd(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function kM(e,t){const r={};for(const n in e){const i=e[n];if(t!=null&&t.hasOwnProperty(n)){const a=t[n](i);a!=null&&Object.assign(r,a);continue}i===!0?r[`data-${n.toLowerCase()}`]="":i&&(r[`data-${n.toLowerCase()}`]=i.toString())}return r}function LM(e,t){return typeof e=="function"?e(t):e}function TM(e,t){return typeof e=="function"?e(t):e}const _o={};function cp(e,t,r,n,i){let a={...ud(e,_o)};return t&&(a=ul(a,t)),r&&(a=ul(a,r)),n&&(a=ul(a,n)),a}function RM(e){if(e.length===0)return _o;if(e.length===1)return ud(e[0],_o);let t={...ud(e[0],_o)};for(let r=1;r<e.length;r+=1)t=ul(t,e[r]);return t}function ul(e,t){return zw(t)?t(e):DM(e,t)}function DM(e,t){if(!t)return e;for(const r in t){const n=t[r];switch(r){case"style":{e[r]=cd(e.style,n);break}case"className":{e[r]=Uw(e.className,n);break}default:MM(r,n)?e[r]=AM(e[r],n):e[r]=n}}return e}function MM(e,t){const r=e.charCodeAt(0),n=e.charCodeAt(1),i=e.charCodeAt(2);return r===111&&n===110&&i>=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function zw(e){return typeof e=="function"}function ud(e,t){return zw(e)?e(t):e??_o}function AM(e,t){return t?e?r=>{if(PM(r)){const i=r;hd(i);const a=t(i);return i.baseUIHandlerPrevented||e==null||e(i),a}const n=t(r);return e==null||e(r),n}:t:e}function hd(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Uw(e,t){return t?e?t+" "+e:t:e}function PM(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function Ls(e,t,r={}){const n=t.render,i=IM(t,r);if(r.enabled===!1)return null;const a=r.state??zr;return BM(e,n,i,a)}function IM(e,t={}){const{className:r,style:n,render:i}=e,{state:a=zr,ref:l,props:s,stateAttributesMapping:o,enabled:c=!0}=t,f=c?LM(r,a):void 0,u=c?TM(n,a):void 0,p=c?kM(a,o):zr,_=c?cd(p,Array.isArray(s)?RM(s):s)??zr:zr;return typeof document<"u"&&(c?Array.isArray(l)?_.ref=wM([_.ref,Ev(i),...l]):_.ref=ld(_.ref,Ev(i),l):ld(null,null)),c?(f!==void 0&&(_.className=Uw(_.className,f)),u!==void 0&&(_.style=cd(_.style,u)),_):zr}const OM=Symbol.for("react.lazy");function BM(e,t,r,n){if(t){if(typeof t=="function")return t(r,n);const i=cp(r,t.props);i.ref=r.ref;let a=t;return(a==null?void 0:a.$$typeof)===OM&&(a=E.Children.toArray(t)[0]),E.cloneElement(a,i)}if(e&&typeof e=="string")return NM(e,r);throw new Error(Yr(8))}function NM(e,t){return e==="button"?E.createElement("button",{type:"button",...t,key:t.key}):e==="img"?E.createElement("img",{alt:"",...t,key:t.key}):E.createElement(e,t)}const jM={...Jv};let kv=0;function FM(e,t="mui"){const[r,n]=E.useState(e),i=e||r;return E.useEffect(()=>{r==null&&(kv+=1,n(`${t}-${kv}`))},[r,t]),i}const Lv=jM.useId;function up(e,t){if(Lv!==void 0){const r=Lv();return e??(t?`${t}-${r}`:r)}return FM(e,t)}function Ww(e){return up(e,"base-ui")}function hp(){return typeof window<"u"}function Ko(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function HM(e){return hp()?e instanceof Element||e instanceof Ko(e).Element:!1}function $M(e){return hp()?e instanceof HTMLElement||e instanceof Ko(e).HTMLElement:!1}function zM(e){return!hp()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ko(e).ShadowRoot}const UM=E.createContext(void 0);function WM(e=!1){const t=E.useContext(UM);if(t===void 0&&!e)throw new Error(Yr(16));return t}function VM(e){const{focusableWhenDisabled:t,disabled:r,composite:n=!1,tabIndex:i=0,isNativeButton:a}=e,l=n&&t!==!1,s=n&&t===!1;return{props:E.useMemo(()=>{const c={onKeyDown(f){r&&t&&f.key!=="Tab"&&f.preventDefault()}};return n||(c.tabIndex=i,!a&&r&&(c.tabIndex=t?i:-1)),(a&&(t||l)||!a&&r)&&(c["aria-disabled"]=r),a&&(!t||s)&&(c.disabled=r),c},[n,r,t,l,s,a,i])}}function Vw(e={}){const{disabled:t=!1,focusableWhenDisabled:r,tabIndex:n=0,native:i=!0}=e,a=E.useRef(null),l=WM(!0)!==void 0,s=Xr(()=>{const p=a.current;return!!((p==null?void 0:p.tagName)==="A"&&(p!=null&&p.href))}),{props:o}=VM({focusableWhenDisabled:r,disabled:t,composite:l,tabIndex:n,isNativeButton:i}),c=E.useCallback(()=>{const p=a.current;KM(p)&&l&&t&&o.disabled===void 0&&p.disabled&&(p.disabled=!1)},[t,o.disabled,l]);qt(c,[c]);const f=E.useCallback((p={})=>{const{onClick:_,onMouseDown:y,onKeyUp:v,onKeyDown:h,onPointerDown:m,...d}=p;return cp({type:i?"button":void 0,onClick(w){if(t){w.preventDefault();return}_==null||_(w)},onMouseDown(w){t||y==null||y(w)},onKeyDown(w){if(t||(hd(w),h==null||h(w)),w.baseUIHandlerPrevented)return;const b=w.target===w.currentTarget&&!i&&!s()&&!t,x=w.key==="Enter",C=w.key===" ";b&&((C||x)&&w.preventDefault(),x&&(_==null||_(w)))},onKeyUp(w){t||(hd(w),v==null||v(w)),!w.baseUIHandlerPrevented&&w.target===w.currentTarget&&!i&&!t&&w.key===" "&&(_==null||_(w))},onPointerDown(w){if(t){w.preventDefault();return}m==null||m(w)}},i?void 0:{role:"button"},o,d)},[t,o,i,s]),u=Xr(p=>{a.current=p,c()});return{getButtonProps:f,buttonRef:u}}function KM(e){return $M(e)&&e.tagName==="BUTTON"}const Kw=E.createContext(void 0);function GM(){const e=E.useContext(Kw);if(e===void 0)throw new Error(Yr(63));return e}let Tv=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}({});const qM={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},XM={valid(e){return e===null?null:e?{[Tv.valid]:""}:{[Tv.invalid]:""}}};let Rv=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}({});const Gw={...XM,checked(e){return e?{[Rv.checked]:""}:{[Rv.unchecked]:""}}};function YM(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}const JM=E.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:ur,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function qw(){return E.useContext(JM)}const QM=E.createContext({invalid:void 0,name:void 0,validityData:{state:qM,errors:[],error:"",value:"",initialValue:null},setValidityData:ur,disabled:void 0,touched:!1,setTouched:ur,dirty:!1,setDirty:ur,filled:!1,setFilled:ur,focused:!1,setFocused:ur,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=zr)=>e,getInputValidationProps:(e=zr)=>e,inputRef:{current:null},commit:async()=>{}}});function dp(e=!0){const t=E.useContext(QM);if(t.setValidityData===ur&&!e)throw new Error(Yr(28));return t}function ZM(e){const{enabled:t=!0,value:r,id:n,name:i,controlRef:a,commit:l}=e,{formRef:s}=qw(),{invalid:o,markedDirtyRef:c,validityData:f,setValidityData:u}=dp(),p=Xr(e.getValue);qt(()=>{if(!t)return;let _=r;_===void 0&&(_=p()),f.initialValue===null&&_!==null&&u(y=>({...y,initialValue:_}))},[t,u,r,f.initialValue,p]),qt(()=>{!t||!n||s.current.fields.set(n,{getValue:p,name:i,controlRef:a,validityData:YM(f,o),validate(_=!0){let y=r;y===void 0&&(y=p()),c.current=!0,_?hn.flushSync(()=>l(y)):l(y)}})},[l,a,t,s,p,n,o,c,i,f,r]),qt(()=>{const _=s.current.fields;return()=>{n&&_.delete(n)}},[s,n])}const e3=E.createContext({controlId:void 0,registerControlId:ur,labelId:void 0,setLabelId:ur,messageIds:[],setMessageIds:ur,getDescriptionProps:e=>e});function Xw(){return E.useContext(e3)}function t3(e={}){const{id:t,implicit:r=!1,controlRef:n}=e,{controlId:i,registerControlId:a}=Xw(),l=Ww(t),s=r?i:void 0,o=ks(()=>Symbol("labelable-control")),c=E.useRef(!1),f=E.useRef(t!=null),u=Xr(()=>{!c.current||a===ur||(c.current=!1,a(o.current,void 0))});return qt(()=>{if(a===ur)return;let p;if(r){const _=n==null?void 0:n.current;HM(_)&&_.closest("label")!=null?p=t??null:p=s??l}else if(t!=null)f.current=!0,p=t;else if(f.current)p=l;else{u();return}if(p===void 0){u();return}c.current=!0,a(o.current,p)},[t,n,s,a,r,l,o,u]),E.useEffect(()=>u,[u]),i??l}const r3="none";function n3(e,t,r,n){let i=!1,a=!1;const l=zr;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:r,...l}}function s3(e,t){const r=E.useRef(e),n=Xr(t);qt(()=>{r.current!==e&&n(r.current)},[e,n]),qt(()=>{r.current=e},[e])}const i3=E.forwardRef(function(t,r){const{checked:n,className:i,defaultChecked:a,id:l,inputRef:s,name:o,nativeButton:c=!1,onCheckedChange:f,readOnly:u=!1,required:p=!1,disabled:_=!1,render:y,uncheckedValue:v,value:h,...m}=t,{clearErrors:d}=qw(),{state:g,setTouched:w,setDirty:b,validityData:x,setFilled:C,setFocused:S,shouldValidateOnChange:k,validationMode:L,disabled:A,name:M,validation:D}=dp(),{labelId:O}=Xw(),z=A||_,F=M??o,H=Xr(f),I=E.useRef(null),R=ld(I,s,D.inputRef),P=E.useRef(null),N=Ww(),j=t3({id:l,implicit:!1,controlRef:P}),W=c?void 0:j,[V,Z]=gM({controlled:n,default:!!a,name:"Switch",state:"checked"});ZM({id:N,commit:D.commit,value:V,controlRef:P,name:F,getValue:()=>V}),qt(()=>{I.current&&C(I.current.checked)},[I,C]),s3(V,()=>{d(F),b(V!==x.initialValue),C(V),k()?D.commit(V):D.commit(V,!0)});const{getButtonProps:Q,buttonRef:$}=Vw({disabled:z,native:c}),B={id:c?j:N,role:"switch","aria-checked":V,"aria-readonly":u||void 0,"aria-required":p||void 0,"aria-labelledby":O,onFocus(){z||S(!0)},onBlur(){const Y=I.current;!Y||z||(w(!0),S(!1),L==="onBlur"&&D.commit(Y.checked))},onClick(Y){var _e;u||z||(Y.preventDefault(),(_e=I.current)==null||_e.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:Y.shiftKey,ctrlKey:Y.ctrlKey,altKey:Y.altKey,metaKey:Y.metaKey})))}},K=E.useMemo(()=>cp({checked:V,disabled:z,id:W,name:F,required:p,style:F?CM:ap,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:R,onChange(Y){if(Y.nativeEvent.defaultPrevented)return;const _e=Y.target.checked,de=n3(r3,Y.nativeEvent);H==null||H(_e,de),!de.isCanceled&&Z(_e)},onFocus(){var Y;(Y=P.current)==null||Y.focus()}},D.getInputValidationProps,h!==void 0?{value:h}:zr),[V,z,R,W,F,H,p,Z,D,h]),U=E.useMemo(()=>({...g,checked:V,disabled:z,readOnly:u,required:p}),[g,V,z,u,p]),te=Ls("span",t,{state:U,ref:[r,P,$],props:[B,D.getValidationProps,m,Q],stateAttributesMapping:Gw});return T.jsxs(Kw.Provider,{value:U,children:[te,!V&&F&&v!==void 0&&T.jsx("input",{type:"hidden",name:F,value:v}),T.jsx("input",{...K})]})}),o3=E.forwardRef(function(t,r){const{render:n,className:i,...a}=t,{state:l}=dp(),s=GM(),o={...l,...s};return Ls("span",t,{state:o,ref:r,stateAttributesMapping:Gw,props:a})});function Yw(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=Yw(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function a3(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=Yw(e))&&(n&&(n+=" "),n+=t);return n}const l3=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},c3=(e,t)=>({classGroupId:e,validator:t}),Jw=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Xl="-",Dv=[],u3="arbitrary..",h3=e=>{const t=f3(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return d3(l);const s=l.split(Xl),o=s[0]===""&&s.length>1?1:0;return Qw(s,o,t)},getConflictingClassGroupIds:(l,s)=>{if(s){const o=n[l],c=r[l];return o?c?l3(c,o):o:c||Dv}return r[l]||Dv}}},Qw=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const i=e[t],a=r.nextPart.get(i);if(a){const c=Qw(e,t+1,a);if(c)return c}const l=r.validators;if(l===null)return;const s=t===0?e.join(Xl):e.slice(t).join(Xl),o=l.length;for(let c=0;c<o;c++){const f=l[c];if(f.validator(s))return f.classGroupId}},d3=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?u3+n:void 0})(),f3=e=>{const{theme:t,classGroups:r}=e;return p3(r,t)},p3=(e,t)=>{const r=Jw();for(const n in e){const i=e[n];fp(i,r,n,t)}return r},fp=(e,t,r,n)=>{const i=e.length;for(let a=0;a<i;a++){const l=e[a];m3(l,t,r,n)}},m3=(e,t,r,n)=>{if(typeof e=="string"){g3(e,t,r);return}if(typeof e=="function"){v3(e,t,r,n);return}_3(e,t,r,n)},g3=(e,t,r)=>{const n=e===""?t:Zw(t,e);n.classGroupId=r},v3=(e,t,r,n)=>{if(y3(e)){fp(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(c3(r,e))},_3=(e,t,r,n)=>{const i=Object.entries(e),a=i.length;for(let l=0;l<a;l++){const[s,o]=i[l];fp(o,Zw(t,s),r,n)}},Zw=(e,t)=>{let r=e;const n=t.split(Xl),i=n.length;for(let a=0;a<i;a++){const l=n[a];let s=r.nextPart.get(l);s||(s=Jw(),r.nextPart.set(l,s)),r=s}return r},y3=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,w3=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const i=(a,l)=>{r[a]=l,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(a){let l=r[a];if(l!==void 0)return l;if((l=n[a])!==void 0)return i(a,l),l},set(a,l){a in r?r[a]=l:i(a,l)}}},dd="!",Mv=":",S3=[],Av=(e,t,r,n,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),x3=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=i=>{const a=[];let l=0,s=0,o=0,c;const f=i.length;for(let v=0;v<f;v++){const h=i[v];if(l===0&&s===0){if(h===Mv){a.push(i.slice(o,v)),o=v+1;continue}if(h==="/"){c=v;continue}}h==="["?l++:h==="]"?l--:h==="("?s++:h===")"&&s--}const u=a.length===0?i:i.slice(o);let p=u,_=!1;u.endsWith(dd)?(p=u.slice(0,-1),_=!0):u.startsWith(dd)&&(p=u.slice(1),_=!0);const y=c&&c>o?c-o:void 0;return Av(a,_,p,y)};if(t){const i=t+Mv,a=n;n=l=>l.startsWith(i)?a(l.slice(i.length)):Av(S3,!1,l,void 0,!0)}if(r){const i=n;n=a=>r({className:a,parseClassName:i})}return n},b3=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let i=[];for(let a=0;a<r.length;a++){const l=r[a],s=l[0]==="[",o=t.has(l);s||o?(i.length>0&&(i.sort(),n.push(...i),i=[]),n.push(l)):i.push(l)}return i.length>0&&(i.sort(),n.push(...i)),n}},C3=e=>({cache:w3(e.cacheSize),parseClassName:x3(e),sortModifiers:b3(e),...h3(e)}),E3=/\s+/,k3=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:a}=t,l=[],s=e.trim().split(E3);let o="";for(let c=s.length-1;c>=0;c-=1){const f=s[c],{isExternal:u,modifiers:p,hasImportantModifier:_,baseClassName:y,maybePostfixModifierPosition:v}=r(f);if(u){o=f+(o.length>0?" "+o:o);continue}let h=!!v,m=n(h?y.substring(0,v):y);if(!m){if(!h){o=f+(o.length>0?" "+o:o);continue}if(m=n(y),!m){o=f+(o.length>0?" "+o:o);continue}h=!1}const d=p.length===0?"":p.length===1?p[0]:a(p).join(":"),g=_?d+dd:d,w=g+m;if(l.indexOf(w)>-1)continue;l.push(w);const b=i(m,h);for(let x=0;x<b.length;++x){const C=b[x];l.push(g+C)}o=f+(o.length>0?" "+o:o)}return o},L3=(...e)=>{let t=0,r,n,i="";for(;t<e.length;)(r=e[t++])&&(n=eS(r))&&(i&&(i+=" "),i+=n);return i},eS=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=eS(e[n]))&&(r&&(r+=" "),r+=t);return r},T3=(e,...t)=>{let r,n,i,a;const l=o=>{const c=t.reduce((f,u)=>u(f),e());return r=C3(c),n=r.cache.get,i=r.cache.set,a=s,s(o)},s=o=>{const c=n(o);if(c)return c;const f=k3(o,r);return i(o,f),f};return a=l,(...o)=>a(L3(...o))},R3=[],yt=e=>{const t=r=>r[e]||R3;return t.isThemeGetter=!0,t},tS=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,rS=/^\((?:(\w[\w-]*):)?(.+)\)$/i,D3=/^\d+\/\d+$/,M3=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,A3=/\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$/,P3=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,I3=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,O3=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Is=e=>D3.test(e),He=e=>!!e&&!Number.isNaN(Number(e)),bn=e=>!!e&&Number.isInteger(Number(e)),Lu=e=>e.endsWith("%")&&He(e.slice(0,-1)),rn=e=>M3.test(e),B3=()=>!0,N3=e=>A3.test(e)&&!P3.test(e),nS=()=>!1,j3=e=>I3.test(e),F3=e=>O3.test(e),H3=e=>!xe(e)&&!be(e),$3=e=>Di(e,oS,nS),xe=e=>tS.test(e),ns=e=>Di(e,aS,N3),Tu=e=>Di(e,K3,He),Pv=e=>Di(e,sS,nS),z3=e=>Di(e,iS,F3),ja=e=>Di(e,lS,j3),be=e=>rS.test(e),zi=e=>Mi(e,aS),U3=e=>Mi(e,G3),Iv=e=>Mi(e,sS),W3=e=>Mi(e,oS),V3=e=>Mi(e,iS),Fa=e=>Mi(e,lS,!0),Di=(e,t,r)=>{const n=tS.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Mi=(e,t,r=!1)=>{const n=rS.exec(e);return n?n[1]?t(n[1]):r:!1},sS=e=>e==="position"||e==="percentage",iS=e=>e==="image"||e==="url",oS=e=>e==="length"||e==="size"||e==="bg-size",aS=e=>e==="length",K3=e=>e==="number",G3=e=>e==="family-name",lS=e=>e==="shadow",q3=()=>{const e=yt("color"),t=yt("font"),r=yt("text"),n=yt("font-weight"),i=yt("tracking"),a=yt("leading"),l=yt("breakpoint"),s=yt("container"),o=yt("spacing"),c=yt("radius"),f=yt("shadow"),u=yt("inset-shadow"),p=yt("text-shadow"),_=yt("drop-shadow"),y=yt("blur"),v=yt("perspective"),h=yt("aspect"),m=yt("ease"),d=yt("animate"),g=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],b=()=>[...w(),be,xe],x=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],S=()=>[be,xe,o],k=()=>[Is,"full","auto",...S()],L=()=>[bn,"none","subgrid",be,xe],A=()=>["auto",{span:["full",bn,be,xe]},bn,be,xe],M=()=>[bn,"auto",be,xe],D=()=>["auto","min","max","fr",be,xe],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],F=()=>["auto",...S()],H=()=>[Is,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...S()],I=()=>[e,be,xe],R=()=>[...w(),Iv,Pv,{position:[be,xe]}],P=()=>["no-repeat",{repeat:["","x","y","space","round"]}],N=()=>["auto","cover","contain",W3,$3,{size:[be,xe]}],j=()=>[Lu,zi,ns],W=()=>["","none","full",c,be,xe],V=()=>["",He,zi,ns],Z=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$=()=>[He,Lu,Iv,Pv],B=()=>["","none",y,be,xe],K=()=>["none",He,be,xe],U=()=>["none",He,be,xe],te=()=>[He,be,xe],Y=()=>[Is,"full",...S()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[rn],breakpoint:[rn],color:[B3],container:[rn],"drop-shadow":[rn],ease:["in","out","in-out"],font:[H3],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[rn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[rn],shadow:[rn],spacing:["px",He],text:[rn],"text-shadow":[rn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Is,xe,be,h]}],container:["container"],columns:[{columns:[He,xe,be,s]}],"break-after":[{"break-after":g()}],"break-before":[{"break-before":g()}],"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:b()}],overflow:[{overflow:x()}],"overflow-x":[{"overflow-x":x()}],"overflow-y":[{"overflow-y":x()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:k()}],"inset-x":[{"inset-x":k()}],"inset-y":[{"inset-y":k()}],start:[{start:k()}],end:[{end:k()}],top:[{top:k()}],right:[{right:k()}],bottom:[{bottom:k()}],left:[{left:k()}],visibility:["visible","invisible","collapse"],z:[{z:[bn,"auto",be,xe]}],basis:[{basis:[Is,"full","auto",s,...S()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[He,Is,"auto","initial","none",xe]}],grow:[{grow:["",He,be,xe]}],shrink:[{shrink:["",He,be,xe]}],order:[{order:[bn,"first","last","none",be,xe]}],"grid-cols":[{"grid-cols":L()}],"col-start-end":[{col:A()}],"col-start":[{"col-start":M()}],"col-end":[{"col-end":M()}],"grid-rows":[{"grid-rows":L()}],"row-start-end":[{row:A()}],"row-start":[{"row-start":M()}],"row-end":[{"row-end":M()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:S()}],"gap-x":[{"gap-x":S()}],"gap-y":[{"gap-y":S()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:S()}],px:[{px:S()}],py:[{py:S()}],ps:[{ps:S()}],pe:[{pe:S()}],pt:[{pt:S()}],pr:[{pr:S()}],pb:[{pb:S()}],pl:[{pl:S()}],m:[{m:F()}],mx:[{mx:F()}],my:[{my:F()}],ms:[{ms:F()}],me:[{me:F()}],mt:[{mt:F()}],mr:[{mr:F()}],mb:[{mb:F()}],ml:[{ml:F()}],"space-x":[{"space-x":S()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":S()}],"space-y-reverse":["space-y-reverse"],size:[{size:H()}],w:[{w:[s,"screen",...H()]}],"min-w":[{"min-w":[s,"screen","none",...H()]}],"max-w":[{"max-w":[s,"screen","none","prose",{screen:[l]},...H()]}],h:[{h:["screen","lh",...H()]}],"min-h":[{"min-h":["screen","lh","none",...H()]}],"max-h":[{"max-h":["screen","lh",...H()]}],"font-size":[{text:["base",r,zi,ns]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,be,Tu]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Lu,xe]}],"font-family":[{font:[U3,xe,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,be,xe]}],"line-clamp":[{"line-clamp":[He,"none",be,Tu]}],leading:[{leading:[a,...S()]}],"list-image":[{"list-image":["none",be,xe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",be,xe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Z(),"wavy"]}],"text-decoration-thickness":[{decoration:[He,"from-font","auto",be,ns]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[He,"auto",be,xe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:S()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",be,xe]}],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",be,xe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:R()}],"bg-repeat":[{bg:P()}],"bg-size":[{bg:N()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},bn,be,xe],radial:["",be,xe],conic:[bn,be,xe]},V3,z3]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:j()}],"gradient-via-pos":[{via:j()}],"gradient-to-pos":[{to:j()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:W()}],"rounded-s":[{"rounded-s":W()}],"rounded-e":[{"rounded-e":W()}],"rounded-t":[{"rounded-t":W()}],"rounded-r":[{"rounded-r":W()}],"rounded-b":[{"rounded-b":W()}],"rounded-l":[{"rounded-l":W()}],"rounded-ss":[{"rounded-ss":W()}],"rounded-se":[{"rounded-se":W()}],"rounded-ee":[{"rounded-ee":W()}],"rounded-es":[{"rounded-es":W()}],"rounded-tl":[{"rounded-tl":W()}],"rounded-tr":[{"rounded-tr":W()}],"rounded-br":[{"rounded-br":W()}],"rounded-bl":[{"rounded-bl":W()}],"border-w":[{border:V()}],"border-w-x":[{"border-x":V()}],"border-w-y":[{"border-y":V()}],"border-w-s":[{"border-s":V()}],"border-w-e":[{"border-e":V()}],"border-w-t":[{"border-t":V()}],"border-w-r":[{"border-r":V()}],"border-w-b":[{"border-b":V()}],"border-w-l":[{"border-l":V()}],"divide-x":[{"divide-x":V()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":V()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Z(),"hidden","none"]}],"divide-style":[{divide:[...Z(),"hidden","none"]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...Z(),"none","hidden"]}],"outline-offset":[{"outline-offset":[He,be,xe]}],"outline-w":[{outline:["",He,zi,ns]}],"outline-color":[{outline:I()}],shadow:[{shadow:["","none",f,Fa,ja]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":["none",u,Fa,ja]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:V()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[He,ns]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":V()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":["none",p,Fa,ja]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[He,be,xe]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"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":[He]}],"mask-image-linear-from-pos":[{"mask-linear-from":$()}],"mask-image-linear-to-pos":[{"mask-linear-to":$()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":$()}],"mask-image-t-to-pos":[{"mask-t-to":$()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":$()}],"mask-image-r-to-pos":[{"mask-r-to":$()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":$()}],"mask-image-b-to-pos":[{"mask-b-to":$()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":$()}],"mask-image-l-to-pos":[{"mask-l-to":$()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":$()}],"mask-image-x-to-pos":[{"mask-x-to":$()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":$()}],"mask-image-y-to-pos":[{"mask-y-to":$()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[be,xe]}],"mask-image-radial-from-pos":[{"mask-radial-from":$()}],"mask-image-radial-to-pos":[{"mask-radial-to":$()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"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":w()}],"mask-image-conic-pos":[{"mask-conic":[He]}],"mask-image-conic-from-pos":[{"mask-conic-from":$()}],"mask-image-conic-to-pos":[{"mask-conic-to":$()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:R()}],"mask-repeat":[{mask:P()}],"mask-size":[{mask:N()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",be,xe]}],filter:[{filter:["","none",be,xe]}],blur:[{blur:B()}],brightness:[{brightness:[He,be,xe]}],contrast:[{contrast:[He,be,xe]}],"drop-shadow":[{"drop-shadow":["","none",_,Fa,ja]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:["",He,be,xe]}],"hue-rotate":[{"hue-rotate":[He,be,xe]}],invert:[{invert:["",He,be,xe]}],saturate:[{saturate:[He,be,xe]}],sepia:[{sepia:["",He,be,xe]}],"backdrop-filter":[{"backdrop-filter":["","none",be,xe]}],"backdrop-blur":[{"backdrop-blur":B()}],"backdrop-brightness":[{"backdrop-brightness":[He,be,xe]}],"backdrop-contrast":[{"backdrop-contrast":[He,be,xe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",He,be,xe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[He,be,xe]}],"backdrop-invert":[{"backdrop-invert":["",He,be,xe]}],"backdrop-opacity":[{"backdrop-opacity":[He,be,xe]}],"backdrop-saturate":[{"backdrop-saturate":[He,be,xe]}],"backdrop-sepia":[{"backdrop-sepia":["",He,be,xe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":S()}],"border-spacing-x":[{"border-spacing-x":S()}],"border-spacing-y":[{"border-spacing-y":S()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",be,xe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[He,"initial",be,xe]}],ease:[{ease:["linear","initial",m,be,xe]}],delay:[{delay:[He,be,xe]}],animate:[{animate:["none",d,be,xe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,be,xe]}],"perspective-origin":[{"perspective-origin":b()}],rotate:[{rotate:K()}],"rotate-x":[{"rotate-x":K()}],"rotate-y":[{"rotate-y":K()}],"rotate-z":[{"rotate-z":K()}],scale:[{scale:U()}],"scale-x":[{"scale-x":U()}],"scale-y":[{"scale-y":U()}],"scale-z":[{"scale-z":U()}],"scale-3d":["scale-3d"],skew:[{skew:te()}],"skew-x":[{"skew-x":te()}],"skew-y":[{"skew-y":te()}],transform:[{transform:[be,xe,"","none","gpu","cpu"]}],"transform-origin":[{origin:b()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Y()}],"translate-x":[{"translate-x":Y()}],"translate-y":[{"translate-y":Y()}],"translate-z":[{"translate-z":Y()}],"translate-none":["translate-none"],accent:[{accent:I()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:I()}],"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",be,xe]}],"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":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"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",be,xe]}],fill:[{fill:["none",...I()]}],"stroke-w":[{stroke:[He,zi,ns,Tu]}],stroke:[{stroke:["none",...I()]}],"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"]}},X3=T3(q3);function Yl(...e){return X3(a3(e))}function Cn({checked:e,onCheckedChange:t,disabled:r,className:n}){return T.jsx(i3,{checked:e,onCheckedChange:t,disabled:r,className:Yl("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",n),children:T.jsx(o3,{className:Yl("pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform","translate-x-1 group-data-[checked]:translate-x-5")})})}let Ar=null,pp=!1;const Jl={},cS=500;function mp(){if(typeof window>"u")return null;if((Ar==null?void 0:Ar.state)==="closed"&&(Ar=null),!Ar){const e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Ar=new e}return Ar}function Y3(){Ar&&(Ar.close().catch(()=>{}),Ar=null),mp()}function J3(){return pp}function Ru(){Ar&&(Y3(),pp=!0)}if(typeof window<"u"){window.addEventListener("pageshow",t=>{t.persisted&&Ru()}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&Ru()});let e=Date.now();setInterval(()=>{const t=Date.now();t-e>15e3&&Ru(),e=t},5e3)}async function fd(){const e=mp();e&&e.state==="suspended"&&await e.resume().catch(()=>{}),pp=!1}async function Q3(e){e.state==="suspended"&&await e.resume().catch(()=>{})}async function uS(e){const t=mp();if(!t||(await Q3(t),t.state!=="running"))return;const{frequencies:r,durationMs:n,attackMs:i,peakGain:a,type:l="sine"}=e,s=t.currentTime,o=n/1e3,c=i/1e3,f=t.createGain();f.connect(t.destination);const u=s+o*.7;f.gain.setValueAtTime(0,s),f.gain.linearRampToValueAtTime(a,s+c),f.gain.setValueAtTime(a,u),f.gain.linearRampToValueAtTime(0,s+o);const p=r.map(y=>{const v=t.createOscillator();return v.type=l,v.frequency.setValueAtTime(y,s),v.connect(f),v});for(const y of p)y.start(s),y.stop(s+o);const _=p[p.length-1];_.onended=()=>{for(const y of p)y.disconnect();f.disconnect()}}async function pd(){const e=Date.now();if(!(e-(Jl.permission||0)<cS)){Jl.permission=e;try{await uS({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:"sine"})}catch{}}}async function md(){const e=Date.now();if(!(e-(Jl.idle||0)<cS)){Jl.idle=e;try{await uS({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:"sine"})}catch{}}}function Z3({isOpen:e,onClose:t}){const r=pe(X=>X.defaultProjectDir),n=pe(X=>X.setDefaultProjectDir),i=pe(X=>X.commandPresets),a=pe(X=>X.setCommandPresets),l=pe(X=>X.defaultPresetId),s=pe(X=>X.setDefaultPresetId),o=pe(X=>X.sessionSortMode),c=pe(X=>X.setSessionSortMode),f=pe(X=>X.sessionSortDirection),u=pe(X=>X.setSessionSortDirection),p=pe(X=>X.useWebGL),_=pe(X=>X.setUseWebGL),y=pe(X=>X.fontSize),v=pe(X=>X.setFontSize),h=pe(X=>X.lineHeight),m=pe(X=>X.setLineHeight),d=pe(X=>X.letterSpacing),g=pe(X=>X.setLetterSpacing),w=pe(X=>X.fontOption),b=pe(X=>X.setFontOption),x=pe(X=>X.customFontFamily),C=pe(X=>X.setCustomFontFamily),S=pe(X=>X.shortcutModifier),k=pe(X=>X.setShortcutModifier),L=pe(X=>X.showProjectName),A=pe(X=>X.setShowProjectName),M=pe(X=>X.showLastUserMessage),D=pe(X=>X.setShowLastUserMessage),O=pe(X=>X.showSessionIdPrefix),z=pe(X=>X.setShowSessionIdPrefix),F=ql(X=>X.theme),H=ql(X=>X.setTheme),I=pe(X=>X.soundOnPermission),R=pe(X=>X.setSoundOnPermission),P=pe(X=>X.soundOnIdle),N=pe(X=>X.setSoundOnIdle),[j,W]=E.useState(r),[V,Z]=E.useState(i),[Q,$]=E.useState(l),[B,K]=E.useState(o),[U,te]=E.useState(f),[Y,_e]=E.useState(p),[de,re]=E.useState(y),[le,ne]=E.useState(h),[fe,ge]=E.useState(d),[se,oe]=E.useState(w),[ue,ae]=E.useState(x),[ve,Ce]=E.useState(S),[Le,je]=E.useState(L),[Fe,Pe]=E.useState(M),[Oe,Ee]=E.useState(O),[q,ee]=E.useState(F),[Ne,Ge]=E.useState(I),[Ae,G]=E.useState(P),[me,J]=E.useState(!0),[Se,ie]=E.useState(!1),[he,ke]=E.useState(24),[Re,$e]=E.useState(!1),[Ue,Ie]=E.useState(!1),[De,et]=E.useState(""),[ze,Te]=E.useState(""),[Me,We]=E.useState(""),Ye=E.useRef(null);if(E.useEffect(()=>{if(Ye.current&&(clearTimeout(Ye.current),Ye.current=null),e){if(W(r),Z(i),$(l),K(o),te(f),_e(p),re(y),ne(h),ge(d),oe(w),ae(x),Ce(S),je(L),Pe(M),Ee(O),ee(F),Ge(I),G(P),Ie(!1),et(""),Te(""),We(""),fetch("/api/settings/tmux-mouse-mode").then(X=>X.json()).then(X=>J(X.enabled)).catch(()=>{}),fetch("/api/settings/inactive-max-age-hours").then(X=>X.json()).then(X=>ke(X.hours)).catch(()=>{}),typeof document<"u"){const X=document.querySelector(".xterm-helper-textarea");X&&typeof X.setAttribute=="function"&&(typeof X.blur=="function"&&X.blur(),X.setAttribute("disabled","true"))}}else typeof document<"u"&&(Ye.current=setTimeout(()=>{if(typeof document>"u")return;const X=document.querySelector(".xterm-helper-textarea");X&&(X.removeAttribute("disabled"),X.focus())},300));return()=>{Ye.current&&(clearTimeout(Ye.current),Ye.current=null)}},[i,l,r,o,f,p,y,h,d,w,x,S,L,M,O,F,I,P,e]),E.useEffect(()=>{if(!e||typeof window>"u"||typeof window.addEventListener!="function")return;const X=tt=>{tt.key==="Escape"&&(typeof tt.stopPropagation=="function"&&tt.stopPropagation(),t())};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[e,t]),!e)return null;const $t=X=>{X.preventDefault();const tt=j.trim(),Jr=Y!==p;n(tt||Th),a(V),s(Q),c(B),u(U),_(Y),v(de),m(le),g(fe),b(se),C(ue),k(ve),A(Le),D(Fe),z(Oe),H(q),R(Ne),N(Ae),t({webglChanged:Jr})},_t=(X,tt)=>{Z(Jr=>Jr.map(Qr=>Qr.id===X?{...Qr,...tt}:Qr))},zt=X=>{var Qr;const tt=V.find(Rs=>Rs.id===X);if(!tt||tt.isBuiltIn)return;const Jr=V.filter(Rs=>Rs.id!==X);Z(Jr),X===Q&&$(((Qr=Jr[0])==null?void 0:Qr.id)||"claude")},It=()=>{if(!De.trim()||!ze.trim()||V.length>=si)return;const X={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:De.trim(),command:ze.trim(),isBuiltIn:!1,agentType:Me||void 0};Z([...V,X]),Ie(!1),et(""),Te(""),We("")},wn=V.length<si,Ts=X=>{ie(!0),J(X),fetch("/api/settings/tmux-mouse-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:X})}).catch(()=>J(!X)).finally(()=>ie(!1))},ca=X=>{const tt=he;$e(!0),ke(X),fetch("/api/settings/inactive-max-age-hours",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({hours:X})}).catch(()=>ke(tt)).finally(()=>$e(!1))};return T.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:X=>{X.target===X.currentTarget&&t()},children:T.jsxs("form",{onSubmit:$t,className:"w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated",children:[T.jsxs("div",{className:"p-6 pb-0",children:[T.jsx("h2",{className:"text-sm font-semibold uppercase tracking-wider text-primary text-balance",children:"Settings"}),T.jsx("p",{className:"mt-2 text-xs text-muted text-pretty",children:"Configure default directory, command presets, and display options."})]}),T.jsx("div",{className:"flex-1 overflow-y-auto px-6 pb-4",children:T.jsxs("div",{className:"mt-5 space-y-4",children:[T.jsxs("div",{children:[T.jsx("label",{className:"mb-1.5 block text-xs text-secondary",children:"Default Project Directory"}),T.jsx("input",{value:j,onChange:X=>W(X.target.value),placeholder:Th,className:"input",autoFocus:!0})]}),T.jsxs("div",{className:"border-t border-border pt-4",children:[T.jsxs("div",{className:"flex items-center justify-between mb-2",children:[T.jsx("label",{className:"text-xs text-secondary",children:"Command Presets"}),T.jsx("select",{value:Q,onChange:X=>$(X.target.value),className:"input text-xs py-1 px-2 w-auto",children:V.map(X=>T.jsx("option",{value:X.id,children:X.label},X.id))})]}),T.jsx("p",{className:"text-[10px] text-muted mb-3",children:"Default preset is pre-selected when creating new sessions."}),T.jsx("div",{className:"space-y-3",children:V.map(X=>T.jsxs("div",{className:"border border-border p-3 space-y-2",children:[T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsx("div",{className:"flex items-center gap-2",children:T.jsx("input",{value:X.label,onChange:tt=>_t(X.id,{label:tt.target.value}),className:"input text-sm py-1 px-2 w-32",placeholder:"Label"})}),!X.isBuiltIn&&T.jsx("button",{type:"button",onClick:()=>zt(X.id),className:"btn text-xs px-2 py-1 text-error hover:bg-error/10",children:"Delete"})]}),T.jsxs("div",{children:[T.jsx("label",{className:"text-[10px] text-muted block mb-1",children:"Command"}),T.jsx("input",{value:X.command,onChange:tt=>_t(X.id,{command:tt.target.value}),className:"input text-xs py-1 px-2 font-mono w-full",placeholder:"command --flags"})]}),!X.isBuiltIn&&T.jsxs("div",{children:[T.jsx("label",{className:"text-[10px] text-muted block mb-1",children:"Icon"}),T.jsxs("select",{value:X.agentType||"",onChange:tt=>_t(X.id,{agentType:tt.target.value||void 0}),className:"input text-xs py-1 px-2 w-auto",children:[T.jsx("option",{value:"",children:"Terminal"}),T.jsx("option",{value:"claude",children:"Claude"}),T.jsx("option",{value:"codex",children:"Codex"})]})]})]},X.id))}),Ue?T.jsxs("div",{className:"mt-3 border border-border p-3 space-y-2",children:[T.jsx("div",{className:"text-xs text-secondary mb-2",children:"New Preset"}),T.jsx("input",{value:De,onChange:X=>et(X.target.value),className:"input text-xs py-1 px-2 w-full",placeholder:"Label"}),T.jsx("input",{value:ze,onChange:X=>Te(X.target.value),className:"input text-xs py-1 px-2 font-mono w-full",placeholder:"command --flags"}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsxs("select",{value:Me,onChange:X=>We(X.target.value),className:"input text-xs py-1 px-2 w-auto",children:[T.jsx("option",{value:"",children:"Terminal Icon"}),T.jsx("option",{value:"claude",children:"Claude Icon"}),T.jsx("option",{value:"codex",children:"Codex Icon"})]}),T.jsx("div",{className:"flex-1"}),T.jsx("button",{type:"button",onClick:()=>Ie(!1),className:"btn text-xs px-2 py-1",children:"Cancel"}),T.jsx("button",{type:"button",onClick:It,disabled:!De.trim()||!ze.trim(),className:"btn btn-primary text-xs px-2 py-1",children:"Add"})]})]}):T.jsx("button",{type:"button",onClick:()=>Ie(!0),disabled:!wn,className:"btn text-xs mt-3 w-full",children:wn?"+ Add Preset":`Max ${si} presets`})]}),T.jsxs("div",{className:"border-t border-border pt-4",children:[T.jsx("label",{className:"mb-2 block text-xs text-secondary",children:"Session List Order"}),T.jsxs("div",{className:"flex gap-2",children:[T.jsx("button",{type:"button",className:`btn flex-1 ${B==="created"?"btn-primary":""}`,onClick:()=>K("created"),children:"Created"}),T.jsx("button",{type:"button",className:`btn flex-1 ${B==="status"?"btn-primary":""}`,onClick:()=>K("status"),children:"Status"}),T.jsx("button",{type:"button",className:`btn flex-1 ${B==="manual"?"btn-primary":""}`,onClick:()=>K("manual"),children:"Manual"})]}),T.jsx("p",{className:"mt-1.5 text-[10px] text-muted",children:B==="status"?"Sessions auto-resort by status (waiting, working, unknown)":B==="manual"?"Drag sessions to reorder manually":"Sessions stay in creation order"})]}),B==="created"&&T.jsxs("div",{children:[T.jsx("label",{className:"mb-2 block text-xs text-secondary",children:"Sort Direction"}),T.jsxs("div",{className:"flex gap-2",children:[T.jsx("button",{type:"button",className:`btn flex-1 ${U==="desc"?"btn-primary":""}`,onClick:()=>te("desc"),children:"Newest First"}),T.jsx("button",{type:"button",className:`btn flex-1 ${U==="asc"?"btn-primary":""}`,onClick:()=>te("asc"),children:"Oldest First"})]})]}),T.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[T.jsx("label",{className:"mb-1 block text-xs text-secondary",children:"Session List Details"}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Project Name"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Show the project folder name under each session."})]}),T.jsx(Cn,{checked:Le,onCheckedChange:je})]}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Last User Message"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Show the most recent user input next to the project name."})]}),T.jsx(Cn,{checked:Fe,onCheckedChange:Pe})]}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Session ID Prefix"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Show first 5 characters of agent session IDs in the list."})]}),T.jsx(Cn,{checked:Oe,onCheckedChange:Ee})]}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Inactive Sessions Lookback"}),T.jsxs("div",{className:"text-[10px] text-muted",children:["Show inactive sessions from the last N hours (",Cu,"-",Eu,")."]})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("input",{type:"number",min:Cu,max:Eu,value:he,onChange:X=>{const tt=parseInt(X.target.value,10);tt>=Cu&&tt<=Eu&&ca(tt)},disabled:Re,className:"input text-xs py-1 px-2 w-16 text-center"}),T.jsx("span",{className:"text-xs text-muted",children:"hrs"})]})]})]}),T.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[T.jsx("label",{className:"mb-1 block text-xs text-secondary",children:"Notifications"}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{className:"flex-1",children:[T.jsx("div",{className:"text-sm text-primary",children:"Permission Sound"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Play a ping when any session needs permission."})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("button",{type:"button",onClick:()=>void pd(),className:"btn text-xs px-2 py-1",children:"Test"}),T.jsx(Cn,{checked:Ne,onCheckedChange:X=>{Ge(X),X&&fd()}})]})]}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{className:"flex-1",children:[T.jsx("div",{className:"text-sm text-primary",children:"Idle Sound"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Play a chime when a session finishes working."})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("button",{type:"button",onClick:()=>void md(),className:"btn text-xs px-2 py-1",children:"Test"}),T.jsx(Cn,{checked:Ae,onCheckedChange:X=>{G(X),X&&fd()}})]})]})]}),T.jsxs("div",{className:"border-t border-border pt-4",children:[T.jsx("label",{className:"mb-2 block text-xs text-secondary",children:"Terminal Rendering"}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"WebGL Acceleration"}),T.jsx("div",{className:"text-[10px] text-muted",children:"GPU rendering for better performance. Turn off if text looks fuzzy or flickering."})]}),T.jsx(Cn,{checked:Y,onCheckedChange:_e})]}),Y!==p&&T.jsx("p",{className:"mt-2 text-[10px] text-approval",children:"Terminal will reload when saved"}),T.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Mouse Mode"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Enable tmux mouse mode for trackpad/scroll wheel support."})]}),T.jsx(Cn,{checked:me,onCheckedChange:Ts,disabled:Se})]}),T.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Font Size"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Terminal text size in pixels (6-24)"})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("button",{type:"button",onClick:()=>re(Math.max(6,de-1)),className:"flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover",children:T.jsx("span",{className:"text-sm font-bold",children:"−"})}),T.jsx("span",{className:"text-sm text-secondary w-6 text-center",children:de}),T.jsx("button",{type:"button",onClick:()=>re(Math.min(24,de+1)),className:"flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover",children:T.jsx("span",{className:"text-sm font-bold",children:"+"})})]})]}),T.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Line Height"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Vertical spacing (1.0 = compact, 2.0 = spacious)"})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("input",{type:"range",min:"1.0",max:"2.0",step:"0.1",value:le,onChange:X=>ne(parseFloat(X.target.value)),className:"w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent"}),T.jsx("span",{className:"text-xs text-secondary w-8 text-right",children:le.toFixed(1)})]})]}),T.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Letter Spacing"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Horizontal spacing between characters in pixels"})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("input",{type:"range",min:"-3",max:"3",step:"1",value:fe,onChange:X=>ge(parseInt(X.target.value,10)),className:"w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent"}),T.jsxs("span",{className:"text-xs text-secondary w-8 text-right",children:[fe,"px"]})]})]}),T.jsxs("div",{className:"mt-4",children:[T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Font Family"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Terminal typeface"})]}),T.jsx("select",{value:se,onChange:X=>oe(X.target.value),className:"input text-xs py-1 px-2 w-auto",children:Rh.map(X=>T.jsx("option",{value:X.id,children:X.label},X.id))})]}),se==="custom"&&T.jsx("input",{value:ue,onChange:X=>ae(X.target.value),placeholder:'"Fira Code", monospace',className:"input text-xs mt-2 font-mono"})]}),T.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Dark Mode"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Switch between dark and light themes."})]}),T.jsx(Cn,{checked:q==="dark",onCheckedChange:X=>ee(X?"dark":"light")})]})]}),T.jsxs("div",{className:"border-t border-border pt-4",children:[T.jsx("label",{className:"mb-2 block text-xs text-secondary",children:"Keyboard Shortcut Modifier"}),T.jsx("div",{className:"grid grid-cols-5 gap-1",children:["auto","ctrl-option","ctrl-shift","cmd-option","cmd-shift"].map(X=>T.jsx("button",{type:"button",className:`btn text-xs px-2 ${ve===X?"btn-primary":""}`,onClick:()=>Ce(X),children:X==="auto"?"Auto":ii(X)},X))}),T.jsx("p",{className:"mt-1.5 text-[10px] text-muted",children:ve==="auto"?`Platform default: ${ii(ea("auto"))}`:`Shortcuts: ${ii(ve)}+[N/X/[/]]`})]})]})}),T.jsxs("div",{className:"flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated",children:[T.jsx("button",{type:"button",onClick:()=>t(),className:"btn",children:"Cancel"}),T.jsx("button",{type:"submit",className:"btn btn-primary",children:"Save"})]})]})})}const eA=[];function gp(e){E.useEffect(e,eA)}const vp=E.createContext(void 0);function _p(){const e=E.useContext(vp);if(!e)throw new Error(Yr(73));return e}var Ql=Symbol("NOT_FOUND");function tA(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function rA(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function nA(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(r=>typeof r=="function")){const r=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${t}[${r}]`)}}var Ov=e=>Array.isArray(e)?e:[e];function sA(e){const t=Array.isArray(e[0])?e[0]:e;return nA(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function iA(e,t){const r=[],{length:n}=e;for(let i=0;i<n;i++)r.push(e[i].apply(null,t));return r}function oA(e){let t;return{get(r){return t&&e(t.key,r)?t.value:Ql},put(r,n){t={key:r,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function aA(e,t){let r=[];function n(s){const o=r.findIndex(c=>t(s,c.key));if(o>-1){const c=r[o];return o>0&&(r.splice(o,1),r.unshift(c)),c.value}return Ql}function i(s,o){n(s)===Ql&&(r.unshift({key:s,value:o}),r.length>e&&r.pop())}function a(){return r}function l(){r=[]}return{get:n,put:i,getEntries:a,clear:l}}var lA=(e,t)=>e===t;function cA(e){return function(r,n){if(r===null||n===null||r.length!==n.length)return!1;const{length:i}=r;for(let a=0;a<i;a++)if(!e(r[a],n[a]))return!1;return!0}}function uA(e,t){const r=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:n=lA,maxSize:i=1,resultEqualityCheck:a}=r,l=cA(n);let s=0;const o=i<=1?oA(l):aA(i,l);function c(){let f=o.get(arguments);if(f===Ql){if(f=e.apply(null,arguments),s++,a){const p=o.getEntries().find(_=>a(_.value,f));p&&(f=p.value,s!==0&&s--)}o.put(arguments,f)}return f}return c.clearCache=()=>{o.clear(),c.resetResultsCount()},c.resultsCount=()=>s,c.resetResultsCount=()=>{s=0},c}var hA=class{constructor(e){this.value=e}deref(){return this.value}},dA=typeof WeakRef<"u"?WeakRef:hA,fA=0,Bv=1;function Ha(){return{s:fA,v:void 0,o:null,p:null}}function hS(e,t={}){let r=Ha();const{resultEqualityCheck:n}=t;let i,a=0;function l(){var u;let s=r;const{length:o}=arguments;for(let p=0,_=o;p<_;p++){const y=arguments[p];if(typeof y=="function"||typeof y=="object"&&y!==null){let v=s.o;v===null&&(s.o=v=new WeakMap);const h=v.get(y);h===void 0?(s=Ha(),v.set(y,s)):s=h}else{let v=s.p;v===null&&(s.p=v=new Map);const h=v.get(y);h===void 0?(s=Ha(),v.set(y,s)):s=h}}const c=s;let f;if(s.s===Bv)f=s.v;else if(f=e.apply(null,arguments),a++,n){const p=((u=i==null?void 0:i.deref)==null?void 0:u.call(i))??i;p!=null&&n(p,f)&&(f=p,a!==0&&a--),i=typeof f=="object"&&f!==null||typeof f=="function"?new dA(f):f}return c.s=Bv,c.v=f,f}return l.clearCache=()=>{r=Ha(),l.resetResultsCount()},l.resultsCount=()=>a,l.resetResultsCount=()=>{a=0},l}function dS(e,...t){const r=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,n=(...i)=>{let a=0,l=0,s,o={},c=i.pop();typeof c=="object"&&(o=c,c=i.pop()),tA(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const f={...r,...o},{memoize:u,memoizeOptions:p=[],argsMemoize:_=hS,argsMemoizeOptions:y=[]}=f,v=Ov(p),h=Ov(y),m=sA(i),d=u(function(){return a++,c.apply(null,arguments)},...v),g=_(function(){l++;const b=iA(m,arguments);return s=d.apply(null,b),s},...h);return Object.assign(g,{resultFunc:c,memoizedResultFunc:d,dependencies:m,dependencyRecomputations:()=>l,resetDependencyRecomputations:()=>{l=0},lastResult:()=>s,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:u,argsMemoize:_})};return Object.assign(n,{withTypes:()=>n}),n}var pA=dS(hS),mA=Object.assign((e,t=pA)=>{rA(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const r=Object.keys(e),n=r.map(a=>e[a]);return t(n,(...a)=>a.reduce((l,s,o)=>(l[r[o]]=s,l),{}))},{withTypes:()=>mA});const gA=dS({memoize:uA,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),Tr=(e,t,r,n,i,a,...l)=>{if(l.length>0)throw new Error(Yr(1));let s;if(e&&t)s=(o,c,f,u)=>{const p=e(o,c,f,u);return t(p,c,f,u)};else if(e)s=e;else throw new Error("Missing arguments");return s},vA=(...e)=>{const t=new WeakMap;let r=1;const n=e[e.length-1],i=e.length-1||1,a=n.length-i;if(a>3)throw new Error(Yr(2));return(s,o,c,f)=>{let u=s.__cacheKey__;u||(u={id:r},s.__cacheKey__=u,r+=1);let p=t.get(u);if(!p){let _=e;const y=[void 0,void 0,void 0];switch(a){case 0:break;case 1:{_=[...e.slice(0,-1),()=>y[0],n];break}case 2:{_=[...e.slice(0,-1),()=>y[0],()=>y[1],n];break}case 3:{_=[...e.slice(0,-1),()=>y[0],()=>y[1],()=>y[2],n];break}default:throw new Error(Yr(2))}p=gA(..._),p.selectorArgs=y,t.set(u,p)}switch(p.selectorArgs[0]=o,p.selectorArgs[1]=c,p.selectorArgs[2]=f,a){case 0:return p(s);case 1:return p(s,o);case 2:return p(s,o,c);case 3:return p(s,o,c,f);default:throw new Error("unreachable")}}};var fS={exports:{}},pS={};/**
300
+ `,onClick:()=>{bv(),o(J.id)},children:Se+1},J.id)})})]}),T.jsxs("div",{className:"relative flex-1",children:[T.jsx("div",{ref:fe,className:"absolute inset-0"}),!e&&T.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-muted",children:"Select a session to view terminal"}),e&&le&&T.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."}),O&&e&&!F&&T.jsxs("button",{onClick:ue,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:[T.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:T.jsx("path",{d:"M12 5v14M5 12l7 7 7-7"})}),T.jsx("span",{className:"text-sm font-medium",children:"Jump to bottom"})]})]}),e&&T.jsx(aM,{onSendKey:qe,disabled:n!=="connected"||le,sessions:t.map(J=>({id:J.id,name:J.name,status:J.status})),currentSessionId:e.id,onSelectSession:o,hideSessionSwitcher:!0,onRefocus:Ae,isKeyboardVisible:me,onEnterTextMode:G}),(D||M)&&T.jsx(lM,{isOpen:j,onClose:()=>W(!1),sessions:t,inactiveSessions:r,selectedSessionId:(e==null?void 0:e.id)??null,onSelect:o,onRename:u,onResume:p,onSetPinned:_,onNewSession:c,loading:v,error:h}),I&&e&&T.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:T.jsxs("div",{className:"mx-4 w-full max-w-sm rounded-lg border border-border bg-elevated p-4 shadow-xl",children:[T.jsx("h3",{className:"text-base font-medium text-primary mb-2 text-balance",children:"Kill Session"}),T.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.']}),T.jsxs("div",{className:"flex justify-end gap-2",children:[T.jsx("button",{onClick:()=>R(!1),className:"btn py-1.5 px-3 text-sm",children:"Cancel"}),T.jsx("button",{ref:Y,onClick:je,className:"btn btn-danger py-1.5 px-3 text-sm",children:"Kill Session"})]})]})})]})}function pM({onSelect:e,onCancel:t,initialPath:r}){const[n,i]=E.useState(r||"~"),[a,l]=E.useState(null),[s,o]=E.useState(null),[c,f]=E.useState(!0),[u,p]=E.useState(-1),_=E.useRef(null),y=pe(g=>g.recentPaths),v=E.useCallback(async g=>{var x;(x=_.current)==null||x.abort();const w=new AbortController;_.current=w;const{signal:b}=w;f(!0),o(null),l(null),p(-1),i(g);try{const C=await fetch(`/api/directories?path=${encodeURIComponent(g)}`,{signal:b});if(!C.ok){const k=await C.json();throw new Error(k.message||"Failed to load directory")}const S=await C.json();if(_.current!==w)return;l(S),i(S.path)}catch(C){if(_.current!==w)return;const S=C;(S==null?void 0:S.name)!=="AbortError"&&o((S==null?void 0:S.message)||"Failed to load directory")}finally{_.current===w&&f(!1)}},[]);E.useEffect(()=>(v(r||"~"),()=>{var g;(g=_.current)==null||g.abort()}),[v,r]);const h=(a==null?void 0:a.directories)??[],m=(a==null?void 0:a.path)||n,d=a==null?void 0:a.parent;return E.useEffect(()=>{const g=w=>{if(w.key==="Escape"){w.preventDefault(),t();return}if(!c){if(w.key==="ArrowDown"){w.preventDefault(),p(b=>h.length===0?-1:b<0?0:Math.min(b+1,h.length-1));return}if(w.key==="ArrowUp"){w.preventDefault(),p(b=>h.length===0?-1:b<0?h.length-1:Math.max(b-1,0));return}if(w.key==="Enter"){w.preventDefault();const b=h[u];b?v(b.path):m&&e(m);return}w.key==="Backspace"&&d&&(w.preventDefault(),v(d))}};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[h,m,v,u,c,t,e,d]),T.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:g=>{g.target===g.currentTarget&&t()},"data-testid":"directory-browser",children:T.jsxs("div",{className:"w-full max-w-lg border border-border bg-elevated p-4",children:[T.jsxs("div",{className:"flex items-center gap-3 border-b border-border pb-2",children:[T.jsx("button",{type:"button",className:"btn",onClick:()=>{d&&v(d)},disabled:!d||c,children:"Up"}),T.jsx("div",{className:"min-w-0 flex-1 truncate text-xs font-mono text-secondary",title:m,"data-testid":"directory-current-path",children:m})]}),T.jsx("div",{className:"mt-3 max-h-60 overflow-y-auto border border-border bg-surface",children:c?T.jsx("div",{className:"px-3 py-4 text-xs text-muted","data-testid":"directory-loading",children:"Loading directories..."}):s?T.jsxs("div",{className:"px-3 py-4 text-xs","data-testid":"directory-error",children:[T.jsx("p",{className:"text-danger",children:s}),T.jsx("button",{type:"button",className:"btn mt-3",onClick:()=>v(n),children:"Retry"})]}):h.length===0?T.jsx("div",{className:"px-3 py-4 text-xs text-muted","data-testid":"directory-empty",children:"No subdirectories"}):T.jsx("div",{className:"py-1",children:h.map((g,w)=>T.jsxs("button",{type:"button",onClick:()=>v(g.path),onMouseEnter:()=>p(w),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-xs ${w===u?"bg-hover text-primary":"text-secondary"}`,"data-testid":"directory-entry","data-entry-name":g.name,"data-entry-path":g.path,children:[T.jsx(EC,{width:14,height:14,className:"shrink-0 text-muted","aria-hidden":"true"}),T.jsx("span",{className:"truncate",children:g.name})]},g.path))})}),a!=null&&a.truncated?T.jsx("p",{className:"mt-2 text-[10px] text-muted",children:"Showing first 200 directories."}):null,T.jsxs("div",{className:"mt-4 border-t border-border pt-3",children:[T.jsx("div",{className:"text-[10px] uppercase tracking-wider text-secondary",children:"Recent"}),y.length===0?T.jsx("p",{className:"mt-2 text-xs text-muted",children:"No recent paths yet."}):T.jsx("div",{className:"mt-2 space-y-1",children:y.map(g=>T.jsx("button",{type:"button",className:"block w-full truncate text-left text-xs text-secondary hover:text-primary",onClick:()=>v(g),title:g,"data-testid":"directory-recent","data-recent-path":g,children:g},g))})]}),T.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[T.jsx("button",{type:"button",onClick:t,className:"btn",children:"Cancel"}),T.jsx("button",{type:"button",onClick:()=>{m&&e(m)},className:"btn btn-primary",disabled:c||!m,children:"Select"})]})]})})}function mM({isOpen:e,onClose:t,onCreate:r,defaultProjectDir:n,commandPresets:i,defaultPresetId:a,lastProjectPath:l,activeProjectPath:s,remoteHosts:o=[],remoteAllowControl:c=!1,initialHost:f,initialPath:u,initialCommand:p}){const[_,y]=E.useState(""),[v,h]=E.useState(""),[m,d]=E.useState(null),[g,w]=E.useState(""),[b,x]=E.useState(!1),[C,S]=E.useState(""),k=E.useRef(null),L=E.useRef(null),A=E.useRef(null),M=c&&o.length>0;if(E.useEffect(()=>{if(!e){y(""),h(""),d(null),w(""),x(!1),S(f??""),setTimeout(()=>{if(typeof document>"u"||typeof document.querySelector!="function")return;const W=document.querySelector(".xterm-helper-textarea");W&&(W.removeAttribute("disabled"),W.focus())},300);return}if(typeof document<"u"&&typeof document.querySelector=="function"){const W=document.querySelector(".xterm-helper-textarea");W&&typeof W.setAttribute=="function"&&(typeof W.blur=="function"&&W.blur(),W.setAttribute("disabled","true"))}const N=(u==null?void 0:u.trim())||(s==null?void 0:s.trim())||l||n||"";y(N),h(""),S(f??"");const j=p==null?void 0:p.trim();if(j){const W=i.find(V=>Hi(V)===j);W?(d(W.id),w(Hi(W))):(d(null),w(j))}else{const W=i.find(V=>V.id===a);W?(d(a),w(Hi(W))):i.length>0?(d(i[0].id),w(Hi(i[0]))):(d(null),w(""))}setTimeout(()=>{var W;if((W=A.current)==null||W.focus(),L.current){const V=L.current;V.scrollLeft=V.scrollWidth}},50)},[s,i,a,n,e,l,f,u,p]),E.useEffect(()=>{if(!e||typeof window>"u"||typeof window.addEventListener!="function")return;const N=()=>k.current?Array.from(k.current.querySelectorAll('input:not([disabled]), select:not([disabled]), button:not([disabled]):not([tabindex="-1"]), [tabindex="0"]')):[],j=W=>{var V,Z;if(!b){if(W.key==="Escape"){typeof W.stopPropagation=="function"&&W.stopPropagation(),t();return}if(W.key==="Enter"){const Q=document.activeElement;if(!Q||Q.tagName==="INPUT"||Q.closest('[data-testid="host-select"]')||!Q.closest('[data-testid="command-select"]'))return;W.preventDefault(),typeof W.stopPropagation=="function"&&W.stopPropagation(),(V=k.current)==null||V.requestSubmit();return}if(W.key==="Tab"){W.preventDefault(),typeof W.stopPropagation=="function"&&W.stopPropagation();const Q=N();if(Q.length===0)return;const $=document.activeElement,B=Q.indexOf($);let K;B===-1?K=W.shiftKey?Q.length-1:0:W.shiftKey?K=B<=0?Q.length-1:B-1:K=B>=Q.length-1?0:B+1,(Z=Q[K])==null||Z.focus()}}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[e,t,b]),!e)return null;const D=N=>{const j=i.find(W=>W.id===N);j&&(d(N),w(Hi(j)))},O=()=>{d(null),w("")},z=m===null,F=C!=="",H=N=>{N.preventDefault();const j=_.trim();if(!j)return;const W=g.trim();r(j,v.trim()||void 0,W||void 0,F?C:void 0),t()},I=[...i.map(N=>({id:N.id,label:N.label,isCustom:!1,agentType:N.agentType,command:N.command})),{id:"custom",label:"Custom",isCustom:!0,agentType:void 0,command:void 0}],R=[{id:"",label:"Local",ok:!0,error:void 0},...o.map(N=>({id:N.host,label:N.host,ok:N.ok,error:N.error}))],P=_.trim()||"~";return T.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:N=>{N.target===N.currentTarget&&t()},children:[T.jsxs("form",{ref:k,onSubmit:H,className:"w-full max-w-md border border-border bg-elevated p-6",children:[T.jsx("h2",{id:"new-session-title",className:"text-sm font-semibold uppercase tracking-wider text-primary text-balance",children:"New Session"}),T.jsxs("div",{className:"mt-4 space-y-4",children:[M&&T.jsxs("div",{children:[T.jsx("label",{className:"mb-1.5 block text-xs text-secondary",children:"Host"}),T.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Host","data-testid":"host-select",children:R.map((N,j)=>{const W=C===N.id,V=!N.ok&&!W;return T.jsx("button",{type:"button",role:"radio","aria-checked":W,"aria-label":N.label,title:N.ok?void 0:N.error||"Unreachable",tabIndex:W?0:-1,onClick:()=>S(N.id),onKeyDown:Z=>{var U;let Q=j;if(Z.key==="ArrowRight"||Z.key==="ArrowDown")Z.preventDefault(),Q=(j+1)%R.length;else if(Z.key==="ArrowLeft"||Z.key==="ArrowUp")Z.preventDefault(),Q=(j-1+R.length)%R.length;else return;const $=R[Q];S($.id);const B=Z.currentTarget.parentElement,K=B==null?void 0:B.querySelectorAll('[role="radio"]');(U=K==null?void 0:K[Q])==null||U.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${W?"btn-primary":""} ${V?"opacity-60":""}`,children:N.label},N.id||"local")})})]}),T.jsxs("div",{children:[T.jsx("label",{className:"mb-1.5 block text-xs text-secondary",children:"Command"}),T.jsx("div",{className:"flex flex-wrap gap-2",role:"radiogroup","aria-label":"Command preset","data-testid":"command-select",children:I.map((N,j)=>{const W=N.isCustom?z:m===N.id;return T.jsxs("button",{ref:W?A:void 0,type:"button",role:"radio","aria-checked":W,tabIndex:W?0:-1,onClick:()=>{N.isCustom?O():D(N.id)},onKeyDown:V=>{var K;let Z=j;if(V.key==="ArrowRight"||V.key==="ArrowDown")V.preventDefault(),Z=(j+1)%I.length;else if(V.key==="ArrowLeft"||V.key==="ArrowUp")V.preventDefault(),Z=(j-1+I.length)%I.length;else return;const Q=I[Z];Q.isCustom?O():D(Q.id);const $=V.currentTarget.parentElement,B=$==null?void 0:$.querySelectorAll('[role="radio"]');(K=B==null?void 0:B[Z])==null||K.focus()},className:`btn text-xs focus:outline-none focus:ring-2 focus:ring-primary ${W?"btn-primary":""}`,children:[T.jsx(Cc,{agentType:N.agentType,command:N.command,className:"inline-block h-3.5 w-3.5 shrink-0"}),N.label]},N.id)})}),T.jsx("input",{value:g,onChange:N=>w(N.target.value),placeholder:"Enter command...",className:"input mt-2 font-mono text-xs"})]}),T.jsxs("div",{children:[T.jsx("label",{className:"mb-1.5 block text-xs text-secondary",children:"Project Path"}),T.jsxs("div",{className:"flex gap-2",children:[T.jsx("input",{ref:L,value:_,onChange:N=>y(N.target.value),placeholder:F?"/home/user/project":s||l||n||"/Users/you/code/my-project",className:"input flex-1 text-sm"}),!F&&T.jsx("button",{type:"button",className:"btn",onClick:()=>x(!0),children:"Browse"})]})]}),T.jsxs("div",{children:[T.jsx("label",{className:"mb-1.5 block text-xs text-secondary",children:"Display Name"}),T.jsx("input",{value:v,onChange:N=>h(N.target.value),placeholder:"auto-generated",className:"input text-sm placeholder:italic"})]})]}),T.jsxs("div",{className:"mt-6 flex justify-end gap-2",children:[T.jsx("button",{type:"button",onClick:t,className:"btn",children:"Cancel"}),T.jsx("button",{type:"submit",className:"btn btn-primary",children:"Create"})]})]}),b&&!F&&T.jsx(pM,{initialPath:P,onSelect:N=>{y(N),x(!1)},onCancel:()=>x(!1)})]})}const Cu=1,Eu=168;function gM({controlled:e,default:t,name:r,state:n="value"}){const{current:i}=E.useRef(e!==void 0),[a,l]=E.useState(t),s=i?e:a,o=E.useCallback(c=>{i||l(c)},[]);return[s,o]}const Cv={};function ks(e,t){const r=E.useRef(Cv);return r.current===Cv&&(r.current=e(t)),r}const ku=Jv[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],vM=ku&&ku!==E.useLayoutEffect?ku:e=>e();function Xr(e){const t=ks(_M).current;return t.next=e,vM(t.effect),t.trampoline}function _M(){const e={next:void 0,callback:yM,trampoline:(...t)=>{var r;return(r=e.callback)==null?void 0:r.call(e,...t)},effect:()=>{e.callback=e.next}};return e}function yM(){}function ld(e,t,r,n){const i=ks(Fw).current;return SM(i,e,t,r,n)&&Hw(i,[e,t,r,n]),i.callback}function wM(e){const t=ks(Fw).current;return xM(t,e)&&Hw(t,e),t.callback}function Fw(){return{callback:null,cleanup:null,refs:[]}}function SM(e,t,r,n,i){return e.refs[0]!==t||e.refs[1]!==r||e.refs[2]!==n||e.refs[3]!==i}function xM(e,t){return e.refs.length!==t.length||e.refs.some((r,n)=>r!==t[n])}function Hw(e,t){if(e.refs=t,t.every(r=>r==null)){e.callback=null;return}e.callback=r=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),r!=null){const n=Array(t.length).fill(null);for(let i=0;i<t.length;i+=1){const a=t[i];if(a!=null)switch(typeof a){case"function":{const l=a(r);typeof l=="function"&&(n[i]=l);break}case"object":{a.current=r;break}}}e.cleanup=()=>{for(let i=0;i<t.length;i+=1){const a=t[i];if(a!=null)switch(typeof a){case"function":{const l=n[i];typeof l=="function"?l():a(null);break}case"object":{a.current=null;break}}}}}}}const bM=()=>{},qt=typeof document<"u"?E.useLayoutEffect:bM,$w={clipPath:"inset(50%)",overflow:"hidden",whiteSpace:"nowrap",border:0,padding:0,width:1,height:1,margin:-1},ap={...$w,position:"fixed",top:0,left:0},CM={...$w,position:"absolute"};function ur(){}const zr=Object.freeze({});function Yr(e,...t){const r=new URL("https://base-ui.com/production-error");return r.searchParams.set("code",e.toString()),t.forEach(n=>r.searchParams.append("args[]",n)),`Base UI error #${e}; visit ${r} for the full message.`}const EM=parseInt(E.version,10);function lp(e){return EM>=e}function Ev(e){if(!E.isValidElement(e))return null;const t=e,r=t.props;return(lp(19)?r==null?void 0:r.ref:t.ref)??null}function cd(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function kM(e,t){const r={};for(const n in e){const i=e[n];if(t!=null&&t.hasOwnProperty(n)){const a=t[n](i);a!=null&&Object.assign(r,a);continue}i===!0?r[`data-${n.toLowerCase()}`]="":i&&(r[`data-${n.toLowerCase()}`]=i.toString())}return r}function LM(e,t){return typeof e=="function"?e(t):e}function TM(e,t){return typeof e=="function"?e(t):e}const _o={};function cp(e,t,r,n,i){let a={...ud(e,_o)};return t&&(a=ul(a,t)),r&&(a=ul(a,r)),n&&(a=ul(a,n)),a}function RM(e){if(e.length===0)return _o;if(e.length===1)return ud(e[0],_o);let t={...ud(e[0],_o)};for(let r=1;r<e.length;r+=1)t=ul(t,e[r]);return t}function ul(e,t){return zw(t)?t(e):DM(e,t)}function DM(e,t){if(!t)return e;for(const r in t){const n=t[r];switch(r){case"style":{e[r]=cd(e.style,n);break}case"className":{e[r]=Uw(e.className,n);break}default:MM(r,n)?e[r]=AM(e[r],n):e[r]=n}}return e}function MM(e,t){const r=e.charCodeAt(0),n=e.charCodeAt(1),i=e.charCodeAt(2);return r===111&&n===110&&i>=65&&i<=90&&(typeof t=="function"||typeof t>"u")}function zw(e){return typeof e=="function"}function ud(e,t){return zw(e)?e(t):e??_o}function AM(e,t){return t?e?r=>{if(PM(r)){const i=r;hd(i);const a=t(i);return i.baseUIHandlerPrevented||e==null||e(i),a}const n=t(r);return e==null||e(r),n}:t:e}function hd(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function Uw(e,t){return t?e?t+" "+e:t:e}function PM(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}function Ls(e,t,r={}){const n=t.render,i=IM(t,r);if(r.enabled===!1)return null;const a=r.state??zr;return BM(e,n,i,a)}function IM(e,t={}){const{className:r,style:n,render:i}=e,{state:a=zr,ref:l,props:s,stateAttributesMapping:o,enabled:c=!0}=t,f=c?LM(r,a):void 0,u=c?TM(n,a):void 0,p=c?kM(a,o):zr,_=c?cd(p,Array.isArray(s)?RM(s):s)??zr:zr;return typeof document<"u"&&(c?Array.isArray(l)?_.ref=wM([_.ref,Ev(i),...l]):_.ref=ld(_.ref,Ev(i),l):ld(null,null)),c?(f!==void 0&&(_.className=Uw(_.className,f)),u!==void 0&&(_.style=cd(_.style,u)),_):zr}const OM=Symbol.for("react.lazy");function BM(e,t,r,n){if(t){if(typeof t=="function")return t(r,n);const i=cp(r,t.props);i.ref=r.ref;let a=t;return(a==null?void 0:a.$$typeof)===OM&&(a=E.Children.toArray(t)[0]),E.cloneElement(a,i)}if(e&&typeof e=="string")return NM(e,r);throw new Error(Yr(8))}function NM(e,t){return e==="button"?E.createElement("button",{type:"button",...t,key:t.key}):e==="img"?E.createElement("img",{alt:"",...t,key:t.key}):E.createElement(e,t)}const jM={...Jv};let kv=0;function FM(e,t="mui"){const[r,n]=E.useState(e),i=e||r;return E.useEffect(()=>{r==null&&(kv+=1,n(`${t}-${kv}`))},[r,t]),i}const Lv=jM.useId;function up(e,t){if(Lv!==void 0){const r=Lv();return e??(t?`${t}-${r}`:r)}return FM(e,t)}function Ww(e){return up(e,"base-ui")}function hp(){return typeof window<"u"}function Ko(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function HM(e){return hp()?e instanceof Element||e instanceof Ko(e).Element:!1}function $M(e){return hp()?e instanceof HTMLElement||e instanceof Ko(e).HTMLElement:!1}function zM(e){return!hp()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ko(e).ShadowRoot}const UM=E.createContext(void 0);function WM(e=!1){const t=E.useContext(UM);if(t===void 0&&!e)throw new Error(Yr(16));return t}function VM(e){const{focusableWhenDisabled:t,disabled:r,composite:n=!1,tabIndex:i=0,isNativeButton:a}=e,l=n&&t!==!1,s=n&&t===!1;return{props:E.useMemo(()=>{const c={onKeyDown(f){r&&t&&f.key!=="Tab"&&f.preventDefault()}};return n||(c.tabIndex=i,!a&&r&&(c.tabIndex=t?i:-1)),(a&&(t||l)||!a&&r)&&(c["aria-disabled"]=r),a&&(!t||s)&&(c.disabled=r),c},[n,r,t,l,s,a,i])}}function Vw(e={}){const{disabled:t=!1,focusableWhenDisabled:r,tabIndex:n=0,native:i=!0}=e,a=E.useRef(null),l=WM(!0)!==void 0,s=Xr(()=>{const p=a.current;return!!((p==null?void 0:p.tagName)==="A"&&(p!=null&&p.href))}),{props:o}=VM({focusableWhenDisabled:r,disabled:t,composite:l,tabIndex:n,isNativeButton:i}),c=E.useCallback(()=>{const p=a.current;KM(p)&&l&&t&&o.disabled===void 0&&p.disabled&&(p.disabled=!1)},[t,o.disabled,l]);qt(c,[c]);const f=E.useCallback((p={})=>{const{onClick:_,onMouseDown:y,onKeyUp:v,onKeyDown:h,onPointerDown:m,...d}=p;return cp({type:i?"button":void 0,onClick(w){if(t){w.preventDefault();return}_==null||_(w)},onMouseDown(w){t||y==null||y(w)},onKeyDown(w){if(t||(hd(w),h==null||h(w)),w.baseUIHandlerPrevented)return;const b=w.target===w.currentTarget&&!i&&!s()&&!t,x=w.key==="Enter",C=w.key===" ";b&&((C||x)&&w.preventDefault(),x&&(_==null||_(w)))},onKeyUp(w){t||(hd(w),v==null||v(w)),!w.baseUIHandlerPrevented&&w.target===w.currentTarget&&!i&&!t&&w.key===" "&&(_==null||_(w))},onPointerDown(w){if(t){w.preventDefault();return}m==null||m(w)}},i?void 0:{role:"button"},o,d)},[t,o,i,s]),u=Xr(p=>{a.current=p,c()});return{getButtonProps:f,buttonRef:u}}function KM(e){return $M(e)&&e.tagName==="BUTTON"}const Kw=E.createContext(void 0);function GM(){const e=E.useContext(Kw);if(e===void 0)throw new Error(Yr(63));return e}let Tv=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}({});const qM={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},XM={valid(e){return e===null?null:e?{[Tv.valid]:""}:{[Tv.invalid]:""}}};let Rv=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}({});const Gw={...XM,checked(e){return e?{[Rv.checked]:""}:{[Rv.unchecked]:""}}};function YM(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}const JM=E.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:ur,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function qw(){return E.useContext(JM)}const QM=E.createContext({invalid:void 0,name:void 0,validityData:{state:qM,errors:[],error:"",value:"",initialValue:null},setValidityData:ur,disabled:void 0,touched:!1,setTouched:ur,dirty:!1,setDirty:ur,filled:!1,setFilled:ur,focused:!1,setFocused:ur,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=zr)=>e,getInputValidationProps:(e=zr)=>e,inputRef:{current:null},commit:async()=>{}}});function dp(e=!0){const t=E.useContext(QM);if(t.setValidityData===ur&&!e)throw new Error(Yr(28));return t}function ZM(e){const{enabled:t=!0,value:r,id:n,name:i,controlRef:a,commit:l}=e,{formRef:s}=qw(),{invalid:o,markedDirtyRef:c,validityData:f,setValidityData:u}=dp(),p=Xr(e.getValue);qt(()=>{if(!t)return;let _=r;_===void 0&&(_=p()),f.initialValue===null&&_!==null&&u(y=>({...y,initialValue:_}))},[t,u,r,f.initialValue,p]),qt(()=>{!t||!n||s.current.fields.set(n,{getValue:p,name:i,controlRef:a,validityData:YM(f,o),validate(_=!0){let y=r;y===void 0&&(y=p()),c.current=!0,_?hn.flushSync(()=>l(y)):l(y)}})},[l,a,t,s,p,n,o,c,i,f,r]),qt(()=>{const _=s.current.fields;return()=>{n&&_.delete(n)}},[s,n])}const e3=E.createContext({controlId:void 0,registerControlId:ur,labelId:void 0,setLabelId:ur,messageIds:[],setMessageIds:ur,getDescriptionProps:e=>e});function Xw(){return E.useContext(e3)}function t3(e={}){const{id:t,implicit:r=!1,controlRef:n}=e,{controlId:i,registerControlId:a}=Xw(),l=Ww(t),s=r?i:void 0,o=ks(()=>Symbol("labelable-control")),c=E.useRef(!1),f=E.useRef(t!=null),u=Xr(()=>{!c.current||a===ur||(c.current=!1,a(o.current,void 0))});return qt(()=>{if(a===ur)return;let p;if(r){const _=n==null?void 0:n.current;HM(_)&&_.closest("label")!=null?p=t??null:p=s??l}else if(t!=null)f.current=!0,p=t;else if(f.current)p=l;else{u();return}if(p===void 0){u();return}c.current=!0,a(o.current,p)},[t,n,s,a,r,l,o,u]),E.useEffect(()=>u,[u]),i??l}const r3="none";function n3(e,t,r,n){let i=!1,a=!1;const l=zr;return{reason:e,event:t??new Event("base-ui"),cancel(){i=!0},allowPropagation(){a=!0},get isCanceled(){return i},get isPropagationAllowed(){return a},trigger:r,...l}}function s3(e,t){const r=E.useRef(e),n=Xr(t);qt(()=>{r.current!==e&&n(r.current)},[e,n]),qt(()=>{r.current=e},[e])}const i3=E.forwardRef(function(t,r){const{checked:n,className:i,defaultChecked:a,id:l,inputRef:s,name:o,nativeButton:c=!1,onCheckedChange:f,readOnly:u=!1,required:p=!1,disabled:_=!1,render:y,uncheckedValue:v,value:h,...m}=t,{clearErrors:d}=qw(),{state:g,setTouched:w,setDirty:b,validityData:x,setFilled:C,setFocused:S,shouldValidateOnChange:k,validationMode:L,disabled:A,name:M,validation:D}=dp(),{labelId:O}=Xw(),z=A||_,F=M??o,H=Xr(f),I=E.useRef(null),R=ld(I,s,D.inputRef),P=E.useRef(null),N=Ww(),j=t3({id:l,implicit:!1,controlRef:P}),W=c?void 0:j,[V,Z]=gM({controlled:n,default:!!a,name:"Switch",state:"checked"});ZM({id:N,commit:D.commit,value:V,controlRef:P,name:F,getValue:()=>V}),qt(()=>{I.current&&C(I.current.checked)},[I,C]),s3(V,()=>{d(F),b(V!==x.initialValue),C(V),k()?D.commit(V):D.commit(V,!0)});const{getButtonProps:Q,buttonRef:$}=Vw({disabled:z,native:c}),B={id:c?j:N,role:"switch","aria-checked":V,"aria-readonly":u||void 0,"aria-required":p||void 0,"aria-labelledby":O,onFocus(){z||S(!0)},onBlur(){const Y=I.current;!Y||z||(w(!0),S(!1),L==="onBlur"&&D.commit(Y.checked))},onClick(Y){var _e;u||z||(Y.preventDefault(),(_e=I.current)==null||_e.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:Y.shiftKey,ctrlKey:Y.ctrlKey,altKey:Y.altKey,metaKey:Y.metaKey})))}},K=E.useMemo(()=>cp({checked:V,disabled:z,id:W,name:F,required:p,style:F?CM:ap,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:R,onChange(Y){if(Y.nativeEvent.defaultPrevented)return;const _e=Y.target.checked,de=n3(r3,Y.nativeEvent);H==null||H(_e,de),!de.isCanceled&&Z(_e)},onFocus(){var Y;(Y=P.current)==null||Y.focus()}},D.getInputValidationProps,h!==void 0?{value:h}:zr),[V,z,R,W,F,H,p,Z,D,h]),U=E.useMemo(()=>({...g,checked:V,disabled:z,readOnly:u,required:p}),[g,V,z,u,p]),te=Ls("span",t,{state:U,ref:[r,P,$],props:[B,D.getValidationProps,m,Q],stateAttributesMapping:Gw});return T.jsxs(Kw.Provider,{value:U,children:[te,!V&&F&&v!==void 0&&T.jsx("input",{type:"hidden",name:F,value:v}),T.jsx("input",{...K})]})}),o3=E.forwardRef(function(t,r){const{render:n,className:i,...a}=t,{state:l}=dp(),s=GM(),o={...l,...s};return Ls("span",t,{state:o,ref:r,stateAttributesMapping:Gw,props:a})});function Yw(e){var t,r,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(r=Yw(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function a3(){for(var e,t,r=0,n="",i=arguments.length;r<i;r++)(e=arguments[r])&&(t=Yw(e))&&(n&&(n+=" "),n+=t);return n}const l3=(e,t)=>{const r=new Array(e.length+t.length);for(let n=0;n<e.length;n++)r[n]=e[n];for(let n=0;n<t.length;n++)r[e.length+n]=t[n];return r},c3=(e,t)=>({classGroupId:e,validator:t}),Jw=(e=new Map,t=null,r)=>({nextPart:e,validators:t,classGroupId:r}),Xl="-",Dv=[],u3="arbitrary..",h3=e=>{const t=f3(e),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:l=>{if(l.startsWith("[")&&l.endsWith("]"))return d3(l);const s=l.split(Xl),o=s[0]===""&&s.length>1?1:0;return Qw(s,o,t)},getConflictingClassGroupIds:(l,s)=>{if(s){const o=n[l],c=r[l];return o?c?l3(c,o):o:c||Dv}return r[l]||Dv}}},Qw=(e,t,r)=>{if(e.length-t===0)return r.classGroupId;const i=e[t],a=r.nextPart.get(i);if(a){const c=Qw(e,t+1,a);if(c)return c}const l=r.validators;if(l===null)return;const s=t===0?e.join(Xl):e.slice(t).join(Xl),o=l.length;for(let c=0;c<o;c++){const f=l[c];if(f.validator(s))return f.classGroupId}},d3=e=>e.slice(1,-1).indexOf(":")===-1?void 0:(()=>{const t=e.slice(1,-1),r=t.indexOf(":"),n=t.slice(0,r);return n?u3+n:void 0})(),f3=e=>{const{theme:t,classGroups:r}=e;return p3(r,t)},p3=(e,t)=>{const r=Jw();for(const n in e){const i=e[n];fp(i,r,n,t)}return r},fp=(e,t,r,n)=>{const i=e.length;for(let a=0;a<i;a++){const l=e[a];m3(l,t,r,n)}},m3=(e,t,r,n)=>{if(typeof e=="string"){g3(e,t,r);return}if(typeof e=="function"){v3(e,t,r,n);return}_3(e,t,r,n)},g3=(e,t,r)=>{const n=e===""?t:Zw(t,e);n.classGroupId=r},v3=(e,t,r,n)=>{if(y3(e)){fp(e(n),t,r,n);return}t.validators===null&&(t.validators=[]),t.validators.push(c3(r,e))},_3=(e,t,r,n)=>{const i=Object.entries(e),a=i.length;for(let l=0;l<a;l++){const[s,o]=i[l];fp(o,Zw(t,s),r,n)}},Zw=(e,t)=>{let r=e;const n=t.split(Xl),i=n.length;for(let a=0;a<i;a++){const l=n[a];let s=r.nextPart.get(l);s||(s=Jw(),r.nextPart.set(l,s)),r=s}return r},y3=e=>"isThemeGetter"in e&&e.isThemeGetter===!0,w3=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,r=Object.create(null),n=Object.create(null);const i=(a,l)=>{r[a]=l,t++,t>e&&(t=0,n=r,r=Object.create(null))};return{get(a){let l=r[a];if(l!==void 0)return l;if((l=n[a])!==void 0)return i(a,l),l},set(a,l){a in r?r[a]=l:i(a,l)}}},dd="!",Mv=":",S3=[],Av=(e,t,r,n,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:r,maybePostfixModifierPosition:n,isExternal:i}),x3=e=>{const{prefix:t,experimentalParseClassName:r}=e;let n=i=>{const a=[];let l=0,s=0,o=0,c;const f=i.length;for(let v=0;v<f;v++){const h=i[v];if(l===0&&s===0){if(h===Mv){a.push(i.slice(o,v)),o=v+1;continue}if(h==="/"){c=v;continue}}h==="["?l++:h==="]"?l--:h==="("?s++:h===")"&&s--}const u=a.length===0?i:i.slice(o);let p=u,_=!1;u.endsWith(dd)?(p=u.slice(0,-1),_=!0):u.startsWith(dd)&&(p=u.slice(1),_=!0);const y=c&&c>o?c-o:void 0;return Av(a,_,p,y)};if(t){const i=t+Mv,a=n;n=l=>l.startsWith(i)?a(l.slice(i.length)):Av(S3,!1,l,void 0,!0)}if(r){const i=n;n=a=>r({className:a,parseClassName:i})}return n},b3=e=>{const t=new Map;return e.orderSensitiveModifiers.forEach((r,n)=>{t.set(r,1e6+n)}),r=>{const n=[];let i=[];for(let a=0;a<r.length;a++){const l=r[a],s=l[0]==="[",o=t.has(l);s||o?(i.length>0&&(i.sort(),n.push(...i),i=[]),n.push(l)):i.push(l)}return i.length>0&&(i.sort(),n.push(...i)),n}},C3=e=>({cache:w3(e.cacheSize),parseClassName:x3(e),sortModifiers:b3(e),...h3(e)}),E3=/\s+/,k3=(e,t)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i,sortModifiers:a}=t,l=[],s=e.trim().split(E3);let o="";for(let c=s.length-1;c>=0;c-=1){const f=s[c],{isExternal:u,modifiers:p,hasImportantModifier:_,baseClassName:y,maybePostfixModifierPosition:v}=r(f);if(u){o=f+(o.length>0?" "+o:o);continue}let h=!!v,m=n(h?y.substring(0,v):y);if(!m){if(!h){o=f+(o.length>0?" "+o:o);continue}if(m=n(y),!m){o=f+(o.length>0?" "+o:o);continue}h=!1}const d=p.length===0?"":p.length===1?p[0]:a(p).join(":"),g=_?d+dd:d,w=g+m;if(l.indexOf(w)>-1)continue;l.push(w);const b=i(m,h);for(let x=0;x<b.length;++x){const C=b[x];l.push(g+C)}o=f+(o.length>0?" "+o:o)}return o},L3=(...e)=>{let t=0,r,n,i="";for(;t<e.length;)(r=e[t++])&&(n=eS(r))&&(i&&(i+=" "),i+=n);return i},eS=e=>{if(typeof e=="string")return e;let t,r="";for(let n=0;n<e.length;n++)e[n]&&(t=eS(e[n]))&&(r&&(r+=" "),r+=t);return r},T3=(e,...t)=>{let r,n,i,a;const l=o=>{const c=t.reduce((f,u)=>u(f),e());return r=C3(c),n=r.cache.get,i=r.cache.set,a=s,s(o)},s=o=>{const c=n(o);if(c)return c;const f=k3(o,r);return i(o,f),f};return a=l,(...o)=>a(L3(...o))},R3=[],yt=e=>{const t=r=>r[e]||R3;return t.isThemeGetter=!0,t},tS=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,rS=/^\((?:(\w[\w-]*):)?(.+)\)$/i,D3=/^\d+\/\d+$/,M3=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,A3=/\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$/,P3=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,I3=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,O3=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,Is=e=>D3.test(e),He=e=>!!e&&!Number.isNaN(Number(e)),bn=e=>!!e&&Number.isInteger(Number(e)),Lu=e=>e.endsWith("%")&&He(e.slice(0,-1)),rn=e=>M3.test(e),B3=()=>!0,N3=e=>A3.test(e)&&!P3.test(e),nS=()=>!1,j3=e=>I3.test(e),F3=e=>O3.test(e),H3=e=>!xe(e)&&!be(e),$3=e=>Di(e,oS,nS),xe=e=>tS.test(e),ns=e=>Di(e,aS,N3),Tu=e=>Di(e,K3,He),Pv=e=>Di(e,sS,nS),z3=e=>Di(e,iS,F3),ja=e=>Di(e,lS,j3),be=e=>rS.test(e),zi=e=>Mi(e,aS),U3=e=>Mi(e,G3),Iv=e=>Mi(e,sS),W3=e=>Mi(e,oS),V3=e=>Mi(e,iS),Fa=e=>Mi(e,lS,!0),Di=(e,t,r)=>{const n=tS.exec(e);return n?n[1]?t(n[1]):r(n[2]):!1},Mi=(e,t,r=!1)=>{const n=rS.exec(e);return n?n[1]?t(n[1]):r:!1},sS=e=>e==="position"||e==="percentage",iS=e=>e==="image"||e==="url",oS=e=>e==="length"||e==="size"||e==="bg-size",aS=e=>e==="length",K3=e=>e==="number",G3=e=>e==="family-name",lS=e=>e==="shadow",q3=()=>{const e=yt("color"),t=yt("font"),r=yt("text"),n=yt("font-weight"),i=yt("tracking"),a=yt("leading"),l=yt("breakpoint"),s=yt("container"),o=yt("spacing"),c=yt("radius"),f=yt("shadow"),u=yt("inset-shadow"),p=yt("text-shadow"),_=yt("drop-shadow"),y=yt("blur"),v=yt("perspective"),h=yt("aspect"),m=yt("ease"),d=yt("animate"),g=()=>["auto","avoid","all","avoid-page","page","left","right","column"],w=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],b=()=>[...w(),be,xe],x=()=>["auto","hidden","clip","visible","scroll"],C=()=>["auto","contain","none"],S=()=>[be,xe,o],k=()=>[Is,"full","auto",...S()],L=()=>[bn,"none","subgrid",be,xe],A=()=>["auto",{span:["full",bn,be,xe]},bn,be,xe],M=()=>[bn,"auto",be,xe],D=()=>["auto","min","max","fr",be,xe],O=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],z=()=>["start","end","center","stretch","center-safe","end-safe"],F=()=>["auto",...S()],H=()=>[Is,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...S()],I=()=>[e,be,xe],R=()=>[...w(),Iv,Pv,{position:[be,xe]}],P=()=>["no-repeat",{repeat:["","x","y","space","round"]}],N=()=>["auto","cover","contain",W3,$3,{size:[be,xe]}],j=()=>[Lu,zi,ns],W=()=>["","none","full",c,be,xe],V=()=>["",He,zi,ns],Z=()=>["solid","dashed","dotted","double"],Q=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],$=()=>[He,Lu,Iv,Pv],B=()=>["","none",y,be,xe],K=()=>["none",He,be,xe],U=()=>["none",He,be,xe],te=()=>[He,be,xe],Y=()=>[Is,"full",...S()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[rn],breakpoint:[rn],color:[B3],container:[rn],"drop-shadow":[rn],ease:["in","out","in-out"],font:[H3],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[rn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[rn],shadow:[rn],spacing:["px",He],text:[rn],"text-shadow":[rn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",Is,xe,be,h]}],container:["container"],columns:[{columns:[He,xe,be,s]}],"break-after":[{"break-after":g()}],"break-before":[{"break-before":g()}],"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:b()}],overflow:[{overflow:x()}],"overflow-x":[{"overflow-x":x()}],"overflow-y":[{"overflow-y":x()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:k()}],"inset-x":[{"inset-x":k()}],"inset-y":[{"inset-y":k()}],start:[{start:k()}],end:[{end:k()}],top:[{top:k()}],right:[{right:k()}],bottom:[{bottom:k()}],left:[{left:k()}],visibility:["visible","invisible","collapse"],z:[{z:[bn,"auto",be,xe]}],basis:[{basis:[Is,"full","auto",s,...S()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[He,Is,"auto","initial","none",xe]}],grow:[{grow:["",He,be,xe]}],shrink:[{shrink:["",He,be,xe]}],order:[{order:[bn,"first","last","none",be,xe]}],"grid-cols":[{"grid-cols":L()}],"col-start-end":[{col:A()}],"col-start":[{"col-start":M()}],"col-end":[{"col-end":M()}],"grid-rows":[{"grid-rows":L()}],"row-start-end":[{row:A()}],"row-start":[{"row-start":M()}],"row-end":[{"row-end":M()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":D()}],"auto-rows":[{"auto-rows":D()}],gap:[{gap:S()}],"gap-x":[{"gap-x":S()}],"gap-y":[{"gap-y":S()}],"justify-content":[{justify:[...O(),"normal"]}],"justify-items":[{"justify-items":[...z(),"normal"]}],"justify-self":[{"justify-self":["auto",...z()]}],"align-content":[{content:["normal",...O()]}],"align-items":[{items:[...z(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...z(),{baseline:["","last"]}]}],"place-content":[{"place-content":O()}],"place-items":[{"place-items":[...z(),"baseline"]}],"place-self":[{"place-self":["auto",...z()]}],p:[{p:S()}],px:[{px:S()}],py:[{py:S()}],ps:[{ps:S()}],pe:[{pe:S()}],pt:[{pt:S()}],pr:[{pr:S()}],pb:[{pb:S()}],pl:[{pl:S()}],m:[{m:F()}],mx:[{mx:F()}],my:[{my:F()}],ms:[{ms:F()}],me:[{me:F()}],mt:[{mt:F()}],mr:[{mr:F()}],mb:[{mb:F()}],ml:[{ml:F()}],"space-x":[{"space-x":S()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":S()}],"space-y-reverse":["space-y-reverse"],size:[{size:H()}],w:[{w:[s,"screen",...H()]}],"min-w":[{"min-w":[s,"screen","none",...H()]}],"max-w":[{"max-w":[s,"screen","none","prose",{screen:[l]},...H()]}],h:[{h:["screen","lh",...H()]}],"min-h":[{"min-h":["screen","lh","none",...H()]}],"max-h":[{"max-h":["screen","lh",...H()]}],"font-size":[{text:["base",r,zi,ns]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[n,be,Tu]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",Lu,xe]}],"font-family":[{font:[U3,xe,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,be,xe]}],"line-clamp":[{"line-clamp":[He,"none",be,Tu]}],leading:[{leading:[a,...S()]}],"list-image":[{"list-image":["none",be,xe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",be,xe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...Z(),"wavy"]}],"text-decoration-thickness":[{decoration:[He,"from-font","auto",be,ns]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[He,"auto",be,xe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:S()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",be,xe]}],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",be,xe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:R()}],"bg-repeat":[{bg:P()}],"bg-size":[{bg:N()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},bn,be,xe],radial:["",be,xe],conic:[bn,be,xe]},V3,z3]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:j()}],"gradient-via-pos":[{via:j()}],"gradient-to-pos":[{to:j()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:W()}],"rounded-s":[{"rounded-s":W()}],"rounded-e":[{"rounded-e":W()}],"rounded-t":[{"rounded-t":W()}],"rounded-r":[{"rounded-r":W()}],"rounded-b":[{"rounded-b":W()}],"rounded-l":[{"rounded-l":W()}],"rounded-ss":[{"rounded-ss":W()}],"rounded-se":[{"rounded-se":W()}],"rounded-ee":[{"rounded-ee":W()}],"rounded-es":[{"rounded-es":W()}],"rounded-tl":[{"rounded-tl":W()}],"rounded-tr":[{"rounded-tr":W()}],"rounded-br":[{"rounded-br":W()}],"rounded-bl":[{"rounded-bl":W()}],"border-w":[{border:V()}],"border-w-x":[{"border-x":V()}],"border-w-y":[{"border-y":V()}],"border-w-s":[{"border-s":V()}],"border-w-e":[{"border-e":V()}],"border-w-t":[{"border-t":V()}],"border-w-r":[{"border-r":V()}],"border-w-b":[{"border-b":V()}],"border-w-l":[{"border-l":V()}],"divide-x":[{"divide-x":V()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":V()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...Z(),"hidden","none"]}],"divide-style":[{divide:[...Z(),"hidden","none"]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...Z(),"none","hidden"]}],"outline-offset":[{"outline-offset":[He,be,xe]}],"outline-w":[{outline:["",He,zi,ns]}],"outline-color":[{outline:I()}],shadow:[{shadow:["","none",f,Fa,ja]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":["none",u,Fa,ja]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:V()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[He,ns]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":V()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":["none",p,Fa,ja]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[He,be,xe]}],"mix-blend":[{"mix-blend":[...Q(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Q()}],"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":[He]}],"mask-image-linear-from-pos":[{"mask-linear-from":$()}],"mask-image-linear-to-pos":[{"mask-linear-to":$()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":$()}],"mask-image-t-to-pos":[{"mask-t-to":$()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":$()}],"mask-image-r-to-pos":[{"mask-r-to":$()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":$()}],"mask-image-b-to-pos":[{"mask-b-to":$()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":$()}],"mask-image-l-to-pos":[{"mask-l-to":$()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":$()}],"mask-image-x-to-pos":[{"mask-x-to":$()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":$()}],"mask-image-y-to-pos":[{"mask-y-to":$()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[be,xe]}],"mask-image-radial-from-pos":[{"mask-radial-from":$()}],"mask-image-radial-to-pos":[{"mask-radial-to":$()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"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":w()}],"mask-image-conic-pos":[{"mask-conic":[He]}],"mask-image-conic-from-pos":[{"mask-conic-from":$()}],"mask-image-conic-to-pos":[{"mask-conic-to":$()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:R()}],"mask-repeat":[{mask:P()}],"mask-size":[{mask:N()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",be,xe]}],filter:[{filter:["","none",be,xe]}],blur:[{blur:B()}],brightness:[{brightness:[He,be,xe]}],contrast:[{contrast:[He,be,xe]}],"drop-shadow":[{"drop-shadow":["","none",_,Fa,ja]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:["",He,be,xe]}],"hue-rotate":[{"hue-rotate":[He,be,xe]}],invert:[{invert:["",He,be,xe]}],saturate:[{saturate:[He,be,xe]}],sepia:[{sepia:["",He,be,xe]}],"backdrop-filter":[{"backdrop-filter":["","none",be,xe]}],"backdrop-blur":[{"backdrop-blur":B()}],"backdrop-brightness":[{"backdrop-brightness":[He,be,xe]}],"backdrop-contrast":[{"backdrop-contrast":[He,be,xe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",He,be,xe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[He,be,xe]}],"backdrop-invert":[{"backdrop-invert":["",He,be,xe]}],"backdrop-opacity":[{"backdrop-opacity":[He,be,xe]}],"backdrop-saturate":[{"backdrop-saturate":[He,be,xe]}],"backdrop-sepia":[{"backdrop-sepia":["",He,be,xe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":S()}],"border-spacing-x":[{"border-spacing-x":S()}],"border-spacing-y":[{"border-spacing-y":S()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",be,xe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[He,"initial",be,xe]}],ease:[{ease:["linear","initial",m,be,xe]}],delay:[{delay:[He,be,xe]}],animate:[{animate:["none",d,be,xe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[v,be,xe]}],"perspective-origin":[{"perspective-origin":b()}],rotate:[{rotate:K()}],"rotate-x":[{"rotate-x":K()}],"rotate-y":[{"rotate-y":K()}],"rotate-z":[{"rotate-z":K()}],scale:[{scale:U()}],"scale-x":[{"scale-x":U()}],"scale-y":[{"scale-y":U()}],"scale-z":[{"scale-z":U()}],"scale-3d":["scale-3d"],skew:[{skew:te()}],"skew-x":[{"skew-x":te()}],"skew-y":[{"skew-y":te()}],transform:[{transform:[be,xe,"","none","gpu","cpu"]}],"transform-origin":[{origin:b()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:Y()}],"translate-x":[{"translate-x":Y()}],"translate-y":[{"translate-y":Y()}],"translate-z":[{"translate-z":Y()}],"translate-none":["translate-none"],accent:[{accent:I()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:I()}],"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",be,xe]}],"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":S()}],"scroll-mx":[{"scroll-mx":S()}],"scroll-my":[{"scroll-my":S()}],"scroll-ms":[{"scroll-ms":S()}],"scroll-me":[{"scroll-me":S()}],"scroll-mt":[{"scroll-mt":S()}],"scroll-mr":[{"scroll-mr":S()}],"scroll-mb":[{"scroll-mb":S()}],"scroll-ml":[{"scroll-ml":S()}],"scroll-p":[{"scroll-p":S()}],"scroll-px":[{"scroll-px":S()}],"scroll-py":[{"scroll-py":S()}],"scroll-ps":[{"scroll-ps":S()}],"scroll-pe":[{"scroll-pe":S()}],"scroll-pt":[{"scroll-pt":S()}],"scroll-pr":[{"scroll-pr":S()}],"scroll-pb":[{"scroll-pb":S()}],"scroll-pl":[{"scroll-pl":S()}],"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",be,xe]}],fill:[{fill:["none",...I()]}],"stroke-w":[{stroke:[He,zi,ns,Tu]}],stroke:[{stroke:["none",...I()]}],"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"]}},X3=T3(q3);function Yl(...e){return X3(a3(e))}function Cn({checked:e,onCheckedChange:t,disabled:r,className:n}){return T.jsx(i3,{checked:e,onCheckedChange:t,disabled:r,className:Yl("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",n),children:T.jsx(o3,{className:Yl("pointer-events-none block size-4 rounded-full bg-white shadow-sm transition-transform","translate-x-1 group-data-[checked]:translate-x-5")})})}let Ar=null,pp=!1;const Jl={},cS=500;function mp(){if(typeof window>"u")return null;if((Ar==null?void 0:Ar.state)==="closed"&&(Ar=null),!Ar){const e=window.AudioContext??window.webkitAudioContext;if(!e)return null;Ar=new e}return Ar}function Y3(){Ar&&(Ar.close().catch(()=>{}),Ar=null),mp()}function J3(){return pp}function Ru(){Ar&&(Y3(),pp=!0)}if(typeof window<"u"){window.addEventListener("pageshow",t=>{t.persisted&&Ru()}),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&Ru()});let e=Date.now();setInterval(()=>{const t=Date.now();t-e>15e3&&Ru(),e=t},5e3)}async function fd(){const e=mp();e&&e.state==="suspended"&&await e.resume().catch(()=>{}),pp=!1}async function Q3(e){e.state==="suspended"&&await e.resume().catch(()=>{})}async function uS(e){const t=mp();if(!t||(await Q3(t),t.state!=="running"))return;const{frequencies:r,durationMs:n,attackMs:i,peakGain:a,type:l="sine"}=e,s=t.currentTime,o=n/1e3,c=i/1e3,f=t.createGain();f.connect(t.destination);const u=s+o*.7;f.gain.setValueAtTime(0,s),f.gain.linearRampToValueAtTime(a,s+c),f.gain.setValueAtTime(a,u),f.gain.linearRampToValueAtTime(0,s+o);const p=r.map(y=>{const v=t.createOscillator();return v.type=l,v.frequency.setValueAtTime(y,s),v.connect(f),v});for(const y of p)y.start(s),y.stop(s+o);const _=p[p.length-1];_.onended=()=>{for(const y of p)y.disconnect();f.disconnect()}}async function pd(){const e=Date.now();if(!(e-(Jl.permission||0)<cS)){Jl.permission=e;try{await uS({frequencies:[880],durationMs:150,attackMs:5,peakGain:.15,type:"sine"})}catch{}}}async function md(){const e=Date.now();if(!(e-(Jl.idle||0)<cS)){Jl.idle=e;try{await uS({frequencies:[440,550],durationMs:300,attackMs:10,peakGain:.08,type:"sine"})}catch{}}}function Z3({isOpen:e,onClose:t}){const r=pe(X=>X.defaultProjectDir),n=pe(X=>X.setDefaultProjectDir),i=pe(X=>X.commandPresets),a=pe(X=>X.setCommandPresets),l=pe(X=>X.defaultPresetId),s=pe(X=>X.setDefaultPresetId),o=pe(X=>X.sessionSortMode),c=pe(X=>X.setSessionSortMode),f=pe(X=>X.sessionSortDirection),u=pe(X=>X.setSessionSortDirection),p=pe(X=>X.useWebGL),_=pe(X=>X.setUseWebGL),y=pe(X=>X.fontSize),v=pe(X=>X.setFontSize),h=pe(X=>X.lineHeight),m=pe(X=>X.setLineHeight),d=pe(X=>X.letterSpacing),g=pe(X=>X.setLetterSpacing),w=pe(X=>X.fontOption),b=pe(X=>X.setFontOption),x=pe(X=>X.customFontFamily),C=pe(X=>X.setCustomFontFamily),S=pe(X=>X.shortcutModifier),k=pe(X=>X.setShortcutModifier),L=pe(X=>X.showProjectName),A=pe(X=>X.setShowProjectName),M=pe(X=>X.showLastUserMessage),D=pe(X=>X.setShowLastUserMessage),O=pe(X=>X.showSessionIdPrefix),z=pe(X=>X.setShowSessionIdPrefix),F=ql(X=>X.theme),H=ql(X=>X.setTheme),I=pe(X=>X.soundOnPermission),R=pe(X=>X.setSoundOnPermission),P=pe(X=>X.soundOnIdle),N=pe(X=>X.setSoundOnIdle),[j,W]=E.useState(r),[V,Z]=E.useState(i),[Q,$]=E.useState(l),[B,K]=E.useState(o),[U,te]=E.useState(f),[Y,_e]=E.useState(p),[de,re]=E.useState(y),[le,ne]=E.useState(h),[fe,ge]=E.useState(d),[se,oe]=E.useState(w),[ue,ae]=E.useState(x),[ve,Ce]=E.useState(S),[Le,je]=E.useState(L),[Fe,Pe]=E.useState(M),[Oe,Ee]=E.useState(O),[q,ee]=E.useState(F),[Ne,qe]=E.useState(I),[Ae,G]=E.useState(P),[me,J]=E.useState(!0),[Se,ie]=E.useState(!1),[he,ke]=E.useState(24),[Re,$e]=E.useState(!1),[Ue,Ie]=E.useState(!1),[De,et]=E.useState(""),[ze,Te]=E.useState(""),[Me,We]=E.useState(""),Ye=E.useRef(null);if(E.useEffect(()=>{if(Ye.current&&(clearTimeout(Ye.current),Ye.current=null),e){if(W(r),Z(i),$(l),K(o),te(f),_e(p),re(y),ne(h),ge(d),oe(w),ae(x),Ce(S),je(L),Pe(M),Ee(O),ee(F),qe(I),G(P),Ie(!1),et(""),Te(""),We(""),fetch("/api/settings/tmux-mouse-mode").then(X=>X.json()).then(X=>J(X.enabled)).catch(()=>{}),fetch("/api/settings/inactive-max-age-hours").then(X=>X.json()).then(X=>ke(X.hours)).catch(()=>{}),typeof document<"u"){const X=document.querySelector(".xterm-helper-textarea");X&&typeof X.setAttribute=="function"&&(typeof X.blur=="function"&&X.blur(),X.setAttribute("disabled","true"))}}else typeof document<"u"&&(Ye.current=setTimeout(()=>{if(typeof document>"u")return;const X=document.querySelector(".xterm-helper-textarea");X&&(X.removeAttribute("disabled"),X.focus())},300));return()=>{Ye.current&&(clearTimeout(Ye.current),Ye.current=null)}},[i,l,r,o,f,p,y,h,d,w,x,S,L,M,O,F,I,P,e]),E.useEffect(()=>{if(!e||typeof window>"u"||typeof window.addEventListener!="function")return;const X=tt=>{tt.key==="Escape"&&(typeof tt.stopPropagation=="function"&&tt.stopPropagation(),t())};return window.addEventListener("keydown",X),()=>window.removeEventListener("keydown",X)},[e,t]),!e)return null;const $t=X=>{X.preventDefault();const tt=j.trim(),Jr=Y!==p;n(tt||Th),a(V),s(Q),c(B),u(U),_(Y),v(de),m(le),g(fe),b(se),C(ue),k(ve),A(Le),D(Fe),z(Oe),H(q),R(Ne),N(Ae),t({webglChanged:Jr})},_t=(X,tt)=>{Z(Jr=>Jr.map(Qr=>Qr.id===X?{...Qr,...tt}:Qr))},zt=X=>{var Qr;const tt=V.find(Rs=>Rs.id===X);if(!tt||tt.isBuiltIn)return;const Jr=V.filter(Rs=>Rs.id!==X);Z(Jr),X===Q&&$(((Qr=Jr[0])==null?void 0:Qr.id)||"claude")},It=()=>{if(!De.trim()||!ze.trim()||V.length>=si)return;const X={id:`custom-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,label:De.trim(),command:ze.trim(),isBuiltIn:!1,agentType:Me||void 0};Z([...V,X]),Ie(!1),et(""),Te(""),We("")},wn=V.length<si,Ts=X=>{ie(!0),J(X),fetch("/api/settings/tmux-mouse-mode",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:X})}).catch(()=>J(!X)).finally(()=>ie(!1))},ca=X=>{const tt=he;$e(!0),ke(X),fetch("/api/settings/inactive-max-age-hours",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({hours:X})}).catch(()=>ke(tt)).finally(()=>$e(!1))};return T.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4",onClick:X=>{X.target===X.currentTarget&&t()},children:T.jsxs("form",{onSubmit:$t,className:"w-full max-w-lg max-h-[90vh] flex flex-col border border-border bg-elevated",children:[T.jsxs("div",{className:"p-6 pb-0",children:[T.jsx("h2",{className:"text-sm font-semibold uppercase tracking-wider text-primary text-balance",children:"Settings"}),T.jsx("p",{className:"mt-2 text-xs text-muted text-pretty",children:"Configure default directory, command presets, and display options."})]}),T.jsx("div",{className:"flex-1 overflow-y-auto px-6 pb-4",children:T.jsxs("div",{className:"mt-5 space-y-4",children:[T.jsxs("div",{children:[T.jsx("label",{className:"mb-1.5 block text-xs text-secondary",children:"Default Project Directory"}),T.jsx("input",{value:j,onChange:X=>W(X.target.value),placeholder:Th,className:"input",autoFocus:!0})]}),T.jsxs("div",{className:"border-t border-border pt-4",children:[T.jsxs("div",{className:"flex items-center justify-between mb-2",children:[T.jsx("label",{className:"text-xs text-secondary",children:"Command Presets"}),T.jsx("select",{value:Q,onChange:X=>$(X.target.value),className:"input text-xs py-1 px-2 w-auto",children:V.map(X=>T.jsx("option",{value:X.id,children:X.label},X.id))})]}),T.jsx("p",{className:"text-[10px] text-muted mb-3",children:"Default preset is pre-selected when creating new sessions."}),T.jsx("div",{className:"space-y-3",children:V.map(X=>T.jsxs("div",{className:"border border-border p-3 space-y-2",children:[T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsx("div",{className:"flex items-center gap-2",children:T.jsx("input",{value:X.label,onChange:tt=>_t(X.id,{label:tt.target.value}),className:"input text-sm py-1 px-2 w-32",placeholder:"Label"})}),!X.isBuiltIn&&T.jsx("button",{type:"button",onClick:()=>zt(X.id),className:"btn text-xs px-2 py-1 text-error hover:bg-error/10",children:"Delete"})]}),T.jsxs("div",{children:[T.jsx("label",{className:"text-[10px] text-muted block mb-1",children:"Command"}),T.jsx("input",{value:X.command,onChange:tt=>_t(X.id,{command:tt.target.value}),className:"input text-xs py-1 px-2 font-mono w-full",placeholder:"command --flags"})]}),!X.isBuiltIn&&T.jsxs("div",{children:[T.jsx("label",{className:"text-[10px] text-muted block mb-1",children:"Icon"}),T.jsxs("select",{value:X.agentType||"",onChange:tt=>_t(X.id,{agentType:tt.target.value||void 0}),className:"input text-xs py-1 px-2 w-auto",children:[T.jsx("option",{value:"",children:"Terminal"}),T.jsx("option",{value:"claude",children:"Claude"}),T.jsx("option",{value:"codex",children:"Codex"})]})]})]},X.id))}),Ue?T.jsxs("div",{className:"mt-3 border border-border p-3 space-y-2",children:[T.jsx("div",{className:"text-xs text-secondary mb-2",children:"New Preset"}),T.jsx("input",{value:De,onChange:X=>et(X.target.value),className:"input text-xs py-1 px-2 w-full",placeholder:"Label"}),T.jsx("input",{value:ze,onChange:X=>Te(X.target.value),className:"input text-xs py-1 px-2 font-mono w-full",placeholder:"command --flags"}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsxs("select",{value:Me,onChange:X=>We(X.target.value),className:"input text-xs py-1 px-2 w-auto",children:[T.jsx("option",{value:"",children:"Terminal Icon"}),T.jsx("option",{value:"claude",children:"Claude Icon"}),T.jsx("option",{value:"codex",children:"Codex Icon"})]}),T.jsx("div",{className:"flex-1"}),T.jsx("button",{type:"button",onClick:()=>Ie(!1),className:"btn text-xs px-2 py-1",children:"Cancel"}),T.jsx("button",{type:"button",onClick:It,disabled:!De.trim()||!ze.trim(),className:"btn btn-primary text-xs px-2 py-1",children:"Add"})]})]}):T.jsx("button",{type:"button",onClick:()=>Ie(!0),disabled:!wn,className:"btn text-xs mt-3 w-full",children:wn?"+ Add Preset":`Max ${si} presets`})]}),T.jsxs("div",{className:"border-t border-border pt-4",children:[T.jsx("label",{className:"mb-2 block text-xs text-secondary",children:"Session List Order"}),T.jsxs("div",{className:"flex gap-2",children:[T.jsx("button",{type:"button",className:`btn flex-1 ${B==="created"?"btn-primary":""}`,onClick:()=>K("created"),children:"Created"}),T.jsx("button",{type:"button",className:`btn flex-1 ${B==="status"?"btn-primary":""}`,onClick:()=>K("status"),children:"Status"}),T.jsx("button",{type:"button",className:`btn flex-1 ${B==="manual"?"btn-primary":""}`,onClick:()=>K("manual"),children:"Manual"})]}),T.jsx("p",{className:"mt-1.5 text-[10px] text-muted",children:B==="status"?"Sessions auto-resort by status (waiting, working, unknown)":B==="manual"?"Drag sessions to reorder manually":"Sessions stay in creation order"})]}),B==="created"&&T.jsxs("div",{children:[T.jsx("label",{className:"mb-2 block text-xs text-secondary",children:"Sort Direction"}),T.jsxs("div",{className:"flex gap-2",children:[T.jsx("button",{type:"button",className:`btn flex-1 ${U==="desc"?"btn-primary":""}`,onClick:()=>te("desc"),children:"Newest First"}),T.jsx("button",{type:"button",className:`btn flex-1 ${U==="asc"?"btn-primary":""}`,onClick:()=>te("asc"),children:"Oldest First"})]})]}),T.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[T.jsx("label",{className:"mb-1 block text-xs text-secondary",children:"Session List Details"}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Project Name"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Show the project folder name under each session."})]}),T.jsx(Cn,{checked:Le,onCheckedChange:je})]}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Last User Message"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Show the most recent user input next to the project name."})]}),T.jsx(Cn,{checked:Fe,onCheckedChange:Pe})]}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Session ID Prefix"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Show first 5 characters of agent session IDs in the list."})]}),T.jsx(Cn,{checked:Oe,onCheckedChange:Ee})]}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Inactive Sessions Lookback"}),T.jsxs("div",{className:"text-[10px] text-muted",children:["Show inactive sessions from the last N hours (",Cu,"-",Eu,")."]})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("input",{type:"number",min:Cu,max:Eu,value:he,onChange:X=>{const tt=parseInt(X.target.value,10);tt>=Cu&&tt<=Eu&&ca(tt)},disabled:Re,className:"input text-xs py-1 px-2 w-16 text-center"}),T.jsx("span",{className:"text-xs text-muted",children:"hrs"})]})]})]}),T.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[T.jsx("label",{className:"mb-1 block text-xs text-secondary",children:"Notifications"}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{className:"flex-1",children:[T.jsx("div",{className:"text-sm text-primary",children:"Permission Sound"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Play a ping when any session needs permission."})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("button",{type:"button",onClick:()=>void pd(),className:"btn text-xs px-2 py-1",children:"Test"}),T.jsx(Cn,{checked:Ne,onCheckedChange:X=>{qe(X),X&&fd()}})]})]}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{className:"flex-1",children:[T.jsx("div",{className:"text-sm text-primary",children:"Idle Sound"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Play a chime when a session finishes working."})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("button",{type:"button",onClick:()=>void md(),className:"btn text-xs px-2 py-1",children:"Test"}),T.jsx(Cn,{checked:Ae,onCheckedChange:X=>{G(X),X&&fd()}})]})]})]}),T.jsxs("div",{className:"border-t border-border pt-4",children:[T.jsx("label",{className:"mb-2 block text-xs text-secondary",children:"Terminal Rendering"}),T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"WebGL Acceleration"}),T.jsx("div",{className:"text-[10px] text-muted",children:"GPU rendering for better performance. Turn off if text looks fuzzy or flickering."})]}),T.jsx(Cn,{checked:Y,onCheckedChange:_e})]}),Y!==p&&T.jsx("p",{className:"mt-2 text-[10px] text-approval",children:"Terminal will reload when saved"}),T.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Mouse Mode"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Enable tmux mouse mode for trackpad/scroll wheel support."})]}),T.jsx(Cn,{checked:me,onCheckedChange:Ts,disabled:Se})]}),T.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Font Size"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Terminal text size in pixels (6-24)"})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("button",{type:"button",onClick:()=>re(Math.max(6,de-1)),className:"flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover",children:T.jsx("span",{className:"text-sm font-bold",children:"−"})}),T.jsx("span",{className:"text-sm text-secondary w-6 text-center",children:de}),T.jsx("button",{type:"button",onClick:()=>re(Math.min(24,de+1)),className:"flex h-7 w-7 items-center justify-center rounded bg-surface border border-border text-secondary hover:bg-hover",children:T.jsx("span",{className:"text-sm font-bold",children:"+"})})]})]}),T.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Line Height"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Vertical spacing (1.0 = compact, 2.0 = spacious)"})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("input",{type:"range",min:"1.0",max:"2.0",step:"0.1",value:le,onChange:X=>ne(parseFloat(X.target.value)),className:"w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent"}),T.jsx("span",{className:"text-xs text-secondary w-8 text-right",children:le.toFixed(1)})]})]}),T.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Letter Spacing"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Horizontal spacing between characters in pixels"})]}),T.jsxs("div",{className:"flex items-center gap-2",children:[T.jsx("input",{type:"range",min:"-3",max:"3",step:"1",value:fe,onChange:X=>ge(parseInt(X.target.value,10)),className:"w-20 h-1 bg-border rounded-lg appearance-none cursor-pointer accent-accent"}),T.jsxs("span",{className:"text-xs text-secondary w-8 text-right",children:[fe,"px"]})]})]}),T.jsxs("div",{className:"mt-4",children:[T.jsxs("div",{className:"flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Font Family"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Terminal typeface"})]}),T.jsx("select",{value:se,onChange:X=>oe(X.target.value),className:"input text-xs py-1 px-2 w-auto",children:Rh.map(X=>T.jsx("option",{value:X.id,children:X.label},X.id))})]}),se==="custom"&&T.jsx("input",{value:ue,onChange:X=>ae(X.target.value),placeholder:'"Fira Code", monospace',className:"input text-xs mt-2 font-mono"})]}),T.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[T.jsxs("div",{children:[T.jsx("div",{className:"text-sm text-primary",children:"Dark Mode"}),T.jsx("div",{className:"text-[10px] text-muted",children:"Switch between dark and light themes."})]}),T.jsx(Cn,{checked:q==="dark",onCheckedChange:X=>ee(X?"dark":"light")})]})]}),T.jsxs("div",{className:"border-t border-border pt-4",children:[T.jsx("label",{className:"mb-2 block text-xs text-secondary",children:"Keyboard Shortcut Modifier"}),T.jsx("div",{className:"grid grid-cols-5 gap-1",children:["auto","ctrl-option","ctrl-shift","cmd-option","cmd-shift"].map(X=>T.jsx("button",{type:"button",className:`btn text-xs px-2 ${ve===X?"btn-primary":""}`,onClick:()=>Ce(X),children:X==="auto"?"Auto":ii(X)},X))}),T.jsx("p",{className:"mt-1.5 text-[10px] text-muted",children:ve==="auto"?`Platform default: ${ii(ea("auto"))}`:`Shortcuts: ${ii(ve)}+[N/X/[/]]`})]})]})}),T.jsxs("div",{className:"flex justify-end gap-2 p-6 pt-4 border-t border-border bg-elevated",children:[T.jsx("button",{type:"button",onClick:()=>t(),className:"btn",children:"Cancel"}),T.jsx("button",{type:"submit",className:"btn btn-primary",children:"Save"})]})]})})}const eA=[];function gp(e){E.useEffect(e,eA)}const vp=E.createContext(void 0);function _p(){const e=E.useContext(vp);if(!e)throw new Error(Yr(73));return e}var Ql=Symbol("NOT_FOUND");function tA(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function rA(e,t=`expected an object, instead received ${typeof e}`){if(typeof e!="object")throw new TypeError(t)}function nA(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(r=>typeof r=="function")){const r=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${t}[${r}]`)}}var Ov=e=>Array.isArray(e)?e:[e];function sA(e){const t=Array.isArray(e[0])?e[0]:e;return nA(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function iA(e,t){const r=[],{length:n}=e;for(let i=0;i<n;i++)r.push(e[i].apply(null,t));return r}function oA(e){let t;return{get(r){return t&&e(t.key,r)?t.value:Ql},put(r,n){t={key:r,value:n}},getEntries(){return t?[t]:[]},clear(){t=void 0}}}function aA(e,t){let r=[];function n(s){const o=r.findIndex(c=>t(s,c.key));if(o>-1){const c=r[o];return o>0&&(r.splice(o,1),r.unshift(c)),c.value}return Ql}function i(s,o){n(s)===Ql&&(r.unshift({key:s,value:o}),r.length>e&&r.pop())}function a(){return r}function l(){r=[]}return{get:n,put:i,getEntries:a,clear:l}}var lA=(e,t)=>e===t;function cA(e){return function(r,n){if(r===null||n===null||r.length!==n.length)return!1;const{length:i}=r;for(let a=0;a<i;a++)if(!e(r[a],n[a]))return!1;return!0}}function uA(e,t){const r=typeof t=="object"?t:{equalityCheck:t},{equalityCheck:n=lA,maxSize:i=1,resultEqualityCheck:a}=r,l=cA(n);let s=0;const o=i<=1?oA(l):aA(i,l);function c(){let f=o.get(arguments);if(f===Ql){if(f=e.apply(null,arguments),s++,a){const p=o.getEntries().find(_=>a(_.value,f));p&&(f=p.value,s!==0&&s--)}o.put(arguments,f)}return f}return c.clearCache=()=>{o.clear(),c.resetResultsCount()},c.resultsCount=()=>s,c.resetResultsCount=()=>{s=0},c}var hA=class{constructor(e){this.value=e}deref(){return this.value}},dA=typeof WeakRef<"u"?WeakRef:hA,fA=0,Bv=1;function Ha(){return{s:fA,v:void 0,o:null,p:null}}function hS(e,t={}){let r=Ha();const{resultEqualityCheck:n}=t;let i,a=0;function l(){var u;let s=r;const{length:o}=arguments;for(let p=0,_=o;p<_;p++){const y=arguments[p];if(typeof y=="function"||typeof y=="object"&&y!==null){let v=s.o;v===null&&(s.o=v=new WeakMap);const h=v.get(y);h===void 0?(s=Ha(),v.set(y,s)):s=h}else{let v=s.p;v===null&&(s.p=v=new Map);const h=v.get(y);h===void 0?(s=Ha(),v.set(y,s)):s=h}}const c=s;let f;if(s.s===Bv)f=s.v;else if(f=e.apply(null,arguments),a++,n){const p=((u=i==null?void 0:i.deref)==null?void 0:u.call(i))??i;p!=null&&n(p,f)&&(f=p,a!==0&&a--),i=typeof f=="object"&&f!==null||typeof f=="function"?new dA(f):f}return c.s=Bv,c.v=f,f}return l.clearCache=()=>{r=Ha(),l.resetResultsCount()},l.resultsCount=()=>a,l.resetResultsCount=()=>{a=0},l}function dS(e,...t){const r=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,n=(...i)=>{let a=0,l=0,s,o={},c=i.pop();typeof c=="object"&&(o=c,c=i.pop()),tA(c,`createSelector expects an output function after the inputs, but received: [${typeof c}]`);const f={...r,...o},{memoize:u,memoizeOptions:p=[],argsMemoize:_=hS,argsMemoizeOptions:y=[]}=f,v=Ov(p),h=Ov(y),m=sA(i),d=u(function(){return a++,c.apply(null,arguments)},...v),g=_(function(){l++;const b=iA(m,arguments);return s=d.apply(null,b),s},...h);return Object.assign(g,{resultFunc:c,memoizedResultFunc:d,dependencies:m,dependencyRecomputations:()=>l,resetDependencyRecomputations:()=>{l=0},lastResult:()=>s,recomputations:()=>a,resetRecomputations:()=>{a=0},memoize:u,argsMemoize:_})};return Object.assign(n,{withTypes:()=>n}),n}var pA=dS(hS),mA=Object.assign((e,t=pA)=>{rA(e,`createStructuredSelector expects first argument to be an object where each property is a selector, instead received a ${typeof e}`);const r=Object.keys(e),n=r.map(a=>e[a]);return t(n,(...a)=>a.reduce((l,s,o)=>(l[r[o]]=s,l),{}))},{withTypes:()=>mA});const gA=dS({memoize:uA,memoizeOptions:{maxSize:1,equalityCheck:Object.is}}),Tr=(e,t,r,n,i,a,...l)=>{if(l.length>0)throw new Error(Yr(1));let s;if(e&&t)s=(o,c,f,u)=>{const p=e(o,c,f,u);return t(p,c,f,u)};else if(e)s=e;else throw new Error("Missing arguments");return s},vA=(...e)=>{const t=new WeakMap;let r=1;const n=e[e.length-1],i=e.length-1||1,a=n.length-i;if(a>3)throw new Error(Yr(2));return(s,o,c,f)=>{let u=s.__cacheKey__;u||(u={id:r},s.__cacheKey__=u,r+=1);let p=t.get(u);if(!p){let _=e;const y=[void 0,void 0,void 0];switch(a){case 0:break;case 1:{_=[...e.slice(0,-1),()=>y[0],n];break}case 2:{_=[...e.slice(0,-1),()=>y[0],()=>y[1],n];break}case 3:{_=[...e.slice(0,-1),()=>y[0],()=>y[1],()=>y[2],n];break}default:throw new Error(Yr(2))}p=gA(..._),p.selectorArgs=y,t.set(u,p)}switch(p.selectorArgs[0]=o,p.selectorArgs[1]=c,p.selectorArgs[2]=f,a){case 0:return p(s);case 1:return p(s,o);case 2:return p(s,o,c);case 3:return p(s,o,c,f);default:throw new Error("unreachable")}}};var fS={exports:{}},pS={};/**
301
301
  * @license React
302
302
  * use-sync-external-store-shim.production.js
303
303
  *
@@ -313,4 +313,4 @@ void main() {
313
313
  *
314
314
  * This source code is licensed under the MIT license found in the
315
315
  * LICENSE file in the root directory of this source tree.
316
- */var Ec=E,LA=mS;function TA(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var RA=typeof Object.is=="function"?Object.is:TA,DA=LA.useSyncExternalStore,MA=Ec.useRef,AA=Ec.useEffect,PA=Ec.useMemo,IA=Ec.useDebugValue;vS.useSyncExternalStoreWithSelector=function(e,t,r,n,i){var a=MA(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=PA(function(){function o(_){if(!c){if(c=!0,f=_,_=n(_),i!==void 0&&l.hasValue){var y=l.value;if(i(y,_))return u=y}return u=_}if(y=u,RA(f,_))return y;var v=n(_);return i!==void 0&&i(y,v)?(f=_,y):(f=_,u=v)}var c=!1,f,u,p=r===void 0?null:r;return[function(){return o(t())},p===null?void 0:function(){return o(p())}]},[t,r,n,i]);var s=DA(e,a[0],a[1]);return AA(function(){l.hasValue=!0,l.value=s},[s]),IA(s),s};gS.exports=vS;var OA=gS.exports;const BA=lp(19),NA=BA?FA:HA;function _S(e,t,r,n,i){return NA(e,t,r,n,i)}function jA(e,t,r,n,i){const a=E.useCallback(()=>t(e.getSnapshot(),r,n,i),[e,t,r,n,i]);return mS.useSyncExternalStore(e.subscribe,a,a)}function FA(e,t,r,n,i){return jA(e,t,r,n,i)}function HA(e,t,r,n,i){return OA.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,a=>t(a,r,n,i))}class $A{constructor(t){rt(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));rt(this,"getSnapshot",()=>this.state);this.state=t,this.listeners=new Set,this.updateTick=0}setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const r=this.updateTick;for(const n of this.listeners){if(r!==this.updateTick)return;n(t)}}update(t){for(const r in t)if(!Object.is(this.state[r],t[r])){this.setState({...this.state,...t});return}}set(t,r){Object.is(this.state[t],r)||this.setState({...this.state,[t]:r})}notifyAll(){const t={...this.state};this.setState(t)}use(t,r,n,i){return _S(this,t,r,n,i)}}class zA extends $A{constructor(t,r={},n){super(t),this.context=r,this.selectors=n}useSyncedValue(t,r){E.useDebugValue(t),qt(()=>{this.state[t]!==r&&this.set(t,r)},[t,r])}useSyncedValueWithCleanup(t,r){const n=this;qt(()=>(n.state[t]!==r&&n.set(t,r),()=>{n.set(t,void 0)}),[n,t,r])}useSyncedValues(t){const r=this,n=Object.values(t);qt(()=>{r.update(t)},[r,...n])}useControlledProp(t,r){E.useDebugValue(t);const n=r!==void 0;qt(()=>{n&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})},[t,r,n])}select(t,r,n,i){const a=this.selectors[t];return a(this.state,r,n,i)}useState(t,r,n,i){return E.useDebugValue(t),_S(this,this.selectors[t],r,n,i)}useContextCallback(t,r){E.useDebugValue(t);const n=Xr(r??ur);this.context[t]=n}useStateSetter(t){const r=E.useRef(void 0);return r.current===void 0&&(r.current=n=>{this.set(t,n)}),r.current}observe(t,r){let n;typeof t=="function"?n=t:n=this.selectors[t];let i=n(this.state);return r(i,i,this),this.subscribe(a=>{const l=n(a);if(!Object.is(i,l)){const s=i;i=l,r(l,s,this)}})}}const $a=null;class UA{constructor(){rt(this,"callbacks",[]);rt(this,"callbacksCount",0);rt(this,"nextId",1);rt(this,"startId",1);rt(this,"isScheduled",!1);rt(this,"tick",t=>{var i;this.isScheduled=!1;const r=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let a=0;a<r.length;a+=1)(i=r[a])==null||i.call(r,t)})}request(t){const r=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),r}cancel(t){const r=t-this.startId;r<0||r>=this.callbacks.length||(this.callbacks[r]=null,this.callbacksCount-=1)}}const za=new UA;class yp{constructor(){rt(this,"currentId",$a);rt(this,"cancel",()=>{this.currentId!==$a&&(za.cancel(this.currentId),this.currentId=$a)});rt(this,"disposeEffect",()=>this.cancel)}static create(){return new yp}static request(t){return za.request(t)}static cancel(t){return za.cancel(t)}request(t){this.cancel(),this.currentId=za.request(()=>{this.currentId=$a,t()})}}function WA(){const e=ks(yp.create).current;return gp(e.disposeEffect),e}const Ui=0;class Go{constructor(){rt(this,"currentId",Ui);rt(this,"clear",()=>{this.currentId!==Ui&&(clearTimeout(this.currentId),this.currentId=Ui)});rt(this,"disposeEffect",()=>this.clear)}static create(){return new Go}start(t,r){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ui,r()},t)}isStarted(){return this.currentId!==Ui}}function VA(){const e=ks(Go.create).current;return gp(e.disposeEffect),e}let Nv=0;function yS(e){return Nv+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${Nv}`}function Js(e){return(e==null?void 0:e.ownerDocument)||document}function Mu(e,t){if(typeof e=="string")return{description:e};if(typeof e=="function"){const r=e(t);return typeof r=="string"?{description:r}:r}return e}const la=typeof navigator<"u",Au=YA(),KA=QA(),GA=JA();typeof CSS>"u"||!CSS.supports||CSS.supports("-webkit-backdrop-filter:none");Au.platform==="MacIntel"&&Au.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(Au.platform);const qA=la&&/apple/i.test(navigator.vendor);la&&KA.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const XA=GA.includes("jsdom/");function YA(){if(!la)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e!=null&&e.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function JA(){if(!la)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:r})=>`${t}/${r}`).join(" "):navigator.userAgent}function QA(){if(!la)return"";const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform??""}function Zl(e){var r;let t=e.activeElement;for(;((r=t==null?void 0:t.shadowRoot)==null?void 0:r.activeElement)!=null;)t=t.shadowRoot.activeElement;return t}function yi(e,t){var n;if(!e||!t)return!1;const r=(n=t.getRootNode)==null?void 0:n.call(t);if(e.contains(t))return!0;if(r&&zM(r)){let i=t;for(;i;){if(e===i)return!0;i=i.parentNode||i.host}}return!1}function wp(e){return"composedPath"in e?e.composedPath()[0]:e.target}function gd(e){if(!e||XA)return!0;try{return e.matches(":focus-visible")}catch{return!0}}const Ua=vA(e=>e.toasts,e=>{const t=new Map;let r=0,n=0;return e.forEach((i,a)=>{const l=i.transitionStatus==="ending";t.set(i.id,{value:i,domIndex:a,visibleIndex:l?-1:r,offsetY:n}),n+=i.height||0,l||(r+=1)}),t}),nn={toasts:Tr(e=>e.toasts),isEmpty:Tr(e=>e.toasts.length===0),toast:Tr(Ua,(e,t)=>{var r;return(r=e.get(t))==null?void 0:r.value}),toastIndex:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.domIndex)??-1}),toastOffsetY:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.offsetY)??0}),toastVisibleIndex:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.visibleIndex)??-1}),hovering:Tr(e=>e.hovering),focused:Tr(e=>e.focused),expanded:Tr(e=>e.hovering||e.focused),expandedOrOutOfFocus:Tr(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:Tr(e=>e.prevFocusElement)};class ZA extends zA{constructor(r){super(r,{},nn);rt(this,"timers",new Map);rt(this,"areTimersPaused",!1);rt(this,"setViewport",r=>{this.set("viewport",r)});rt(this,"disposeEffect",()=>()=>{this.timers.forEach(r=>{var n;(n=r.timeout)==null||n.clear()}),this.timers.clear()});rt(this,"addToast",r=>{const{toasts:n,timeout:i,limit:a}=this.state,l=r.id||yS("toast"),s={...r,id:l,transitionStatus:"starting"},o=[s,...n],c=o.filter(u=>u.transitionStatus!=="ending");if(c.length>a){const u=c.length-a,p=c.slice(-u),_=new Set(p.map(y=>y.id));this.setToasts(o.map(y=>{const v=_.has(y.id);return y.limited!==v?{...y,limited:v}:y}))}else this.setToasts(o.map(u=>u.limited?{...u,limited:!1}:u));const f=s.timeout??i;return s.type!=="loading"&&f>0&&this.scheduleTimer(l,f,()=>this.closeToast(l)),nn.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),l});rt(this,"updateToast",(r,n)=>{this.updateToastInternal(r,n)});rt(this,"updateToastInternal",(r,n)=>{var v,h;const{timeout:i,toasts:a}=this.state,l=nn.toast(this.state,r)??null;if(!l||l.transitionStatus==="ending")return;const s={...l,...n};this.setToasts(a.map(m=>m.id===r?{...m,...n}:m));const o=s.timeout??i,c=(l==null?void 0:l.timeout)??i,f=Object.hasOwn(n,"timeout"),u=s.transitionStatus!=="ending"&&s.type!=="loading"&&o>0,p=this.timers.has(r),_=c!==o,y=(l==null?void 0:l.type)==="loading";if(!u&&p){const m=this.timers.get(r);(v=m==null?void 0:m.timeout)==null||v.clear(),this.timers.delete(r);return}if(u&&(!p||_||f||y)){const m=this.timers.get(r);m&&((h=m.timeout)==null||h.clear(),this.timers.delete(r)),this.scheduleTimer(r,o,()=>this.closeToast(r)),nn.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}});rt(this,"closeToast",r=>{var c;const n=nn.toast(this.state,r);(c=n==null?void 0:n.onClose)==null||c.call(n);const{limit:i,toasts:a}=this.state;let l=0;const s=a.map(f=>{if(f.id===r)return{...f,transitionStatus:"ending",height:0};if(f.transitionStatus==="ending")return f;const u=l>=i;return l+=1,f.limited!==u?{...f,limited:u}:f}),o=this.timers.get(r);o&&o.timeout&&(o.timeout.clear(),this.timers.delete(r)),this.handleFocusManagement(r),this.setToasts(s)});rt(this,"promiseToast",(r,n)=>{const i=Mu(n.loading),a=this.addToast({...i,type:"loading"}),l=r.then(s=>{const o=Mu(n.success,s);return this.updateToast(a,{...o,type:"success",timeout:o.timeout}),s}).catch(s=>{const o=Mu(n.error,s);return this.updateToast(a,{...o,type:"error",timeout:o.timeout}),Promise.reject(s)});return{}.hasOwnProperty.call(n,"setPromise")&&n.setPromise(l),l});rt(this,"handleDocumentPointerDown",r=>{if(r.pointerType!=="touch")return;const n=wp(r);yi(this.state.viewport,n)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))})}setFocused(r){this.set("focused",r)}setHovering(r){this.set("hovering",r)}setIsWindowFocused(r){this.set("isWindowFocused",r)}setPrevFocusElement(r){this.set("prevFocusElement",r)}removeToast(r){var l;const n=nn.toastIndex(this.state,r);if(n===-1)return;const i=this.state.toasts[n];(l=i==null?void 0:i.onRemove)==null||l.call(i);const a=[...this.state.toasts];a.splice(n,1),this.setToasts(a)}pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(r=>{if(r.timeout){r.timeout.clear();const n=Date.now()-r.start,i=r.delay-n;r.remaining=i>0?i:0}}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((r,n)=>{r.remaining=r.remaining>0?r.remaining:r.delay,r.timeout??(r.timeout=Go.create()),r.timeout.start(r.remaining,()=>{this.timers.delete(n),r.callback()}),r.start=Date.now()}))}restoreFocusToPrevElement(){var r;(r=this.state.prevFocusElement)==null||r.focus({preventScroll:!0})}scheduleTimer(r,n,i){const a=Date.now(),l=!nn.expandedOrOutOfFocus(this.state),s=l?Go.create():void 0;s==null||s.start(n,()=>{this.timers.delete(r),i()}),this.timers.set(r,{timeout:s,start:l?a:0,delay:n,remaining:n,callback:i})}setToasts(r){const n={toasts:r};r.length===0&&(n.hovering=!1,n.focused=!1),this.update(n)}handleFocusManagement(r){var o,c;const n=Zl(Js(this.state.viewport));if(!this.state.viewport||!yi(this.state.viewport,n)||!gd(n))return;const i=nn.toasts(this.state),a=nn.toastIndex(this.state,r);let l=null,s=a+1;for(;s<i.length;){if(i[s].transitionStatus!=="ending"){l=i[s];break}s+=1}if(!l)for(s=a-1;s>=0;){if(i[s].transitionStatus!=="ending"){l=i[s];break}s-=1}l?(c=(o=l.ref)==null?void 0:o.current)==null||c.focus():this.restoreFocusToPrevElement()}}const eP=function(t){const{children:r,timeout:n=5e3,limit:i=3,toastManager:a}=t,l=ks(()=>new ZA({timeout:n,limit:i,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return gp(l.disposeEffect),E.useEffect(function(){return a?a[" subscribe"](({action:c,options:f})=>{const u=f.id;c==="promise"&&f.promise?l.promiseToast(f.promise,f):c==="update"&&u?l.updateToast(u,f):c==="close"&&u?l.closeToast(u):l.addToast(f)}):void 0},[l,n,a]),l.useSyncedValues({timeout:n,limit:i}),T.jsx(vp.Provider,{value:l,children:r})},Pu=E.forwardRef(function(t,r){const[n,i]=E.useState();qt(()=>{qA&&i("button")},[]);const a={tabIndex:0,role:n};return T.jsx("span",{...t,ref:r,style:ap,"aria-hidden":n?void 0:!0,...a,"data-base-ui-focus-guard":""})});let tP=function(e){return e.frontmostHeight="--toast-frontmost-height",e}({});const rP=E.forwardRef(function(t,r){var M;const{render:n,className:i,children:a,...l}=t,s=_p(),o=VA(),c=E.useRef(!1),f=E.useRef(!1),u=s.useState("isEmpty"),p=s.useState("toasts"),_=s.useState("focused"),y=s.useState("expanded"),v=s.useState("prevFocusElement"),h=((M=p[0])==null?void 0:M.height)??0,m=E.useMemo(()=>p.some(D=>D.transitionStatus==="ending"),[p]);E.useEffect(()=>{const D=s.state.viewport;if(!D)return;function O(F){u||F.key==="F6"&&F.target!==D&&(F.preventDefault(),s.setPrevFocusElement(Zl(Js(D))),D==null||D.focus({preventScroll:!0}),s.pauseTimers(),s.setFocused(!0))}const z=Ko(D);return z.addEventListener("keydown",O),()=>{z.removeEventListener("keydown",O)}},[s,u]),E.useEffect(()=>{const D=s.state.viewport;if(!D||u)return;const O=Ko(D);function z(H){H.target===O&&(s.setIsWindowFocused(!1),s.pauseTimers())}function F(H){if(H.relatedTarget||H.target===O)return;const I=wp(H),R=Zl(Js(D));(!yi(D,I)||!gd(R))&&s.resumeTimers(),o.start(0,()=>s.setIsWindowFocused(!0))}return O.addEventListener("blur",z,!0),O.addEventListener("focus",F,!0),()=>{O.removeEventListener("blur",z,!0),O.removeEventListener("focus",F,!0)}},[s,o,u]),E.useEffect(()=>{const D=s.state.viewport;if(!D||u)return;const O=Js(D);return O.addEventListener("pointerdown",s.handleDocumentPointerDown,!0),()=>{O.removeEventListener("pointerdown",s.handleDocumentPointerDown,!0)}},[u,s]);function d(D){var z,F,H;const O=s.state.viewport;O&&(c.current=!0,D.relatedTarget===O?(H=(F=(z=p[0])==null?void 0:z.ref)==null?void 0:F.current)==null||H.focus():s.restoreFocusToPrevElement())}function g(D){D.key==="Tab"&&D.shiftKey&&D.target===s.state.viewport&&(D.preventDefault(),s.restoreFocusToPrevElement(),s.resumeTimers())}E.useEffect(()=>{!s.state.isWindowFocused||m||!f.current||(s.resumeTimers(),s.setHovering(!1),f.current=!1)},[m,s]);function w(){s.pauseTimers(),s.setHovering(!0),f.current=!1}function b(){m?f.current=!0:(s.resumeTimers(),s.setHovering(!1))}function x(){if(c.current){c.current=!1;return}_||gd(Js(s.state.viewport).activeElement)&&(s.setFocused(!0),s.pauseTimers())}function C(D){!_||yi(s.state.viewport,D.relatedTarget)||(s.setFocused(!1),s.resumeTimers())}const S={tabIndex:-1,role:"region","aria-live":"polite","aria-atomic":!1,"aria-relevant":"additions text","aria-label":"Notifications",onMouseEnter:w,onMouseMove:w,onMouseLeave:b,onFocus:x,onBlur:C,onKeyDown:g,onClick:x},k={expanded:y},L=Ls("div",t,{ref:[r,s.setViewport],state:k,props:[S,{style:{[tP.frontmostHeight]:h?`${h}px`:void 0}},l,{children:T.jsxs(E.Fragment,{children:[!u&&v&&T.jsx(Pu,{onFocus:d}),a,!u&&v&&T.jsx(Pu,{onFocus:d})]})}]}),A=E.useMemo(()=>p.filter(D=>D.priority==="high"),[p]);return T.jsxs(E.Fragment,{children:[!u&&v&&T.jsx(Pu,{onFocus:d}),L,!_&&A.length>0&&T.jsx("div",{style:ap,children:A.map(D=>T.jsxs("div",{role:"alert","aria-atomic":!0,children:[T.jsx("div",{children:D.title}),T.jsx("div",{children:D.description})]},D.id))})]})});function nP(e){return lp(19)?e:e?"true":void 0}const wS=E.createContext(void 0);function Sp(){const e=E.useContext(wS);if(!e)throw new Error(Yr(66));return e}let xp=function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e}({});const sP={[xp.startingStyle]:""},iP={[xp.endingStyle]:""},oP={transitionStatus(e){return e==="starting"?sP:e==="ending"?iP:null}};function aP(e){return e==null?e:"current"in e?e.current:e}function lP(e,t=!1,r=!0){const n=WA();return Xr((i,a=null)=>{n.cancel();function l(){hn.flushSync(i)}const s=aP(e);if(s==null)return;const o=s;if(typeof o.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{let u=function(){const _=xp.startingStyle;if(!o.hasAttribute(_)){n.request(p);return}const y=new MutationObserver(()=>{o.hasAttribute(_)||(y.disconnect(),p())});y.observe(o,{attributes:!0,attributeFilter:[_]}),a==null||a.addEventListener("abort",()=>y.disconnect(),{once:!0})},p=function(){Promise.all(o.getAnimations().map(_=>_.finished)).then(()=>{a!=null&&a.aborted||l()}).catch(()=>{const _=o.getAnimations();if(r){if(a!=null&&a.aborted)return;l()}else _.length>0&&_.some(y=>y.pending||y.playState!=="finished")&&p()})};var c=u,f=p;if(t){u();return}n.request(p)}})}function cP(e){const{enabled:t=!0,open:r,ref:n,onComplete:i}=e,a=Xr(i),l=lP(n,r,!1);E.useEffect(()=>{if(!t)return;const s=new AbortController;return l(a,s.signal),()=>{s.abort()}},[t,r,a,l])}let ss=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}({});const uP={...oP,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},Wi=40,hP=10,En=.5,dP=1;function jv(e,t,r){switch(e){case"up":return-r;case"down":return r;case"left":return-t;case"right":return t;default:return 0}}function fP(e){const r=window.getComputedStyle(e).transform;let n=0,i=0,a=1;if(r&&r!=="none"){const l=r.match(/matrix(?:3d)?\(([^)]+)\)/);if(l){const s=l[1].split(", ").map(parseFloat);s.length===6?(n=s[4],i=s[5],a=Math.sqrt(s[0]*s[0]+s[1]*s[1])):s.length===16&&(n=s[12],i=s[13],a=s[0])}}return{x:n,y:i,scale:a}}const pP=E.forwardRef(function(t,r){var ge;const{toast:n,render:i,className:a,swipeDirection:l=["down","right"],...s}=t,o=((ge=n.positionerProps)==null?void 0:ge.anchor)!==void 0;let c=[];o||(c=Array.isArray(l)?l:[l]);const f=c.length>0,u=_p(),[p,_]=E.useState(void 0),[y,v]=E.useState(!1),[h,m]=E.useState(!1),[d,g]=E.useState(!1),[w,b]=E.useState({x:0,y:0}),[x,C]=E.useState({x:0,y:0,scale:1}),[S,k]=E.useState(),[L,A]=E.useState(),[M,D]=E.useState(null),O=E.useRef(null),z=E.useRef({x:0,y:0}),F=E.useRef({x:0,y:0,scale:1}),H=E.useRef(void 0),I=E.useRef(0),R=E.useRef(!1),P=E.useRef({x:0,y:0}),N=E.useRef(!1),j=u.useState("toastIndex",n.id),W=u.useState("toastVisibleIndex",n.id),V=u.useState("toastOffsetY",n.id),Z=u.useState("focused"),Q=u.useState("expanded");cP({open:n.transitionStatus!=="ending",ref:O,onComplete(){n.transitionStatus==="ending"&&u.removeToast(n.id)}});const $=Xr((se=!1)=>{const oe=O.current;if(!oe)return;const ue=oe.style.height;oe.style.height="auto";const ae=oe.offsetHeight;oe.style.height=ue;function ve(){u.updateToastInternal(n.id,{ref:O,height:ae,...n.transitionStatus==="starting"?{transitionStatus:void 0}:{}})}se?hn.flushSync(ve):ve()});qt($,[$]);function B(se,oe){let ue=se,ae=oe;return!c.includes("left")&&!c.includes("right")?ue=se>0?se**En:-(Math.abs(se)**En):(!c.includes("right")&&se>0&&(ue=se**En),!c.includes("left")&&se<0&&(ue=-(Math.abs(se)**En))),!c.includes("up")&&!c.includes("down")?ae=oe>0?oe**En:-(Math.abs(oe)**En):(!c.includes("down")&&oe>0&&(ae=oe**En),!c.includes("up")&&oe<0&&(ae=-(Math.abs(oe)**En))),{x:ue,y:ae}}function K(se){var ae;if(se.button!==0)return;se.pointerType==="touch"&&u.pauseTimers();const oe=wp(se.nativeEvent);if(!(oe&&oe.closest('button,a,input,textarea,[role="button"],[data-swipe-ignore]'))){if(R.current=!1,H.current=void 0,I.current=0,z.current={x:se.clientX,y:se.clientY},P.current=z.current,O.current){const ve=fP(O.current);F.current=ve,C(ve),b({x:ve.x,y:ve.y})}u.setHovering(!0),v(!0),m(!1),D(null),N.current=!0,(ae=O.current)==null||ae.setPointerCapture(se.pointerId)}}function U(se){if(!y)return;se.preventDefault(),N.current&&(z.current={x:se.clientX,y:se.clientY},N.current=!1);const{clientY:oe,clientX:ue,movementX:ae,movementY:ve}=se;(ve<0&&oe>P.current.y||ve>0&&oe<P.current.y)&&(P.current={x:P.current.x,y:oe}),(ae<0&&ue>P.current.x||ae>0&&ue<P.current.x)&&(P.current={x:ue,y:P.current.y});const Ce=ue-z.current.x,Le=oe-z.current.y,je=oe-P.current.y,Fe=ue-P.current.x;if(!h&&Math.sqrt(Ce*Ce+Le*Le)>=dP&&(m(!0),M===null)){const Ne=c.includes("left")||c.includes("right"),Ge=c.includes("up")||c.includes("down");if(Ne&&Ge){const Ae=Math.abs(Ce),G=Math.abs(Le);D(Ae>G?"horizontal":"vertical")}}let Pe;if(!H.current)M==="vertical"?Le>0?Pe="down":Le<0&&(Pe="up"):M==="horizontal"?Ce>0?Pe="right":Ce<0&&(Pe="left"):Math.abs(Ce)>=Math.abs(Le)?Pe=Ce>0?"right":"left":Pe=Le>0?"down":"up",Pe&&c.includes(Pe)&&(H.current=Pe,I.current=jv(Pe,Ce,Le),_(Pe));else{const ee=H.current,Ne=jv(ee,Fe,je);Ne>Wi?(R.current=!1,_(ee)):!(c.includes("left")&&c.includes("right"))&&!(c.includes("up")&&c.includes("down"))&&I.current-Ne>=hP&&(R.current=!0)}const Oe=B(Ce,Le);let Ee=F.current.x,q=F.current.y;M==="horizontal"?(c.includes("left")||c.includes("right"))&&(Ee+=Oe.x):(M==="vertical"||(c.includes("left")||c.includes("right"))&&(Ee+=Oe.x),(c.includes("up")||c.includes("down"))&&(q+=Oe.y)),b({x:Ee,y:q})}function te(se){var Ce;if(!y)return;if(v(!1),m(!1),D(null),(Ce=O.current)==null||Ce.releasePointerCapture(se.pointerId),R.current){b({x:x.x,y:x.y}),_(void 0);return}let oe=!1;const ue=w.x-x.x,ae=w.y-x.y;let ve;for(const Le of c){switch(Le){case"right":ue>Wi&&(oe=!0,ve="right");break;case"left":ue<-Wi&&(oe=!0,ve="left");break;case"down":ae>Wi&&(oe=!0,ve="down");break;case"up":ae<-Wi&&(oe=!0,ve="up");break}if(oe)break}oe?(_(ve),g(!0),u.closeToast(n.id)):(b({x:x.x,y:x.y}),_(void 0))}function Y(se){if(se.key==="Escape"){if(!O.current||!yi(O.current,Zl(Js(O.current))))return;u.closeToast(n.id)}}E.useEffect(()=>{if(!f)return;const se=O.current;if(!se)return;function oe(ue){yi(se,ue.target)&&ue.preventDefault()}return se.addEventListener("touchmove",oe,{passive:!1}),()=>{se.removeEventListener("touchmove",oe)}},[f]);function _e(){if(!y&&w.x===x.x&&w.y===x.y&&!d)return{[ss.swipeMovementX]:"0px",[ss.swipeMovementY]:"0px"};const se=w.x-x.x,oe=w.y-x.y;return{transition:y?"none":void 0,transform:y?`translateX(${w.x}px) translateY(${w.y}px) scale(${x.scale})`:void 0,[ss.swipeMovementX]:`${se}px`,[ss.swipeMovementY]:`${oe}px`}}const de=n.priority==="high",re={role:de?"alertdialog":"dialog",tabIndex:0,"aria-modal":!1,"aria-labelledby":S,"aria-describedby":L,"aria-hidden":de&&!Z?!0:void 0,onPointerDown:f?K:void 0,onPointerMove:f?U:void 0,onPointerUp:f?te:void 0,onKeyDown:Y,inert:nP(n.limited),style:{..._e(),[ss.index]:n.transitionStatus==="ending"?j:W,[ss.offsetY]:`${V}px`,[ss.height]:n.height?`${n.height}px`:void 0}},le=E.useMemo(()=>({rootRef:O,toast:n,titleId:S,setTitleId:k,descriptionId:L,setDescriptionId:A,swiping:y,swipeDirection:p,recalculateHeight:$,index:j,visibleIndex:W,expanded:Q}),[n,S,L,y,p,$,j,W,Q]),ne={transitionStatus:n.transitionStatus,expanded:Q,limited:n.limited||!1,type:n.type,swiping:le.swiping,swipeDirection:le.swipeDirection},fe=Ls("div",t,{ref:[r,le.rootRef],state:ne,stateAttributesMapping:uP,props:[re,s]});return T.jsx(wS.Provider,{value:le,children:fe})}),mP=E.forwardRef(function(t,r){const{render:n,className:i,id:a,children:l,...s}=t,{toast:o,setDescriptionId:c}=Sp(),f=l??o.description,u=!!f,p=up(a);qt(()=>{if(u)return c(p),()=>{c(void 0)}},[u,p,c]);const _={type:o.type},y=Ls("p",t,{ref:r,state:_,props:{...s,id:p,children:f}});return u?y:null}),gP=E.forwardRef(function(t,r){const{render:n,className:i,id:a,children:l,...s}=t,{toast:o,setTitleId:c}=Sp(),f=l??o.title,u=!!f,p=up(a);qt(()=>{if(u)return c(p),()=>{c(void 0)}},[u,p,c]);const _={type:o.type},y=Ls("h2",t,{ref:r,state:_,props:{...s,id:p,children:f}});return u?y:null}),vP=E.forwardRef(function(t,r){const{render:n,className:i,disabled:a,nativeButton:l=!0,...s}=t,o=_p(),{toast:c}=Sp(),f=o.useState("expanded"),[u,p]=E.useState(!1),{getButtonProps:_,buttonRef:y}=Vw({disabled:a,native:l}),v={type:c.type};return Ls("button",t,{ref:[r,y],state:v,props:[{"aria-hidden":!f&&!u,onClick(){o.closeToast(c.id)},onFocus(){p(!0)},onBlur(){p(!1)}},s,_]})});function _P(){const e=E.useContext(vp);if(!e)throw new Error(Yr(73));const t=e.useState("toasts");return E.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function yP(){const e=new Set;function t(r){e.forEach(n=>n(r))}return{" subscribe":function(n){return e.add(n),()=>{e.delete(n)}},add(r){const n=r.id||yS("toast"),i={...r,id:n,transitionStatus:"starting"};return t({action:"add",options:i}),n},close(r){t({action:"close",options:{id:r}})},update(r,n){t({action:"update",options:{...n,id:r}})},promise(r,n){let i=r;return t({action:"promise",options:{...n,promise:r,setPromise(a){i=a}}}),i}}}const wP=5e3,SS=yP();function SP({toast:e}){return T.jsxs(pP,{toast:e,className:Yl("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:[T.jsxs("div",{className:"flex-1 min-w-0",children:[T.jsx(gP,{className:Yl("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&&T.jsx(mP,{className:"mt-1 text-xs text-muted line-clamp-2",children:e.description})]}),T.jsx(vP,{className:"shrink-0 text-muted hover:text-primary transition-colors","aria-label":"Close",children:T.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:[T.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),T.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}function xP(){const{toasts:e}=_P();return T.jsx(T.Fragment,{children:e.map(t=>T.jsx(SP,{toast:t},t.id))})}function bP(){return T.jsxs(eP,{timeout:wP,toastManager:SS,children:[T.jsx(xP,{}),T.jsx(rP,{className:"fixed bottom-4 right-4 z-[100] flex flex-col gap-2"})]})}const Fv=["CONNECTING","OPEN","CLOSING","CLOSED"],CP=3e3,EP=8e3,kP=15e3,LP=5e3,Iu=2e4,TP=1e4,RP=1500,DP=5e3,MP=750,AP=4,PP=5e3;class IP{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.pingSeq=0,this.connectionEpoch=0,this.consecutiveFailures=0,this.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{var t;if(Ke("ws_visibility",{state:document.visibilityState,...this.wsSnap()},"info"),document.visibilityState==="visible"){const r=Date.now(),n=r-this.lastTick;this.lastTick=r,Ke("ws_resume",{gapMs:n,...this.wsSnap()},"info"),((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?this.verifyConnection():this.forceReconnect("visibilitychange",!0)}else this.stopHeartbeat(),this.cancelVerify(),this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)},this.onPageShow=t=>{Ke("ws_pageshow",{persisted:t.persisted,...this.wsSnap()},"info"),t.persisted&&(this.lastTick=Date.now(),this.forceReconnect("pageshow",!0))}}wsSnap(){return{status:this.status,ws:this.ws?Fv[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){const a=this.ws.readyState===WebSocket.OPEN;if(a&&this.status==="connected"){Ke("ws_connect_skip",{reason:"already_open",...this.wsSnap()});return}Ke("ws_connect_destroy_zombie",{reason:a?"open_desynced":"not_open",...this.wsSnap()}),this.destroySocket()}this.manualClose=!1,this.clearConnectTimer(),this.setStatus("connecting");const r=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`;Ke("ws_connect",{url:r,resume:this.isResumeAttempt,...this.wsSnap()},"info");const n=new WebSocket(r);this.ws=n,this.leakedSockets.add(n);const i=this.isResumeAttempt?EP:CP;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{if(this.ws!==n)return;this.connectTimer=null,n.readyState===WebSocket.OPEN&&this.status==="connected"||(Ke("ws_connect_timeout",{wsState:Fv[n.readyState],managerStatus:this.status,timeoutMs:i,...this.wsSnap()},"info"),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect())},i),n.onopen=()=>{if(this.ws!==n){Ke("ws_onopen_stale",this.wsSnap(),"info");return}Ke("ws_onopen",this.wsSnap(),"info"),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=0,this.connectionEpoch+=1,this.leakedSockets.delete(n),this.setStatus("connected"),this.startHeartbeat()},n.onmessage=a=>{try{const l=a.data,s=performance.now(),o=JSON.parse(l),c=performance.now()-s,f=o;if(f._parseMs=Math.round(c),f._rawLength=l.length,o.type==="pong"){o.seq===this.pingSeq&&(this.clearPongTimer(),this.verifyTimer!==null&&(this.cancelVerify(),Ke("ws_verify_ok",this.wsSnap(),"info"),this.startHeartbeat(DP)));return}this.listeners.forEach(u=>u(o))}catch{}},n.onerror=()=>{this.ws===n&&(Ke("ws_onerror",this.wsSnap(),"info"),this.clearConnectTimer())},n.onclose=a=>{if(this.ws!==n){Ke("ws_onclose_stale",{code:a.code,...this.wsSnap()},"info");return}Ke("ws_onclose",{code:a.code,reason:a.reason,clean:a.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),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(()=>{const t=Date.now(),r=t-this.lastTick;this.isHidden()||(r>kP&&(Ke("ws_time_jump",{gapMs:r,...this.wsSnap()},"info"),this.forceReconnect("time_jump",!0)),this.lastTick=t)},LP))}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(t){var r;if(((r=this.ws)==null?void 0:r.readyState)!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(t)),!0}catch(n){return Ke("ws_send_error",{messageType:t.type,error:n instanceof Error?n.message:String(n),...this.wsSnap()},"info"),this.destroySocket(),this.scheduleReconnect(),!1}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}subscribeStatus(t){return this.statusListeners.add(t),t(this.status,this.error,this.connectionEpoch),()=>this.statusListeners.delete(t)}getStatus(){return this.status}getConnectionEpoch(){return this.connectionEpoch}verifyConnection(){this.cancelVerify(),this.stopHeartbeat(),this.pingSeq+=1;const t=this.pingSeq,r=this.ws;if(Ke("ws_verify",{seq:t,...this.wsSnap()},"info"),!this.send({type:"ping",seq:t})){Ke("ws_verify_send_fail",this.wsSnap(),"info"),this.forceReconnect("verify_send_fail",!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===r&&(Ke("ws_verify_timeout",this.wsSnap(),"info"),this.forceReconnect("verify_timeout",!0))},RP)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(t="unknown",r=!1){var a;if(this.manualClose){Ke("ws_force_skip",{trigger:t,reason:"manual_close"});return}const n=Date.now(),i=r?200:500;if(n-this.lastForceReconnectTs<i){Ke("ws_force_skip",{trigger:t,reason:"debounce",force:r});return}if(!r&&((a=this.ws)==null?void 0:a.readyState)===WebSocket.OPEN&&this.status==="connected"){Ke("ws_force_skip",{trigger:t,reason:"already_connected"});return}this.lastForceReconnectTs=n,Ke("ws_force_reconnect",{trigger:t,force:r,...this.wsSnap()},"info"),this.reconnectAttempts=0,this.consecutiveFailures=0,this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.destroySocket(),r?(this.purgeLeakedSockets(),this.isResumeAttempt=!0,this.setStatus("reconnecting"),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},MP)):this.connect()}startHeartbeat(t){this.stopHeartbeat();const r=()=>{var n;((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN&&(this.pingSeq+=1,this.send({type:"ping",seq:this.pingSeq})&&(this.clearPongTimer(),this.pongTimer=window.setTimeout(()=>{this.pongTimer=null,Ke("ws_pong_timeout",this.wsSnap(),"info"),this.destroySocket(),this.scheduleReconnect()},TP)))};t!==void 0&&t<Iu?this.heartbeatTimer=window.setTimeout(()=>{r(),this.heartbeatTimer=window.setInterval(r,Iu)},t):this.heartbeatTimer=window.setInterval(r,Iu)}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(t,r=null){this.status=t,this.error=r,this.statusListeners.forEach(n=>n(t,r,this.connectionEpoch))}scheduleReconnect(){if(this.stopHeartbeat(),this.isHidden()){Ke("ws_schedule_skip",{reason:"hidden",...this.wsSnap()}),this.setStatus("reconnecting");return}if(this.consecutiveFailures>=AP){Ke("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()},PP);return}this.reconnectAttempts+=1;const t=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);Ke("ws_schedule_reconnect",{delay:t,...this.wsSnap()}),this.setStatus("reconnecting"),this.reconnectTimer&&window.clearTimeout(this.reconnectTimer),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},t)}isHidden(){return typeof document<"u"&&document.visibilityState==="hidden"}clearConnectTimer(){this.connectTimer&&(window.clearTimeout(this.connectTimer),this.connectTimer=null)}destroySocket(){if(this.clearConnectTimer(),this.stopHeartbeat(),this.cancelVerify(),!this.ws)return;const t=this.ws;this.ws=null,this.leakedSockets.add(t),t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}}purgeLeakedSockets(){if(this.leakedSockets.size!==0){Ke("ws_purge_leaked",{count:this.leakedSockets.size},"info");for(const t of this.leakedSockets)try{t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null,t.close()}catch{}this.leakedSockets.clear()}}}const sn=new IP;function OP(){const e=qe(o=>o.setConnectionStatus),t=qe(o=>o.setConnectionError),[r,n]=E.useState(sn.getStatus()),[i,a]=E.useState(sn.getConnectionEpoch());E.useEffect(()=>{sn.connect(),sn.startLifecycleListeners();const o=sn.subscribeStatus((c,f,u)=>{n(c),a(u),e(c),t(f)});return()=>{o(),sn.stopLifecycleListeners()}},[t,e]);const l=E.useMemo(()=>o=>{sn.send(o)},[]),s=E.useMemo(()=>sn.subscribe.bind(sn),[]);return{status:r,connectionEpoch:i,sendMessage:l,subscribe:s}}const BP=100;function NP({viewport:e,win:t,doc:r}){if(!e)return!1;const n=Math.max(0,e.offsetTop||0),i=Math.max(0,e.offsetLeft||0),a=t.innerHeight-(e.height+n),l=Math.max(0,a),s=Math.max(0,e.height||0),o=Math.max(0,e.width||0);return r.documentElement.style.setProperty("--keyboard-inset",`${l}px`),r.documentElement.style.setProperty("--viewport-offset-top",`${n}px`),r.documentElement.style.setProperty("--viewport-offset-left",`${i}px`),r.documentElement.style.setProperty("--visual-viewport-height",`${s}px`),r.documentElement.style.setProperty("--visual-viewport-width",`${o}px`),l>BP?r.documentElement.classList.add("keyboard-visible"):r.documentElement.classList.remove("keyboard-visible"),!0}function jP(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 FP(){E.useEffect(()=>{const e=window.visualViewport;if(!e)return;let t=null,r=null;const n=()=>{var v;const _=document.activeElement;if(!_)return!1;const y=(v=_.tagName)==null?void 0:v.toLowerCase();return y==="input"||y==="textarea"?!0:!!_.isContentEditable},i=()=>{NP({viewport:e,win:window,doc:document})},a=()=>{if(typeof window.requestAnimationFrame!="function"){i();return}t!==null&&window.cancelAnimationFrame(t);const _=performance.now(),y=()=>{i(),performance.now()-_<1500?t=window.requestAnimationFrame(y):t=null};t=window.requestAnimationFrame(y)},l=()=>{if(!n()){o();return}i()},s=()=>{r!==null||typeof window.setInterval!="function"||(r=window.setInterval(l,250),l())},o=()=>{r===null||typeof window.clearInterval!="function"||(window.clearInterval(r),r=null)},c=()=>{n()?(a(),s(),i()):o()},f=()=>{c()},u=()=>{c()},p=()=>{a()};return i(),c(),e.addEventListener("resize",i),e.addEventListener("scroll",i),typeof window.addEventListener=="function"&&(window.addEventListener("resize",i),window.addEventListener("orientationchange",p)),typeof document.addEventListener=="function"&&(document.addEventListener("focusin",f),document.addEventListener("focusout",u),document.addEventListener("focus",f,!0),document.addEventListener("blur",u,!0)),()=>{e.removeEventListener("resize",i),e.removeEventListener("scroll",i),typeof window.removeEventListener=="function"&&(window.removeEventListener("resize",i),window.removeEventListener("orientationchange",p)),typeof document.removeEventListener=="function"&&(document.removeEventListener("focusin",f),document.removeEventListener("focusout",u),document.removeEventListener("focus",f,!0),document.removeEventListener("blur",u,!0)),t!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(t),o(),jP(document)}},[])}function HP(){const[e,t]=E.useState(!1),[r,n]=E.useState(void 0),[i,a]=E.useState(void 0),[l,s]=E.useState(void 0),[o,c]=E.useState(!1),[f,u]=E.useState(null),[p,_]=E.useState(null),y=qe(q=>q.sessions),v=qe(q=>q.agentSessions),h=qe(q=>q.selectedSessionId),m=qe(q=>q.setSessions),d=qe(q=>q.setAgentSessions),g=qe(q=>q.setHostStatuses),w=qe(q=>q.updateSession),b=qe(q=>q.setSelectedSessionId),x=qe(q=>q.hasLoaded),C=qe(q=>q.connectionStatus),S=qe(q=>q.connectionError),k=qe(q=>q.clearExitingSession),L=qe(q=>q.markSessionExiting),A=qe(q=>q.setRemoteAllowControl),M=qe(q=>q.setRemoteAllowAttach),D=qe(q=>q.setHostLabel),O=qe(q=>q.hostStatuses),z=qe(q=>q.remoteAllowControl),F=qe(q=>q.hostLabel),H=ql(q=>q.theme),I=hC(),R=pe(q=>q.defaultProjectDir),P=pe(q=>q.commandPresets),N=pe(q=>q.defaultPresetId),j=pe(q=>q.lastProjectPath),W=pe(q=>q.setLastProjectPath),V=pe(q=>q.addRecentPath),Z=pe(q=>q.shortcutModifier),Q=pe(q=>q.sidebarWidth),$=pe(q=>q.setSidebarWidth),B=pe(q=>q.projectFilters),K=pe(q=>q.hostFilters),U=pe(q=>q.soundOnPermission),te=pe(q=>q.soundOnIdle),{sendMessage:Y,subscribe:_e,connectionEpoch:de}=OP();FP(),E.useEffect(()=>{if(typeof document>"u"||!U&&!te)return;let q=!1;const ee=()=>{q&&!J3()||(q=!0,fd())};return document.addEventListener("click",ee,{passive:!0}),document.addEventListener("keydown",ee,{passive:!0}),document.addEventListener("touchstart",ee,{passive:!0}),()=>{document.removeEventListener("click",ee),document.removeEventListener("keydown",ee),document.removeEventListener("touchstart",ee)}},[U,te]);const re=E.useRef(!1),le=E.useCallback(q=>{q.preventDefault(),re.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);E.useEffect(()=>{if(typeof document>"u"||typeof document.addEventListener!="function")return;const q=Ne=>{if(!re.current)return;const Ge=Ne.clientX;$(Math.max(ty,Math.min(ry,Ge)))},ee=()=>{re.current&&(re.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",ee),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",ee)}},[$]),E.useEffect(()=>{const q=_e(ee=>{var Ne,Ge;if(ee.type==="sessions"){const Ae=qe.getState().sessions,{soundOnPermission:G,soundOnIdle:me}=pe.getState();if(G||me)for(const J of ee.sessions){const Se=Ae.find(ie=>ie.id===J.id);Se&&Se.status!==J.status&&(Se.status!=="permission"&&J.status==="permission"&&G&&pd(),Se.status==="working"&&J.status==="waiting"&&me&&md())}m(ee.sessions)}if(ee.type==="host-status"&&g(ee.hosts),ee.type==="server-config"&&(A(ee.remoteAllowControl),M(ee.remoteAllowAttach),D(ee.hostLabel),ee.clientLogLevel&&YR(ee.clientLogLevel)),ee.type==="session-update"){const G=qe.getState().sessions.find(Se=>Se.id===ee.session.id),me=G==null?void 0:G.status,J=ee.session.status;if(w(ee.session),me){const{soundOnPermission:Se,soundOnIdle:ie}=pe.getState();me!=="permission"&&J==="permission"&&Se&&pd(),me==="working"&&J==="waiting"&&ie&&md()}}if(ee.type==="session-created"){const Ae=qe.getState().sessions;Ae.some(J=>J.id===ee.session.id)||m([ee.session,...Ae]),b(ee.session.id),V(ee.session.projectPath);const{projectFilters:G,setProjectFilters:me}=pe.getState();G.length>0&&!G.includes(ee.session.projectPath)&&me([...G,ee.session.projectPath])}if(ee.type==="session-removed"){const Ae=qe.getState().sessions,G=Ae.filter(me=>me.id!==ee.sessionId);G.length!==Ae.length&&m(G)}if(ee.type==="agent-sessions"&&d(ee.active,ee.inactive),ee.type==="session-orphaned"&&!ee.supersededBy){const Ae=qe.getState().sessions,G=Ae.filter(me=>{var J;return((J=me.agentSessionId)==null?void 0:J.trim())!==ee.session.sessionId});G.length!==Ae.length&&m(G)}if(ee.type==="session-activated"){const Ae=qe.getState().sessions.find(G=>G.tmuxWindow===ee.window);Ae&&w({...Ae,agentSessionId:ee.session.sessionId,agentSessionName:ee.session.displayName,logFilePath:ee.session.logFilePath,isPinned:ee.session.isPinned,lastUserMessage:ee.session.lastUserMessage??Ae.lastUserMessage})}if(ee.type==="session-resume-result")if(ee.ok&&ee.session){const Ae=qe.getState().sessions;Ae.some(G=>G.id===ee.session.id)||m([ee.session,...Ae]),b(ee.session.id)}else ee.ok||(u(`${(Ne=ee.error)==null?void 0:Ne.code}: ${(Ge=ee.error)==null?void 0:Ge.message}`),window.setTimeout(()=>u(null),6e3));ee.type==="terminal-error"&&(!ee.sessionId||ee.sessionId===h)&&(u(`${ee.code}: ${ee.message}`),window.setTimeout(()=>u(null),6e3)),ee.type==="terminal-ready"&&ee.sessionId===h&&u(null),ee.type==="error"&&(u(ee.message),window.setTimeout(()=>u(null),6e3)),ee.type==="kill-failed"&&(k(ee.sessionId),u(ee.message),window.setTimeout(()=>u(null),6e3)),ee.type==="session-pin-result"&&!ee.ok&&ee.error&&(u(ee.error),window.setTimeout(()=>u(null),6e3)),ee.type==="session-resurrection-failed"&&SS.add({title:"Session resurrection failed",description:`"${ee.displayName}" could not be resumed: ${ee.error}`,type:"error",timeout:8e3})});return()=>{q()}},[h,V,k,Y,b,m,d,g,A,M,D,_e,w]);const ne=E.useMemo(()=>y.find(q=>q.id===h)||null,[h,y]);E.useEffect(()=>{ne!=null&&ne.projectPath&&!ne.remote&&W(ne.projectPath)},[ne==null?void 0:ne.projectPath,ne==null?void 0:ne.remote,W]);const fe=pe(q=>q.sessionSortMode),ge=pe(q=>q.sessionSortDirection),se=pe(q=>q.manualSessionOrder),oe=E.useMemo(()=>np(y,{mode:fe,direction:ge,manualOrder:se}),[y,fe,ge,se]),ue=E.useMemo(()=>{let q=oe;return B.length>0&&(q=q.filter(ee=>B.includes(ee.projectPath))),K.length>0&&(q=q.filter(ee=>K.includes(ee.host??""))),q},[oe,B,K]);E.useEffect(()=>{h&&ue.length>0&&!ue.some(q=>q.id===h)&&b(ue[0].id)},[h,ue,b]),E.useEffect(()=>{window.matchMedia("(max-width: 767px)").matches&&x&&h===null&&oe.length>0&&b(oe[0].id)},[x,h,oe,b]);const ae=E.useCallback(q=>{L(q),Y({type:"session-kill",sessionId:q})},[L,Y]);E.useEffect(()=>{const q=ea(Z),ee=Ne=>{if(Ne.defaultPrevented)return;const Ge=Ne.code,Ae=WC(Ne,q);if(Ae&&(Ge==="BracketLeft"||Ge==="BracketRight")){Ne.preventDefault();const G=ue;if(G.length===0)return;const me=G.findIndex(ie=>ie.id===h);if(me===-1){b(G[0].id);return}const Se=(me+(Ge==="BracketLeft"?-1:1)+G.length)%G.length;b(G[Se].id);return}if(Ae&&Ge==="KeyN"){Ne.preventDefault(),!e&&I&&t(!0);return}if(Ae&&Ge==="KeyX"){Ne.preventDefault(),h&&!e&&ae(h);return}};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[e,h,b,ue,ae,Z,I]);const ve=()=>I?(n(void 0),a(void 0),s(void 0),t(!0),!0):!1,Ce=()=>c(!0),Le=(q,ee,Ne,Ge)=>{Y({type:"session-create",projectPath:q,name:ee,command:Ne,host:Ge}),Ge||W(q)},je=q=>{Y({type:"session-resume",sessionId:q})},Fe=(q,ee)=>{Y({type:"session-rename",sessionId:q,newName:ee})},Pe=E.useCallback(q=>{const ee=y.find(Ne=>Ne.id===q);ee&&Y({type:"session-create",projectPath:ee.projectPath,command:ee.command||void 0,host:ee.remote&&ee.host?ee.host:void 0})},[y,Y]),Oe=E.useCallback((q,ee)=>{Y({type:"session-pin",sessionId:q,isPinned:ee})},[Y]);E.useEffect(()=>{document.documentElement.setAttribute("data-theme",H)},[H]),E.useEffect(()=>{fetch("/api/server-info").then(q=>q.json()).then(q=>_(q)).catch(()=>{})},[]);const Ee=E.useMemo(()=>F?O.filter(q=>q.host!==F):O,[O,F]);return T.jsxs("div",{className:"flex h-full overflow-hidden",children:[T.jsxs("div",{className:"hidden h-full flex-col md:flex md:shrink-0",style:{width:Q},children:[T.jsx(KC,{connectionStatus:C,onNewSession:ve,onOpenSettings:Ce,tailscaleIp:(p==null?void 0:p.tailscaleIp)??null}),T.jsx(fw,{sessions:y,inactiveSessions:v.inactive,selectedSessionId:h,onSelect:b,onRename:Fe,onResume:je,onKill:ae,onDuplicate:Pe,onSetPinned:Oe,loading:!x,error:S||f})]}),T.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:le}),T.jsx(fM,{session:ne,sessions:ue,connectionStatus:C,connectionEpoch:de,sendMessage:Y,subscribe:_e,onClose:()=>b(null),onSelectSession:b,onNewSession:ve,onKillSession:ae,onRenameSession:Fe,onOpenSettings:Ce,onResumeSession:je,onSetPinned:Oe,inactiveSessions:v.inactive,loading:!x,error:S||f}),T.jsx(mM,{isOpen:e,onClose:()=>t(!1),onCreate:Le,defaultProjectDir:R,commandPresets:P,defaultPresetId:N,lastProjectPath:j,activeProjectPath:ne&&!ne.remote?ne.projectPath:void 0,remoteHosts:Ee,remoteAllowControl:z,initialHost:r,initialPath:i,initialCommand:l}),T.jsx(Z3,{isOpen:o,onClose:()=>c(!1)}),T.jsx(bP,{})]})}const $P="modulepreload",zP=function(e){return"/"+e},Hv={},UP=function(t,r,n){let i=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),s=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=Promise.allSettled(r.map(o=>{if(o=zP(o),o in Hv)return;Hv[o]=!0;const c=o.endsWith(".css"),f=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${f}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":$P,c||(u.as="script"),u.crossOrigin="",u.href=o,s&&u.setAttribute("nonce",s),document.head.appendChild(u),c)return new Promise((p,_)=>{u.addEventListener("load",p),u.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${o}`)))})}))}function a(l){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=l,window.dispatchEvent(s),!s.defaultPrevented)throw l}return i.then(l=>{for(const s of l||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};function WP(e={}){const{immediate:t=!1,onNeedRefresh:r,onOfflineReady:n,onRegistered:i,onRegisteredSW:a,onRegisterError:l}=e;let s,o;const c=async(u=!0)=>{await o};async function f(){if("serviceWorker"in navigator){if(s=await UP(async()=>{const{Workbox:u}=await import("./workbox-window.prod.es5-vqzQaGvo.js");return{Workbox:u}},[]).then(({Workbox:u})=>new u("/sw.js",{scope:"/",type:"classic"})).catch(u=>{l==null||l(u)}),!s)return;s.addEventListener("activated",u=>{(u.isUpdate||u.isExternal)&&window.location.reload()}),s.addEventListener("installed",u=>{u.isUpdate||n==null||n()}),s.register({immediate:t}).then(u=>{a?a("/sw.js",u):i==null||i(u)}).catch(u=>{l==null||l(u)})}}return o=f(),c}Zo()&&document.documentElement.classList.add("ios");$C()&&document.documentElement.classList.add("ios-pwa");WP({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},5*60*1e3),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&t.update()}))}});const xS=document.getElementById("root");if(!xS)throw new Error("Root element not found");ey(xS).render(T.jsx(gt.StrictMode,{children:T.jsx(HP,{})}));
316
+ */var Ec=E,LA=mS;function TA(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var RA=typeof Object.is=="function"?Object.is:TA,DA=LA.useSyncExternalStore,MA=Ec.useRef,AA=Ec.useEffect,PA=Ec.useMemo,IA=Ec.useDebugValue;vS.useSyncExternalStoreWithSelector=function(e,t,r,n,i){var a=MA(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=PA(function(){function o(_){if(!c){if(c=!0,f=_,_=n(_),i!==void 0&&l.hasValue){var y=l.value;if(i(y,_))return u=y}return u=_}if(y=u,RA(f,_))return y;var v=n(_);return i!==void 0&&i(y,v)?(f=_,y):(f=_,u=v)}var c=!1,f,u,p=r===void 0?null:r;return[function(){return o(t())},p===null?void 0:function(){return o(p())}]},[t,r,n,i]);var s=DA(e,a[0],a[1]);return AA(function(){l.hasValue=!0,l.value=s},[s]),IA(s),s};gS.exports=vS;var OA=gS.exports;const BA=lp(19),NA=BA?FA:HA;function _S(e,t,r,n,i){return NA(e,t,r,n,i)}function jA(e,t,r,n,i){const a=E.useCallback(()=>t(e.getSnapshot(),r,n,i),[e,t,r,n,i]);return mS.useSyncExternalStore(e.subscribe,a,a)}function FA(e,t,r,n,i){return jA(e,t,r,n,i)}function HA(e,t,r,n,i){return OA.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getSnapshot,a=>t(a,r,n,i))}class $A{constructor(t){rt(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));rt(this,"getSnapshot",()=>this.state);this.state=t,this.listeners=new Set,this.updateTick=0}setState(t){if(this.state===t)return;this.state=t,this.updateTick+=1;const r=this.updateTick;for(const n of this.listeners){if(r!==this.updateTick)return;n(t)}}update(t){for(const r in t)if(!Object.is(this.state[r],t[r])){this.setState({...this.state,...t});return}}set(t,r){Object.is(this.state[t],r)||this.setState({...this.state,[t]:r})}notifyAll(){const t={...this.state};this.setState(t)}use(t,r,n,i){return _S(this,t,r,n,i)}}class zA extends $A{constructor(t,r={},n){super(t),this.context=r,this.selectors=n}useSyncedValue(t,r){E.useDebugValue(t),qt(()=>{this.state[t]!==r&&this.set(t,r)},[t,r])}useSyncedValueWithCleanup(t,r){const n=this;qt(()=>(n.state[t]!==r&&n.set(t,r),()=>{n.set(t,void 0)}),[n,t,r])}useSyncedValues(t){const r=this,n=Object.values(t);qt(()=>{r.update(t)},[r,...n])}useControlledProp(t,r){E.useDebugValue(t);const n=r!==void 0;qt(()=>{n&&!Object.is(this.state[t],r)&&super.setState({...this.state,[t]:r})},[t,r,n])}select(t,r,n,i){const a=this.selectors[t];return a(this.state,r,n,i)}useState(t,r,n,i){return E.useDebugValue(t),_S(this,this.selectors[t],r,n,i)}useContextCallback(t,r){E.useDebugValue(t);const n=Xr(r??ur);this.context[t]=n}useStateSetter(t){const r=E.useRef(void 0);return r.current===void 0&&(r.current=n=>{this.set(t,n)}),r.current}observe(t,r){let n;typeof t=="function"?n=t:n=this.selectors[t];let i=n(this.state);return r(i,i,this),this.subscribe(a=>{const l=n(a);if(!Object.is(i,l)){const s=i;i=l,r(l,s,this)}})}}const $a=null;class UA{constructor(){rt(this,"callbacks",[]);rt(this,"callbacksCount",0);rt(this,"nextId",1);rt(this,"startId",1);rt(this,"isScheduled",!1);rt(this,"tick",t=>{var i;this.isScheduled=!1;const r=this.callbacks,n=this.callbacksCount;if(this.callbacks=[],this.callbacksCount=0,this.startId=this.nextId,n>0)for(let a=0;a<r.length;a+=1)(i=r[a])==null||i.call(r,t)})}request(t){const r=this.nextId;return this.nextId+=1,this.callbacks.push(t),this.callbacksCount+=1,(!this.isScheduled||!1)&&(requestAnimationFrame(this.tick),this.isScheduled=!0),r}cancel(t){const r=t-this.startId;r<0||r>=this.callbacks.length||(this.callbacks[r]=null,this.callbacksCount-=1)}}const za=new UA;class yp{constructor(){rt(this,"currentId",$a);rt(this,"cancel",()=>{this.currentId!==$a&&(za.cancel(this.currentId),this.currentId=$a)});rt(this,"disposeEffect",()=>this.cancel)}static create(){return new yp}static request(t){return za.request(t)}static cancel(t){return za.cancel(t)}request(t){this.cancel(),this.currentId=za.request(()=>{this.currentId=$a,t()})}}function WA(){const e=ks(yp.create).current;return gp(e.disposeEffect),e}const Ui=0;class Go{constructor(){rt(this,"currentId",Ui);rt(this,"clear",()=>{this.currentId!==Ui&&(clearTimeout(this.currentId),this.currentId=Ui)});rt(this,"disposeEffect",()=>this.clear)}static create(){return new Go}start(t,r){this.clear(),this.currentId=setTimeout(()=>{this.currentId=Ui,r()},t)}isStarted(){return this.currentId!==Ui}}function VA(){const e=ks(Go.create).current;return gp(e.disposeEffect),e}let Nv=0;function yS(e){return Nv+=1,`${e}-${Math.random().toString(36).slice(2,6)}-${Nv}`}function Js(e){return(e==null?void 0:e.ownerDocument)||document}function Mu(e,t){if(typeof e=="string")return{description:e};if(typeof e=="function"){const r=e(t);return typeof r=="string"?{description:r}:r}return e}const la=typeof navigator<"u",Au=YA(),KA=QA(),GA=JA();typeof CSS>"u"||!CSS.supports||CSS.supports("-webkit-backdrop-filter:none");Au.platform==="MacIntel"&&Au.maxTouchPoints>1||/iP(hone|ad|od)|iOS/.test(Au.platform);const qA=la&&/apple/i.test(navigator.vendor);la&&KA.toLowerCase().startsWith("mac")&&navigator.maxTouchPoints;const XA=GA.includes("jsdom/");function YA(){if(!la)return{platform:"",maxTouchPoints:-1};const e=navigator.userAgentData;return e!=null&&e.platform?{platform:e.platform,maxTouchPoints:navigator.maxTouchPoints}:{platform:navigator.platform??"",maxTouchPoints:navigator.maxTouchPoints??-1}}function JA(){if(!la)return"";const e=navigator.userAgentData;return e&&Array.isArray(e.brands)?e.brands.map(({brand:t,version:r})=>`${t}/${r}`).join(" "):navigator.userAgent}function QA(){if(!la)return"";const e=navigator.userAgentData;return e!=null&&e.platform?e.platform:navigator.platform??""}function Zl(e){var r;let t=e.activeElement;for(;((r=t==null?void 0:t.shadowRoot)==null?void 0:r.activeElement)!=null;)t=t.shadowRoot.activeElement;return t}function yi(e,t){var n;if(!e||!t)return!1;const r=(n=t.getRootNode)==null?void 0:n.call(t);if(e.contains(t))return!0;if(r&&zM(r)){let i=t;for(;i;){if(e===i)return!0;i=i.parentNode||i.host}}return!1}function wp(e){return"composedPath"in e?e.composedPath()[0]:e.target}function gd(e){if(!e||XA)return!0;try{return e.matches(":focus-visible")}catch{return!0}}const Ua=vA(e=>e.toasts,e=>{const t=new Map;let r=0,n=0;return e.forEach((i,a)=>{const l=i.transitionStatus==="ending";t.set(i.id,{value:i,domIndex:a,visibleIndex:l?-1:r,offsetY:n}),n+=i.height||0,l||(r+=1)}),t}),nn={toasts:Tr(e=>e.toasts),isEmpty:Tr(e=>e.toasts.length===0),toast:Tr(Ua,(e,t)=>{var r;return(r=e.get(t))==null?void 0:r.value}),toastIndex:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.domIndex)??-1}),toastOffsetY:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.offsetY)??0}),toastVisibleIndex:Tr(Ua,(e,t)=>{var r;return((r=e.get(t))==null?void 0:r.visibleIndex)??-1}),hovering:Tr(e=>e.hovering),focused:Tr(e=>e.focused),expanded:Tr(e=>e.hovering||e.focused),expandedOrOutOfFocus:Tr(e=>e.hovering||e.focused||!e.isWindowFocused),prevFocusElement:Tr(e=>e.prevFocusElement)};class ZA extends zA{constructor(r){super(r,{},nn);rt(this,"timers",new Map);rt(this,"areTimersPaused",!1);rt(this,"setViewport",r=>{this.set("viewport",r)});rt(this,"disposeEffect",()=>()=>{this.timers.forEach(r=>{var n;(n=r.timeout)==null||n.clear()}),this.timers.clear()});rt(this,"addToast",r=>{const{toasts:n,timeout:i,limit:a}=this.state,l=r.id||yS("toast"),s={...r,id:l,transitionStatus:"starting"},o=[s,...n],c=o.filter(u=>u.transitionStatus!=="ending");if(c.length>a){const u=c.length-a,p=c.slice(-u),_=new Set(p.map(y=>y.id));this.setToasts(o.map(y=>{const v=_.has(y.id);return y.limited!==v?{...y,limited:v}:y}))}else this.setToasts(o.map(u=>u.limited?{...u,limited:!1}:u));const f=s.timeout??i;return s.type!=="loading"&&f>0&&this.scheduleTimer(l,f,()=>this.closeToast(l)),nn.expandedOrOutOfFocus(this.state)&&this.pauseTimers(),l});rt(this,"updateToast",(r,n)=>{this.updateToastInternal(r,n)});rt(this,"updateToastInternal",(r,n)=>{var v,h;const{timeout:i,toasts:a}=this.state,l=nn.toast(this.state,r)??null;if(!l||l.transitionStatus==="ending")return;const s={...l,...n};this.setToasts(a.map(m=>m.id===r?{...m,...n}:m));const o=s.timeout??i,c=(l==null?void 0:l.timeout)??i,f=Object.hasOwn(n,"timeout"),u=s.transitionStatus!=="ending"&&s.type!=="loading"&&o>0,p=this.timers.has(r),_=c!==o,y=(l==null?void 0:l.type)==="loading";if(!u&&p){const m=this.timers.get(r);(v=m==null?void 0:m.timeout)==null||v.clear(),this.timers.delete(r);return}if(u&&(!p||_||f||y)){const m=this.timers.get(r);m&&((h=m.timeout)==null||h.clear(),this.timers.delete(r)),this.scheduleTimer(r,o,()=>this.closeToast(r)),nn.expandedOrOutOfFocus(this.state)&&this.pauseTimers()}});rt(this,"closeToast",r=>{var c;const n=nn.toast(this.state,r);(c=n==null?void 0:n.onClose)==null||c.call(n);const{limit:i,toasts:a}=this.state;let l=0;const s=a.map(f=>{if(f.id===r)return{...f,transitionStatus:"ending",height:0};if(f.transitionStatus==="ending")return f;const u=l>=i;return l+=1,f.limited!==u?{...f,limited:u}:f}),o=this.timers.get(r);o&&o.timeout&&(o.timeout.clear(),this.timers.delete(r)),this.handleFocusManagement(r),this.setToasts(s)});rt(this,"promiseToast",(r,n)=>{const i=Mu(n.loading),a=this.addToast({...i,type:"loading"}),l=r.then(s=>{const o=Mu(n.success,s);return this.updateToast(a,{...o,type:"success",timeout:o.timeout}),s}).catch(s=>{const o=Mu(n.error,s);return this.updateToast(a,{...o,type:"error",timeout:o.timeout}),Promise.reject(s)});return{}.hasOwnProperty.call(n,"setPromise")&&n.setPromise(l),l});rt(this,"handleDocumentPointerDown",r=>{if(r.pointerType!=="touch")return;const n=wp(r);yi(this.state.viewport,n)||(this.resumeTimers(),this.update({hovering:!1,focused:!1}))})}setFocused(r){this.set("focused",r)}setHovering(r){this.set("hovering",r)}setIsWindowFocused(r){this.set("isWindowFocused",r)}setPrevFocusElement(r){this.set("prevFocusElement",r)}removeToast(r){var l;const n=nn.toastIndex(this.state,r);if(n===-1)return;const i=this.state.toasts[n];(l=i==null?void 0:i.onRemove)==null||l.call(i);const a=[...this.state.toasts];a.splice(n,1),this.setToasts(a)}pauseTimers(){this.areTimersPaused||(this.areTimersPaused=!0,this.timers.forEach(r=>{if(r.timeout){r.timeout.clear();const n=Date.now()-r.start,i=r.delay-n;r.remaining=i>0?i:0}}))}resumeTimers(){this.areTimersPaused&&(this.areTimersPaused=!1,this.timers.forEach((r,n)=>{r.remaining=r.remaining>0?r.remaining:r.delay,r.timeout??(r.timeout=Go.create()),r.timeout.start(r.remaining,()=>{this.timers.delete(n),r.callback()}),r.start=Date.now()}))}restoreFocusToPrevElement(){var r;(r=this.state.prevFocusElement)==null||r.focus({preventScroll:!0})}scheduleTimer(r,n,i){const a=Date.now(),l=!nn.expandedOrOutOfFocus(this.state),s=l?Go.create():void 0;s==null||s.start(n,()=>{this.timers.delete(r),i()}),this.timers.set(r,{timeout:s,start:l?a:0,delay:n,remaining:n,callback:i})}setToasts(r){const n={toasts:r};r.length===0&&(n.hovering=!1,n.focused=!1),this.update(n)}handleFocusManagement(r){var o,c;const n=Zl(Js(this.state.viewport));if(!this.state.viewport||!yi(this.state.viewport,n)||!gd(n))return;const i=nn.toasts(this.state),a=nn.toastIndex(this.state,r);let l=null,s=a+1;for(;s<i.length;){if(i[s].transitionStatus!=="ending"){l=i[s];break}s+=1}if(!l)for(s=a-1;s>=0;){if(i[s].transitionStatus!=="ending"){l=i[s];break}s-=1}l?(c=(o=l.ref)==null?void 0:o.current)==null||c.focus():this.restoreFocusToPrevElement()}}const eP=function(t){const{children:r,timeout:n=5e3,limit:i=3,toastManager:a}=t,l=ks(()=>new ZA({timeout:n,limit:i,viewport:null,toasts:[],hovering:!1,focused:!1,isWindowFocused:!0,prevFocusElement:null})).current;return gp(l.disposeEffect),E.useEffect(function(){return a?a[" subscribe"](({action:c,options:f})=>{const u=f.id;c==="promise"&&f.promise?l.promiseToast(f.promise,f):c==="update"&&u?l.updateToast(u,f):c==="close"&&u?l.closeToast(u):l.addToast(f)}):void 0},[l,n,a]),l.useSyncedValues({timeout:n,limit:i}),T.jsx(vp.Provider,{value:l,children:r})},Pu=E.forwardRef(function(t,r){const[n,i]=E.useState();qt(()=>{qA&&i("button")},[]);const a={tabIndex:0,role:n};return T.jsx("span",{...t,ref:r,style:ap,"aria-hidden":n?void 0:!0,...a,"data-base-ui-focus-guard":""})});let tP=function(e){return e.frontmostHeight="--toast-frontmost-height",e}({});const rP=E.forwardRef(function(t,r){var M;const{render:n,className:i,children:a,...l}=t,s=_p(),o=VA(),c=E.useRef(!1),f=E.useRef(!1),u=s.useState("isEmpty"),p=s.useState("toasts"),_=s.useState("focused"),y=s.useState("expanded"),v=s.useState("prevFocusElement"),h=((M=p[0])==null?void 0:M.height)??0,m=E.useMemo(()=>p.some(D=>D.transitionStatus==="ending"),[p]);E.useEffect(()=>{const D=s.state.viewport;if(!D)return;function O(F){u||F.key==="F6"&&F.target!==D&&(F.preventDefault(),s.setPrevFocusElement(Zl(Js(D))),D==null||D.focus({preventScroll:!0}),s.pauseTimers(),s.setFocused(!0))}const z=Ko(D);return z.addEventListener("keydown",O),()=>{z.removeEventListener("keydown",O)}},[s,u]),E.useEffect(()=>{const D=s.state.viewport;if(!D||u)return;const O=Ko(D);function z(H){H.target===O&&(s.setIsWindowFocused(!1),s.pauseTimers())}function F(H){if(H.relatedTarget||H.target===O)return;const I=wp(H),R=Zl(Js(D));(!yi(D,I)||!gd(R))&&s.resumeTimers(),o.start(0,()=>s.setIsWindowFocused(!0))}return O.addEventListener("blur",z,!0),O.addEventListener("focus",F,!0),()=>{O.removeEventListener("blur",z,!0),O.removeEventListener("focus",F,!0)}},[s,o,u]),E.useEffect(()=>{const D=s.state.viewport;if(!D||u)return;const O=Js(D);return O.addEventListener("pointerdown",s.handleDocumentPointerDown,!0),()=>{O.removeEventListener("pointerdown",s.handleDocumentPointerDown,!0)}},[u,s]);function d(D){var z,F,H;const O=s.state.viewport;O&&(c.current=!0,D.relatedTarget===O?(H=(F=(z=p[0])==null?void 0:z.ref)==null?void 0:F.current)==null||H.focus():s.restoreFocusToPrevElement())}function g(D){D.key==="Tab"&&D.shiftKey&&D.target===s.state.viewport&&(D.preventDefault(),s.restoreFocusToPrevElement(),s.resumeTimers())}E.useEffect(()=>{!s.state.isWindowFocused||m||!f.current||(s.resumeTimers(),s.setHovering(!1),f.current=!1)},[m,s]);function w(){s.pauseTimers(),s.setHovering(!0),f.current=!1}function b(){m?f.current=!0:(s.resumeTimers(),s.setHovering(!1))}function x(){if(c.current){c.current=!1;return}_||gd(Js(s.state.viewport).activeElement)&&(s.setFocused(!0),s.pauseTimers())}function C(D){!_||yi(s.state.viewport,D.relatedTarget)||(s.setFocused(!1),s.resumeTimers())}const S={tabIndex:-1,role:"region","aria-live":"polite","aria-atomic":!1,"aria-relevant":"additions text","aria-label":"Notifications",onMouseEnter:w,onMouseMove:w,onMouseLeave:b,onFocus:x,onBlur:C,onKeyDown:g,onClick:x},k={expanded:y},L=Ls("div",t,{ref:[r,s.setViewport],state:k,props:[S,{style:{[tP.frontmostHeight]:h?`${h}px`:void 0}},l,{children:T.jsxs(E.Fragment,{children:[!u&&v&&T.jsx(Pu,{onFocus:d}),a,!u&&v&&T.jsx(Pu,{onFocus:d})]})}]}),A=E.useMemo(()=>p.filter(D=>D.priority==="high"),[p]);return T.jsxs(E.Fragment,{children:[!u&&v&&T.jsx(Pu,{onFocus:d}),L,!_&&A.length>0&&T.jsx("div",{style:ap,children:A.map(D=>T.jsxs("div",{role:"alert","aria-atomic":!0,children:[T.jsx("div",{children:D.title}),T.jsx("div",{children:D.description})]},D.id))})]})});function nP(e){return lp(19)?e:e?"true":void 0}const wS=E.createContext(void 0);function Sp(){const e=E.useContext(wS);if(!e)throw new Error(Yr(66));return e}let xp=function(e){return e.startingStyle="data-starting-style",e.endingStyle="data-ending-style",e}({});const sP={[xp.startingStyle]:""},iP={[xp.endingStyle]:""},oP={transitionStatus(e){return e==="starting"?sP:e==="ending"?iP:null}};function aP(e){return e==null?e:"current"in e?e.current:e}function lP(e,t=!1,r=!0){const n=WA();return Xr((i,a=null)=>{n.cancel();function l(){hn.flushSync(i)}const s=aP(e);if(s==null)return;const o=s;if(typeof o.getAnimations!="function"||globalThis.BASE_UI_ANIMATIONS_DISABLED)i();else{let u=function(){const _=xp.startingStyle;if(!o.hasAttribute(_)){n.request(p);return}const y=new MutationObserver(()=>{o.hasAttribute(_)||(y.disconnect(),p())});y.observe(o,{attributes:!0,attributeFilter:[_]}),a==null||a.addEventListener("abort",()=>y.disconnect(),{once:!0})},p=function(){Promise.all(o.getAnimations().map(_=>_.finished)).then(()=>{a!=null&&a.aborted||l()}).catch(()=>{const _=o.getAnimations();if(r){if(a!=null&&a.aborted)return;l()}else _.length>0&&_.some(y=>y.pending||y.playState!=="finished")&&p()})};var c=u,f=p;if(t){u();return}n.request(p)}})}function cP(e){const{enabled:t=!0,open:r,ref:n,onComplete:i}=e,a=Xr(i),l=lP(n,r,!1);E.useEffect(()=>{if(!t)return;const s=new AbortController;return l(a,s.signal),()=>{s.abort()}},[t,r,a,l])}let ss=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}({});const uP={...oP,swipeDirection(e){return e?{"data-swipe-direction":e}:null}},Wi=40,hP=10,En=.5,dP=1;function jv(e,t,r){switch(e){case"up":return-r;case"down":return r;case"left":return-t;case"right":return t;default:return 0}}function fP(e){const r=window.getComputedStyle(e).transform;let n=0,i=0,a=1;if(r&&r!=="none"){const l=r.match(/matrix(?:3d)?\(([^)]+)\)/);if(l){const s=l[1].split(", ").map(parseFloat);s.length===6?(n=s[4],i=s[5],a=Math.sqrt(s[0]*s[0]+s[1]*s[1])):s.length===16&&(n=s[12],i=s[13],a=s[0])}}return{x:n,y:i,scale:a}}const pP=E.forwardRef(function(t,r){var ge;const{toast:n,render:i,className:a,swipeDirection:l=["down","right"],...s}=t,o=((ge=n.positionerProps)==null?void 0:ge.anchor)!==void 0;let c=[];o||(c=Array.isArray(l)?l:[l]);const f=c.length>0,u=_p(),[p,_]=E.useState(void 0),[y,v]=E.useState(!1),[h,m]=E.useState(!1),[d,g]=E.useState(!1),[w,b]=E.useState({x:0,y:0}),[x,C]=E.useState({x:0,y:0,scale:1}),[S,k]=E.useState(),[L,A]=E.useState(),[M,D]=E.useState(null),O=E.useRef(null),z=E.useRef({x:0,y:0}),F=E.useRef({x:0,y:0,scale:1}),H=E.useRef(void 0),I=E.useRef(0),R=E.useRef(!1),P=E.useRef({x:0,y:0}),N=E.useRef(!1),j=u.useState("toastIndex",n.id),W=u.useState("toastVisibleIndex",n.id),V=u.useState("toastOffsetY",n.id),Z=u.useState("focused"),Q=u.useState("expanded");cP({open:n.transitionStatus!=="ending",ref:O,onComplete(){n.transitionStatus==="ending"&&u.removeToast(n.id)}});const $=Xr((se=!1)=>{const oe=O.current;if(!oe)return;const ue=oe.style.height;oe.style.height="auto";const ae=oe.offsetHeight;oe.style.height=ue;function ve(){u.updateToastInternal(n.id,{ref:O,height:ae,...n.transitionStatus==="starting"?{transitionStatus:void 0}:{}})}se?hn.flushSync(ve):ve()});qt($,[$]);function B(se,oe){let ue=se,ae=oe;return!c.includes("left")&&!c.includes("right")?ue=se>0?se**En:-(Math.abs(se)**En):(!c.includes("right")&&se>0&&(ue=se**En),!c.includes("left")&&se<0&&(ue=-(Math.abs(se)**En))),!c.includes("up")&&!c.includes("down")?ae=oe>0?oe**En:-(Math.abs(oe)**En):(!c.includes("down")&&oe>0&&(ae=oe**En),!c.includes("up")&&oe<0&&(ae=-(Math.abs(oe)**En))),{x:ue,y:ae}}function K(se){var ae;if(se.button!==0)return;se.pointerType==="touch"&&u.pauseTimers();const oe=wp(se.nativeEvent);if(!(oe&&oe.closest('button,a,input,textarea,[role="button"],[data-swipe-ignore]'))){if(R.current=!1,H.current=void 0,I.current=0,z.current={x:se.clientX,y:se.clientY},P.current=z.current,O.current){const ve=fP(O.current);F.current=ve,C(ve),b({x:ve.x,y:ve.y})}u.setHovering(!0),v(!0),m(!1),D(null),N.current=!0,(ae=O.current)==null||ae.setPointerCapture(se.pointerId)}}function U(se){if(!y)return;se.preventDefault(),N.current&&(z.current={x:se.clientX,y:se.clientY},N.current=!1);const{clientY:oe,clientX:ue,movementX:ae,movementY:ve}=se;(ve<0&&oe>P.current.y||ve>0&&oe<P.current.y)&&(P.current={x:P.current.x,y:oe}),(ae<0&&ue>P.current.x||ae>0&&ue<P.current.x)&&(P.current={x:ue,y:P.current.y});const Ce=ue-z.current.x,Le=oe-z.current.y,je=oe-P.current.y,Fe=ue-P.current.x;if(!h&&Math.sqrt(Ce*Ce+Le*Le)>=dP&&(m(!0),M===null)){const Ne=c.includes("left")||c.includes("right"),qe=c.includes("up")||c.includes("down");if(Ne&&qe){const Ae=Math.abs(Ce),G=Math.abs(Le);D(Ae>G?"horizontal":"vertical")}}let Pe;if(!H.current)M==="vertical"?Le>0?Pe="down":Le<0&&(Pe="up"):M==="horizontal"?Ce>0?Pe="right":Ce<0&&(Pe="left"):Math.abs(Ce)>=Math.abs(Le)?Pe=Ce>0?"right":"left":Pe=Le>0?"down":"up",Pe&&c.includes(Pe)&&(H.current=Pe,I.current=jv(Pe,Ce,Le),_(Pe));else{const ee=H.current,Ne=jv(ee,Fe,je);Ne>Wi?(R.current=!1,_(ee)):!(c.includes("left")&&c.includes("right"))&&!(c.includes("up")&&c.includes("down"))&&I.current-Ne>=hP&&(R.current=!0)}const Oe=B(Ce,Le);let Ee=F.current.x,q=F.current.y;M==="horizontal"?(c.includes("left")||c.includes("right"))&&(Ee+=Oe.x):(M==="vertical"||(c.includes("left")||c.includes("right"))&&(Ee+=Oe.x),(c.includes("up")||c.includes("down"))&&(q+=Oe.y)),b({x:Ee,y:q})}function te(se){var Ce;if(!y)return;if(v(!1),m(!1),D(null),(Ce=O.current)==null||Ce.releasePointerCapture(se.pointerId),R.current){b({x:x.x,y:x.y}),_(void 0);return}let oe=!1;const ue=w.x-x.x,ae=w.y-x.y;let ve;for(const Le of c){switch(Le){case"right":ue>Wi&&(oe=!0,ve="right");break;case"left":ue<-Wi&&(oe=!0,ve="left");break;case"down":ae>Wi&&(oe=!0,ve="down");break;case"up":ae<-Wi&&(oe=!0,ve="up");break}if(oe)break}oe?(_(ve),g(!0),u.closeToast(n.id)):(b({x:x.x,y:x.y}),_(void 0))}function Y(se){if(se.key==="Escape"){if(!O.current||!yi(O.current,Zl(Js(O.current))))return;u.closeToast(n.id)}}E.useEffect(()=>{if(!f)return;const se=O.current;if(!se)return;function oe(ue){yi(se,ue.target)&&ue.preventDefault()}return se.addEventListener("touchmove",oe,{passive:!1}),()=>{se.removeEventListener("touchmove",oe)}},[f]);function _e(){if(!y&&w.x===x.x&&w.y===x.y&&!d)return{[ss.swipeMovementX]:"0px",[ss.swipeMovementY]:"0px"};const se=w.x-x.x,oe=w.y-x.y;return{transition:y?"none":void 0,transform:y?`translateX(${w.x}px) translateY(${w.y}px) scale(${x.scale})`:void 0,[ss.swipeMovementX]:`${se}px`,[ss.swipeMovementY]:`${oe}px`}}const de=n.priority==="high",re={role:de?"alertdialog":"dialog",tabIndex:0,"aria-modal":!1,"aria-labelledby":S,"aria-describedby":L,"aria-hidden":de&&!Z?!0:void 0,onPointerDown:f?K:void 0,onPointerMove:f?U:void 0,onPointerUp:f?te:void 0,onKeyDown:Y,inert:nP(n.limited),style:{..._e(),[ss.index]:n.transitionStatus==="ending"?j:W,[ss.offsetY]:`${V}px`,[ss.height]:n.height?`${n.height}px`:void 0}},le=E.useMemo(()=>({rootRef:O,toast:n,titleId:S,setTitleId:k,descriptionId:L,setDescriptionId:A,swiping:y,swipeDirection:p,recalculateHeight:$,index:j,visibleIndex:W,expanded:Q}),[n,S,L,y,p,$,j,W,Q]),ne={transitionStatus:n.transitionStatus,expanded:Q,limited:n.limited||!1,type:n.type,swiping:le.swiping,swipeDirection:le.swipeDirection},fe=Ls("div",t,{ref:[r,le.rootRef],state:ne,stateAttributesMapping:uP,props:[re,s]});return T.jsx(wS.Provider,{value:le,children:fe})}),mP=E.forwardRef(function(t,r){const{render:n,className:i,id:a,children:l,...s}=t,{toast:o,setDescriptionId:c}=Sp(),f=l??o.description,u=!!f,p=up(a);qt(()=>{if(u)return c(p),()=>{c(void 0)}},[u,p,c]);const _={type:o.type},y=Ls("p",t,{ref:r,state:_,props:{...s,id:p,children:f}});return u?y:null}),gP=E.forwardRef(function(t,r){const{render:n,className:i,id:a,children:l,...s}=t,{toast:o,setTitleId:c}=Sp(),f=l??o.title,u=!!f,p=up(a);qt(()=>{if(u)return c(p),()=>{c(void 0)}},[u,p,c]);const _={type:o.type},y=Ls("h2",t,{ref:r,state:_,props:{...s,id:p,children:f}});return u?y:null}),vP=E.forwardRef(function(t,r){const{render:n,className:i,disabled:a,nativeButton:l=!0,...s}=t,o=_p(),{toast:c}=Sp(),f=o.useState("expanded"),[u,p]=E.useState(!1),{getButtonProps:_,buttonRef:y}=Vw({disabled:a,native:l}),v={type:c.type};return Ls("button",t,{ref:[r,y],state:v,props:[{"aria-hidden":!f&&!u,onClick(){o.closeToast(c.id)},onFocus(){p(!0)},onBlur(){p(!1)}},s,_]})});function _P(){const e=E.useContext(vp);if(!e)throw new Error(Yr(73));const t=e.useState("toasts");return E.useMemo(()=>({toasts:t,add:e.addToast,close:e.closeToast,update:e.updateToast,promise:e.promiseToast}),[t,e])}function yP(){const e=new Set;function t(r){e.forEach(n=>n(r))}return{" subscribe":function(n){return e.add(n),()=>{e.delete(n)}},add(r){const n=r.id||yS("toast"),i={...r,id:n,transitionStatus:"starting"};return t({action:"add",options:i}),n},close(r){t({action:"close",options:{id:r}})},update(r,n){t({action:"update",options:{...n,id:r}})},promise(r,n){let i=r;return t({action:"promise",options:{...n,promise:r,setPromise(a){i=a}}}),i}}}const wP=5e3,SS=yP();function SP({toast:e}){return T.jsxs(pP,{toast:e,className:Yl("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:[T.jsxs("div",{className:"flex-1 min-w-0",children:[T.jsx(gP,{className:Yl("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&&T.jsx(mP,{className:"mt-1 text-xs text-muted line-clamp-2",children:e.description})]}),T.jsx(vP,{className:"shrink-0 text-muted hover:text-primary transition-colors","aria-label":"Close",children:T.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:[T.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),T.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}function xP(){const{toasts:e}=_P();return T.jsx(T.Fragment,{children:e.map(t=>T.jsx(SP,{toast:t},t.id))})}function bP(){return T.jsxs(eP,{timeout:wP,toastManager:SS,children:[T.jsx(xP,{}),T.jsx(rP,{className:"fixed bottom-4 right-4 z-[100] flex flex-col gap-2"})]})}const Fv=["CONNECTING","OPEN","CLOSING","CLOSED"],CP=3e3,EP=8e3,kP=15e3,LP=5e3,Iu=2e4,TP=1e4,RP=1500,DP=5e3,MP=750,AP=4,PP=5e3;class IP{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.pingSeq=0,this.connectionEpoch=0,this.consecutiveFailures=0,this.isResumeAttempt=!1,this.leakedSockets=new Set,this.verifyTimer=null,this.onVisibilityChange=()=>{var t;if(Ge("ws_visibility",{state:document.visibilityState,...this.wsSnap()},"info"),document.visibilityState==="visible"){const r=Date.now(),n=r-this.lastTick;this.lastTick=r,Ge("ws_resume",{gapMs:n,...this.wsSnap()},"info"),((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?this.verifyConnection():this.forceReconnect("visibilitychange",!0)}else this.stopHeartbeat(),this.cancelVerify(),this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)},this.onPageShow=t=>{Ge("ws_pageshow",{persisted:t.persisted,...this.wsSnap()},"info"),t.persisted&&(this.lastTick=Date.now(),this.forceReconnect("pageshow",!0))}}wsSnap(){return{status:this.status,ws:this.ws?Fv[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){const a=this.ws.readyState===WebSocket.OPEN;if(a&&this.status==="connected"){Ge("ws_connect_skip",{reason:"already_open",...this.wsSnap()});return}Ge("ws_connect_destroy_zombie",{reason:a?"open_desynced":"not_open",...this.wsSnap()}),this.destroySocket()}this.manualClose=!1,this.clearConnectTimer(),this.setStatus("connecting");const r=`${window.location.protocol==="https:"?"wss":"ws"}://${window.location.host}/ws`;Ge("ws_connect",{url:r,resume:this.isResumeAttempt,...this.wsSnap()},"info");const n=new WebSocket(r);this.ws=n,this.leakedSockets.add(n);const i=this.isResumeAttempt?EP:CP;this.isResumeAttempt=!1,this.connectTimer=window.setTimeout(()=>{if(this.ws!==n)return;this.connectTimer=null,n.readyState===WebSocket.OPEN&&this.status==="connected"||(Ge("ws_connect_timeout",{wsState:Fv[n.readyState],managerStatus:this.status,timeoutMs:i,...this.wsSnap()},"info"),this.consecutiveFailures+=1,this.destroySocket(),this.scheduleReconnect())},i),n.onopen=()=>{if(this.ws!==n){Ge("ws_onopen_stale",this.wsSnap(),"info");return}Ge("ws_onopen",this.wsSnap(),"info"),this.clearConnectTimer(),this.reconnectAttempts=0,this.consecutiveFailures=0,this.connectionEpoch+=1,this.leakedSockets.delete(n),this.setStatus("connected"),this.startHeartbeat()},n.onmessage=a=>{try{const l=a.data,s=performance.now(),o=JSON.parse(l),c=performance.now()-s,f=o;if(f._parseMs=Math.round(c),f._rawLength=l.length,o.type==="pong"){o.seq===this.pingSeq&&(this.clearPongTimer(),this.verifyTimer!==null&&(this.cancelVerify(),Ge("ws_verify_ok",this.wsSnap(),"info"),this.startHeartbeat(DP)));return}this.listeners.forEach(u=>u(o))}catch{}},n.onerror=()=>{this.ws===n&&(Ge("ws_onerror",this.wsSnap(),"info"),this.clearConnectTimer())},n.onclose=a=>{if(this.ws!==n){Ge("ws_onclose_stale",{code:a.code,...this.wsSnap()},"info");return}Ge("ws_onclose",{code:a.code,reason:a.reason,clean:a.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),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(()=>{const t=Date.now(),r=t-this.lastTick;this.isHidden()||(r>kP&&(Ge("ws_time_jump",{gapMs:r,...this.wsSnap()},"info"),this.forceReconnect("time_jump",!0)),this.lastTick=t)},LP))}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(t){var r;if(((r=this.ws)==null?void 0:r.readyState)!==WebSocket.OPEN)return!1;try{return this.ws.send(JSON.stringify(t)),!0}catch(n){return Ge("ws_send_error",{messageType:t.type,error:n instanceof Error?n.message:String(n),...this.wsSnap()},"info"),this.destroySocket(),this.scheduleReconnect(),!1}}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}subscribeStatus(t){return this.statusListeners.add(t),t(this.status,this.error,this.connectionEpoch),()=>this.statusListeners.delete(t)}getStatus(){return this.status}getConnectionEpoch(){return this.connectionEpoch}verifyConnection(){this.cancelVerify(),this.stopHeartbeat(),this.pingSeq+=1;const t=this.pingSeq,r=this.ws;if(Ge("ws_verify",{seq:t,...this.wsSnap()},"info"),!this.send({type:"ping",seq:t})){Ge("ws_verify_send_fail",this.wsSnap(),"info"),this.forceReconnect("verify_send_fail",!0);return}this.verifyTimer=window.setTimeout(()=>{this.verifyTimer=null,this.ws===r&&(Ge("ws_verify_timeout",this.wsSnap(),"info"),this.forceReconnect("verify_timeout",!0))},RP)}cancelVerify(){this.verifyTimer!==null&&(window.clearTimeout(this.verifyTimer),this.verifyTimer=null)}forceReconnect(t="unknown",r=!1){var a;if(this.manualClose){Ge("ws_force_skip",{trigger:t,reason:"manual_close"});return}const n=Date.now(),i=r?200:500;if(n-this.lastForceReconnectTs<i){Ge("ws_force_skip",{trigger:t,reason:"debounce",force:r});return}if(!r&&((a=this.ws)==null?void 0:a.readyState)===WebSocket.OPEN&&this.status==="connected"){Ge("ws_force_skip",{trigger:t,reason:"already_connected"});return}this.lastForceReconnectTs=n,Ge("ws_force_reconnect",{trigger:t,force:r,...this.wsSnap()},"info"),this.reconnectAttempts=0,this.consecutiveFailures=0,this.reconnectTimer&&(window.clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.destroySocket(),r?(this.purgeLeakedSockets(),this.isResumeAttempt=!0,this.setStatus("reconnecting"),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},MP)):this.connect()}startHeartbeat(t){this.stopHeartbeat();const r=()=>{var n;((n=this.ws)==null?void 0:n.readyState)===WebSocket.OPEN&&(this.pingSeq+=1,this.send({type:"ping",seq:this.pingSeq})&&(this.clearPongTimer(),this.pongTimer=window.setTimeout(()=>{this.pongTimer=null,Ge("ws_pong_timeout",this.wsSnap(),"info"),this.destroySocket(),this.scheduleReconnect()},TP)))};t!==void 0&&t<Iu?this.heartbeatTimer=window.setTimeout(()=>{r(),this.heartbeatTimer=window.setInterval(r,Iu)},t):this.heartbeatTimer=window.setInterval(r,Iu)}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(t,r=null){this.status=t,this.error=r,this.statusListeners.forEach(n=>n(t,r,this.connectionEpoch))}scheduleReconnect(){if(this.stopHeartbeat(),this.isHidden()){Ge("ws_schedule_skip",{reason:"hidden",...this.wsSnap()}),this.setStatus("reconnecting");return}if(this.consecutiveFailures>=AP){Ge("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()},PP);return}this.reconnectAttempts+=1;const t=Math.min(1e3*2**(this.reconnectAttempts-1),3e4);Ge("ws_schedule_reconnect",{delay:t,...this.wsSnap()}),this.setStatus("reconnecting"),this.reconnectTimer&&window.clearTimeout(this.reconnectTimer),this.reconnectTimer=window.setTimeout(()=>{this.reconnectTimer=null,this.connect()},t)}isHidden(){return typeof document<"u"&&document.visibilityState==="hidden"}clearConnectTimer(){this.connectTimer&&(window.clearTimeout(this.connectTimer),this.connectTimer=null)}destroySocket(){if(this.clearConnectTimer(),this.stopHeartbeat(),this.cancelVerify(),!this.ws)return;const t=this.ws;this.ws=null,this.leakedSockets.add(t),t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null;try{t.close()}catch{}}purgeLeakedSockets(){if(this.leakedSockets.size!==0){Ge("ws_purge_leaked",{count:this.leakedSockets.size},"info");for(const t of this.leakedSockets)try{t.onopen=null,t.onmessage=null,t.onerror=null,t.onclose=null,t.close()}catch{}this.leakedSockets.clear()}}}const sn=new IP;function OP(){const e=Ke(o=>o.setConnectionStatus),t=Ke(o=>o.setConnectionError),[r,n]=E.useState(sn.getStatus()),[i,a]=E.useState(sn.getConnectionEpoch());E.useEffect(()=>{sn.connect(),sn.startLifecycleListeners();const o=sn.subscribeStatus((c,f,u)=>{n(c),a(u),e(c),t(f)});return()=>{o(),sn.stopLifecycleListeners()}},[t,e]);const l=E.useMemo(()=>o=>{sn.send(o)},[]),s=E.useMemo(()=>sn.subscribe.bind(sn),[]);return{status:r,connectionEpoch:i,sendMessage:l,subscribe:s}}const BP=100;function NP({viewport:e,win:t,doc:r}){if(!e)return!1;const n=Math.max(0,e.offsetTop||0),i=Math.max(0,e.offsetLeft||0),a=t.innerHeight-(e.height+n),l=Math.max(0,a),s=Math.max(0,e.height||0),o=Math.max(0,e.width||0);return r.documentElement.style.setProperty("--keyboard-inset",`${l}px`),r.documentElement.style.setProperty("--viewport-offset-top",`${n}px`),r.documentElement.style.setProperty("--viewport-offset-left",`${i}px`),r.documentElement.style.setProperty("--visual-viewport-height",`${s}px`),r.documentElement.style.setProperty("--visual-viewport-width",`${o}px`),l>BP?r.documentElement.classList.add("keyboard-visible"):r.documentElement.classList.remove("keyboard-visible"),!0}function jP(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 FP(){E.useEffect(()=>{const e=window.visualViewport;if(!e)return;let t=null,r=null;const n=()=>{var v;const _=document.activeElement;if(!_)return!1;const y=(v=_.tagName)==null?void 0:v.toLowerCase();return y==="input"||y==="textarea"?!0:!!_.isContentEditable},i=()=>{NP({viewport:e,win:window,doc:document})},a=()=>{if(typeof window.requestAnimationFrame!="function"){i();return}t!==null&&window.cancelAnimationFrame(t);const _=performance.now(),y=()=>{i(),performance.now()-_<1500?t=window.requestAnimationFrame(y):t=null};t=window.requestAnimationFrame(y)},l=()=>{if(!n()){o();return}i()},s=()=>{r!==null||typeof window.setInterval!="function"||(r=window.setInterval(l,250),l())},o=()=>{r===null||typeof window.clearInterval!="function"||(window.clearInterval(r),r=null)},c=()=>{n()?(a(),s(),i()):o()},f=()=>{c()},u=()=>{c()},p=()=>{a()};return i(),c(),e.addEventListener("resize",i),e.addEventListener("scroll",i),typeof window.addEventListener=="function"&&(window.addEventListener("resize",i),window.addEventListener("orientationchange",p)),typeof document.addEventListener=="function"&&(document.addEventListener("focusin",f),document.addEventListener("focusout",u),document.addEventListener("focus",f,!0),document.addEventListener("blur",u,!0)),()=>{e.removeEventListener("resize",i),e.removeEventListener("scroll",i),typeof window.removeEventListener=="function"&&(window.removeEventListener("resize",i),window.removeEventListener("orientationchange",p)),typeof document.removeEventListener=="function"&&(document.removeEventListener("focusin",f),document.removeEventListener("focusout",u),document.removeEventListener("focus",f,!0),document.removeEventListener("blur",u,!0)),t!==null&&typeof window.cancelAnimationFrame=="function"&&window.cancelAnimationFrame(t),o(),jP(document)}},[])}function HP(){const[e,t]=E.useState(!1),[r,n]=E.useState(void 0),[i,a]=E.useState(void 0),[l,s]=E.useState(void 0),[o,c]=E.useState(!1),[f,u]=E.useState(null),[p,_]=E.useState(null),y=Ke(q=>q.sessions),v=Ke(q=>q.agentSessions),h=Ke(q=>q.selectedSessionId),m=Ke(q=>q.setSessions),d=Ke(q=>q.setAgentSessions),g=Ke(q=>q.setHostStatuses),w=Ke(q=>q.updateSession),b=Ke(q=>q.setSelectedSessionId),x=Ke(q=>q.hasLoaded),C=Ke(q=>q.connectionStatus),S=Ke(q=>q.connectionError),k=Ke(q=>q.clearExitingSession),L=Ke(q=>q.markSessionExiting),A=Ke(q=>q.setRemoteAllowControl),M=Ke(q=>q.setRemoteAllowAttach),D=Ke(q=>q.setHostLabel),O=Ke(q=>q.hostStatuses),z=Ke(q=>q.remoteAllowControl),F=Ke(q=>q.hostLabel),H=ql(q=>q.theme),I=hC(),R=pe(q=>q.defaultProjectDir),P=pe(q=>q.commandPresets),N=pe(q=>q.defaultPresetId),j=pe(q=>q.lastProjectPath),W=pe(q=>q.setLastProjectPath),V=pe(q=>q.addRecentPath),Z=pe(q=>q.shortcutModifier),Q=pe(q=>q.sidebarWidth),$=pe(q=>q.setSidebarWidth),B=pe(q=>q.projectFilters),K=pe(q=>q.hostFilters),U=pe(q=>q.soundOnPermission),te=pe(q=>q.soundOnIdle),{sendMessage:Y,subscribe:_e,connectionEpoch:de}=OP();FP(),E.useEffect(()=>{if(typeof document>"u"||!U&&!te)return;let q=!1;const ee=()=>{q&&!J3()||(q=!0,fd())};return document.addEventListener("click",ee,{passive:!0}),document.addEventListener("keydown",ee,{passive:!0}),document.addEventListener("touchstart",ee,{passive:!0}),()=>{document.removeEventListener("click",ee),document.removeEventListener("keydown",ee),document.removeEventListener("touchstart",ee)}},[U,te]);const re=E.useRef(!1),le=E.useCallback(q=>{q.preventDefault(),re.current=!0,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[]);E.useEffect(()=>{if(typeof document>"u"||typeof document.addEventListener!="function")return;const q=Ne=>{if(!re.current)return;const qe=Ne.clientX;$(Math.max(ty,Math.min(ry,qe)))},ee=()=>{re.current&&(re.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",q),document.addEventListener("mouseup",ee),()=>{document.removeEventListener("mousemove",q),document.removeEventListener("mouseup",ee)}},[$]),E.useEffect(()=>{const q=_e(ee=>{var Ne,qe;if(ee.type==="sessions"){const Ae=Ke.getState().sessions,{soundOnPermission:G,soundOnIdle:me}=pe.getState();if(G||me)for(const J of ee.sessions){const Se=Ae.find(ie=>ie.id===J.id);Se&&Se.status!==J.status&&(Se.status!=="permission"&&J.status==="permission"&&G&&pd(),Se.status==="working"&&J.status==="waiting"&&me&&md())}m(ee.sessions)}if(ee.type==="host-status"&&g(ee.hosts),ee.type==="server-config"&&(A(ee.remoteAllowControl),M(ee.remoteAllowAttach),D(ee.hostLabel),ee.clientLogLevel&&YR(ee.clientLogLevel)),ee.type==="session-update"){const G=Ke.getState().sessions.find(Se=>Se.id===ee.session.id),me=G==null?void 0:G.status,J=ee.session.status;if(w(ee.session),me){const{soundOnPermission:Se,soundOnIdle:ie}=pe.getState();me!=="permission"&&J==="permission"&&Se&&pd(),me==="working"&&J==="waiting"&&ie&&md()}}if(ee.type==="session-created"){const Ae=Ke.getState().sessions;Ae.some(J=>J.id===ee.session.id)||m([ee.session,...Ae]),b(ee.session.id),V(ee.session.projectPath);const{projectFilters:G,setProjectFilters:me}=pe.getState();G.length>0&&!G.includes(ee.session.projectPath)&&me([...G,ee.session.projectPath])}if(ee.type==="session-removed"){const Ae=Ke.getState().sessions,G=Ae.filter(me=>me.id!==ee.sessionId);G.length!==Ae.length&&m(G)}if(ee.type==="agent-sessions"&&d(ee.active,ee.inactive),ee.type==="agent-sessions-active"){const Ae=Ke.getState().agentSessions;d(ee.active,Ae.inactive)}if(ee.type==="session-orphaned"&&!ee.supersededBy){const Ae=Ke.getState().sessions,G=Ae.filter(me=>{var J;return((J=me.agentSessionId)==null?void 0:J.trim())!==ee.session.sessionId});G.length!==Ae.length&&m(G)}if(ee.type==="session-activated"){const Ae=Ke.getState().sessions.find(G=>G.tmuxWindow===ee.window);Ae&&w({...Ae,agentSessionId:ee.session.sessionId,agentSessionName:ee.session.displayName,logFilePath:ee.session.logFilePath,isPinned:ee.session.isPinned,lastUserMessage:ee.session.lastUserMessage??Ae.lastUserMessage})}if(ee.type==="session-resume-result")if(ee.ok&&ee.session){const Ae=Ke.getState().sessions;Ae.some(G=>G.id===ee.session.id)||m([ee.session,...Ae]),b(ee.session.id)}else ee.ok||(u(`${(Ne=ee.error)==null?void 0:Ne.code}: ${(qe=ee.error)==null?void 0:qe.message}`),window.setTimeout(()=>u(null),6e3));ee.type==="terminal-error"&&(!ee.sessionId||ee.sessionId===h)&&(u(`${ee.code}: ${ee.message}`),window.setTimeout(()=>u(null),6e3)),ee.type==="terminal-ready"&&ee.sessionId===h&&u(null),ee.type==="error"&&(u(ee.message),window.setTimeout(()=>u(null),6e3)),ee.type==="kill-failed"&&(k(ee.sessionId),u(ee.message),window.setTimeout(()=>u(null),6e3)),ee.type==="session-pin-result"&&!ee.ok&&ee.error&&(u(ee.error),window.setTimeout(()=>u(null),6e3)),ee.type==="session-resurrection-failed"&&SS.add({title:"Session resurrection failed",description:`"${ee.displayName}" could not be resumed: ${ee.error}`,type:"error",timeout:8e3})});return()=>{q()}},[h,V,k,Y,b,m,d,g,A,M,D,_e,w]);const ne=E.useMemo(()=>y.find(q=>q.id===h)||null,[h,y]);E.useEffect(()=>{ne!=null&&ne.projectPath&&!ne.remote&&W(ne.projectPath)},[ne==null?void 0:ne.projectPath,ne==null?void 0:ne.remote,W]);const fe=pe(q=>q.sessionSortMode),ge=pe(q=>q.sessionSortDirection),se=pe(q=>q.manualSessionOrder),oe=E.useMemo(()=>np(y,{mode:fe,direction:ge,manualOrder:se}),[y,fe,ge,se]),ue=E.useMemo(()=>{let q=oe;return B.length>0&&(q=q.filter(ee=>B.includes(ee.projectPath))),K.length>0&&(q=q.filter(ee=>K.includes(ee.host??""))),q},[oe,B,K]);E.useEffect(()=>{h&&ue.length>0&&!ue.some(q=>q.id===h)&&b(ue[0].id)},[h,ue,b]),E.useEffect(()=>{window.matchMedia("(max-width: 767px)").matches&&x&&h===null&&oe.length>0&&b(oe[0].id)},[x,h,oe,b]);const ae=E.useCallback(q=>{L(q),Y({type:"session-kill",sessionId:q})},[L,Y]);E.useEffect(()=>{const q=ea(Z),ee=Ne=>{if(Ne.defaultPrevented)return;const qe=Ne.code,Ae=WC(Ne,q);if(Ae&&(qe==="BracketLeft"||qe==="BracketRight")){Ne.preventDefault();const G=ue;if(G.length===0)return;const me=G.findIndex(ie=>ie.id===h);if(me===-1){b(G[0].id);return}const Se=(me+(qe==="BracketLeft"?-1:1)+G.length)%G.length;b(G[Se].id);return}if(Ae&&qe==="KeyN"){Ne.preventDefault(),!e&&I&&t(!0);return}if(Ae&&qe==="KeyX"){Ne.preventDefault(),h&&!e&&ae(h);return}};return window.addEventListener("keydown",ee),()=>window.removeEventListener("keydown",ee)},[e,h,b,ue,ae,Z,I]);const ve=()=>I?(n(void 0),a(void 0),s(void 0),t(!0),!0):!1,Ce=()=>c(!0),Le=(q,ee,Ne,qe)=>{Y({type:"session-create",projectPath:q,name:ee,command:Ne,host:qe}),qe||W(q)},je=q=>{Y({type:"session-resume",sessionId:q})},Fe=(q,ee)=>{Y({type:"session-rename",sessionId:q,newName:ee})},Pe=E.useCallback(q=>{const ee=y.find(Ne=>Ne.id===q);ee&&Y({type:"session-create",projectPath:ee.projectPath,command:ee.command||void 0,host:ee.remote&&ee.host?ee.host:void 0})},[y,Y]),Oe=E.useCallback((q,ee)=>{Y({type:"session-pin",sessionId:q,isPinned:ee})},[Y]);E.useEffect(()=>{document.documentElement.setAttribute("data-theme",H)},[H]),E.useEffect(()=>{fetch("/api/server-info").then(q=>q.json()).then(q=>_(q)).catch(()=>{})},[]);const Ee=E.useMemo(()=>F?O.filter(q=>q.host!==F):O,[O,F]);return T.jsxs("div",{className:"flex h-full overflow-hidden",children:[T.jsxs("div",{className:"hidden h-full flex-col md:flex md:shrink-0",style:{width:Q},children:[T.jsx(KC,{connectionStatus:C,onNewSession:ve,onOpenSettings:Ce,tailscaleIp:(p==null?void 0:p.tailscaleIp)??null}),T.jsx(fw,{sessions:y,inactiveSessions:v.inactive,selectedSessionId:h,onSelect:b,onRename:Fe,onResume:je,onKill:ae,onDuplicate:Pe,onSetPinned:Oe,loading:!x,error:S||f})]}),T.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:le}),T.jsx(fM,{session:ne,sessions:ue,connectionStatus:C,connectionEpoch:de,sendMessage:Y,subscribe:_e,onClose:()=>b(null),onSelectSession:b,onNewSession:ve,onKillSession:ae,onRenameSession:Fe,onOpenSettings:Ce,onResumeSession:je,onSetPinned:Oe,inactiveSessions:v.inactive,loading:!x,error:S||f}),T.jsx(mM,{isOpen:e,onClose:()=>t(!1),onCreate:Le,defaultProjectDir:R,commandPresets:P,defaultPresetId:N,lastProjectPath:j,activeProjectPath:ne&&!ne.remote?ne.projectPath:void 0,remoteHosts:Ee,remoteAllowControl:z,initialHost:r,initialPath:i,initialCommand:l}),T.jsx(Z3,{isOpen:o,onClose:()=>c(!1)}),T.jsx(bP,{})]})}const $P="modulepreload",zP=function(e){return"/"+e},Hv={},UP=function(t,r,n){let i=Promise.resolve();if(r&&r.length>0){document.getElementsByTagName("link");const l=document.querySelector("meta[property=csp-nonce]"),s=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));i=Promise.allSettled(r.map(o=>{if(o=zP(o),o in Hv)return;Hv[o]=!0;const c=o.endsWith(".css"),f=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${o}"]${f}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":$P,c||(u.as="script"),u.crossOrigin="",u.href=o,s&&u.setAttribute("nonce",s),document.head.appendChild(u),c)return new Promise((p,_)=>{u.addEventListener("load",p),u.addEventListener("error",()=>_(new Error(`Unable to preload CSS for ${o}`)))})}))}function a(l){const s=new Event("vite:preloadError",{cancelable:!0});if(s.payload=l,window.dispatchEvent(s),!s.defaultPrevented)throw l}return i.then(l=>{for(const s of l||[])s.status==="rejected"&&a(s.reason);return t().catch(a)})};function WP(e={}){const{immediate:t=!1,onNeedRefresh:r,onOfflineReady:n,onRegistered:i,onRegisteredSW:a,onRegisterError:l}=e;let s,o;const c=async(u=!0)=>{await o};async function f(){if("serviceWorker"in navigator){if(s=await UP(async()=>{const{Workbox:u}=await import("./workbox-window.prod.es5-vqzQaGvo.js");return{Workbox:u}},[]).then(({Workbox:u})=>new u("/sw.js",{scope:"/",type:"classic"})).catch(u=>{l==null||l(u)}),!s)return;s.addEventListener("activated",u=>{(u.isUpdate||u.isExternal)&&window.location.reload()}),s.addEventListener("installed",u=>{u.isUpdate||n==null||n()}),s.register({immediate:t}).then(u=>{a?a("/sw.js",u):i==null||i(u)}).catch(u=>{l==null||l(u)})}}return o=f(),c}Zo()&&document.documentElement.classList.add("ios");$C()&&document.documentElement.classList.add("ios-pwa");WP({immediate:!0,onRegisteredSW(e,t){t&&(setInterval(()=>{t.update()},5*60*1e3),document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&t.update()}))}});const xS=document.getElementById("root");if(!xS)throw new Error("Root element not found");ey(xS).render(T.jsx(gt.StrictMode,{children:T.jsx(HP,{})}));