@jait/gateway 0.1.128 → 0.1.129
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tools/thread-tools.d.ts.map +1 -1
- package/dist/tools/thread-tools.js +1 -7
- package/dist/tools/thread-tools.js.map +1 -1
- package/package.json +1 -1
- package/web-dist/assets/{index-Bfxg12rR.js → index-Dy1EReds.js} +18 -18
- package/web-dist/dist/assets/{index-Bfxg12rR.js → index-Dy1EReds.js} +18 -18
- package/web-dist/dist/index.html +1 -1
- package/web-dist/index.html +1 -1
|
@@ -604,11 +604,11 @@ Error generating stack: `+v.message+`
|
|
|
604
604
|
`)},q8=function(){var e=parseInt(document.body.getAttribute(Kf)||"0",10);return isFinite(e)?e:0},HH=function(){y.useEffect(function(){return document.body.setAttribute(Kf,(q8()+1).toString()),function(){var e=q8()-1;e<=0?document.body.removeAttribute(Kf):document.body.setAttribute(Kf,e.toString())}},[])},UH=function(e){var n=e.noRelative,r=e.noImportant,i=e.gapMode,s=i===void 0?"margin":i;HH();var o=y.useMemo(function(){return IH(s)},[s]);return y.createElement(BH,{styles:FH(o,!n,s,r?"":"!important")})},vw=!1;if(typeof window<"u")try{var f1=Object.defineProperty({},"passive",{get:function(){return vw=!0,!0}});window.addEventListener("test",f1,f1),window.removeEventListener("test",f1,f1)}catch{vw=!1}var Ef=vw?{passive:!1}:!1,VH=function(e){return e.tagName==="TEXTAREA"},SN=function(e,n){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[n]!=="hidden"&&!(r.overflowY===r.overflowX&&!VH(e)&&r[n]==="visible")},WH=function(e){return SN(e,"overflowY")},qH=function(e){return SN(e,"overflowX")},K8=function(e,n){var r=n.ownerDocument,i=n;do{typeof ShadowRoot<"u"&&i instanceof ShadowRoot&&(i=i.host);var s=CN(e,i);if(s){var o=jN(e,i),a=o[1],c=o[2];if(a>c)return!0}i=i.parentNode}while(i&&i!==r.body);return!1},KH=function(e){var n=e.scrollTop,r=e.scrollHeight,i=e.clientHeight;return[n,r,i]},GH=function(e){var n=e.scrollLeft,r=e.scrollWidth,i=e.clientWidth;return[n,r,i]},CN=function(e,n){return e==="v"?WH(n):qH(n)},jN=function(e,n){return e==="v"?KH(n):GH(n)},YH=function(e,n){return e==="h"&&n==="rtl"?-1:1},XH=function(e,n,r,i,s){var o=YH(e,window.getComputedStyle(n).direction),a=o*i,c=r.target,d=n.contains(c),h=!1,g=a>0,p=0,_=0;do{if(!c)break;var b=jN(e,c),x=b[0],C=b[1],j=b[2],S=C-j-o*x;(x||S)&&CN(e,c)&&(p+=S,_+=x);var E=c.parentNode;c=E&&E.nodeType===Node.DOCUMENT_FRAGMENT_NODE?E.host:E}while(!d&&c!==document.body||d&&(n.contains(c)||n===c));return(g&&Math.abs(p)<1||!g&&Math.abs(_)<1)&&(h=!0),h},d1=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},G8=function(e){return[e.deltaX,e.deltaY]},Y8=function(e){return e&&"current"in e?e.current:e},JH=function(e,n){return e[0]===n[0]&&e[1]===n[1]},ZH=function(e){return`
|
|
605
605
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
606
606
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
607
|
-
`)},QH=0,Of=[];function eU(e){var n=y.useRef([]),r=y.useRef([0,0]),i=y.useRef(),s=y.useState(QH++)[0],o=y.useState(wN)[0],a=y.useRef(e);y.useEffect(function(){a.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var C=xH([e.lockRef.current],(e.shards||[]).map(Y8),!0).filter(Boolean);return C.forEach(function(j){return j.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),C.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var c=y.useCallback(function(C,j){if("touches"in C&&C.touches.length===2||C.type==="wheel"&&C.ctrlKey)return!a.current.allowPinchZoom;var S=d1(C),E=r.current,O="deltaX"in C?C.deltaX:E[0]-S[0],N="deltaY"in C?C.deltaY:E[1]-S[1],T,P=C.target,D=Math.abs(O)>Math.abs(N)?"h":"v";if("touches"in C&&D==="h"&&P.type==="range")return!1;var H=window.getSelection(),J=H&&H.anchorNode,I=J?J===P||J.contains(P):!1;if(I)return!1;var B=K8(D,P);if(!B)return!0;if(B?T=D:(T=D==="v"?"h":"v",B=K8(D,P)),!B)return!1;if(!i.current&&"changedTouches"in C&&(O||N)&&(i.current=T),!T)return!0;var F=i.current||T;return XH(F,j,C,F==="h"?O:N)},[]),d=y.useCallback(function(C){var j=C;if(!(!Of.length||Of[Of.length-1]!==o)){var S="deltaY"in j?G8(j):d1(j),E=n.current.filter(function(T){return T.name===j.type&&(T.target===j.target||j.target===T.shadowParent)&&JH(T.delta,S)})[0];if(E&&E.should){j.cancelable&&j.preventDefault();return}if(!E){var O=(a.current.shards||[]).map(Y8).filter(Boolean).filter(function(T){return T.contains(j.target)}),N=O.length>0?c(j,O[0]):!a.current.noIsolation;N&&j.cancelable&&j.preventDefault()}}},[]),h=y.useCallback(function(C,j,S,E){var O={name:C,delta:j,target:S,should:E,shadowParent:tU(S)};n.current.push(O),setTimeout(function(){n.current=n.current.filter(function(N){return N!==O})},1)},[]),g=y.useCallback(function(C){r.current=d1(C),i.current=void 0},[]),p=y.useCallback(function(C){h(C.type,G8(C),C.target,c(C,e.lockRef.current))},[]),_=y.useCallback(function(C){h(C.type,d1(C),C.target,c(C,e.lockRef.current))},[]);y.useEffect(function(){return Of.push(o),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:_}),document.addEventListener("wheel",d,Ef),document.addEventListener("touchmove",d,Ef),document.addEventListener("touchstart",g,Ef),function(){Of=Of.filter(function(C){return C!==o}),document.removeEventListener("wheel",d,Ef),document.removeEventListener("touchmove",d,Ef),document.removeEventListener("touchstart",g,Ef)}},[]);var b=e.removeScrollBar,x=e.inert;return y.createElement(y.Fragment,null,x?y.createElement(o,{styles:ZH(s)}):null,b?y.createElement(UH,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function tU(e){for(var n=null;e!==null;)e instanceof ShadowRoot&&(n=e.host,e=e.host),e=e.parentNode;return n}const nU=TH(xN,eU);var vv=y.forwardRef(function(e,n){return y.createElement(yv,Ho({},e,{ref:n,sideCar:nU}))});vv.classNames=yv.classNames;var rU=function(e){if(typeof document>"u")return null;var n=Array.isArray(e)?e[0]:e;return n.ownerDocument.body},Nf=new WeakMap,h1=new WeakMap,p1={},ax=0,kN=function(e){return e&&(e.host||kN(e.parentNode))},iU=function(e,n){return n.map(function(r){if(e.contains(r))return r;var i=kN(r);return i&&e.contains(i)?i:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},sU=function(e,n,r,i){var s=iU(n,Array.isArray(e)?e:[e]);p1[r]||(p1[r]=new WeakMap);var o=p1[r],a=[],c=new Set,d=new Set(s),h=function(p){!p||c.has(p)||(c.add(p),h(p.parentNode))};s.forEach(h);var g=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(_){if(c.has(_))g(_);else try{var b=_.getAttribute(i),x=b!==null&&b!=="false",C=(Nf.get(_)||0)+1,j=(o.get(_)||0)+1;Nf.set(_,C),o.set(_,j),a.push(_),C===1&&x&&h1.set(_,!0),j===1&&_.setAttribute(r,"true"),x||_.setAttribute(i,"true")}catch(S){console.error("aria-hidden: cannot operate on ",_,S)}})};return g(n),c.clear(),ax++,function(){a.forEach(function(p){var _=Nf.get(p)-1,b=o.get(p)-1;Nf.set(p,_),o.set(p,b),_||(h1.has(p)||p.removeAttribute(i),h1.delete(p)),b||p.removeAttribute(r)}),ax--,ax||(Nf=new WeakMap,Nf=new WeakMap,h1=new WeakMap,p1={})}},_5=function(e,n,r){r===void 0&&(r="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),s=rU(e);return s?(i.push.apply(i,Array.from(s.querySelectorAll("[aria-live], script"))),sU(i,s,r,"aria-hidden")):function(){return null}},_v="Dialog",[EN]=_F(_v),[oU,wo]=EN(_v),ON=e=>{const{__scopeDialog:n,children:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,c=y.useRef(null),d=y.useRef(null),[h,g]=Ka({prop:i,defaultProp:s??!1,onChange:o,caller:_v});return f.jsx(oU,{scope:n,triggerRef:c,contentRef:d,contentId:$s(),titleId:$s(),descriptionId:$s(),open:h,onOpenChange:g,onOpenToggle:y.useCallback(()=>g(p=>!p),[g]),modal:a,children:r})};ON.displayName=_v;var NN="DialogTrigger",aU=y.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,s=wo(NN,r),o=Jt(n,s.triggerRef);return f.jsx(vg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":w5(s.open),...i,ref:o,onClick:ot(e.onClick,s.onOpenToggle)})});aU.displayName=NN;var b5="DialogPortal",[lU,TN]=EN(b5,{forceMount:void 0}),PN=e=>{const{__scopeDialog:n,forceMount:r,children:i,container:s}=e,o=wo(b5,n);return f.jsx(lU,{scope:n,forceMount:r,children:y.Children.map(i,a=>f.jsx(si,{present:r||o.open,children:f.jsx(yg,{asChild:!0,container:s,children:a})}))})};PN.displayName=b5;var Sy="DialogOverlay",AN=y.forwardRef((e,n)=>{const r=TN(Sy,e.__scopeDialog),{forceMount:i=r.forceMount,...s}=e,o=wo(Sy,e.__scopeDialog);return o.modal?f.jsx(si,{present:i||o.open,children:f.jsx(uU,{...s,ref:n})}):null});AN.displayName=Sy;var cU=vN("DialogOverlay.RemoveScroll"),uU=y.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,s=wo(Sy,r);return f.jsx(vv,{as:cU,allowPinchZoom:!0,shards:[s.contentRef],children:f.jsx(vg.div,{"data-state":w5(s.open),...i,ref:n,style:{pointerEvents:"auto",...i.style}})})}),hu="DialogContent",MN=y.forwardRef((e,n)=>{const r=TN(hu,e.__scopeDialog),{forceMount:i=r.forceMount,...s}=e,o=wo(hu,e.__scopeDialog);return f.jsx(si,{present:i||o.open,children:o.modal?f.jsx(fU,{...s,ref:n}):f.jsx(dU,{...s,ref:n})})});MN.displayName=hu;var fU=y.forwardRef((e,n)=>{const r=wo(hu,e.__scopeDialog),i=y.useRef(null),s=Jt(n,r.contentRef,i);return y.useEffect(()=>{const o=i.current;if(o)return _5(o)},[]),f.jsx(RN,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ot(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:ot(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&o.preventDefault()}),onFocusOutside:ot(e.onFocusOutside,o=>o.preventDefault())})}),dU=y.forwardRef((e,n)=>{const r=wo(hu,e.__scopeDialog),i=y.useRef(!1),s=y.useRef(!1);return f.jsx(RN,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var a,c;(a=e.onCloseAutoFocus)==null||a.call(e,o),o.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),o.preventDefault()),i.current=!1,s.current=!1},onInteractOutside:o=>{var d,h;(d=e.onInteractOutside)==null||d.call(e,o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const a=o.target;((h=r.triggerRef.current)==null?void 0:h.contains(a))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&s.current&&o.preventDefault()}})}),RN=y.forwardRef((e,n)=>{const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,...a}=e,c=wo(hu,r),d=y.useRef(null),h=Jt(n,d);return v5(),f.jsxs(f.Fragment,{children:[f.jsx(gv,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:s,onUnmountAutoFocus:o,children:f.jsx(gg,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":w5(c.open),...a,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(hU,{titleId:c.titleId}),f.jsx(mU,{contentRef:d,descriptionId:c.descriptionId})]})]})}),x5="DialogTitle",DN=y.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,s=wo(x5,r);return f.jsx(vg.h2,{id:s.titleId,...i,ref:n})});DN.displayName=x5;var zN="DialogDescription",LN=y.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,s=wo(zN,r);return f.jsx(vg.p,{id:s.descriptionId,...i,ref:n})});LN.displayName=zN;var $N="DialogClose",IN=y.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,s=wo($N,r);return f.jsx(vg.button,{type:"button",...i,ref:n,onClick:ot(e.onClick,()=>s.onOpenChange(!1))})});IN.displayName=$N;function w5(e){return e?"open":"closed"}var BN="DialogTitleWarning",[
|
|
607
|
+
`)},QH=0,Of=[];function eU(e){var n=y.useRef([]),r=y.useRef([0,0]),i=y.useRef(),s=y.useState(QH++)[0],o=y.useState(wN)[0],a=y.useRef(e);y.useEffect(function(){a.current=e},[e]),y.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(s));var C=xH([e.lockRef.current],(e.shards||[]).map(Y8),!0).filter(Boolean);return C.forEach(function(j){return j.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),C.forEach(function(j){return j.classList.remove("allow-interactivity-".concat(s))})}}},[e.inert,e.lockRef.current,e.shards]);var c=y.useCallback(function(C,j){if("touches"in C&&C.touches.length===2||C.type==="wheel"&&C.ctrlKey)return!a.current.allowPinchZoom;var S=d1(C),E=r.current,O="deltaX"in C?C.deltaX:E[0]-S[0],N="deltaY"in C?C.deltaY:E[1]-S[1],T,P=C.target,D=Math.abs(O)>Math.abs(N)?"h":"v";if("touches"in C&&D==="h"&&P.type==="range")return!1;var H=window.getSelection(),J=H&&H.anchorNode,I=J?J===P||J.contains(P):!1;if(I)return!1;var B=K8(D,P);if(!B)return!0;if(B?T=D:(T=D==="v"?"h":"v",B=K8(D,P)),!B)return!1;if(!i.current&&"changedTouches"in C&&(O||N)&&(i.current=T),!T)return!0;var F=i.current||T;return XH(F,j,C,F==="h"?O:N)},[]),d=y.useCallback(function(C){var j=C;if(!(!Of.length||Of[Of.length-1]!==o)){var S="deltaY"in j?G8(j):d1(j),E=n.current.filter(function(T){return T.name===j.type&&(T.target===j.target||j.target===T.shadowParent)&&JH(T.delta,S)})[0];if(E&&E.should){j.cancelable&&j.preventDefault();return}if(!E){var O=(a.current.shards||[]).map(Y8).filter(Boolean).filter(function(T){return T.contains(j.target)}),N=O.length>0?c(j,O[0]):!a.current.noIsolation;N&&j.cancelable&&j.preventDefault()}}},[]),h=y.useCallback(function(C,j,S,E){var O={name:C,delta:j,target:S,should:E,shadowParent:tU(S)};n.current.push(O),setTimeout(function(){n.current=n.current.filter(function(N){return N!==O})},1)},[]),g=y.useCallback(function(C){r.current=d1(C),i.current=void 0},[]),p=y.useCallback(function(C){h(C.type,G8(C),C.target,c(C,e.lockRef.current))},[]),_=y.useCallback(function(C){h(C.type,d1(C),C.target,c(C,e.lockRef.current))},[]);y.useEffect(function(){return Of.push(o),e.setCallbacks({onScrollCapture:p,onWheelCapture:p,onTouchMoveCapture:_}),document.addEventListener("wheel",d,Ef),document.addEventListener("touchmove",d,Ef),document.addEventListener("touchstart",g,Ef),function(){Of=Of.filter(function(C){return C!==o}),document.removeEventListener("wheel",d,Ef),document.removeEventListener("touchmove",d,Ef),document.removeEventListener("touchstart",g,Ef)}},[]);var b=e.removeScrollBar,x=e.inert;return y.createElement(y.Fragment,null,x?y.createElement(o,{styles:ZH(s)}):null,b?y.createElement(UH,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function tU(e){for(var n=null;e!==null;)e instanceof ShadowRoot&&(n=e.host,e=e.host),e=e.parentNode;return n}const nU=TH(xN,eU);var vv=y.forwardRef(function(e,n){return y.createElement(yv,Ho({},e,{ref:n,sideCar:nU}))});vv.classNames=yv.classNames;var rU=function(e){if(typeof document>"u")return null;var n=Array.isArray(e)?e[0]:e;return n.ownerDocument.body},Nf=new WeakMap,h1=new WeakMap,p1={},ax=0,kN=function(e){return e&&(e.host||kN(e.parentNode))},iU=function(e,n){return n.map(function(r){if(e.contains(r))return r;var i=kN(r);return i&&e.contains(i)?i:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},sU=function(e,n,r,i){var s=iU(n,Array.isArray(e)?e:[e]);p1[r]||(p1[r]=new WeakMap);var o=p1[r],a=[],c=new Set,d=new Set(s),h=function(p){!p||c.has(p)||(c.add(p),h(p.parentNode))};s.forEach(h);var g=function(p){!p||d.has(p)||Array.prototype.forEach.call(p.children,function(_){if(c.has(_))g(_);else try{var b=_.getAttribute(i),x=b!==null&&b!=="false",C=(Nf.get(_)||0)+1,j=(o.get(_)||0)+1;Nf.set(_,C),o.set(_,j),a.push(_),C===1&&x&&h1.set(_,!0),j===1&&_.setAttribute(r,"true"),x||_.setAttribute(i,"true")}catch(S){console.error("aria-hidden: cannot operate on ",_,S)}})};return g(n),c.clear(),ax++,function(){a.forEach(function(p){var _=Nf.get(p)-1,b=o.get(p)-1;Nf.set(p,_),o.set(p,b),_||(h1.has(p)||p.removeAttribute(i),h1.delete(p)),b||p.removeAttribute(r)}),ax--,ax||(Nf=new WeakMap,Nf=new WeakMap,h1=new WeakMap,p1={})}},_5=function(e,n,r){r===void 0&&(r="data-aria-hidden");var i=Array.from(Array.isArray(e)?e:[e]),s=rU(e);return s?(i.push.apply(i,Array.from(s.querySelectorAll("[aria-live], script"))),sU(i,s,r,"aria-hidden")):function(){return null}},_v="Dialog",[EN]=_F(_v),[oU,wo]=EN(_v),ON=e=>{const{__scopeDialog:n,children:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=e,c=y.useRef(null),d=y.useRef(null),[h,g]=Ka({prop:i,defaultProp:s??!1,onChange:o,caller:_v});return f.jsx(oU,{scope:n,triggerRef:c,contentRef:d,contentId:$s(),titleId:$s(),descriptionId:$s(),open:h,onOpenChange:g,onOpenToggle:y.useCallback(()=>g(p=>!p),[g]),modal:a,children:r})};ON.displayName=_v;var NN="DialogTrigger",aU=y.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,s=wo(NN,r),o=Jt(n,s.triggerRef);return f.jsx(vg.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":w5(s.open),...i,ref:o,onClick:ot(e.onClick,s.onOpenToggle)})});aU.displayName=NN;var b5="DialogPortal",[lU,TN]=EN(b5,{forceMount:void 0}),PN=e=>{const{__scopeDialog:n,forceMount:r,children:i,container:s}=e,o=wo(b5,n);return f.jsx(lU,{scope:n,forceMount:r,children:y.Children.map(i,a=>f.jsx(si,{present:r||o.open,children:f.jsx(yg,{asChild:!0,container:s,children:a})}))})};PN.displayName=b5;var Sy="DialogOverlay",AN=y.forwardRef((e,n)=>{const r=TN(Sy,e.__scopeDialog),{forceMount:i=r.forceMount,...s}=e,o=wo(Sy,e.__scopeDialog);return o.modal?f.jsx(si,{present:i||o.open,children:f.jsx(uU,{...s,ref:n})}):null});AN.displayName=Sy;var cU=vN("DialogOverlay.RemoveScroll"),uU=y.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,s=wo(Sy,r);return f.jsx(vv,{as:cU,allowPinchZoom:!0,shards:[s.contentRef],children:f.jsx(vg.div,{"data-state":w5(s.open),...i,ref:n,style:{pointerEvents:"auto",...i.style}})})}),hu="DialogContent",MN=y.forwardRef((e,n)=>{const r=TN(hu,e.__scopeDialog),{forceMount:i=r.forceMount,...s}=e,o=wo(hu,e.__scopeDialog);return f.jsx(si,{present:i||o.open,children:o.modal?f.jsx(fU,{...s,ref:n}):f.jsx(dU,{...s,ref:n})})});MN.displayName=hu;var fU=y.forwardRef((e,n)=>{const r=wo(hu,e.__scopeDialog),i=y.useRef(null),s=Jt(n,r.contentRef,i);return y.useEffect(()=>{const o=i.current;if(o)return _5(o)},[]),f.jsx(RN,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ot(e.onCloseAutoFocus,o=>{var a;o.preventDefault(),(a=r.triggerRef.current)==null||a.focus()}),onPointerDownOutside:ot(e.onPointerDownOutside,o=>{const a=o.detail.originalEvent,c=a.button===0&&a.ctrlKey===!0;(a.button===2||c)&&o.preventDefault()}),onFocusOutside:ot(e.onFocusOutside,o=>o.preventDefault())})}),dU=y.forwardRef((e,n)=>{const r=wo(hu,e.__scopeDialog),i=y.useRef(!1),s=y.useRef(!1);return f.jsx(RN,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:o=>{var a,c;(a=e.onCloseAutoFocus)==null||a.call(e,o),o.defaultPrevented||(i.current||(c=r.triggerRef.current)==null||c.focus(),o.preventDefault()),i.current=!1,s.current=!1},onInteractOutside:o=>{var d,h;(d=e.onInteractOutside)==null||d.call(e,o),o.defaultPrevented||(i.current=!0,o.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const a=o.target;((h=r.triggerRef.current)==null?void 0:h.contains(a))&&o.preventDefault(),o.detail.originalEvent.type==="focusin"&&s.current&&o.preventDefault()}})}),RN=y.forwardRef((e,n)=>{const{__scopeDialog:r,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,...a}=e,c=wo(hu,r),d=y.useRef(null),h=Jt(n,d);return v5(),f.jsxs(f.Fragment,{children:[f.jsx(gv,{asChild:!0,loop:!0,trapped:i,onMountAutoFocus:s,onUnmountAutoFocus:o,children:f.jsx(gg,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":w5(c.open),...a,ref:h,onDismiss:()=>c.onOpenChange(!1)})}),f.jsxs(f.Fragment,{children:[f.jsx(hU,{titleId:c.titleId}),f.jsx(mU,{contentRef:d,descriptionId:c.descriptionId})]})]})}),x5="DialogTitle",DN=y.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,s=wo(x5,r);return f.jsx(vg.h2,{id:s.titleId,...i,ref:n})});DN.displayName=x5;var zN="DialogDescription",LN=y.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,s=wo(zN,r);return f.jsx(vg.p,{id:s.descriptionId,...i,ref:n})});LN.displayName=zN;var $N="DialogClose",IN=y.forwardRef((e,n)=>{const{__scopeDialog:r,...i}=e,s=wo($N,r);return f.jsx(vg.button,{type:"button",...i,ref:n,onClick:ot(e.onClick,()=>s.onOpenChange(!1))})});IN.displayName=$N;function w5(e){return e?"open":"closed"}var BN="DialogTitleWarning",[TSe,FN]=vF(BN,{contentName:hu,titleName:x5,docsSlug:"dialog"}),hU=({titleId:e})=>{const n=FN(BN),r=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
|
|
608
608
|
|
|
609
609
|
If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
610
610
|
|
|
611
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return y.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},pU="DialogDescriptionWarning",mU=({contentRef:e,descriptionId:n})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${FN(pU).contentName}}.`;return y.useEffect(()=>{var o;const s=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");n&&s&&(document.getElementById(n)||console.warn(i))},[i,e,n]),null},gU=ON,yU=PN,HN=AN,UN=MN,VN=DN,WN=LN,vU=IN;const Cu=gU,_U=yU,qN=y.forwardRef(({className:e,...n},r)=>f.jsx(HN,{ref:r,className:We("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...n}));qN.displayName=HN.displayName;const fc=y.forwardRef(({className:e,children:n,...r},i)=>f.jsxs(_U,{children:[f.jsx(qN,{}),f.jsxs(UN,{ref:i,className:We("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[n,f.jsxs(vU,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[f.jsx(Mr,{className:"h-4 w-4"}),f.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));fc.displayName=UN.displayName;const Ga=({className:e,...n})=>f.jsx("div",{className:We("flex flex-col space-y-1.5 text-center sm:text-left",e),...n});Ga.displayName="DialogHeader";const _g=({className:e,...n})=>f.jsx("div",{className:We("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...n});_g.displayName="DialogFooter";const Ya=y.forwardRef(({className:e,...n},r)=>f.jsx(VN,{ref:r,className:We("text-lg font-semibold leading-none tracking-tight",e),...n}));Ya.displayName=VN.displayName;const Cy=y.forwardRef(({className:e,...n},r)=>f.jsx(WN,{ref:r,className:We("text-sm text-muted-foreground",e),...n}));Cy.displayName=WN.displayName;function bU(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,xU(s,...n)]}function xU(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function wU(e){const n=SU(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(jU);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function SU(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=EU(s),c=kU(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var CU=Symbol("radix.slottable");function jU(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===CU}function kU(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function EU(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var OU=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],NU=OU.reduce((e,n)=>{const r=wU(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function TU(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,PU(s,...n)]}function PU(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function X8(e){const n=AU(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(RU);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function AU(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=zU(s),c=DU(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var MU=Symbol("radix.slottable");function RU(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===MU}function DU(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function zU(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function S5(e){const n=e+"CollectionProvider",[r,i]=TU(n),[s,o]=r(n,{collectionRef:{current:null},itemMap:new Map}),a=C=>{const{scope:j,children:S}=C,E=Xe.useRef(null),O=Xe.useRef(new Map).current;return f.jsx(s,{scope:j,itemMap:O,collectionRef:E,children:S})};a.displayName=n;const c=e+"CollectionSlot",d=X8(c),h=Xe.forwardRef((C,j)=>{const{scope:S,children:E}=C,O=o(c,S),N=Jt(j,O.collectionRef);return f.jsx(d,{ref:N,children:E})});h.displayName=c;const g=e+"CollectionItemSlot",p="data-radix-collection-item",_=X8(g),b=Xe.forwardRef((C,j)=>{const{scope:S,children:E,...O}=C,N=Xe.useRef(null),T=Jt(j,N),P=o(g,S);return Xe.useEffect(()=>(P.itemMap.set(N,{ref:N,...O}),()=>void P.itemMap.delete(N))),f.jsx(_,{[p]:"",ref:T,children:E})});b.displayName=g;function x(C){const j=o(e+"CollectionConsumer",C);return Xe.useCallback(()=>{const E=j.collectionRef.current;if(!E)return[];const O=Array.from(E.querySelectorAll(`[${p}]`));return Array.from(j.itemMap.values()).sort((P,D)=>O.indexOf(P.ref.current)-O.indexOf(D.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:a,Slot:h,ItemSlot:b},x,i]}function LU(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,$U(s,...n)]}function $U(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}var IU=y.createContext(void 0);function bg(e){const n=y.useContext(IU);return e||n||"ltr"}const BU=["top","right","bottom","left"],ac=Math.min,ds=Math.max,jy=Math.round,m1=Math.floor,Ko=e=>({x:e,y:e}),FU={left:"right",right:"left",bottom:"top",top:"bottom"};function _w(e,n,r){return ds(e,ac(n,r))}function Xa(e,n){return typeof e=="function"?e(n):e}function Ja(e){return e.split("-")[0]}function dd(e){return e.split("-")[1]}function C5(e){return e==="x"?"y":"x"}function j5(e){return e==="y"?"height":"width"}function Uo(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function k5(e){return C5(Uo(e))}function HU(e,n,r){r===void 0&&(r=!1);const i=dd(e),s=k5(e),o=j5(s);let a=s==="x"?i===(r?"end":"start")?"right":"left":i==="start"?"bottom":"top";return n.reference[o]>n.floating[o]&&(a=ky(a)),[a,ky(a)]}function UU(e){const n=ky(e);return[bw(e),n,bw(n)]}function bw(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const J8=["left","right"],Z8=["right","left"],VU=["top","bottom"],WU=["bottom","top"];function qU(e,n,r){switch(e){case"top":case"bottom":return r?n?Z8:J8:n?J8:Z8;case"left":case"right":return n?VU:WU;default:return[]}}function KU(e,n,r,i){const s=dd(e);let o=qU(Ja(e),r==="start",i);return s&&(o=o.map(a=>a+"-"+s),n&&(o=o.concat(o.map(bw)))),o}function ky(e){const n=Ja(e);return FU[n]+e.slice(n.length)}function GU(e){return{top:0,right:0,bottom:0,left:0,...e}}function KN(e){return typeof e!="number"?GU(e):{top:e,right:e,bottom:e,left:e}}function Ey(e){const{x:n,y:r,width:i,height:s}=e;return{width:i,height:s,top:r,left:n,right:n+i,bottom:r+s,x:n,y:r}}function Q8(e,n,r){let{reference:i,floating:s}=e;const o=Uo(n),a=k5(n),c=j5(a),d=Ja(n),h=o==="y",g=i.x+i.width/2-s.width/2,p=i.y+i.height/2-s.height/2,_=i[c]/2-s[c]/2;let b;switch(d){case"top":b={x:g,y:i.y-s.height};break;case"bottom":b={x:g,y:i.y+i.height};break;case"right":b={x:i.x+i.width,y:p};break;case"left":b={x:i.x-s.width,y:p};break;default:b={x:i.x,y:i.y}}switch(dd(n)){case"start":b[a]-=_*(r&&h?-1:1);break;case"end":b[a]+=_*(r&&h?-1:1);break}return b}async function YU(e,n){var r;n===void 0&&(n={});const{x:i,y:s,platform:o,rects:a,elements:c,strategy:d}=e,{boundary:h="clippingAncestors",rootBoundary:g="viewport",elementContext:p="floating",altBoundary:_=!1,padding:b=0}=Xa(n,e),x=KN(b),j=c[_?p==="floating"?"reference":"floating":p],S=Ey(await o.getClippingRect({element:(r=await(o.isElement==null?void 0:o.isElement(j)))==null||r?j:j.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(c.floating)),boundary:h,rootBoundary:g,strategy:d})),E=p==="floating"?{x:i,y:s,width:a.floating.width,height:a.floating.height}:a.reference,O=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c.floating)),N=await(o.isElement==null?void 0:o.isElement(O))?await(o.getScale==null?void 0:o.getScale(O))||{x:1,y:1}:{x:1,y:1},T=Ey(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:E,offsetParent:O,strategy:d}):E);return{top:(S.top-T.top+x.top)/N.y,bottom:(T.bottom-S.bottom+x.bottom)/N.y,left:(S.left-T.left+x.left)/N.x,right:(T.right-S.right+x.right)/N.x}}const XU=50,JU=async(e,n,r)=>{const{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:a}=r,c=a.detectOverflow?a:{...a,detectOverflow:YU},d=await(a.isRTL==null?void 0:a.isRTL(n));let h=await a.getElementRects({reference:e,floating:n,strategy:s}),{x:g,y:p}=Q8(h,i,d),_=i,b=0;const x={};for(let C=0;C<o.length;C++){const j=o[C];if(!j)continue;const{name:S,fn:E}=j,{x:O,y:N,data:T,reset:P}=await E({x:g,y:p,initialPlacement:i,placement:_,strategy:s,middlewareData:x,rects:h,platform:c,elements:{reference:e,floating:n}});g=O??g,p=N??p,x[S]={...x[S],...T},P&&b<XU&&(b++,typeof P=="object"&&(P.placement&&(_=P.placement),P.rects&&(h=P.rects===!0?await a.getElementRects({reference:e,floating:n,strategy:s}):P.rects),{x:g,y:p}=Q8(h,_,d)),C=-1)}return{x:g,y:p,placement:_,strategy:s,middlewareData:x}},ZU=e=>({name:"arrow",options:e,async fn(n){const{x:r,y:i,placement:s,rects:o,platform:a,elements:c,middlewareData:d}=n,{element:h,padding:g=0}=Xa(e,n)||{};if(h==null)return{};const p=KN(g),_={x:r,y:i},b=k5(s),x=j5(b),C=await a.getDimensions(h),j=b==="y",S=j?"top":"left",E=j?"bottom":"right",O=j?"clientHeight":"clientWidth",N=o.reference[x]+o.reference[b]-_[b]-o.floating[x],T=_[b]-o.reference[b],P=await(a.getOffsetParent==null?void 0:a.getOffsetParent(h));let D=P?P[O]:0;(!D||!await(a.isElement==null?void 0:a.isElement(P)))&&(D=c.floating[O]||o.floating[x]);const H=N/2-T/2,J=D/2-C[x]/2-1,I=ac(p[S],J),B=ac(p[E],J),F=I,W=D-C[x]-B,z=D/2-C[x]/2+H,V=_w(F,z,W),A=!d.arrow&&dd(s)!=null&&z!==V&&o.reference[x]/2-(z<F?I:B)-C[x]/2<0,U=A?z<F?z-F:z-W:0;return{[b]:_[b]+U,data:{[b]:V,centerOffset:z-V-U,...A&&{alignmentOffset:U}},reset:A}}}),QU=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var r,i;const{placement:s,middlewareData:o,rects:a,initialPlacement:c,platform:d,elements:h}=n,{mainAxis:g=!0,crossAxis:p=!0,fallbackPlacements:_,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:C=!0,...j}=Xa(e,n);if((r=o.arrow)!=null&&r.alignmentOffset)return{};const S=Ja(s),E=Uo(c),O=Ja(c)===c,N=await(d.isRTL==null?void 0:d.isRTL(h.floating)),T=_||(O||!C?[ky(c)]:UU(c)),P=x!=="none";!_&&P&&T.push(...KU(c,C,x,N));const D=[c,...T],H=await d.detectOverflow(n,j),J=[];let I=((i=o.flip)==null?void 0:i.overflows)||[];if(g&&J.push(H[S]),p){const z=HU(s,a,N);J.push(H[z[0]],H[z[1]])}if(I=[...I,{placement:s,overflows:J}],!J.every(z=>z<=0)){var B,F;const z=(((B=o.flip)==null?void 0:B.index)||0)+1,V=D[z];if(V&&(!(p==="alignment"?E!==Uo(V):!1)||I.every(K=>Uo(K.placement)===E?K.overflows[0]>0:!0)))return{data:{index:z,overflows:I},reset:{placement:V}};let A=(F=I.filter(U=>U.overflows[0]<=0).sort((U,K)=>U.overflows[1]-K.overflows[1])[0])==null?void 0:F.placement;if(!A)switch(b){case"bestFit":{var W;const U=(W=I.filter(K=>{if(P){const Y=Uo(K.placement);return Y===E||Y==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(Y=>Y>0).reduce((Y,$)=>Y+$,0)]).sort((K,Y)=>K[1]-Y[1])[0])==null?void 0:W[0];U&&(A=U);break}case"initialPlacement":A=c;break}if(s!==A)return{reset:{placement:A}}}return{}}}};function ej(e,n){return{top:e.top-n.height,right:e.right-n.width,bottom:e.bottom-n.height,left:e.left-n.width}}function tj(e){return BU.some(n=>e[n]>=0)}const eV=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(n){const{rects:r,platform:i}=n,{strategy:s="referenceHidden",...o}=Xa(e,n);switch(s){case"referenceHidden":{const a=await i.detectOverflow(n,{...o,elementContext:"reference"}),c=ej(a,r.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:tj(c)}}}case"escaped":{const a=await i.detectOverflow(n,{...o,altBoundary:!0}),c=ej(a,r.floating);return{data:{escapedOffsets:c,escaped:tj(c)}}}default:return{}}}}},GN=new Set(["left","top"]);async function tV(e,n){const{placement:r,platform:i,elements:s}=e,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),a=Ja(r),c=dd(r),d=Uo(r)==="y",h=GN.has(a)?-1:1,g=o&&d?-1:1,p=Xa(n,e);let{mainAxis:_,crossAxis:b,alignmentAxis:x}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return c&&typeof x=="number"&&(b=c==="end"?x*-1:x),d?{x:b*g,y:_*h}:{x:_*h,y:b*g}}const nV=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var r,i;const{x:s,y:o,placement:a,middlewareData:c}=n,d=await tV(n,e);return a===((r=c.offset)==null?void 0:r.placement)&&(i=c.arrow)!=null&&i.alignmentOffset?{}:{x:s+d.x,y:o+d.y,data:{...d,placement:a}}}}},rV=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:r,y:i,placement:s,platform:o}=n,{mainAxis:a=!0,crossAxis:c=!1,limiter:d={fn:S=>{let{x:E,y:O}=S;return{x:E,y:O}}},...h}=Xa(e,n),g={x:r,y:i},p=await o.detectOverflow(n,h),_=Uo(Ja(s)),b=C5(_);let x=g[b],C=g[_];if(a){const S=b==="y"?"top":"left",E=b==="y"?"bottom":"right",O=x+p[S],N=x-p[E];x=_w(O,x,N)}if(c){const S=_==="y"?"top":"left",E=_==="y"?"bottom":"right",O=C+p[S],N=C-p[E];C=_w(O,C,N)}const j=d.fn({...n,[b]:x,[_]:C});return{...j,data:{x:j.x-r,y:j.y-i,enabled:{[b]:a,[_]:c}}}}}},iV=function(e){return e===void 0&&(e={}),{options:e,fn(n){const{x:r,y:i,placement:s,rects:o,middlewareData:a}=n,{offset:c=0,mainAxis:d=!0,crossAxis:h=!0}=Xa(e,n),g={x:r,y:i},p=Uo(s),_=C5(p);let b=g[_],x=g[p];const C=Xa(c,n),j=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:0,crossAxis:0,...C};if(d){const O=_==="y"?"height":"width",N=o.reference[_]-o.floating[O]+j.mainAxis,T=o.reference[_]+o.reference[O]-j.mainAxis;b<N?b=N:b>T&&(b=T)}if(h){var S,E;const O=_==="y"?"width":"height",N=GN.has(Ja(s)),T=o.reference[p]-o.floating[O]+(N&&((S=a.offset)==null?void 0:S[p])||0)+(N?0:j.crossAxis),P=o.reference[p]+o.reference[O]+(N?0:((E=a.offset)==null?void 0:E[p])||0)-(N?j.crossAxis:0);x<T?x=T:x>P&&(x=P)}return{[_]:b,[p]:x}}}},sV=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){var r,i;const{placement:s,rects:o,platform:a,elements:c}=n,{apply:d=()=>{},...h}=Xa(e,n),g=await a.detectOverflow(n,h),p=Ja(s),_=dd(s),b=Uo(s)==="y",{width:x,height:C}=o.floating;let j,S;p==="top"||p==="bottom"?(j=p,S=_===(await(a.isRTL==null?void 0:a.isRTL(c.floating))?"start":"end")?"left":"right"):(S=p,j=_==="end"?"top":"bottom");const E=C-g.top-g.bottom,O=x-g.left-g.right,N=ac(C-g[j],E),T=ac(x-g[S],O),P=!n.middlewareData.shift;let D=N,H=T;if((r=n.middlewareData.shift)!=null&&r.enabled.x&&(H=O),(i=n.middlewareData.shift)!=null&&i.enabled.y&&(D=E),P&&!_){const I=ds(g.left,0),B=ds(g.right,0),F=ds(g.top,0),W=ds(g.bottom,0);b?H=x-2*(I!==0||B!==0?I+B:ds(g.left,g.right)):D=C-2*(F!==0||W!==0?F+W:ds(g.top,g.bottom))}await d({...n,availableWidth:H,availableHeight:D});const J=await a.getDimensions(c.floating);return x!==J.width||C!==J.height?{reset:{rects:!0}}:{}}}};function bv(){return typeof window<"u"}function hd(e){return YN(e)?(e.nodeName||"").toLowerCase():"#document"}function ps(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function ea(e){var n;return(n=(YN(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function YN(e){return bv()?e instanceof Node||e instanceof ps(e).Node:!1}function vo(e){return bv()?e instanceof Element||e instanceof ps(e).Element:!1}function el(e){return bv()?e instanceof HTMLElement||e instanceof ps(e).HTMLElement:!1}function nj(e){return!bv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ps(e).ShadowRoot}function xg(e){const{overflow:n,overflowX:r,overflowY:i,display:s}=_o(e);return/auto|scroll|overlay|hidden|clip/.test(n+i+r)&&s!=="inline"&&s!=="contents"}function oV(e){return/^(table|td|th)$/.test(hd(e))}function xv(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const aV=/transform|translate|scale|rotate|perspective|filter/,lV=/paint|layout|strict|content/,qc=e=>!!e&&e!=="none";let lx;function E5(e){const n=vo(e)?_o(e):e;return qc(n.transform)||qc(n.translate)||qc(n.scale)||qc(n.rotate)||qc(n.perspective)||!O5()&&(qc(n.backdropFilter)||qc(n.filter))||aV.test(n.willChange||"")||lV.test(n.contain||"")}function cV(e){let n=lc(e);for(;el(n)&&!Qf(n);){if(E5(n))return n;if(xv(n))return null;n=lc(n)}return null}function O5(){return lx==null&&(lx=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),lx}function Qf(e){return/^(html|body|#document)$/.test(hd(e))}function _o(e){return ps(e).getComputedStyle(e)}function wv(e){return vo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lc(e){if(hd(e)==="html")return e;const n=e.assignedSlot||e.parentNode||nj(e)&&e.host||ea(e);return nj(n)?n.host:n}function XN(e){const n=lc(e);return Qf(n)?e.ownerDocument?e.ownerDocument.body:e.body:el(n)&&xg(n)?n:XN(n)}function Ip(e,n,r){var i;n===void 0&&(n=[]),r===void 0&&(r=!0);const s=XN(e),o=s===((i=e.ownerDocument)==null?void 0:i.body),a=ps(s);if(o){const c=xw(a);return n.concat(a,a.visualViewport||[],xg(s)?s:[],c&&r?Ip(c):[])}else return n.concat(s,Ip(s,[],r))}function xw(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function JN(e){const n=_o(e);let r=parseFloat(n.width)||0,i=parseFloat(n.height)||0;const s=el(e),o=s?e.offsetWidth:r,a=s?e.offsetHeight:i,c=jy(r)!==o||jy(i)!==a;return c&&(r=o,i=a),{width:r,height:i,$:c}}function N5(e){return vo(e)?e:e.contextElement}function Gf(e){const n=N5(e);if(!el(n))return Ko(1);const r=n.getBoundingClientRect(),{width:i,height:s,$:o}=JN(n);let a=(o?jy(r.width):r.width)/i,c=(o?jy(r.height):r.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const uV=Ko(0);function ZN(e){const n=ps(e);return!O5()||!n.visualViewport?uV:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function fV(e,n,r){return n===void 0&&(n=!1),!r||n&&r!==ps(e)?!1:n}function pu(e,n,r,i){n===void 0&&(n=!1),r===void 0&&(r=!1);const s=e.getBoundingClientRect(),o=N5(e);let a=Ko(1);n&&(i?vo(i)&&(a=Gf(i)):a=Gf(e));const c=fV(o,r,i)?ZN(o):Ko(0);let d=(s.left+c.x)/a.x,h=(s.top+c.y)/a.y,g=s.width/a.x,p=s.height/a.y;if(o){const _=ps(o),b=i&&vo(i)?ps(i):i;let x=_,C=xw(x);for(;C&&i&&b!==x;){const j=Gf(C),S=C.getBoundingClientRect(),E=_o(C),O=S.left+(C.clientLeft+parseFloat(E.paddingLeft))*j.x,N=S.top+(C.clientTop+parseFloat(E.paddingTop))*j.y;d*=j.x,h*=j.y,g*=j.x,p*=j.y,d+=O,h+=N,x=ps(C),C=xw(x)}}return Ey({width:g,height:p,x:d,y:h})}function Sv(e,n){const r=wv(e).scrollLeft;return n?n.left+r:pu(ea(e)).left+r}function QN(e,n){const r=e.getBoundingClientRect(),i=r.left+n.scrollLeft-Sv(e,r),s=r.top+n.scrollTop;return{x:i,y:s}}function dV(e){let{elements:n,rect:r,offsetParent:i,strategy:s}=e;const o=s==="fixed",a=ea(i),c=n?xv(n.floating):!1;if(i===a||c&&o)return r;let d={scrollLeft:0,scrollTop:0},h=Ko(1);const g=Ko(0),p=el(i);if((p||!p&&!o)&&((hd(i)!=="body"||xg(a))&&(d=wv(i)),p)){const b=pu(i);h=Gf(i),g.x=b.x+i.clientLeft,g.y=b.y+i.clientTop}const _=a&&!p&&!o?QN(a,d):Ko(0);return{width:r.width*h.x,height:r.height*h.y,x:r.x*h.x-d.scrollLeft*h.x+g.x+_.x,y:r.y*h.y-d.scrollTop*h.y+g.y+_.y}}function hV(e){return Array.from(e.getClientRects())}function pV(e){const n=ea(e),r=wv(e),i=e.ownerDocument.body,s=ds(n.scrollWidth,n.clientWidth,i.scrollWidth,i.clientWidth),o=ds(n.scrollHeight,n.clientHeight,i.scrollHeight,i.clientHeight);let a=-r.scrollLeft+Sv(e);const c=-r.scrollTop;return _o(i).direction==="rtl"&&(a+=ds(n.clientWidth,i.clientWidth)-s),{width:s,height:o,x:a,y:c}}const rj=25;function mV(e,n){const r=ps(e),i=ea(e),s=r.visualViewport;let o=i.clientWidth,a=i.clientHeight,c=0,d=0;if(s){o=s.width,a=s.height;const g=O5();(!g||g&&n==="fixed")&&(c=s.offsetLeft,d=s.offsetTop)}const h=Sv(i);if(h<=0){const g=i.ownerDocument,p=g.body,_=getComputedStyle(p),b=g.compatMode==="CSS1Compat"&&parseFloat(_.marginLeft)+parseFloat(_.marginRight)||0,x=Math.abs(i.clientWidth-p.clientWidth-b);x<=rj&&(o-=x)}else h<=rj&&(o+=h);return{width:o,height:a,x:c,y:d}}function gV(e,n){const r=pu(e,!0,n==="fixed"),i=r.top+e.clientTop,s=r.left+e.clientLeft,o=el(e)?Gf(e):Ko(1),a=e.clientWidth*o.x,c=e.clientHeight*o.y,d=s*o.x,h=i*o.y;return{width:a,height:c,x:d,y:h}}function ij(e,n,r){let i;if(n==="viewport")i=mV(e,r);else if(n==="document")i=pV(ea(e));else if(vo(n))i=gV(n,r);else{const s=ZN(e);i={x:n.x-s.x,y:n.y-s.y,width:n.width,height:n.height}}return Ey(i)}function eT(e,n){const r=lc(e);return r===n||!vo(r)||Qf(r)?!1:_o(r).position==="fixed"||eT(r,n)}function yV(e,n){const r=n.get(e);if(r)return r;let i=Ip(e,[],!1).filter(c=>vo(c)&&hd(c)!=="body"),s=null;const o=_o(e).position==="fixed";let a=o?lc(e):e;for(;vo(a)&&!Qf(a);){const c=_o(a),d=E5(a);!d&&c.position==="fixed"&&(s=null),(o?!d&&!s:!d&&c.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||xg(a)&&!d&&eT(e,a))?i=i.filter(g=>g!==a):s=c,a=lc(a)}return n.set(e,i),i}function vV(e){let{element:n,boundary:r,rootBoundary:i,strategy:s}=e;const a=[...r==="clippingAncestors"?xv(n)?[]:yV(n,this._c):[].concat(r),i],c=ij(n,a[0],s);let d=c.top,h=c.right,g=c.bottom,p=c.left;for(let _=1;_<a.length;_++){const b=ij(n,a[_],s);d=ds(b.top,d),h=ac(b.right,h),g=ac(b.bottom,g),p=ds(b.left,p)}return{width:h-p,height:g-d,x:p,y:d}}function _V(e){const{width:n,height:r}=JN(e);return{width:n,height:r}}function bV(e,n,r){const i=el(n),s=ea(n),o=r==="fixed",a=pu(e,!0,o,n);let c={scrollLeft:0,scrollTop:0};const d=Ko(0);function h(){d.x=Sv(s)}if(i||!i&&!o)if((hd(n)!=="body"||xg(s))&&(c=wv(n)),i){const b=pu(n,!0,o,n);d.x=b.x+n.clientLeft,d.y=b.y+n.clientTop}else s&&h();o&&!i&&s&&h();const g=s&&!i&&!o?QN(s,c):Ko(0),p=a.left+c.scrollLeft-d.x-g.x,_=a.top+c.scrollTop-d.y-g.y;return{x:p,y:_,width:a.width,height:a.height}}function cx(e){return _o(e).position==="static"}function sj(e,n){if(!el(e)||_o(e).position==="fixed")return null;if(n)return n(e);let r=e.offsetParent;return ea(e)===r&&(r=r.ownerDocument.body),r}function tT(e,n){const r=ps(e);if(xv(e))return r;if(!el(e)){let s=lc(e);for(;s&&!Qf(s);){if(vo(s)&&!cx(s))return s;s=lc(s)}return r}let i=sj(e,n);for(;i&&oV(i)&&cx(i);)i=sj(i,n);return i&&Qf(i)&&cx(i)&&!E5(i)?r:i||cV(e)||r}const xV=async function(e){const n=this.getOffsetParent||tT,r=this.getDimensions,i=await r(e.floating);return{reference:bV(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function wV(e){return _o(e).direction==="rtl"}const SV={convertOffsetParentRelativeRectToViewportRelativeRect:dV,getDocumentElement:ea,getClippingRect:vV,getOffsetParent:tT,getElementRects:xV,getClientRects:hV,getDimensions:_V,getScale:Gf,isElement:vo,isRTL:wV};function nT(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function CV(e,n){let r=null,i;const s=ea(e);function o(){var c;clearTimeout(i),(c=r)==null||c.disconnect(),r=null}function a(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),o();const h=e.getBoundingClientRect(),{left:g,top:p,width:_,height:b}=h;if(c||n(),!_||!b)return;const x=m1(p),C=m1(s.clientWidth-(g+_)),j=m1(s.clientHeight-(p+b)),S=m1(g),O={rootMargin:-x+"px "+-C+"px "+-j+"px "+-S+"px",threshold:ds(0,ac(1,d))||1};let N=!0;function T(P){const D=P[0].intersectionRatio;if(D!==d){if(!N)return a();D?a(!1,D):i=setTimeout(()=>{a(!1,1e-7)},1e3)}D===1&&!nT(h,e.getBoundingClientRect())&&a(),N=!1}try{r=new IntersectionObserver(T,{...O,root:s.ownerDocument})}catch{r=new IntersectionObserver(T,O)}r.observe(e)}return a(!0),o}function jV(e,n,r,i){i===void 0&&(i={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=i,h=N5(e),g=s||o?[...h?Ip(h):[],...n?Ip(n):[]]:[];g.forEach(S=>{s&&S.addEventListener("scroll",r,{passive:!0}),o&&S.addEventListener("resize",r)});const p=h&&c?CV(h,r):null;let _=-1,b=null;a&&(b=new ResizeObserver(S=>{let[E]=S;E&&E.target===h&&b&&n&&(b.unobserve(n),cancelAnimationFrame(_),_=requestAnimationFrame(()=>{var O;(O=b)==null||O.observe(n)})),r()}),h&&!d&&b.observe(h),n&&b.observe(n));let x,C=d?pu(e):null;d&&j();function j(){const S=pu(e);C&&!nT(C,S)&&r(),C=S,x=requestAnimationFrame(j)}return r(),()=>{var S;g.forEach(E=>{s&&E.removeEventListener("scroll",r),o&&E.removeEventListener("resize",r)}),p==null||p(),(S=b)==null||S.disconnect(),b=null,d&&cancelAnimationFrame(x)}}const kV=nV,EV=rV,OV=QU,NV=sV,TV=eV,oj=ZU,PV=iV,AV=(e,n,r)=>{const i=new Map,s={platform:SV,...r},o={...s.platform,_c:i};return JU(e,n,{...s,platform:o})};var MV=typeof document<"u",RV=function(){},Q1=MV?y.useLayoutEffect:RV;function Oy(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let r,i,s;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==n.length)return!1;for(i=r;i--!==0;)if(!Oy(e[i],n[i]))return!1;return!0}if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!{}.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){const o=s[i];if(!(o==="_owner"&&e.$$typeof)&&!Oy(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}function rT(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function aj(e,n){const r=rT(e);return Math.round(n*r)/r}function ux(e){const n=y.useRef(e);return Q1(()=>{n.current=e}),n}function DV(e){e===void 0&&(e={});const{placement:n="bottom",strategy:r="absolute",middleware:i=[],platform:s,elements:{reference:o,floating:a}={},transform:c=!0,whileElementsMounted:d,open:h}=e,[g,p]=y.useState({x:0,y:0,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[_,b]=y.useState(i);Oy(_,i)||b(i);const[x,C]=y.useState(null),[j,S]=y.useState(null),E=y.useCallback(K=>{K!==P.current&&(P.current=K,C(K))},[]),O=y.useCallback(K=>{K!==D.current&&(D.current=K,S(K))},[]),N=o||x,T=a||j,P=y.useRef(null),D=y.useRef(null),H=y.useRef(g),J=d!=null,I=ux(d),B=ux(s),F=ux(h),W=y.useCallback(()=>{if(!P.current||!D.current)return;const K={placement:n,strategy:r,middleware:_};B.current&&(K.platform=B.current),AV(P.current,D.current,K).then(Y=>{const $={...Y,isPositioned:F.current!==!1};z.current&&!Oy(H.current,$)&&(H.current=$,Su.flushSync(()=>{p($)}))})},[_,n,r,B,F]);Q1(()=>{h===!1&&H.current.isPositioned&&(H.current.isPositioned=!1,p(K=>({...K,isPositioned:!1})))},[h]);const z=y.useRef(!1);Q1(()=>(z.current=!0,()=>{z.current=!1}),[]),Q1(()=>{if(N&&(P.current=N),T&&(D.current=T),N&&T){if(I.current)return I.current(N,T,W);W()}},[N,T,W,I,J]);const V=y.useMemo(()=>({reference:P,floating:D,setReference:E,setFloating:O}),[E,O]),A=y.useMemo(()=>({reference:N,floating:T}),[N,T]),U=y.useMemo(()=>{const K={position:r,left:0,top:0};if(!A.floating)return K;const Y=aj(A.floating,g.x),$=aj(A.floating,g.y);return c?{...K,transform:"translate("+Y+"px, "+$+"px)",...rT(A.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:Y,top:$}},[r,c,A.floating,g.x,g.y]);return y.useMemo(()=>({...g,update:W,refs:V,elements:A,floatingStyles:U}),[g,W,V,A,U])}const zV=e=>{function n(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:i,padding:s}=typeof e=="function"?e(r):e;return i&&n(i)?i.current!=null?oj({element:i.current,padding:s}).fn(r):{}:i?oj({element:i,padding:s}).fn(r):{}}}},LV=(e,n)=>{const r=kV(e);return{name:r.name,fn:r.fn,options:[e,n]}},$V=(e,n)=>{const r=EV(e);return{name:r.name,fn:r.fn,options:[e,n]}},IV=(e,n)=>({fn:PV(e).fn,options:[e,n]}),BV=(e,n)=>{const r=OV(e);return{name:r.name,fn:r.fn,options:[e,n]}},FV=(e,n)=>{const r=NV(e);return{name:r.name,fn:r.fn,options:[e,n]}},HV=(e,n)=>{const r=TV(e);return{name:r.name,fn:r.fn,options:[e,n]}},UV=(e,n)=>{const r=zV(e);return{name:r.name,fn:r.fn,options:[e,n]}};function VV(e){const n=WV(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(KV);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function WV(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=YV(s),c=GV(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var qV=Symbol("radix.slottable");function KV(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qV}function GV(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function YV(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var XV=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],JV=XV.reduce((e,n)=>{const r=VV(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),ZV="Arrow",iT=y.forwardRef((e,n)=>{const{children:r,width:i=10,height:s=5,...o}=e;return f.jsx(JV.svg,{...o,ref:n,width:i,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:f.jsx("polygon",{points:"0,0 30,0 15,10"})})});iT.displayName=ZV;var QV=iT;function eW(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,tW(s,...n)]}function tW(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function nW(e){const n=rW(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(sW);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function rW(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=aW(s),c=oW(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var iW=Symbol("radix.slottable");function sW(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===iW}function oW(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function aW(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var lW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],sT=lW.reduce((e,n)=>{const r=nW(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function oT(e){const[n,r]=y.useState(void 0);return ar(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const o=s[0];let a,c;if("borderBoxSize"in o){const d=o.borderBoxSize,h=Array.isArray(d)?d[0]:d;a=h.inlineSize,c=h.blockSize}else a=e.offsetWidth,c=e.offsetHeight;r({width:a,height:c})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else r(void 0)},[e]),n}var T5="Popper",[aT,pd]=eW(T5),[cW,lT]=aT(T5),cT=e=>{const{__scopePopper:n,children:r}=e,[i,s]=y.useState(null);return f.jsx(cW,{scope:n,anchor:i,onAnchorChange:s,children:r})};cT.displayName=T5;var uT="PopperAnchor",fT=y.forwardRef((e,n)=>{const{__scopePopper:r,virtualRef:i,...s}=e,o=lT(uT,r),a=y.useRef(null),c=Jt(n,a),d=y.useRef(null);return y.useEffect(()=>{const h=d.current;d.current=(i==null?void 0:i.current)||a.current,h!==d.current&&o.onAnchorChange(d.current)}),i?null:f.jsx(sT.div,{...s,ref:c})});fT.displayName=uT;var P5="PopperContent",[uW,fW]=aT(P5),dT=y.forwardRef((e,n)=>{var se,ce,be,ze,fe,Ce;const{__scopePopper:r,side:i="bottom",sideOffset:s=0,align:o="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:g=0,sticky:p="partial",hideWhenDetached:_=!1,updatePositionStrategy:b="optimized",onPlaced:x,...C}=e,j=lT(P5,r),[S,E]=y.useState(null),O=Jt(n,me=>E(me)),[N,T]=y.useState(null),P=oT(N),D=(P==null?void 0:P.width)??0,H=(P==null?void 0:P.height)??0,J=i+(o!=="center"?"-"+o:""),I=typeof g=="number"?g:{top:0,right:0,bottom:0,left:0,...g},B=Array.isArray(h)?h:[h],F=B.length>0,W={padding:I,boundary:B.filter(hW),altBoundary:F},{refs:z,floatingStyles:V,placement:A,isPositioned:U,middlewareData:K}=DV({strategy:"fixed",placement:J,whileElementsMounted:(...me)=>jV(...me,{animationFrame:b==="always"}),elements:{reference:j.anchor},middleware:[LV({mainAxis:s+H,alignmentAxis:a}),d&&$V({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?IV():void 0,...W}),d&&BV({...W}),FV({...W,apply:({elements:me,rects:Ye,availableWidth:tt,availableHeight:Ue})=>{const{width:mt,height:Dt}=Ye.reference,Et=me.floating.style;Et.setProperty("--radix-popper-available-width",`${tt}px`),Et.setProperty("--radix-popper-available-height",`${Ue}px`),Et.setProperty("--radix-popper-anchor-width",`${mt}px`),Et.setProperty("--radix-popper-anchor-height",`${Dt}px`)}}),N&&UV({element:N,padding:c}),pW({arrowWidth:D,arrowHeight:H}),_&&HV({strategy:"referenceHidden",...W})]}),[Y,$]=mT(A),R=Ar(x);ar(()=>{U&&(R==null||R())},[U,R]);const Z=(se=K.arrow)==null?void 0:se.x,L=(ce=K.arrow)==null?void 0:ce.y,Q=((be=K.arrow)==null?void 0:be.centerOffset)!==0,[X,ie]=y.useState();return ar(()=>{S&&ie(window.getComputedStyle(S).zIndex)},[S]),f.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:U?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(ze=K.transformOrigin)==null?void 0:ze.x,(fe=K.transformOrigin)==null?void 0:fe.y].join(" "),...((Ce=K.hide)==null?void 0:Ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:f.jsx(uW,{scope:r,placedSide:Y,onArrowChange:T,arrowX:Z,arrowY:L,shouldHideArrow:Q,children:f.jsx(sT.div,{"data-side":Y,"data-align":$,...C,ref:O,style:{...C.style,animation:U?void 0:"none"}})})})});dT.displayName=P5;var hT="PopperArrow",dW={top:"bottom",right:"left",bottom:"top",left:"right"},pT=y.forwardRef(function(n,r){const{__scopePopper:i,...s}=n,o=fW(hT,i),a=dW[o.placedSide];return f.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:f.jsx(QV,{...s,ref:r,style:{...s.style,display:"block"}})})});pT.displayName=hT;function hW(e){return e!==null}var pW=e=>({name:"transformOrigin",options:e,fn(n){var j,S,E;const{placement:r,rects:i,middlewareData:s}=n,a=((j=s.arrow)==null?void 0:j.centerOffset)!==0,c=a?0:e.arrowWidth,d=a?0:e.arrowHeight,[h,g]=mT(r),p={start:"0%",center:"50%",end:"100%"}[g],_=(((S=s.arrow)==null?void 0:S.x)??0)+c/2,b=(((E=s.arrow)==null?void 0:E.y)??0)+d/2;let x="",C="";return h==="bottom"?(x=a?p:`${_}px`,C=`${-d}px`):h==="top"?(x=a?p:`${_}px`,C=`${i.floating.height+d}px`):h==="right"?(x=`${-d}px`,C=a?p:`${b}px`):h==="left"&&(x=`${i.floating.width+d}px`,C=a?p:`${b}px`),{data:{x,y:C}}}});function mT(e){const[n,r="center"]=e.split("-");return[n,r]}var A5=cT,M5=fT,R5=dT,D5=pT;function gT(e){const n=mW(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(yW);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function mW(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=_W(s),c=vW(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var gW=Symbol("radix.slottable");function yW(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===gW}function vW(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function _W(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var bW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],wg=bW.reduce((e,n)=>{const r=gT(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function xW(e,n){e&&Su.flushSync(()=>e.dispatchEvent(n))}function wW(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,SW(s,...n)]}function SW(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function CW(e){const n=jW(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(EW);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function jW(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=NW(s),c=OW(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var kW=Symbol("radix.slottable");function EW(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kW}function OW(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function NW(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var TW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],yT=TW.reduce((e,n)=>{const r=CW(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),fx="rovingFocusGroup.onEntryFocus",PW={bubbles:!1,cancelable:!0},Sg="RovingFocusGroup",[ww,vT,AW]=S5(Sg),[MW,Cv]=wW(Sg,[AW]),[RW,DW]=MW(Sg),_T=y.forwardRef((e,n)=>f.jsx(ww.Provider,{scope:e.__scopeRovingFocusGroup,children:f.jsx(ww.Slot,{scope:e.__scopeRovingFocusGroup,children:f.jsx(zW,{...e,ref:n})})}));_T.displayName=Sg;var zW=y.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:r,orientation:i,loop:s=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:h,preventScrollOnEntryFocus:g=!1,...p}=e,_=y.useRef(null),b=Jt(n,_),x=bg(o),[C,j]=Ka({prop:a,defaultProp:c??null,onChange:d,caller:Sg}),[S,E]=y.useState(!1),O=Ar(h),N=vT(r),T=y.useRef(!1),[P,D]=y.useState(0);return y.useEffect(()=>{const H=_.current;if(H)return H.addEventListener(fx,O),()=>H.removeEventListener(fx,O)},[O]),f.jsx(RW,{scope:r,orientation:i,dir:x,loop:s,currentTabStopId:C,onItemFocus:y.useCallback(H=>j(H),[j]),onItemShiftTab:y.useCallback(()=>E(!0),[]),onFocusableItemAdd:y.useCallback(()=>D(H=>H+1),[]),onFocusableItemRemove:y.useCallback(()=>D(H=>H-1),[]),children:f.jsx(yT.div,{tabIndex:S||P===0?-1:0,"data-orientation":i,...p,ref:b,style:{outline:"none",...e.style},onMouseDown:ot(e.onMouseDown,()=>{T.current=!0}),onFocus:ot(e.onFocus,H=>{const J=!T.current;if(H.target===H.currentTarget&&J&&!S){const I=new CustomEvent(fx,PW);if(H.currentTarget.dispatchEvent(I),!I.defaultPrevented){const B=N().filter(A=>A.focusable),F=B.find(A=>A.active),W=B.find(A=>A.id===C),V=[F,W,...B].filter(Boolean).map(A=>A.ref.current);wT(V,g)}}T.current=!1}),onBlur:ot(e.onBlur,()=>E(!1))})})}),bT="RovingFocusGroupItem",xT=y.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:r,focusable:i=!0,active:s=!1,tabStopId:o,children:a,...c}=e,d=$s(),h=o||d,g=DW(bT,r),p=g.currentTabStopId===h,_=vT(r),{onFocusableItemAdd:b,onFocusableItemRemove:x,currentTabStopId:C}=g;return y.useEffect(()=>{if(i)return b(),()=>x()},[i,b,x]),f.jsx(ww.ItemSlot,{scope:r,id:h,focusable:i,active:s,children:f.jsx(yT.span,{tabIndex:p?0:-1,"data-orientation":g.orientation,...c,ref:n,onMouseDown:ot(e.onMouseDown,j=>{i?g.onItemFocus(h):j.preventDefault()}),onFocus:ot(e.onFocus,()=>g.onItemFocus(h)),onKeyDown:ot(e.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){g.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const S=IW(j,g.orientation,g.dir);if(S!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let O=_().filter(N=>N.focusable).map(N=>N.ref.current);if(S==="last")O.reverse();else if(S==="prev"||S==="next"){S==="prev"&&O.reverse();const N=O.indexOf(j.currentTarget);O=g.loop?BW(O,N+1):O.slice(N+1)}setTimeout(()=>wT(O))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:C!=null}):a})})});xT.displayName=bT;var LW={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function $W(e,n){return n!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function IW(e,n,r){const i=$W(e.key,r);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return LW[i]}function wT(e,n=!1){const r=document.activeElement;for(const i of e)if(i===r||(i.focus({preventScroll:n}),document.activeElement!==r))return}function BW(e,n){return e.map((r,i)=>e[(n+i)%e.length])}var ST=_T,CT=xT,Sw=["Enter"," "],FW=["ArrowDown","PageUp","Home"],jT=["ArrowUp","PageDown","End"],HW=[...FW,...jT],UW={ltr:[...Sw,"ArrowRight"],rtl:[...Sw,"ArrowLeft"]},VW={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Cg="Menu",[Bp,WW,qW]=S5(Cg),[ju,kT]=LU(Cg,[qW,pd,Cv]),jv=pd(),ET=Cv(),[KW,ku]=ju(Cg),[GW,jg]=ju(Cg),OT=e=>{const{__scopeMenu:n,open:r=!1,children:i,dir:s,onOpenChange:o,modal:a=!0}=e,c=jv(n),[d,h]=y.useState(null),g=y.useRef(!1),p=Ar(o),_=bg(s);return y.useEffect(()=>{const b=()=>{g.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>g.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),f.jsx(A5,{...c,children:f.jsx(KW,{scope:n,open:r,onOpenChange:p,content:d,onContentChange:h,children:f.jsx(GW,{scope:n,onClose:y.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:g,dir:_,modal:a,children:i})})})};OT.displayName=Cg;var YW="MenuAnchor",z5=y.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e,s=jv(r);return f.jsx(M5,{...s,...i,ref:n})});z5.displayName=YW;var L5="MenuPortal",[XW,NT]=ju(L5,{forceMount:void 0}),TT=e=>{const{__scopeMenu:n,forceMount:r,children:i,container:s}=e,o=ku(L5,n);return f.jsx(XW,{scope:n,forceMount:r,children:f.jsx(si,{present:r||o.open,children:f.jsx(yg,{asChild:!0,container:s,children:i})})})};TT.displayName=L5;var Is="MenuContent",[JW,$5]=ju(Is),PT=y.forwardRef((e,n)=>{const r=NT(Is,e.__scopeMenu),{forceMount:i=r.forceMount,...s}=e,o=ku(Is,e.__scopeMenu),a=jg(Is,e.__scopeMenu);return f.jsx(Bp.Provider,{scope:e.__scopeMenu,children:f.jsx(si,{present:i||o.open,children:f.jsx(Bp.Slot,{scope:e.__scopeMenu,children:a.modal?f.jsx(ZW,{...s,ref:n}):f.jsx(QW,{...s,ref:n})})})})}),ZW=y.forwardRef((e,n)=>{const r=ku(Is,e.__scopeMenu),i=y.useRef(null),s=Jt(n,i);return y.useEffect(()=>{const o=i.current;if(o)return _5(o)},[]),f.jsx(I5,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:ot(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),QW=y.forwardRef((e,n)=>{const r=ku(Is,e.__scopeMenu);return f.jsx(I5,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),eq=gT("MenuContent.ScrollLock"),I5=y.forwardRef((e,n)=>{const{__scopeMenu:r,loop:i=!1,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:h,onPointerDownOutside:g,onFocusOutside:p,onInteractOutside:_,onDismiss:b,disableOutsideScroll:x,...C}=e,j=ku(Is,r),S=jg(Is,r),E=jv(r),O=ET(r),N=WW(r),[T,P]=y.useState(null),D=y.useRef(null),H=Jt(n,D,j.onContentChange),J=y.useRef(0),I=y.useRef(""),B=y.useRef(0),F=y.useRef(null),W=y.useRef("right"),z=y.useRef(0),V=x?vv:y.Fragment,A=x?{as:eq,allowPinchZoom:!0}:void 0,U=Y=>{var se,ce;const $=I.current+Y,R=N().filter(be=>!be.disabled),Z=document.activeElement,L=(se=R.find(be=>be.ref.current===Z))==null?void 0:se.textValue,Q=R.map(be=>be.textValue),X=dq(Q,$,L),ie=(ce=R.find(be=>be.textValue===X))==null?void 0:ce.ref.current;(function be(ze){I.current=ze,window.clearTimeout(J.current),ze!==""&&(J.current=window.setTimeout(()=>be(""),1e3))})($),ie&&setTimeout(()=>ie.focus())};y.useEffect(()=>()=>window.clearTimeout(J.current),[]),v5();const K=y.useCallback(Y=>{var R,Z;return W.current===((R=F.current)==null?void 0:R.side)&&pq(Y,(Z=F.current)==null?void 0:Z.area)},[]);return f.jsx(JW,{scope:r,searchRef:I,onItemEnter:y.useCallback(Y=>{K(Y)&&Y.preventDefault()},[K]),onItemLeave:y.useCallback(Y=>{var $;K(Y)||(($=D.current)==null||$.focus(),P(null))},[K]),onTriggerLeave:y.useCallback(Y=>{K(Y)&&Y.preventDefault()},[K]),pointerGraceTimerRef:B,onPointerGraceIntentChange:y.useCallback(Y=>{F.current=Y},[]),children:f.jsx(V,{...A,children:f.jsx(gv,{asChild:!0,trapped:s,onMountAutoFocus:ot(o,Y=>{var $;Y.preventDefault(),($=D.current)==null||$.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:f.jsx(gg,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:h,onPointerDownOutside:g,onFocusOutside:p,onInteractOutside:_,onDismiss:b,children:f.jsx(ST,{asChild:!0,...O,dir:S.dir,orientation:"vertical",loop:i,currentTabStopId:T,onCurrentTabStopIdChange:P,onEntryFocus:ot(d,Y=>{S.isUsingKeyboardRef.current||Y.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(R5,{role:"menu","aria-orientation":"vertical","data-state":KT(j.open),"data-radix-menu-content":"",dir:S.dir,...E,...C,ref:H,style:{outline:"none",...C.style},onKeyDown:ot(C.onKeyDown,Y=>{const R=Y.target.closest("[data-radix-menu-content]")===Y.currentTarget,Z=Y.ctrlKey||Y.altKey||Y.metaKey,L=Y.key.length===1;R&&(Y.key==="Tab"&&Y.preventDefault(),!Z&&L&&U(Y.key));const Q=D.current;if(Y.target!==Q||!HW.includes(Y.key))return;Y.preventDefault();const ie=N().filter(se=>!se.disabled).map(se=>se.ref.current);jT.includes(Y.key)&&ie.reverse(),uq(ie)}),onBlur:ot(e.onBlur,Y=>{Y.currentTarget.contains(Y.target)||(window.clearTimeout(J.current),I.current="")}),onPointerMove:ot(e.onPointerMove,Fp(Y=>{const $=Y.target,R=z.current!==Y.clientX;if(Y.currentTarget.contains($)&&R){const Z=Y.clientX>z.current?"right":"left";W.current=Z,z.current=Y.clientX}}))})})})})})})});PT.displayName=Is;var tq="MenuGroup",B5=y.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return f.jsx(wg.div,{role:"group",...i,ref:n})});B5.displayName=tq;var nq="MenuLabel",AT=y.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return f.jsx(wg.div,{...i,ref:n})});AT.displayName=nq;var Ny="MenuItem",lj="menu.itemSelect",kv=y.forwardRef((e,n)=>{const{disabled:r=!1,onSelect:i,...s}=e,o=y.useRef(null),a=jg(Ny,e.__scopeMenu),c=$5(Ny,e.__scopeMenu),d=Jt(n,o),h=y.useRef(!1),g=()=>{const p=o.current;if(!r&&p){const _=new CustomEvent(lj,{bubbles:!0,cancelable:!0});p.addEventListener(lj,b=>i==null?void 0:i(b),{once:!0}),xW(p,_),_.defaultPrevented?h.current=!1:a.onClose()}};return f.jsx(MT,{...s,ref:d,disabled:r,onClick:ot(e.onClick,g),onPointerDown:p=>{var _;(_=e.onPointerDown)==null||_.call(e,p),h.current=!0},onPointerUp:ot(e.onPointerUp,p=>{var _;h.current||(_=p.currentTarget)==null||_.click()}),onKeyDown:ot(e.onKeyDown,p=>{const _=c.searchRef.current!=="";r||_&&p.key===" "||Sw.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});kv.displayName=Ny;var MT=y.forwardRef((e,n)=>{const{__scopeMenu:r,disabled:i=!1,textValue:s,...o}=e,a=$5(Ny,r),c=ET(r),d=y.useRef(null),h=Jt(n,d),[g,p]=y.useState(!1),[_,b]=y.useState("");return y.useEffect(()=>{const x=d.current;x&&b((x.textContent??"").trim())},[o.children]),f.jsx(Bp.ItemSlot,{scope:r,disabled:i,textValue:s??_,children:f.jsx(CT,{asChild:!0,...c,focusable:!i,children:f.jsx(wg.div,{role:"menuitem","data-highlighted":g?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...o,ref:h,onPointerMove:ot(e.onPointerMove,Fp(x=>{i?a.onItemLeave(x):(a.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ot(e.onPointerLeave,Fp(x=>a.onItemLeave(x))),onFocus:ot(e.onFocus,()=>p(!0)),onBlur:ot(e.onBlur,()=>p(!1))})})})}),rq="MenuCheckboxItem",RT=y.forwardRef((e,n)=>{const{checked:r=!1,onCheckedChange:i,...s}=e;return f.jsx(IT,{scope:e.__scopeMenu,checked:r,children:f.jsx(kv,{role:"menuitemcheckbox","aria-checked":Ty(r)?"mixed":r,...s,ref:n,"data-state":H5(r),onSelect:ot(s.onSelect,()=>i==null?void 0:i(Ty(r)?!0:!r),{checkForDefaultPrevented:!1})})})});RT.displayName=rq;var DT="MenuRadioGroup",[iq,sq]=ju(DT,{value:void 0,onValueChange:()=>{}}),zT=y.forwardRef((e,n)=>{const{value:r,onValueChange:i,...s}=e,o=Ar(i);return f.jsx(iq,{scope:e.__scopeMenu,value:r,onValueChange:o,children:f.jsx(B5,{...s,ref:n})})});zT.displayName=DT;var LT="MenuRadioItem",$T=y.forwardRef((e,n)=>{const{value:r,...i}=e,s=sq(LT,e.__scopeMenu),o=r===s.value;return f.jsx(IT,{scope:e.__scopeMenu,checked:o,children:f.jsx(kv,{role:"menuitemradio","aria-checked":o,...i,ref:n,"data-state":H5(o),onSelect:ot(i.onSelect,()=>{var a;return(a=s.onValueChange)==null?void 0:a.call(s,r)},{checkForDefaultPrevented:!1})})})});$T.displayName=LT;var F5="MenuItemIndicator",[IT,oq]=ju(F5,{checked:!1}),BT=y.forwardRef((e,n)=>{const{__scopeMenu:r,forceMount:i,...s}=e,o=oq(F5,r);return f.jsx(si,{present:i||Ty(o.checked)||o.checked===!0,children:f.jsx(wg.span,{...s,ref:n,"data-state":H5(o.checked)})})});BT.displayName=F5;var aq="MenuSeparator",FT=y.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return f.jsx(wg.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})});FT.displayName=aq;var lq="MenuArrow",HT=y.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e,s=jv(r);return f.jsx(D5,{...s,...i,ref:n})});HT.displayName=lq;var cq="MenuSub",[TSe,UT]=ju(cq),lp="MenuSubTrigger",VT=y.forwardRef((e,n)=>{const r=ku(lp,e.__scopeMenu),i=jg(lp,e.__scopeMenu),s=UT(lp,e.__scopeMenu),o=$5(lp,e.__scopeMenu),a=y.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=o,h={__scopeMenu:e.__scopeMenu},g=y.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return y.useEffect(()=>g,[g]),y.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),f.jsx(z5,{asChild:!0,...h,children:f.jsx(MT,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":s.contentId,"data-state":KT(r.open),...e,ref:lr(n,s.onTriggerChange),onClick:p=>{var _;(_=e.onClick)==null||_.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:ot(e.onPointerMove,Fp(p=>{o.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!r.open&&!a.current&&(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),g()},100))})),onPointerLeave:ot(e.onPointerLeave,Fp(p=>{var b,x;g();const _=(b=r.content)==null?void 0:b.getBoundingClientRect();if(_){const C=(x=r.content)==null?void 0:x.dataset.side,j=C==="right",S=j?-5:5,E=_[j?"left":"right"],O=_[j?"right":"left"];o.onPointerGraceIntentChange({area:[{x:p.clientX+S,y:p.clientY},{x:E,y:_.top},{x:O,y:_.top},{x:O,y:_.bottom},{x:E,y:_.bottom}],side:C}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(p),p.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:ot(e.onKeyDown,p=>{var b;const _=o.searchRef.current!=="";e.disabled||_&&p.key===" "||UW[i.dir].includes(p.key)&&(r.onOpenChange(!0),(b=r.content)==null||b.focus(),p.preventDefault())})})})});VT.displayName=lp;var WT="MenuSubContent",qT=y.forwardRef((e,n)=>{const r=NT(Is,e.__scopeMenu),{forceMount:i=r.forceMount,...s}=e,o=ku(Is,e.__scopeMenu),a=jg(Is,e.__scopeMenu),c=UT(WT,e.__scopeMenu),d=y.useRef(null),h=Jt(n,d);return f.jsx(Bp.Provider,{scope:e.__scopeMenu,children:f.jsx(si,{present:i||o.open,children:f.jsx(Bp.Slot,{scope:e.__scopeMenu,children:f.jsx(I5,{id:c.contentId,"aria-labelledby":c.triggerId,...s,ref:h,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:g=>{var p;a.isUsingKeyboardRef.current&&((p=d.current)==null||p.focus()),g.preventDefault()},onCloseAutoFocus:g=>g.preventDefault(),onFocusOutside:ot(e.onFocusOutside,g=>{g.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:ot(e.onEscapeKeyDown,g=>{a.onClose(),g.preventDefault()}),onKeyDown:ot(e.onKeyDown,g=>{var b;const p=g.currentTarget.contains(g.target),_=VW[a.dir].includes(g.key);p&&_&&(o.onOpenChange(!1),(b=c.trigger)==null||b.focus(),g.preventDefault())})})})})})});qT.displayName=WT;function KT(e){return e?"open":"closed"}function Ty(e){return e==="indeterminate"}function H5(e){return Ty(e)?"indeterminate":e?"checked":"unchecked"}function uq(e){const n=document.activeElement;for(const r of e)if(r===n||(r.focus(),document.activeElement!==n))return}function fq(e,n){return e.map((r,i)=>e[(n+i)%e.length])}function dq(e,n,r){const s=n.length>1&&Array.from(n).every(h=>h===n[0])?n[0]:n,o=r?e.indexOf(r):-1;let a=fq(e,Math.max(o,0));s.length===1&&(a=a.filter(h=>h!==r));const d=a.find(h=>h.toLowerCase().startsWith(s.toLowerCase()));return d!==r?d:void 0}function hq(e,n){const{x:r,y:i}=e;let s=!1;for(let o=0,a=n.length-1;o<n.length;a=o++){const c=n[o],d=n[a],h=c.x,g=c.y,p=d.x,_=d.y;g>i!=_>i&&r<(p-h)*(i-g)/(_-g)+h&&(s=!s)}return s}function pq(e,n){if(!n)return!1;const r={x:e.clientX,y:e.clientY};return hq(r,n)}function Fp(e){return n=>n.pointerType==="mouse"?e(n):void 0}var mq=OT,gq=z5,yq=TT,vq=PT,_q=B5,bq=AT,xq=kv,wq=RT,Sq=zT,Cq=$T,jq=BT,kq=FT,Eq=HT,Oq=VT,Nq=qT,Ev="DropdownMenu",[Tq]=bU(Ev,[kT]),bi=kT(),[Pq,GT]=Tq(Ev),YT=e=>{const{__scopeDropdownMenu:n,children:r,dir:i,open:s,defaultOpen:o,onOpenChange:a,modal:c=!0}=e,d=bi(n),h=y.useRef(null),[g,p]=Ka({prop:s,defaultProp:o??!1,onChange:a,caller:Ev});return f.jsx(Pq,{scope:n,triggerId:$s(),triggerRef:h,contentId:$s(),open:g,onOpenChange:p,onOpenToggle:y.useCallback(()=>p(_=>!_),[p]),modal:c,children:f.jsx(mq,{...d,open:g,onOpenChange:p,dir:i,modal:c,children:r})})};YT.displayName=Ev;var XT="DropdownMenuTrigger",JT=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,disabled:i=!1,...s}=e,o=GT(XT,r),a=bi(r);return f.jsx(gq,{asChild:!0,...a,children:f.jsx(NU.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...s,ref:lr(n,o.triggerRef),onPointerDown:ot(e.onPointerDown,c=>{!i&&c.button===0&&c.ctrlKey===!1&&(o.onOpenToggle(),o.open||c.preventDefault())}),onKeyDown:ot(e.onKeyDown,c=>{i||(["Enter"," "].includes(c.key)&&o.onOpenToggle(),c.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});JT.displayName=XT;var Aq="DropdownMenuPortal",ZT=e=>{const{__scopeDropdownMenu:n,...r}=e,i=bi(n);return f.jsx(yq,{...i,...r})};ZT.displayName=Aq;var QT="DropdownMenuContent",eP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=GT(QT,r),o=bi(r),a=y.useRef(!1);return f.jsx(vq,{id:s.contentId,"aria-labelledby":s.triggerId,...o,...i,ref:n,onCloseAutoFocus:ot(e.onCloseAutoFocus,c=>{var d;a.current||(d=s.triggerRef.current)==null||d.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:ot(e.onInteractOutside,c=>{const d=c.detail.originalEvent,h=d.button===0&&d.ctrlKey===!0,g=d.button===2||h;(!s.modal||g)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});eP.displayName=QT;var Mq="DropdownMenuGroup",Rq=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(_q,{...s,...i,ref:n})});Rq.displayName=Mq;var Dq="DropdownMenuLabel",tP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(bq,{...s,...i,ref:n})});tP.displayName=Dq;var zq="DropdownMenuItem",nP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(xq,{...s,...i,ref:n})});nP.displayName=zq;var Lq="DropdownMenuCheckboxItem",$q=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(wq,{...s,...i,ref:n})});$q.displayName=Lq;var Iq="DropdownMenuRadioGroup",Bq=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(Sq,{...s,...i,ref:n})});Bq.displayName=Iq;var Fq="DropdownMenuRadioItem",rP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(Cq,{...s,...i,ref:n})});rP.displayName=Fq;var Hq="DropdownMenuItemIndicator",iP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(jq,{...s,...i,ref:n})});iP.displayName=Hq;var Uq="DropdownMenuSeparator",sP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(kq,{...s,...i,ref:n})});sP.displayName=Uq;var Vq="DropdownMenuArrow",Wq=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(Eq,{...s,...i,ref:n})});Wq.displayName=Vq;var qq="DropdownMenuSubTrigger",Kq=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(Oq,{...s,...i,ref:n})});Kq.displayName=qq;var Gq="DropdownMenuSubContent",Yq=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(Nq,{...s,...i,ref:n,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Yq.displayName=Gq;var Xq=YT,Jq=JT,Zq=ZT,oP=eP,aP=tP,lP=nP,cP=rP,Qq=iP,uP=sP;const Eu=Xq,Ou=Jq,dc=y.forwardRef(({className:e,sideOffset:n=6,...r},i)=>f.jsx(Zq,{children:f.jsx(oP,{ref:i,sideOffset:n,className:We("z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",e),...r})}));dc.displayName=oP.displayName;const Ov=y.forwardRef(({className:e,...n},r)=>f.jsx(aP,{ref:r,className:We("px-2 py-1.5 text-sm font-semibold",e),...n}));Ov.displayName=aP.displayName;const Xo=y.forwardRef(({className:e,inset:n,...r},i)=>f.jsx(lP,{ref:i,className:We("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",e),...r}));Xo.displayName=lP.displayName;const Vo=y.forwardRef(({className:e,...n},r)=>f.jsx(uP,{ref:r,className:We("-mx-1 my-1 h-px bg-muted",e),...n}));Vo.displayName=uP.displayName;const eK=y.forwardRef(({className:e,children:n,...r},i)=>f.jsxs(cP,{ref:i,className:We("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(Qq,{children:f.jsx(Rr,{className:"h-4 w-4"})})}),n]}));eK.displayName=cP.displayName;const Kr=y.forwardRef(({className:e,type:n,...r},i)=>f.jsx("input",{type:n,className:We("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:i,...r}));Kr.displayName="Input";var tK="Label",fP=y.forwardRef((e,n)=>f.jsx(mv.label,{...e,ref:n,onMouseDown:r=>{var s;r.target.closest("button, input, select, textarea")||((s=e.onMouseDown)==null||s.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));fP.displayName=tK;var dP=fP;const nK=y5("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),or=y.forwardRef(({className:e,...n},r)=>f.jsx(dP,{ref:r,className:We(nK(),e),...n}));or.displayName=dP.displayName;function rK(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,iK(s,...n)]}function iK(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function sK(e){const n=oK(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(lK);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function oK(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=uK(s),c=cK(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var aK=Symbol("radix.slottable");function lK(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===aK}function cK(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function uK(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var fK=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nv=fK.reduce((e,n)=>{const r=sK(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),Tv="Tabs",[dK]=rK(Tv,[Cv]),hP=Cv(),[hK,U5]=dK(Tv),pP=y.forwardRef((e,n)=>{const{__scopeTabs:r,value:i,onValueChange:s,defaultValue:o,orientation:a="horizontal",dir:c,activationMode:d="automatic",...h}=e,g=bg(c),[p,_]=Ka({prop:i,onChange:s,defaultProp:o??"",caller:Tv});return f.jsx(hK,{scope:r,baseId:$s(),value:p,onValueChange:_,orientation:a,dir:g,activationMode:d,children:f.jsx(Nv.div,{dir:g,"data-orientation":a,...h,ref:n})})});pP.displayName=Tv;var mP="TabsList",gP=y.forwardRef((e,n)=>{const{__scopeTabs:r,loop:i=!0,...s}=e,o=U5(mP,r),a=hP(r);return f.jsx(ST,{asChild:!0,...a,orientation:o.orientation,dir:o.dir,loop:i,children:f.jsx(Nv.div,{role:"tablist","aria-orientation":o.orientation,...s,ref:n})})});gP.displayName=mP;var yP="TabsTrigger",vP=y.forwardRef((e,n)=>{const{__scopeTabs:r,value:i,disabled:s=!1,...o}=e,a=U5(yP,r),c=hP(r),d=xP(a.baseId,i),h=wP(a.baseId,i),g=i===a.value;return f.jsx(CT,{asChild:!0,...c,focusable:!s,active:g,children:f.jsx(Nv.button,{type:"button",role:"tab","aria-selected":g,"aria-controls":h,"data-state":g?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:d,...o,ref:n,onMouseDown:ot(e.onMouseDown,p=>{!s&&p.button===0&&p.ctrlKey===!1?a.onValueChange(i):p.preventDefault()}),onKeyDown:ot(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&a.onValueChange(i)}),onFocus:ot(e.onFocus,()=>{const p=a.activationMode!=="manual";!g&&!s&&p&&a.onValueChange(i)})})})});vP.displayName=yP;var _P="TabsContent",bP=y.forwardRef((e,n)=>{const{__scopeTabs:r,value:i,forceMount:s,children:o,...a}=e,c=U5(_P,r),d=xP(c.baseId,i),h=wP(c.baseId,i),g=i===c.value,p=y.useRef(g);return y.useEffect(()=>{const _=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(_)},[]),f.jsx(si,{present:s||g,children:({present:_})=>f.jsx(Nv.div,{"data-state":g?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!_,id:h,tabIndex:0,...a,ref:n,style:{...e.style,animationDuration:p.current?"0s":void 0},children:_&&o})})});bP.displayName=_P;function xP(e,n){return`${e}-trigger-${n}`}function wP(e,n){return`${e}-content-${n}`}var pK=pP,SP=gP,CP=vP,jP=bP;const V5=pK,Pv=y.forwardRef(({className:e,...n},r)=>f.jsx(SP,{ref:r,className:We("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...n}));Pv.displayName=SP.displayName;const Ba=y.forwardRef(({className:e,...n},r)=>f.jsx(CP,{ref:r,className:We("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...n}));Ba.displayName=CP.displayName;const Fa=y.forwardRef(({className:e,...n},r)=>f.jsx(jP,{ref:r,className:We("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...n}));Fa.displayName=jP.displayName;function mK(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,gK(s,...n)]}function gK(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function yK(e){const n=vK(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(bK);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function vK(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=wK(s),c=xK(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var kP=Symbol("radix.slottable");function _K(e){const n=({children:r})=>f.jsx(f.Fragment,{children:r});return n.displayName=`${e}.Slottable`,n.__radixId=kP,n}function bK(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kP}function xK(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function wK(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var SK=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],CK=SK.reduce((e,n)=>{const r=yK(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function jK(e){const n=kK(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(OK);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function kK(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=TK(s),c=NK(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var EK=Symbol("radix.slottable");function OK(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===EK}function NK(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function TK(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var PK=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],AK=PK.reduce((e,n)=>{const r=jK(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),EP=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),MK="VisuallyHidden",OP=y.forwardRef((e,n)=>f.jsx(AK.span,{...e,ref:n,style:{...EP,...e.style}}));OP.displayName=MK;var RK=OP,[Av]=mK("Tooltip",[pd]),Mv=pd(),NP="TooltipProvider",DK=700,Cw="tooltip.open",[zK,W5]=Av(NP),TP=e=>{const{__scopeTooltip:n,delayDuration:r=DK,skipDelayDuration:i=300,disableHoverableContent:s=!1,children:o}=e,a=y.useRef(!0),c=y.useRef(!1),d=y.useRef(0);return y.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),f.jsx(zK,{scope:n,isOpenDelayedRef:a,delayDuration:r,onOpen:y.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,i)},[i]),isPointerInTransitRef:c,onPointerInTransitChange:y.useCallback(h=>{c.current=h},[]),disableHoverableContent:s,children:o})};TP.displayName=NP;var Hp="Tooltip",[LK,kg]=Av(Hp),PP=e=>{const{__scopeTooltip:n,children:r,open:i,defaultOpen:s,onOpenChange:o,disableHoverableContent:a,delayDuration:c}=e,d=W5(Hp,e.__scopeTooltip),h=Mv(n),[g,p]=y.useState(null),_=$s(),b=y.useRef(0),x=a??d.disableHoverableContent,C=c??d.delayDuration,j=y.useRef(!1),[S,E]=Ka({prop:i,defaultProp:s??!1,onChange:D=>{D?(d.onOpen(),document.dispatchEvent(new CustomEvent(Cw))):d.onClose(),o==null||o(D)},caller:Hp}),O=y.useMemo(()=>S?j.current?"delayed-open":"instant-open":"closed",[S]),N=y.useCallback(()=>{window.clearTimeout(b.current),b.current=0,j.current=!1,E(!0)},[E]),T=y.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E(!1)},[E]),P=y.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{j.current=!0,E(!0),b.current=0},C)},[C,E]);return y.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),f.jsx(A5,{...h,children:f.jsx(LK,{scope:n,contentId:_,open:S,stateAttribute:O,trigger:g,onTriggerChange:p,onTriggerEnter:y.useCallback(()=>{d.isOpenDelayedRef.current?P():N()},[d.isOpenDelayedRef,P,N]),onTriggerLeave:y.useCallback(()=>{x?T():(window.clearTimeout(b.current),b.current=0)},[T,x]),onOpen:N,onClose:T,disableHoverableContent:x,children:r})})};PP.displayName=Hp;var jw="TooltipTrigger",AP=y.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,s=kg(jw,r),o=W5(jw,r),a=Mv(r),c=y.useRef(null),d=Jt(n,c,s.onTriggerChange),h=y.useRef(!1),g=y.useRef(!1),p=y.useCallback(()=>h.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),f.jsx(M5,{asChild:!0,...a,children:f.jsx(CK.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...i,ref:d,onPointerMove:ot(e.onPointerMove,_=>{_.pointerType!=="touch"&&!g.current&&!o.isPointerInTransitRef.current&&(s.onTriggerEnter(),g.current=!0)}),onPointerLeave:ot(e.onPointerLeave,()=>{s.onTriggerLeave(),g.current=!1}),onPointerDown:ot(e.onPointerDown,()=>{s.open&&s.onClose(),h.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ot(e.onFocus,()=>{h.current||s.onOpen()}),onBlur:ot(e.onBlur,s.onClose),onClick:ot(e.onClick,s.onClose)})})});AP.displayName=jw;var q5="TooltipPortal",[$K,IK]=Av(q5,{forceMount:void 0}),MP=e=>{const{__scopeTooltip:n,forceMount:r,children:i,container:s}=e,o=kg(q5,n);return f.jsx($K,{scope:n,forceMount:r,children:f.jsx(si,{present:r||o.open,children:f.jsx(yg,{asChild:!0,container:s,children:i})})})};MP.displayName=q5;var ed="TooltipContent",RP=y.forwardRef((e,n)=>{const r=IK(ed,e.__scopeTooltip),{forceMount:i=r.forceMount,side:s="top",...o}=e,a=kg(ed,e.__scopeTooltip);return f.jsx(si,{present:i||a.open,children:a.disableHoverableContent?f.jsx(DP,{side:s,...o,ref:n}):f.jsx(BK,{side:s,...o,ref:n})})}),BK=y.forwardRef((e,n)=>{const r=kg(ed,e.__scopeTooltip),i=W5(ed,e.__scopeTooltip),s=y.useRef(null),o=Jt(n,s),[a,c]=y.useState(null),{trigger:d,onClose:h}=r,g=s.current,{onPointerInTransitChange:p}=i,_=y.useCallback(()=>{c(null),p(!1)},[p]),b=y.useCallback((x,C)=>{const j=x.currentTarget,S={x:x.clientX,y:x.clientY},E=WK(S,j.getBoundingClientRect()),O=qK(S,E),N=KK(C.getBoundingClientRect()),T=YK([...O,...N]);c(T),p(!0)},[p]);return y.useEffect(()=>()=>_(),[_]),y.useEffect(()=>{if(d&&g){const x=j=>b(j,g),C=j=>b(j,d);return d.addEventListener("pointerleave",x),g.addEventListener("pointerleave",C),()=>{d.removeEventListener("pointerleave",x),g.removeEventListener("pointerleave",C)}}},[d,g,b,_]),y.useEffect(()=>{if(a){const x=C=>{const j=C.target,S={x:C.clientX,y:C.clientY},E=(d==null?void 0:d.contains(j))||(g==null?void 0:g.contains(j)),O=!GK(S,a);E?_():O&&(_(),h())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[d,g,a,h,_]),f.jsx(DP,{...e,ref:o})}),[FK,HK]=Av(Hp,{isInside:!1}),UK=_K("TooltipContent"),DP=y.forwardRef((e,n)=>{const{__scopeTooltip:r,children:i,"aria-label":s,onEscapeKeyDown:o,onPointerDownOutside:a,...c}=e,d=kg(ed,r),h=Mv(r),{onClose:g}=d;return y.useEffect(()=>(document.addEventListener(Cw,g),()=>document.removeEventListener(Cw,g)),[g]),y.useEffect(()=>{if(d.trigger){const p=_=>{const b=_.target;b!=null&&b.contains(d.trigger)&&g()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,g]),f.jsx(gg,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:g,children:f.jsxs(R5,{"data-state":d.stateAttribute,...h,...c,ref:n,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[f.jsx(UK,{children:i}),f.jsx(FK,{scope:r,isInside:!0,children:f.jsx(RK,{id:d.contentId,role:"tooltip",children:s||i})})]})})});RP.displayName=ed;var zP="TooltipArrow",VK=y.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,s=Mv(r);return HK(zP,r).isInside?null:f.jsx(D5,{...s,...i,ref:n})});VK.displayName=zP;function WK(e,n){const r=Math.abs(n.top-e.y),i=Math.abs(n.bottom-e.y),s=Math.abs(n.right-e.x),o=Math.abs(n.left-e.x);switch(Math.min(r,i,s,o)){case o:return"left";case s:return"right";case r:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function qK(e,n,r=5){const i=[];switch(n){case"top":i.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":i.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":i.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":i.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return i}function KK(e){const{top:n,right:r,bottom:i,left:s}=e;return[{x:s,y:n},{x:r,y:n},{x:r,y:i},{x:s,y:i}]}function GK(e,n){const{x:r,y:i}=e;let s=!1;for(let o=0,a=n.length-1;o<n.length;a=o++){const c=n[o],d=n[a],h=c.x,g=c.y,p=d.x,_=d.y;g>i!=_>i&&r<(p-h)*(i-g)/(_-g)+h&&(s=!s)}return s}function YK(e){const n=e.slice();return n.sort((r,i)=>r.x<i.x?-1:r.x>i.x?1:r.y<i.y?-1:r.y>i.y?1:0),XK(n)}function XK(e){if(e.length<=1)return e.slice();const n=[];for(let i=0;i<e.length;i++){const s=e[i];for(;n.length>=2;){const o=n[n.length-1],a=n[n.length-2];if((o.x-a.x)*(s.y-a.y)>=(o.y-a.y)*(s.x-a.x))n.pop();else break}n.push(s)}n.pop();const r=[];for(let i=e.length-1;i>=0;i--){const s=e[i];for(;r.length>=2;){const o=r[r.length-1],a=r[r.length-2];if((o.x-a.x)*(s.y-a.y)>=(o.y-a.y)*(s.x-a.x))r.pop();else break}r.push(s)}return r.pop(),n.length===1&&r.length===1&&n[0].x===r[0].x&&n[0].y===r[0].y?n:n.concat(r)}var JK=TP,ZK=PP,QK=AP,eG=MP,LP=RP;const tG=JK,dr=ZK,hr=QK,ir=y.forwardRef(({className:e,sideOffset:n=4,...r},i)=>f.jsx(eG,{children:f.jsx(LP,{ref:i,sideOffset:n,className:We("z-50 overflow-hidden rounded-md bg-foreground px-3 py-1.5 text-xs text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",e),...r})}));ir.displayName=LP.displayName;function Tf(e,n,r){let i=r.initialDeps??[],s,o=!0;function a(){var c,d,h;let g;r.key&&((c=r.debug)!=null&&c.call(r))&&(g=Date.now());const p=e();if(!(p.length!==i.length||p.some((x,C)=>i[C]!==x)))return s;i=p;let b;if(r.key&&((d=r.debug)!=null&&d.call(r))&&(b=Date.now()),s=n(...p),r.key&&((h=r.debug)!=null&&h.call(r))){const x=Math.round((Date.now()-g)*100)/100,C=Math.round((Date.now()-b)*100)/100,j=C/16,S=(E,O)=>{for(E=String(E);E.length<O;)E=" "+E;return E};console.info(`%c⏱ ${S(C,5)} /${S(x,5)} ms`,`
|
|
611
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return y.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},pU="DialogDescriptionWarning",mU=({contentRef:e,descriptionId:n})=>{const i=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${FN(pU).contentName}}.`;return y.useEffect(()=>{var o;const s=(o=e.current)==null?void 0:o.getAttribute("aria-describedby");n&&s&&(document.getElementById(n)||console.warn(i))},[i,e,n]),null},gU=ON,yU=PN,HN=AN,UN=MN,VN=DN,WN=LN,vU=IN;const Cu=gU,_U=yU,qN=y.forwardRef(({className:e,...n},r)=>f.jsx(HN,{ref:r,className:We("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...n}));qN.displayName=HN.displayName;const fc=y.forwardRef(({className:e,children:n,...r},i)=>f.jsxs(_U,{children:[f.jsx(qN,{}),f.jsxs(UN,{ref:i,className:We("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r,children:[n,f.jsxs(vU,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[f.jsx(Mr,{className:"h-4 w-4"}),f.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));fc.displayName=UN.displayName;const Ga=({className:e,...n})=>f.jsx("div",{className:We("flex flex-col space-y-1.5 text-center sm:text-left",e),...n});Ga.displayName="DialogHeader";const _g=({className:e,...n})=>f.jsx("div",{className:We("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...n});_g.displayName="DialogFooter";const Ya=y.forwardRef(({className:e,...n},r)=>f.jsx(VN,{ref:r,className:We("text-lg font-semibold leading-none tracking-tight",e),...n}));Ya.displayName=VN.displayName;const Cy=y.forwardRef(({className:e,...n},r)=>f.jsx(WN,{ref:r,className:We("text-sm text-muted-foreground",e),...n}));Cy.displayName=WN.displayName;function bU(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,xU(s,...n)]}function xU(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function wU(e){const n=SU(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(jU);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function SU(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=EU(s),c=kU(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var CU=Symbol("radix.slottable");function jU(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===CU}function kU(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function EU(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var OU=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],NU=OU.reduce((e,n)=>{const r=wU(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function TU(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,PU(s,...n)]}function PU(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function X8(e){const n=AU(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(RU);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function AU(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=zU(s),c=DU(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var MU=Symbol("radix.slottable");function RU(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===MU}function DU(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function zU(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}function S5(e){const n=e+"CollectionProvider",[r,i]=TU(n),[s,o]=r(n,{collectionRef:{current:null},itemMap:new Map}),a=C=>{const{scope:j,children:S}=C,E=Xe.useRef(null),O=Xe.useRef(new Map).current;return f.jsx(s,{scope:j,itemMap:O,collectionRef:E,children:S})};a.displayName=n;const c=e+"CollectionSlot",d=X8(c),h=Xe.forwardRef((C,j)=>{const{scope:S,children:E}=C,O=o(c,S),N=Jt(j,O.collectionRef);return f.jsx(d,{ref:N,children:E})});h.displayName=c;const g=e+"CollectionItemSlot",p="data-radix-collection-item",_=X8(g),b=Xe.forwardRef((C,j)=>{const{scope:S,children:E,...O}=C,N=Xe.useRef(null),T=Jt(j,N),P=o(g,S);return Xe.useEffect(()=>(P.itemMap.set(N,{ref:N,...O}),()=>void P.itemMap.delete(N))),f.jsx(_,{[p]:"",ref:T,children:E})});b.displayName=g;function x(C){const j=o(e+"CollectionConsumer",C);return Xe.useCallback(()=>{const E=j.collectionRef.current;if(!E)return[];const O=Array.from(E.querySelectorAll(`[${p}]`));return Array.from(j.itemMap.values()).sort((P,D)=>O.indexOf(P.ref.current)-O.indexOf(D.ref.current))},[j.collectionRef,j.itemMap])}return[{Provider:a,Slot:h,ItemSlot:b},x,i]}function LU(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,$U(s,...n)]}function $U(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}var IU=y.createContext(void 0);function bg(e){const n=y.useContext(IU);return e||n||"ltr"}const BU=["top","right","bottom","left"],ac=Math.min,ds=Math.max,jy=Math.round,m1=Math.floor,Ko=e=>({x:e,y:e}),FU={left:"right",right:"left",bottom:"top",top:"bottom"};function _w(e,n,r){return ds(e,ac(n,r))}function Xa(e,n){return typeof e=="function"?e(n):e}function Ja(e){return e.split("-")[0]}function dd(e){return e.split("-")[1]}function C5(e){return e==="x"?"y":"x"}function j5(e){return e==="y"?"height":"width"}function Uo(e){const n=e[0];return n==="t"||n==="b"?"y":"x"}function k5(e){return C5(Uo(e))}function HU(e,n,r){r===void 0&&(r=!1);const i=dd(e),s=k5(e),o=j5(s);let a=s==="x"?i===(r?"end":"start")?"right":"left":i==="start"?"bottom":"top";return n.reference[o]>n.floating[o]&&(a=ky(a)),[a,ky(a)]}function UU(e){const n=ky(e);return[bw(e),n,bw(n)]}function bw(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const J8=["left","right"],Z8=["right","left"],VU=["top","bottom"],WU=["bottom","top"];function qU(e,n,r){switch(e){case"top":case"bottom":return r?n?Z8:J8:n?J8:Z8;case"left":case"right":return n?VU:WU;default:return[]}}function KU(e,n,r,i){const s=dd(e);let o=qU(Ja(e),r==="start",i);return s&&(o=o.map(a=>a+"-"+s),n&&(o=o.concat(o.map(bw)))),o}function ky(e){const n=Ja(e);return FU[n]+e.slice(n.length)}function GU(e){return{top:0,right:0,bottom:0,left:0,...e}}function KN(e){return typeof e!="number"?GU(e):{top:e,right:e,bottom:e,left:e}}function Ey(e){const{x:n,y:r,width:i,height:s}=e;return{width:i,height:s,top:r,left:n,right:n+i,bottom:r+s,x:n,y:r}}function Q8(e,n,r){let{reference:i,floating:s}=e;const o=Uo(n),a=k5(n),c=j5(a),d=Ja(n),h=o==="y",g=i.x+i.width/2-s.width/2,p=i.y+i.height/2-s.height/2,_=i[c]/2-s[c]/2;let b;switch(d){case"top":b={x:g,y:i.y-s.height};break;case"bottom":b={x:g,y:i.y+i.height};break;case"right":b={x:i.x+i.width,y:p};break;case"left":b={x:i.x-s.width,y:p};break;default:b={x:i.x,y:i.y}}switch(dd(n)){case"start":b[a]-=_*(r&&h?-1:1);break;case"end":b[a]+=_*(r&&h?-1:1);break}return b}async function YU(e,n){var r;n===void 0&&(n={});const{x:i,y:s,platform:o,rects:a,elements:c,strategy:d}=e,{boundary:h="clippingAncestors",rootBoundary:g="viewport",elementContext:p="floating",altBoundary:_=!1,padding:b=0}=Xa(n,e),x=KN(b),j=c[_?p==="floating"?"reference":"floating":p],S=Ey(await o.getClippingRect({element:(r=await(o.isElement==null?void 0:o.isElement(j)))==null||r?j:j.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(c.floating)),boundary:h,rootBoundary:g,strategy:d})),E=p==="floating"?{x:i,y:s,width:a.floating.width,height:a.floating.height}:a.reference,O=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c.floating)),N=await(o.isElement==null?void 0:o.isElement(O))?await(o.getScale==null?void 0:o.getScale(O))||{x:1,y:1}:{x:1,y:1},T=Ey(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:E,offsetParent:O,strategy:d}):E);return{top:(S.top-T.top+x.top)/N.y,bottom:(T.bottom-S.bottom+x.bottom)/N.y,left:(S.left-T.left+x.left)/N.x,right:(T.right-S.right+x.right)/N.x}}const XU=50,JU=async(e,n,r)=>{const{placement:i="bottom",strategy:s="absolute",middleware:o=[],platform:a}=r,c=a.detectOverflow?a:{...a,detectOverflow:YU},d=await(a.isRTL==null?void 0:a.isRTL(n));let h=await a.getElementRects({reference:e,floating:n,strategy:s}),{x:g,y:p}=Q8(h,i,d),_=i,b=0;const x={};for(let C=0;C<o.length;C++){const j=o[C];if(!j)continue;const{name:S,fn:E}=j,{x:O,y:N,data:T,reset:P}=await E({x:g,y:p,initialPlacement:i,placement:_,strategy:s,middlewareData:x,rects:h,platform:c,elements:{reference:e,floating:n}});g=O??g,p=N??p,x[S]={...x[S],...T},P&&b<XU&&(b++,typeof P=="object"&&(P.placement&&(_=P.placement),P.rects&&(h=P.rects===!0?await a.getElementRects({reference:e,floating:n,strategy:s}):P.rects),{x:g,y:p}=Q8(h,_,d)),C=-1)}return{x:g,y:p,placement:_,strategy:s,middlewareData:x}},ZU=e=>({name:"arrow",options:e,async fn(n){const{x:r,y:i,placement:s,rects:o,platform:a,elements:c,middlewareData:d}=n,{element:h,padding:g=0}=Xa(e,n)||{};if(h==null)return{};const p=KN(g),_={x:r,y:i},b=k5(s),x=j5(b),C=await a.getDimensions(h),j=b==="y",S=j?"top":"left",E=j?"bottom":"right",O=j?"clientHeight":"clientWidth",N=o.reference[x]+o.reference[b]-_[b]-o.floating[x],T=_[b]-o.reference[b],P=await(a.getOffsetParent==null?void 0:a.getOffsetParent(h));let D=P?P[O]:0;(!D||!await(a.isElement==null?void 0:a.isElement(P)))&&(D=c.floating[O]||o.floating[x]);const H=N/2-T/2,J=D/2-C[x]/2-1,I=ac(p[S],J),B=ac(p[E],J),F=I,W=D-C[x]-B,z=D/2-C[x]/2+H,V=_w(F,z,W),A=!d.arrow&&dd(s)!=null&&z!==V&&o.reference[x]/2-(z<F?I:B)-C[x]/2<0,U=A?z<F?z-F:z-W:0;return{[b]:_[b]+U,data:{[b]:V,centerOffset:z-V-U,...A&&{alignmentOffset:U}},reset:A}}}),QU=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(n){var r,i;const{placement:s,middlewareData:o,rects:a,initialPlacement:c,platform:d,elements:h}=n,{mainAxis:g=!0,crossAxis:p=!0,fallbackPlacements:_,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:C=!0,...j}=Xa(e,n);if((r=o.arrow)!=null&&r.alignmentOffset)return{};const S=Ja(s),E=Uo(c),O=Ja(c)===c,N=await(d.isRTL==null?void 0:d.isRTL(h.floating)),T=_||(O||!C?[ky(c)]:UU(c)),P=x!=="none";!_&&P&&T.push(...KU(c,C,x,N));const D=[c,...T],H=await d.detectOverflow(n,j),J=[];let I=((i=o.flip)==null?void 0:i.overflows)||[];if(g&&J.push(H[S]),p){const z=HU(s,a,N);J.push(H[z[0]],H[z[1]])}if(I=[...I,{placement:s,overflows:J}],!J.every(z=>z<=0)){var B,F;const z=(((B=o.flip)==null?void 0:B.index)||0)+1,V=D[z];if(V&&(!(p==="alignment"?E!==Uo(V):!1)||I.every(K=>Uo(K.placement)===E?K.overflows[0]>0:!0)))return{data:{index:z,overflows:I},reset:{placement:V}};let A=(F=I.filter(U=>U.overflows[0]<=0).sort((U,K)=>U.overflows[1]-K.overflows[1])[0])==null?void 0:F.placement;if(!A)switch(b){case"bestFit":{var W;const U=(W=I.filter(K=>{if(P){const Y=Uo(K.placement);return Y===E||Y==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(Y=>Y>0).reduce((Y,$)=>Y+$,0)]).sort((K,Y)=>K[1]-Y[1])[0])==null?void 0:W[0];U&&(A=U);break}case"initialPlacement":A=c;break}if(s!==A)return{reset:{placement:A}}}return{}}}};function ej(e,n){return{top:e.top-n.height,right:e.right-n.width,bottom:e.bottom-n.height,left:e.left-n.width}}function tj(e){return BU.some(n=>e[n]>=0)}const eV=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(n){const{rects:r,platform:i}=n,{strategy:s="referenceHidden",...o}=Xa(e,n);switch(s){case"referenceHidden":{const a=await i.detectOverflow(n,{...o,elementContext:"reference"}),c=ej(a,r.reference);return{data:{referenceHiddenOffsets:c,referenceHidden:tj(c)}}}case"escaped":{const a=await i.detectOverflow(n,{...o,altBoundary:!0}),c=ej(a,r.floating);return{data:{escapedOffsets:c,escaped:tj(c)}}}default:return{}}}}},GN=new Set(["left","top"]);async function tV(e,n){const{placement:r,platform:i,elements:s}=e,o=await(i.isRTL==null?void 0:i.isRTL(s.floating)),a=Ja(r),c=dd(r),d=Uo(r)==="y",h=GN.has(a)?-1:1,g=o&&d?-1:1,p=Xa(n,e);let{mainAxis:_,crossAxis:b,alignmentAxis:x}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return c&&typeof x=="number"&&(b=c==="end"?x*-1:x),d?{x:b*g,y:_*h}:{x:_*h,y:b*g}}const nV=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(n){var r,i;const{x:s,y:o,placement:a,middlewareData:c}=n,d=await tV(n,e);return a===((r=c.offset)==null?void 0:r.placement)&&(i=c.arrow)!=null&&i.alignmentOffset?{}:{x:s+d.x,y:o+d.y,data:{...d,placement:a}}}}},rV=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(n){const{x:r,y:i,placement:s,platform:o}=n,{mainAxis:a=!0,crossAxis:c=!1,limiter:d={fn:S=>{let{x:E,y:O}=S;return{x:E,y:O}}},...h}=Xa(e,n),g={x:r,y:i},p=await o.detectOverflow(n,h),_=Uo(Ja(s)),b=C5(_);let x=g[b],C=g[_];if(a){const S=b==="y"?"top":"left",E=b==="y"?"bottom":"right",O=x+p[S],N=x-p[E];x=_w(O,x,N)}if(c){const S=_==="y"?"top":"left",E=_==="y"?"bottom":"right",O=C+p[S],N=C-p[E];C=_w(O,C,N)}const j=d.fn({...n,[b]:x,[_]:C});return{...j,data:{x:j.x-r,y:j.y-i,enabled:{[b]:a,[_]:c}}}}}},iV=function(e){return e===void 0&&(e={}),{options:e,fn(n){const{x:r,y:i,placement:s,rects:o,middlewareData:a}=n,{offset:c=0,mainAxis:d=!0,crossAxis:h=!0}=Xa(e,n),g={x:r,y:i},p=Uo(s),_=C5(p);let b=g[_],x=g[p];const C=Xa(c,n),j=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:0,crossAxis:0,...C};if(d){const O=_==="y"?"height":"width",N=o.reference[_]-o.floating[O]+j.mainAxis,T=o.reference[_]+o.reference[O]-j.mainAxis;b<N?b=N:b>T&&(b=T)}if(h){var S,E;const O=_==="y"?"width":"height",N=GN.has(Ja(s)),T=o.reference[p]-o.floating[O]+(N&&((S=a.offset)==null?void 0:S[p])||0)+(N?0:j.crossAxis),P=o.reference[p]+o.reference[O]+(N?0:((E=a.offset)==null?void 0:E[p])||0)-(N?j.crossAxis:0);x<T?x=T:x>P&&(x=P)}return{[_]:b,[p]:x}}}},sV=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(n){var r,i;const{placement:s,rects:o,platform:a,elements:c}=n,{apply:d=()=>{},...h}=Xa(e,n),g=await a.detectOverflow(n,h),p=Ja(s),_=dd(s),b=Uo(s)==="y",{width:x,height:C}=o.floating;let j,S;p==="top"||p==="bottom"?(j=p,S=_===(await(a.isRTL==null?void 0:a.isRTL(c.floating))?"start":"end")?"left":"right"):(S=p,j=_==="end"?"top":"bottom");const E=C-g.top-g.bottom,O=x-g.left-g.right,N=ac(C-g[j],E),T=ac(x-g[S],O),P=!n.middlewareData.shift;let D=N,H=T;if((r=n.middlewareData.shift)!=null&&r.enabled.x&&(H=O),(i=n.middlewareData.shift)!=null&&i.enabled.y&&(D=E),P&&!_){const I=ds(g.left,0),B=ds(g.right,0),F=ds(g.top,0),W=ds(g.bottom,0);b?H=x-2*(I!==0||B!==0?I+B:ds(g.left,g.right)):D=C-2*(F!==0||W!==0?F+W:ds(g.top,g.bottom))}await d({...n,availableWidth:H,availableHeight:D});const J=await a.getDimensions(c.floating);return x!==J.width||C!==J.height?{reset:{rects:!0}}:{}}}};function bv(){return typeof window<"u"}function hd(e){return YN(e)?(e.nodeName||"").toLowerCase():"#document"}function ps(e){var n;return(e==null||(n=e.ownerDocument)==null?void 0:n.defaultView)||window}function ea(e){var n;return(n=(YN(e)?e.ownerDocument:e.document)||window.document)==null?void 0:n.documentElement}function YN(e){return bv()?e instanceof Node||e instanceof ps(e).Node:!1}function vo(e){return bv()?e instanceof Element||e instanceof ps(e).Element:!1}function el(e){return bv()?e instanceof HTMLElement||e instanceof ps(e).HTMLElement:!1}function nj(e){return!bv()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ps(e).ShadowRoot}function xg(e){const{overflow:n,overflowX:r,overflowY:i,display:s}=_o(e);return/auto|scroll|overlay|hidden|clip/.test(n+i+r)&&s!=="inline"&&s!=="contents"}function oV(e){return/^(table|td|th)$/.test(hd(e))}function xv(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const aV=/transform|translate|scale|rotate|perspective|filter/,lV=/paint|layout|strict|content/,qc=e=>!!e&&e!=="none";let lx;function E5(e){const n=vo(e)?_o(e):e;return qc(n.transform)||qc(n.translate)||qc(n.scale)||qc(n.rotate)||qc(n.perspective)||!O5()&&(qc(n.backdropFilter)||qc(n.filter))||aV.test(n.willChange||"")||lV.test(n.contain||"")}function cV(e){let n=lc(e);for(;el(n)&&!Qf(n);){if(E5(n))return n;if(xv(n))return null;n=lc(n)}return null}function O5(){return lx==null&&(lx=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),lx}function Qf(e){return/^(html|body|#document)$/.test(hd(e))}function _o(e){return ps(e).getComputedStyle(e)}function wv(e){return vo(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lc(e){if(hd(e)==="html")return e;const n=e.assignedSlot||e.parentNode||nj(e)&&e.host||ea(e);return nj(n)?n.host:n}function XN(e){const n=lc(e);return Qf(n)?e.ownerDocument?e.ownerDocument.body:e.body:el(n)&&xg(n)?n:XN(n)}function Ip(e,n,r){var i;n===void 0&&(n=[]),r===void 0&&(r=!0);const s=XN(e),o=s===((i=e.ownerDocument)==null?void 0:i.body),a=ps(s);if(o){const c=xw(a);return n.concat(a,a.visualViewport||[],xg(s)?s:[],c&&r?Ip(c):[])}else return n.concat(s,Ip(s,[],r))}function xw(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function JN(e){const n=_o(e);let r=parseFloat(n.width)||0,i=parseFloat(n.height)||0;const s=el(e),o=s?e.offsetWidth:r,a=s?e.offsetHeight:i,c=jy(r)!==o||jy(i)!==a;return c&&(r=o,i=a),{width:r,height:i,$:c}}function N5(e){return vo(e)?e:e.contextElement}function Gf(e){const n=N5(e);if(!el(n))return Ko(1);const r=n.getBoundingClientRect(),{width:i,height:s,$:o}=JN(n);let a=(o?jy(r.width):r.width)/i,c=(o?jy(r.height):r.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const uV=Ko(0);function ZN(e){const n=ps(e);return!O5()||!n.visualViewport?uV:{x:n.visualViewport.offsetLeft,y:n.visualViewport.offsetTop}}function fV(e,n,r){return n===void 0&&(n=!1),!r||n&&r!==ps(e)?!1:n}function pu(e,n,r,i){n===void 0&&(n=!1),r===void 0&&(r=!1);const s=e.getBoundingClientRect(),o=N5(e);let a=Ko(1);n&&(i?vo(i)&&(a=Gf(i)):a=Gf(e));const c=fV(o,r,i)?ZN(o):Ko(0);let d=(s.left+c.x)/a.x,h=(s.top+c.y)/a.y,g=s.width/a.x,p=s.height/a.y;if(o){const _=ps(o),b=i&&vo(i)?ps(i):i;let x=_,C=xw(x);for(;C&&i&&b!==x;){const j=Gf(C),S=C.getBoundingClientRect(),E=_o(C),O=S.left+(C.clientLeft+parseFloat(E.paddingLeft))*j.x,N=S.top+(C.clientTop+parseFloat(E.paddingTop))*j.y;d*=j.x,h*=j.y,g*=j.x,p*=j.y,d+=O,h+=N,x=ps(C),C=xw(x)}}return Ey({width:g,height:p,x:d,y:h})}function Sv(e,n){const r=wv(e).scrollLeft;return n?n.left+r:pu(ea(e)).left+r}function QN(e,n){const r=e.getBoundingClientRect(),i=r.left+n.scrollLeft-Sv(e,r),s=r.top+n.scrollTop;return{x:i,y:s}}function dV(e){let{elements:n,rect:r,offsetParent:i,strategy:s}=e;const o=s==="fixed",a=ea(i),c=n?xv(n.floating):!1;if(i===a||c&&o)return r;let d={scrollLeft:0,scrollTop:0},h=Ko(1);const g=Ko(0),p=el(i);if((p||!p&&!o)&&((hd(i)!=="body"||xg(a))&&(d=wv(i)),p)){const b=pu(i);h=Gf(i),g.x=b.x+i.clientLeft,g.y=b.y+i.clientTop}const _=a&&!p&&!o?QN(a,d):Ko(0);return{width:r.width*h.x,height:r.height*h.y,x:r.x*h.x-d.scrollLeft*h.x+g.x+_.x,y:r.y*h.y-d.scrollTop*h.y+g.y+_.y}}function hV(e){return Array.from(e.getClientRects())}function pV(e){const n=ea(e),r=wv(e),i=e.ownerDocument.body,s=ds(n.scrollWidth,n.clientWidth,i.scrollWidth,i.clientWidth),o=ds(n.scrollHeight,n.clientHeight,i.scrollHeight,i.clientHeight);let a=-r.scrollLeft+Sv(e);const c=-r.scrollTop;return _o(i).direction==="rtl"&&(a+=ds(n.clientWidth,i.clientWidth)-s),{width:s,height:o,x:a,y:c}}const rj=25;function mV(e,n){const r=ps(e),i=ea(e),s=r.visualViewport;let o=i.clientWidth,a=i.clientHeight,c=0,d=0;if(s){o=s.width,a=s.height;const g=O5();(!g||g&&n==="fixed")&&(c=s.offsetLeft,d=s.offsetTop)}const h=Sv(i);if(h<=0){const g=i.ownerDocument,p=g.body,_=getComputedStyle(p),b=g.compatMode==="CSS1Compat"&&parseFloat(_.marginLeft)+parseFloat(_.marginRight)||0,x=Math.abs(i.clientWidth-p.clientWidth-b);x<=rj&&(o-=x)}else h<=rj&&(o+=h);return{width:o,height:a,x:c,y:d}}function gV(e,n){const r=pu(e,!0,n==="fixed"),i=r.top+e.clientTop,s=r.left+e.clientLeft,o=el(e)?Gf(e):Ko(1),a=e.clientWidth*o.x,c=e.clientHeight*o.y,d=s*o.x,h=i*o.y;return{width:a,height:c,x:d,y:h}}function ij(e,n,r){let i;if(n==="viewport")i=mV(e,r);else if(n==="document")i=pV(ea(e));else if(vo(n))i=gV(n,r);else{const s=ZN(e);i={x:n.x-s.x,y:n.y-s.y,width:n.width,height:n.height}}return Ey(i)}function eT(e,n){const r=lc(e);return r===n||!vo(r)||Qf(r)?!1:_o(r).position==="fixed"||eT(r,n)}function yV(e,n){const r=n.get(e);if(r)return r;let i=Ip(e,[],!1).filter(c=>vo(c)&&hd(c)!=="body"),s=null;const o=_o(e).position==="fixed";let a=o?lc(e):e;for(;vo(a)&&!Qf(a);){const c=_o(a),d=E5(a);!d&&c.position==="fixed"&&(s=null),(o?!d&&!s:!d&&c.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||xg(a)&&!d&&eT(e,a))?i=i.filter(g=>g!==a):s=c,a=lc(a)}return n.set(e,i),i}function vV(e){let{element:n,boundary:r,rootBoundary:i,strategy:s}=e;const a=[...r==="clippingAncestors"?xv(n)?[]:yV(n,this._c):[].concat(r),i],c=ij(n,a[0],s);let d=c.top,h=c.right,g=c.bottom,p=c.left;for(let _=1;_<a.length;_++){const b=ij(n,a[_],s);d=ds(b.top,d),h=ac(b.right,h),g=ac(b.bottom,g),p=ds(b.left,p)}return{width:h-p,height:g-d,x:p,y:d}}function _V(e){const{width:n,height:r}=JN(e);return{width:n,height:r}}function bV(e,n,r){const i=el(n),s=ea(n),o=r==="fixed",a=pu(e,!0,o,n);let c={scrollLeft:0,scrollTop:0};const d=Ko(0);function h(){d.x=Sv(s)}if(i||!i&&!o)if((hd(n)!=="body"||xg(s))&&(c=wv(n)),i){const b=pu(n,!0,o,n);d.x=b.x+n.clientLeft,d.y=b.y+n.clientTop}else s&&h();o&&!i&&s&&h();const g=s&&!i&&!o?QN(s,c):Ko(0),p=a.left+c.scrollLeft-d.x-g.x,_=a.top+c.scrollTop-d.y-g.y;return{x:p,y:_,width:a.width,height:a.height}}function cx(e){return _o(e).position==="static"}function sj(e,n){if(!el(e)||_o(e).position==="fixed")return null;if(n)return n(e);let r=e.offsetParent;return ea(e)===r&&(r=r.ownerDocument.body),r}function tT(e,n){const r=ps(e);if(xv(e))return r;if(!el(e)){let s=lc(e);for(;s&&!Qf(s);){if(vo(s)&&!cx(s))return s;s=lc(s)}return r}let i=sj(e,n);for(;i&&oV(i)&&cx(i);)i=sj(i,n);return i&&Qf(i)&&cx(i)&&!E5(i)?r:i||cV(e)||r}const xV=async function(e){const n=this.getOffsetParent||tT,r=this.getDimensions,i=await r(e.floating);return{reference:bV(e.reference,await n(e.floating),e.strategy),floating:{x:0,y:0,width:i.width,height:i.height}}};function wV(e){return _o(e).direction==="rtl"}const SV={convertOffsetParentRelativeRectToViewportRelativeRect:dV,getDocumentElement:ea,getClippingRect:vV,getOffsetParent:tT,getElementRects:xV,getClientRects:hV,getDimensions:_V,getScale:Gf,isElement:vo,isRTL:wV};function nT(e,n){return e.x===n.x&&e.y===n.y&&e.width===n.width&&e.height===n.height}function CV(e,n){let r=null,i;const s=ea(e);function o(){var c;clearTimeout(i),(c=r)==null||c.disconnect(),r=null}function a(c,d){c===void 0&&(c=!1),d===void 0&&(d=1),o();const h=e.getBoundingClientRect(),{left:g,top:p,width:_,height:b}=h;if(c||n(),!_||!b)return;const x=m1(p),C=m1(s.clientWidth-(g+_)),j=m1(s.clientHeight-(p+b)),S=m1(g),O={rootMargin:-x+"px "+-C+"px "+-j+"px "+-S+"px",threshold:ds(0,ac(1,d))||1};let N=!0;function T(P){const D=P[0].intersectionRatio;if(D!==d){if(!N)return a();D?a(!1,D):i=setTimeout(()=>{a(!1,1e-7)},1e3)}D===1&&!nT(h,e.getBoundingClientRect())&&a(),N=!1}try{r=new IntersectionObserver(T,{...O,root:s.ownerDocument})}catch{r=new IntersectionObserver(T,O)}r.observe(e)}return a(!0),o}function jV(e,n,r,i){i===void 0&&(i={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:d=!1}=i,h=N5(e),g=s||o?[...h?Ip(h):[],...n?Ip(n):[]]:[];g.forEach(S=>{s&&S.addEventListener("scroll",r,{passive:!0}),o&&S.addEventListener("resize",r)});const p=h&&c?CV(h,r):null;let _=-1,b=null;a&&(b=new ResizeObserver(S=>{let[E]=S;E&&E.target===h&&b&&n&&(b.unobserve(n),cancelAnimationFrame(_),_=requestAnimationFrame(()=>{var O;(O=b)==null||O.observe(n)})),r()}),h&&!d&&b.observe(h),n&&b.observe(n));let x,C=d?pu(e):null;d&&j();function j(){const S=pu(e);C&&!nT(C,S)&&r(),C=S,x=requestAnimationFrame(j)}return r(),()=>{var S;g.forEach(E=>{s&&E.removeEventListener("scroll",r),o&&E.removeEventListener("resize",r)}),p==null||p(),(S=b)==null||S.disconnect(),b=null,d&&cancelAnimationFrame(x)}}const kV=nV,EV=rV,OV=QU,NV=sV,TV=eV,oj=ZU,PV=iV,AV=(e,n,r)=>{const i=new Map,s={platform:SV,...r},o={...s.platform,_c:i};return JU(e,n,{...s,platform:o})};var MV=typeof document<"u",RV=function(){},Q1=MV?y.useLayoutEffect:RV;function Oy(e,n){if(e===n)return!0;if(typeof e!=typeof n)return!1;if(typeof e=="function"&&e.toString()===n.toString())return!0;let r,i,s;if(e&&n&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==n.length)return!1;for(i=r;i--!==0;)if(!Oy(e[i],n[i]))return!1;return!0}if(s=Object.keys(e),r=s.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!{}.hasOwnProperty.call(n,s[i]))return!1;for(i=r;i--!==0;){const o=s[i];if(!(o==="_owner"&&e.$$typeof)&&!Oy(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}function rT(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function aj(e,n){const r=rT(e);return Math.round(n*r)/r}function ux(e){const n=y.useRef(e);return Q1(()=>{n.current=e}),n}function DV(e){e===void 0&&(e={});const{placement:n="bottom",strategy:r="absolute",middleware:i=[],platform:s,elements:{reference:o,floating:a}={},transform:c=!0,whileElementsMounted:d,open:h}=e,[g,p]=y.useState({x:0,y:0,strategy:r,placement:n,middlewareData:{},isPositioned:!1}),[_,b]=y.useState(i);Oy(_,i)||b(i);const[x,C]=y.useState(null),[j,S]=y.useState(null),E=y.useCallback(K=>{K!==P.current&&(P.current=K,C(K))},[]),O=y.useCallback(K=>{K!==D.current&&(D.current=K,S(K))},[]),N=o||x,T=a||j,P=y.useRef(null),D=y.useRef(null),H=y.useRef(g),J=d!=null,I=ux(d),B=ux(s),F=ux(h),W=y.useCallback(()=>{if(!P.current||!D.current)return;const K={placement:n,strategy:r,middleware:_};B.current&&(K.platform=B.current),AV(P.current,D.current,K).then(Y=>{const $={...Y,isPositioned:F.current!==!1};z.current&&!Oy(H.current,$)&&(H.current=$,Su.flushSync(()=>{p($)}))})},[_,n,r,B,F]);Q1(()=>{h===!1&&H.current.isPositioned&&(H.current.isPositioned=!1,p(K=>({...K,isPositioned:!1})))},[h]);const z=y.useRef(!1);Q1(()=>(z.current=!0,()=>{z.current=!1}),[]),Q1(()=>{if(N&&(P.current=N),T&&(D.current=T),N&&T){if(I.current)return I.current(N,T,W);W()}},[N,T,W,I,J]);const V=y.useMemo(()=>({reference:P,floating:D,setReference:E,setFloating:O}),[E,O]),A=y.useMemo(()=>({reference:N,floating:T}),[N,T]),U=y.useMemo(()=>{const K={position:r,left:0,top:0};if(!A.floating)return K;const Y=aj(A.floating,g.x),$=aj(A.floating,g.y);return c?{...K,transform:"translate("+Y+"px, "+$+"px)",...rT(A.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:Y,top:$}},[r,c,A.floating,g.x,g.y]);return y.useMemo(()=>({...g,update:W,refs:V,elements:A,floatingStyles:U}),[g,W,V,A,U])}const zV=e=>{function n(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:i,padding:s}=typeof e=="function"?e(r):e;return i&&n(i)?i.current!=null?oj({element:i.current,padding:s}).fn(r):{}:i?oj({element:i,padding:s}).fn(r):{}}}},LV=(e,n)=>{const r=kV(e);return{name:r.name,fn:r.fn,options:[e,n]}},$V=(e,n)=>{const r=EV(e);return{name:r.name,fn:r.fn,options:[e,n]}},IV=(e,n)=>({fn:PV(e).fn,options:[e,n]}),BV=(e,n)=>{const r=OV(e);return{name:r.name,fn:r.fn,options:[e,n]}},FV=(e,n)=>{const r=NV(e);return{name:r.name,fn:r.fn,options:[e,n]}},HV=(e,n)=>{const r=TV(e);return{name:r.name,fn:r.fn,options:[e,n]}},UV=(e,n)=>{const r=zV(e);return{name:r.name,fn:r.fn,options:[e,n]}};function VV(e){const n=WV(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(KV);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function WV(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=YV(s),c=GV(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var qV=Symbol("radix.slottable");function KV(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===qV}function GV(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function YV(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var XV=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],JV=XV.reduce((e,n)=>{const r=VV(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),ZV="Arrow",iT=y.forwardRef((e,n)=>{const{children:r,width:i=10,height:s=5,...o}=e;return f.jsx(JV.svg,{...o,ref:n,width:i,height:s,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:f.jsx("polygon",{points:"0,0 30,0 15,10"})})});iT.displayName=ZV;var QV=iT;function eW(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,tW(s,...n)]}function tW(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function nW(e){const n=rW(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(sW);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function rW(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=aW(s),c=oW(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var iW=Symbol("radix.slottable");function sW(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===iW}function oW(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function aW(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var lW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],sT=lW.reduce((e,n)=>{const r=nW(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function oT(e){const[n,r]=y.useState(void 0);return ar(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const i=new ResizeObserver(s=>{if(!Array.isArray(s)||!s.length)return;const o=s[0];let a,c;if("borderBoxSize"in o){const d=o.borderBoxSize,h=Array.isArray(d)?d[0]:d;a=h.inlineSize,c=h.blockSize}else a=e.offsetWidth,c=e.offsetHeight;r({width:a,height:c})});return i.observe(e,{box:"border-box"}),()=>i.unobserve(e)}else r(void 0)},[e]),n}var T5="Popper",[aT,pd]=eW(T5),[cW,lT]=aT(T5),cT=e=>{const{__scopePopper:n,children:r}=e,[i,s]=y.useState(null);return f.jsx(cW,{scope:n,anchor:i,onAnchorChange:s,children:r})};cT.displayName=T5;var uT="PopperAnchor",fT=y.forwardRef((e,n)=>{const{__scopePopper:r,virtualRef:i,...s}=e,o=lT(uT,r),a=y.useRef(null),c=Jt(n,a),d=y.useRef(null);return y.useEffect(()=>{const h=d.current;d.current=(i==null?void 0:i.current)||a.current,h!==d.current&&o.onAnchorChange(d.current)}),i?null:f.jsx(sT.div,{...s,ref:c})});fT.displayName=uT;var P5="PopperContent",[uW,fW]=aT(P5),dT=y.forwardRef((e,n)=>{var se,ce,be,ze,fe,Ce;const{__scopePopper:r,side:i="bottom",sideOffset:s=0,align:o="center",alignOffset:a=0,arrowPadding:c=0,avoidCollisions:d=!0,collisionBoundary:h=[],collisionPadding:g=0,sticky:p="partial",hideWhenDetached:_=!1,updatePositionStrategy:b="optimized",onPlaced:x,...C}=e,j=lT(P5,r),[S,E]=y.useState(null),O=Jt(n,me=>E(me)),[N,T]=y.useState(null),P=oT(N),D=(P==null?void 0:P.width)??0,H=(P==null?void 0:P.height)??0,J=i+(o!=="center"?"-"+o:""),I=typeof g=="number"?g:{top:0,right:0,bottom:0,left:0,...g},B=Array.isArray(h)?h:[h],F=B.length>0,W={padding:I,boundary:B.filter(hW),altBoundary:F},{refs:z,floatingStyles:V,placement:A,isPositioned:U,middlewareData:K}=DV({strategy:"fixed",placement:J,whileElementsMounted:(...me)=>jV(...me,{animationFrame:b==="always"}),elements:{reference:j.anchor},middleware:[LV({mainAxis:s+H,alignmentAxis:a}),d&&$V({mainAxis:!0,crossAxis:!1,limiter:p==="partial"?IV():void 0,...W}),d&&BV({...W}),FV({...W,apply:({elements:me,rects:Ye,availableWidth:tt,availableHeight:Ue})=>{const{width:mt,height:Dt}=Ye.reference,Et=me.floating.style;Et.setProperty("--radix-popper-available-width",`${tt}px`),Et.setProperty("--radix-popper-available-height",`${Ue}px`),Et.setProperty("--radix-popper-anchor-width",`${mt}px`),Et.setProperty("--radix-popper-anchor-height",`${Dt}px`)}}),N&&UV({element:N,padding:c}),pW({arrowWidth:D,arrowHeight:H}),_&&HV({strategy:"referenceHidden",...W})]}),[Y,$]=mT(A),R=Ar(x);ar(()=>{U&&(R==null||R())},[U,R]);const Z=(se=K.arrow)==null?void 0:se.x,L=(ce=K.arrow)==null?void 0:ce.y,Q=((be=K.arrow)==null?void 0:be.centerOffset)!==0,[X,ie]=y.useState();return ar(()=>{S&&ie(window.getComputedStyle(S).zIndex)},[S]),f.jsx("div",{ref:z.setFloating,"data-radix-popper-content-wrapper":"",style:{...V,transform:U?V.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:X,"--radix-popper-transform-origin":[(ze=K.transformOrigin)==null?void 0:ze.x,(fe=K.transformOrigin)==null?void 0:fe.y].join(" "),...((Ce=K.hide)==null?void 0:Ce.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:f.jsx(uW,{scope:r,placedSide:Y,onArrowChange:T,arrowX:Z,arrowY:L,shouldHideArrow:Q,children:f.jsx(sT.div,{"data-side":Y,"data-align":$,...C,ref:O,style:{...C.style,animation:U?void 0:"none"}})})})});dT.displayName=P5;var hT="PopperArrow",dW={top:"bottom",right:"left",bottom:"top",left:"right"},pT=y.forwardRef(function(n,r){const{__scopePopper:i,...s}=n,o=fW(hT,i),a=dW[o.placedSide];return f.jsx("span",{ref:o.onArrowChange,style:{position:"absolute",left:o.arrowX,top:o.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[o.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[o.placedSide],visibility:o.shouldHideArrow?"hidden":void 0},children:f.jsx(QV,{...s,ref:r,style:{...s.style,display:"block"}})})});pT.displayName=hT;function hW(e){return e!==null}var pW=e=>({name:"transformOrigin",options:e,fn(n){var j,S,E;const{placement:r,rects:i,middlewareData:s}=n,a=((j=s.arrow)==null?void 0:j.centerOffset)!==0,c=a?0:e.arrowWidth,d=a?0:e.arrowHeight,[h,g]=mT(r),p={start:"0%",center:"50%",end:"100%"}[g],_=(((S=s.arrow)==null?void 0:S.x)??0)+c/2,b=(((E=s.arrow)==null?void 0:E.y)??0)+d/2;let x="",C="";return h==="bottom"?(x=a?p:`${_}px`,C=`${-d}px`):h==="top"?(x=a?p:`${_}px`,C=`${i.floating.height+d}px`):h==="right"?(x=`${-d}px`,C=a?p:`${b}px`):h==="left"&&(x=`${i.floating.width+d}px`,C=a?p:`${b}px`),{data:{x,y:C}}}});function mT(e){const[n,r="center"]=e.split("-");return[n,r]}var A5=cT,M5=fT,R5=dT,D5=pT;function gT(e){const n=mW(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(yW);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function mW(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=_W(s),c=vW(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var gW=Symbol("radix.slottable");function yW(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===gW}function vW(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function _W(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var bW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],wg=bW.reduce((e,n)=>{const r=gT(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function xW(e,n){e&&Su.flushSync(()=>e.dispatchEvent(n))}function wW(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,SW(s,...n)]}function SW(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function CW(e){const n=jW(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(EW);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function jW(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=NW(s),c=OW(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var kW=Symbol("radix.slottable");function EW(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kW}function OW(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function NW(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var TW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],yT=TW.reduce((e,n)=>{const r=CW(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),fx="rovingFocusGroup.onEntryFocus",PW={bubbles:!1,cancelable:!0},Sg="RovingFocusGroup",[ww,vT,AW]=S5(Sg),[MW,Cv]=wW(Sg,[AW]),[RW,DW]=MW(Sg),_T=y.forwardRef((e,n)=>f.jsx(ww.Provider,{scope:e.__scopeRovingFocusGroup,children:f.jsx(ww.Slot,{scope:e.__scopeRovingFocusGroup,children:f.jsx(zW,{...e,ref:n})})}));_T.displayName=Sg;var zW=y.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:r,orientation:i,loop:s=!1,dir:o,currentTabStopId:a,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:h,preventScrollOnEntryFocus:g=!1,...p}=e,_=y.useRef(null),b=Jt(n,_),x=bg(o),[C,j]=Ka({prop:a,defaultProp:c??null,onChange:d,caller:Sg}),[S,E]=y.useState(!1),O=Ar(h),N=vT(r),T=y.useRef(!1),[P,D]=y.useState(0);return y.useEffect(()=>{const H=_.current;if(H)return H.addEventListener(fx,O),()=>H.removeEventListener(fx,O)},[O]),f.jsx(RW,{scope:r,orientation:i,dir:x,loop:s,currentTabStopId:C,onItemFocus:y.useCallback(H=>j(H),[j]),onItemShiftTab:y.useCallback(()=>E(!0),[]),onFocusableItemAdd:y.useCallback(()=>D(H=>H+1),[]),onFocusableItemRemove:y.useCallback(()=>D(H=>H-1),[]),children:f.jsx(yT.div,{tabIndex:S||P===0?-1:0,"data-orientation":i,...p,ref:b,style:{outline:"none",...e.style},onMouseDown:ot(e.onMouseDown,()=>{T.current=!0}),onFocus:ot(e.onFocus,H=>{const J=!T.current;if(H.target===H.currentTarget&&J&&!S){const I=new CustomEvent(fx,PW);if(H.currentTarget.dispatchEvent(I),!I.defaultPrevented){const B=N().filter(A=>A.focusable),F=B.find(A=>A.active),W=B.find(A=>A.id===C),V=[F,W,...B].filter(Boolean).map(A=>A.ref.current);wT(V,g)}}T.current=!1}),onBlur:ot(e.onBlur,()=>E(!1))})})}),bT="RovingFocusGroupItem",xT=y.forwardRef((e,n)=>{const{__scopeRovingFocusGroup:r,focusable:i=!0,active:s=!1,tabStopId:o,children:a,...c}=e,d=$s(),h=o||d,g=DW(bT,r),p=g.currentTabStopId===h,_=vT(r),{onFocusableItemAdd:b,onFocusableItemRemove:x,currentTabStopId:C}=g;return y.useEffect(()=>{if(i)return b(),()=>x()},[i,b,x]),f.jsx(ww.ItemSlot,{scope:r,id:h,focusable:i,active:s,children:f.jsx(yT.span,{tabIndex:p?0:-1,"data-orientation":g.orientation,...c,ref:n,onMouseDown:ot(e.onMouseDown,j=>{i?g.onItemFocus(h):j.preventDefault()}),onFocus:ot(e.onFocus,()=>g.onItemFocus(h)),onKeyDown:ot(e.onKeyDown,j=>{if(j.key==="Tab"&&j.shiftKey){g.onItemShiftTab();return}if(j.target!==j.currentTarget)return;const S=IW(j,g.orientation,g.dir);if(S!==void 0){if(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)return;j.preventDefault();let O=_().filter(N=>N.focusable).map(N=>N.ref.current);if(S==="last")O.reverse();else if(S==="prev"||S==="next"){S==="prev"&&O.reverse();const N=O.indexOf(j.currentTarget);O=g.loop?BW(O,N+1):O.slice(N+1)}setTimeout(()=>wT(O))}}),children:typeof a=="function"?a({isCurrentTabStop:p,hasTabStop:C!=null}):a})})});xT.displayName=bT;var LW={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function $W(e,n){return n!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function IW(e,n,r){const i=$W(e.key,r);if(!(n==="vertical"&&["ArrowLeft","ArrowRight"].includes(i))&&!(n==="horizontal"&&["ArrowUp","ArrowDown"].includes(i)))return LW[i]}function wT(e,n=!1){const r=document.activeElement;for(const i of e)if(i===r||(i.focus({preventScroll:n}),document.activeElement!==r))return}function BW(e,n){return e.map((r,i)=>e[(n+i)%e.length])}var ST=_T,CT=xT,Sw=["Enter"," "],FW=["ArrowDown","PageUp","Home"],jT=["ArrowUp","PageDown","End"],HW=[...FW,...jT],UW={ltr:[...Sw,"ArrowRight"],rtl:[...Sw,"ArrowLeft"]},VW={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Cg="Menu",[Bp,WW,qW]=S5(Cg),[ju,kT]=LU(Cg,[qW,pd,Cv]),jv=pd(),ET=Cv(),[KW,ku]=ju(Cg),[GW,jg]=ju(Cg),OT=e=>{const{__scopeMenu:n,open:r=!1,children:i,dir:s,onOpenChange:o,modal:a=!0}=e,c=jv(n),[d,h]=y.useState(null),g=y.useRef(!1),p=Ar(o),_=bg(s);return y.useEffect(()=>{const b=()=>{g.current=!0,document.addEventListener("pointerdown",x,{capture:!0,once:!0}),document.addEventListener("pointermove",x,{capture:!0,once:!0})},x=()=>g.current=!1;return document.addEventListener("keydown",b,{capture:!0}),()=>{document.removeEventListener("keydown",b,{capture:!0}),document.removeEventListener("pointerdown",x,{capture:!0}),document.removeEventListener("pointermove",x,{capture:!0})}},[]),f.jsx(A5,{...c,children:f.jsx(KW,{scope:n,open:r,onOpenChange:p,content:d,onContentChange:h,children:f.jsx(GW,{scope:n,onClose:y.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:g,dir:_,modal:a,children:i})})})};OT.displayName=Cg;var YW="MenuAnchor",z5=y.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e,s=jv(r);return f.jsx(M5,{...s,...i,ref:n})});z5.displayName=YW;var L5="MenuPortal",[XW,NT]=ju(L5,{forceMount:void 0}),TT=e=>{const{__scopeMenu:n,forceMount:r,children:i,container:s}=e,o=ku(L5,n);return f.jsx(XW,{scope:n,forceMount:r,children:f.jsx(si,{present:r||o.open,children:f.jsx(yg,{asChild:!0,container:s,children:i})})})};TT.displayName=L5;var Is="MenuContent",[JW,$5]=ju(Is),PT=y.forwardRef((e,n)=>{const r=NT(Is,e.__scopeMenu),{forceMount:i=r.forceMount,...s}=e,o=ku(Is,e.__scopeMenu),a=jg(Is,e.__scopeMenu);return f.jsx(Bp.Provider,{scope:e.__scopeMenu,children:f.jsx(si,{present:i||o.open,children:f.jsx(Bp.Slot,{scope:e.__scopeMenu,children:a.modal?f.jsx(ZW,{...s,ref:n}):f.jsx(QW,{...s,ref:n})})})})}),ZW=y.forwardRef((e,n)=>{const r=ku(Is,e.__scopeMenu),i=y.useRef(null),s=Jt(n,i);return y.useEffect(()=>{const o=i.current;if(o)return _5(o)},[]),f.jsx(I5,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:r.open,disableOutsideScroll:!0,onFocusOutside:ot(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>r.onOpenChange(!1)})}),QW=y.forwardRef((e,n)=>{const r=ku(Is,e.__scopeMenu);return f.jsx(I5,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>r.onOpenChange(!1)})}),eq=gT("MenuContent.ScrollLock"),I5=y.forwardRef((e,n)=>{const{__scopeMenu:r,loop:i=!1,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:h,onPointerDownOutside:g,onFocusOutside:p,onInteractOutside:_,onDismiss:b,disableOutsideScroll:x,...C}=e,j=ku(Is,r),S=jg(Is,r),E=jv(r),O=ET(r),N=WW(r),[T,P]=y.useState(null),D=y.useRef(null),H=Jt(n,D,j.onContentChange),J=y.useRef(0),I=y.useRef(""),B=y.useRef(0),F=y.useRef(null),W=y.useRef("right"),z=y.useRef(0),V=x?vv:y.Fragment,A=x?{as:eq,allowPinchZoom:!0}:void 0,U=Y=>{var se,ce;const $=I.current+Y,R=N().filter(be=>!be.disabled),Z=document.activeElement,L=(se=R.find(be=>be.ref.current===Z))==null?void 0:se.textValue,Q=R.map(be=>be.textValue),X=dq(Q,$,L),ie=(ce=R.find(be=>be.textValue===X))==null?void 0:ce.ref.current;(function be(ze){I.current=ze,window.clearTimeout(J.current),ze!==""&&(J.current=window.setTimeout(()=>be(""),1e3))})($),ie&&setTimeout(()=>ie.focus())};y.useEffect(()=>()=>window.clearTimeout(J.current),[]),v5();const K=y.useCallback(Y=>{var R,Z;return W.current===((R=F.current)==null?void 0:R.side)&&pq(Y,(Z=F.current)==null?void 0:Z.area)},[]);return f.jsx(JW,{scope:r,searchRef:I,onItemEnter:y.useCallback(Y=>{K(Y)&&Y.preventDefault()},[K]),onItemLeave:y.useCallback(Y=>{var $;K(Y)||(($=D.current)==null||$.focus(),P(null))},[K]),onTriggerLeave:y.useCallback(Y=>{K(Y)&&Y.preventDefault()},[K]),pointerGraceTimerRef:B,onPointerGraceIntentChange:y.useCallback(Y=>{F.current=Y},[]),children:f.jsx(V,{...A,children:f.jsx(gv,{asChild:!0,trapped:s,onMountAutoFocus:ot(o,Y=>{var $;Y.preventDefault(),($=D.current)==null||$.focus({preventScroll:!0})}),onUnmountAutoFocus:a,children:f.jsx(gg,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:h,onPointerDownOutside:g,onFocusOutside:p,onInteractOutside:_,onDismiss:b,children:f.jsx(ST,{asChild:!0,...O,dir:S.dir,orientation:"vertical",loop:i,currentTabStopId:T,onCurrentTabStopIdChange:P,onEntryFocus:ot(d,Y=>{S.isUsingKeyboardRef.current||Y.preventDefault()}),preventScrollOnEntryFocus:!0,children:f.jsx(R5,{role:"menu","aria-orientation":"vertical","data-state":KT(j.open),"data-radix-menu-content":"",dir:S.dir,...E,...C,ref:H,style:{outline:"none",...C.style},onKeyDown:ot(C.onKeyDown,Y=>{const R=Y.target.closest("[data-radix-menu-content]")===Y.currentTarget,Z=Y.ctrlKey||Y.altKey||Y.metaKey,L=Y.key.length===1;R&&(Y.key==="Tab"&&Y.preventDefault(),!Z&&L&&U(Y.key));const Q=D.current;if(Y.target!==Q||!HW.includes(Y.key))return;Y.preventDefault();const ie=N().filter(se=>!se.disabled).map(se=>se.ref.current);jT.includes(Y.key)&&ie.reverse(),uq(ie)}),onBlur:ot(e.onBlur,Y=>{Y.currentTarget.contains(Y.target)||(window.clearTimeout(J.current),I.current="")}),onPointerMove:ot(e.onPointerMove,Fp(Y=>{const $=Y.target,R=z.current!==Y.clientX;if(Y.currentTarget.contains($)&&R){const Z=Y.clientX>z.current?"right":"left";W.current=Z,z.current=Y.clientX}}))})})})})})})});PT.displayName=Is;var tq="MenuGroup",B5=y.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return f.jsx(wg.div,{role:"group",...i,ref:n})});B5.displayName=tq;var nq="MenuLabel",AT=y.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return f.jsx(wg.div,{...i,ref:n})});AT.displayName=nq;var Ny="MenuItem",lj="menu.itemSelect",kv=y.forwardRef((e,n)=>{const{disabled:r=!1,onSelect:i,...s}=e,o=y.useRef(null),a=jg(Ny,e.__scopeMenu),c=$5(Ny,e.__scopeMenu),d=Jt(n,o),h=y.useRef(!1),g=()=>{const p=o.current;if(!r&&p){const _=new CustomEvent(lj,{bubbles:!0,cancelable:!0});p.addEventListener(lj,b=>i==null?void 0:i(b),{once:!0}),xW(p,_),_.defaultPrevented?h.current=!1:a.onClose()}};return f.jsx(MT,{...s,ref:d,disabled:r,onClick:ot(e.onClick,g),onPointerDown:p=>{var _;(_=e.onPointerDown)==null||_.call(e,p),h.current=!0},onPointerUp:ot(e.onPointerUp,p=>{var _;h.current||(_=p.currentTarget)==null||_.click()}),onKeyDown:ot(e.onKeyDown,p=>{const _=c.searchRef.current!=="";r||_&&p.key===" "||Sw.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});kv.displayName=Ny;var MT=y.forwardRef((e,n)=>{const{__scopeMenu:r,disabled:i=!1,textValue:s,...o}=e,a=$5(Ny,r),c=ET(r),d=y.useRef(null),h=Jt(n,d),[g,p]=y.useState(!1),[_,b]=y.useState("");return y.useEffect(()=>{const x=d.current;x&&b((x.textContent??"").trim())},[o.children]),f.jsx(Bp.ItemSlot,{scope:r,disabled:i,textValue:s??_,children:f.jsx(CT,{asChild:!0,...c,focusable:!i,children:f.jsx(wg.div,{role:"menuitem","data-highlighted":g?"":void 0,"aria-disabled":i||void 0,"data-disabled":i?"":void 0,...o,ref:h,onPointerMove:ot(e.onPointerMove,Fp(x=>{i?a.onItemLeave(x):(a.onItemEnter(x),x.defaultPrevented||x.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:ot(e.onPointerLeave,Fp(x=>a.onItemLeave(x))),onFocus:ot(e.onFocus,()=>p(!0)),onBlur:ot(e.onBlur,()=>p(!1))})})})}),rq="MenuCheckboxItem",RT=y.forwardRef((e,n)=>{const{checked:r=!1,onCheckedChange:i,...s}=e;return f.jsx(IT,{scope:e.__scopeMenu,checked:r,children:f.jsx(kv,{role:"menuitemcheckbox","aria-checked":Ty(r)?"mixed":r,...s,ref:n,"data-state":H5(r),onSelect:ot(s.onSelect,()=>i==null?void 0:i(Ty(r)?!0:!r),{checkForDefaultPrevented:!1})})})});RT.displayName=rq;var DT="MenuRadioGroup",[iq,sq]=ju(DT,{value:void 0,onValueChange:()=>{}}),zT=y.forwardRef((e,n)=>{const{value:r,onValueChange:i,...s}=e,o=Ar(i);return f.jsx(iq,{scope:e.__scopeMenu,value:r,onValueChange:o,children:f.jsx(B5,{...s,ref:n})})});zT.displayName=DT;var LT="MenuRadioItem",$T=y.forwardRef((e,n)=>{const{value:r,...i}=e,s=sq(LT,e.__scopeMenu),o=r===s.value;return f.jsx(IT,{scope:e.__scopeMenu,checked:o,children:f.jsx(kv,{role:"menuitemradio","aria-checked":o,...i,ref:n,"data-state":H5(o),onSelect:ot(i.onSelect,()=>{var a;return(a=s.onValueChange)==null?void 0:a.call(s,r)},{checkForDefaultPrevented:!1})})})});$T.displayName=LT;var F5="MenuItemIndicator",[IT,oq]=ju(F5,{checked:!1}),BT=y.forwardRef((e,n)=>{const{__scopeMenu:r,forceMount:i,...s}=e,o=oq(F5,r);return f.jsx(si,{present:i||Ty(o.checked)||o.checked===!0,children:f.jsx(wg.span,{...s,ref:n,"data-state":H5(o.checked)})})});BT.displayName=F5;var aq="MenuSeparator",FT=y.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e;return f.jsx(wg.div,{role:"separator","aria-orientation":"horizontal",...i,ref:n})});FT.displayName=aq;var lq="MenuArrow",HT=y.forwardRef((e,n)=>{const{__scopeMenu:r,...i}=e,s=jv(r);return f.jsx(D5,{...s,...i,ref:n})});HT.displayName=lq;var cq="MenuSub",[PSe,UT]=ju(cq),lp="MenuSubTrigger",VT=y.forwardRef((e,n)=>{const r=ku(lp,e.__scopeMenu),i=jg(lp,e.__scopeMenu),s=UT(lp,e.__scopeMenu),o=$5(lp,e.__scopeMenu),a=y.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=o,h={__scopeMenu:e.__scopeMenu},g=y.useCallback(()=>{a.current&&window.clearTimeout(a.current),a.current=null},[]);return y.useEffect(()=>g,[g]),y.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),f.jsx(z5,{asChild:!0,...h,children:f.jsx(MT,{id:s.triggerId,"aria-haspopup":"menu","aria-expanded":r.open,"aria-controls":s.contentId,"data-state":KT(r.open),...e,ref:lr(n,s.onTriggerChange),onClick:p=>{var _;(_=e.onClick)==null||_.call(e,p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),r.open||r.onOpenChange(!0))},onPointerMove:ot(e.onPointerMove,Fp(p=>{o.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!r.open&&!a.current&&(o.onPointerGraceIntentChange(null),a.current=window.setTimeout(()=>{r.onOpenChange(!0),g()},100))})),onPointerLeave:ot(e.onPointerLeave,Fp(p=>{var b,x;g();const _=(b=r.content)==null?void 0:b.getBoundingClientRect();if(_){const C=(x=r.content)==null?void 0:x.dataset.side,j=C==="right",S=j?-5:5,E=_[j?"left":"right"],O=_[j?"right":"left"];o.onPointerGraceIntentChange({area:[{x:p.clientX+S,y:p.clientY},{x:E,y:_.top},{x:O,y:_.top},{x:O,y:_.bottom},{x:E,y:_.bottom}],side:C}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.onPointerGraceIntentChange(null),300)}else{if(o.onTriggerLeave(p),p.defaultPrevented)return;o.onPointerGraceIntentChange(null)}})),onKeyDown:ot(e.onKeyDown,p=>{var b;const _=o.searchRef.current!=="";e.disabled||_&&p.key===" "||UW[i.dir].includes(p.key)&&(r.onOpenChange(!0),(b=r.content)==null||b.focus(),p.preventDefault())})})})});VT.displayName=lp;var WT="MenuSubContent",qT=y.forwardRef((e,n)=>{const r=NT(Is,e.__scopeMenu),{forceMount:i=r.forceMount,...s}=e,o=ku(Is,e.__scopeMenu),a=jg(Is,e.__scopeMenu),c=UT(WT,e.__scopeMenu),d=y.useRef(null),h=Jt(n,d);return f.jsx(Bp.Provider,{scope:e.__scopeMenu,children:f.jsx(si,{present:i||o.open,children:f.jsx(Bp.Slot,{scope:e.__scopeMenu,children:f.jsx(I5,{id:c.contentId,"aria-labelledby":c.triggerId,...s,ref:h,align:"start",side:a.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:g=>{var p;a.isUsingKeyboardRef.current&&((p=d.current)==null||p.focus()),g.preventDefault()},onCloseAutoFocus:g=>g.preventDefault(),onFocusOutside:ot(e.onFocusOutside,g=>{g.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:ot(e.onEscapeKeyDown,g=>{a.onClose(),g.preventDefault()}),onKeyDown:ot(e.onKeyDown,g=>{var b;const p=g.currentTarget.contains(g.target),_=VW[a.dir].includes(g.key);p&&_&&(o.onOpenChange(!1),(b=c.trigger)==null||b.focus(),g.preventDefault())})})})})})});qT.displayName=WT;function KT(e){return e?"open":"closed"}function Ty(e){return e==="indeterminate"}function H5(e){return Ty(e)?"indeterminate":e?"checked":"unchecked"}function uq(e){const n=document.activeElement;for(const r of e)if(r===n||(r.focus(),document.activeElement!==n))return}function fq(e,n){return e.map((r,i)=>e[(n+i)%e.length])}function dq(e,n,r){const s=n.length>1&&Array.from(n).every(h=>h===n[0])?n[0]:n,o=r?e.indexOf(r):-1;let a=fq(e,Math.max(o,0));s.length===1&&(a=a.filter(h=>h!==r));const d=a.find(h=>h.toLowerCase().startsWith(s.toLowerCase()));return d!==r?d:void 0}function hq(e,n){const{x:r,y:i}=e;let s=!1;for(let o=0,a=n.length-1;o<n.length;a=o++){const c=n[o],d=n[a],h=c.x,g=c.y,p=d.x,_=d.y;g>i!=_>i&&r<(p-h)*(i-g)/(_-g)+h&&(s=!s)}return s}function pq(e,n){if(!n)return!1;const r={x:e.clientX,y:e.clientY};return hq(r,n)}function Fp(e){return n=>n.pointerType==="mouse"?e(n):void 0}var mq=OT,gq=z5,yq=TT,vq=PT,_q=B5,bq=AT,xq=kv,wq=RT,Sq=zT,Cq=$T,jq=BT,kq=FT,Eq=HT,Oq=VT,Nq=qT,Ev="DropdownMenu",[Tq]=bU(Ev,[kT]),bi=kT(),[Pq,GT]=Tq(Ev),YT=e=>{const{__scopeDropdownMenu:n,children:r,dir:i,open:s,defaultOpen:o,onOpenChange:a,modal:c=!0}=e,d=bi(n),h=y.useRef(null),[g,p]=Ka({prop:s,defaultProp:o??!1,onChange:a,caller:Ev});return f.jsx(Pq,{scope:n,triggerId:$s(),triggerRef:h,contentId:$s(),open:g,onOpenChange:p,onOpenToggle:y.useCallback(()=>p(_=>!_),[p]),modal:c,children:f.jsx(mq,{...d,open:g,onOpenChange:p,dir:i,modal:c,children:r})})};YT.displayName=Ev;var XT="DropdownMenuTrigger",JT=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,disabled:i=!1,...s}=e,o=GT(XT,r),a=bi(r);return f.jsx(gq,{asChild:!0,...a,children:f.jsx(NU.button,{type:"button",id:o.triggerId,"aria-haspopup":"menu","aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?"open":"closed","data-disabled":i?"":void 0,disabled:i,...s,ref:lr(n,o.triggerRef),onPointerDown:ot(e.onPointerDown,c=>{!i&&c.button===0&&c.ctrlKey===!1&&(o.onOpenToggle(),o.open||c.preventDefault())}),onKeyDown:ot(e.onKeyDown,c=>{i||(["Enter"," "].includes(c.key)&&o.onOpenToggle(),c.key==="ArrowDown"&&o.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});JT.displayName=XT;var Aq="DropdownMenuPortal",ZT=e=>{const{__scopeDropdownMenu:n,...r}=e,i=bi(n);return f.jsx(yq,{...i,...r})};ZT.displayName=Aq;var QT="DropdownMenuContent",eP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=GT(QT,r),o=bi(r),a=y.useRef(!1);return f.jsx(vq,{id:s.contentId,"aria-labelledby":s.triggerId,...o,...i,ref:n,onCloseAutoFocus:ot(e.onCloseAutoFocus,c=>{var d;a.current||(d=s.triggerRef.current)==null||d.focus(),a.current=!1,c.preventDefault()}),onInteractOutside:ot(e.onInteractOutside,c=>{const d=c.detail.originalEvent,h=d.button===0&&d.ctrlKey===!0,g=d.button===2||h;(!s.modal||g)&&(a.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});eP.displayName=QT;var Mq="DropdownMenuGroup",Rq=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(_q,{...s,...i,ref:n})});Rq.displayName=Mq;var Dq="DropdownMenuLabel",tP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(bq,{...s,...i,ref:n})});tP.displayName=Dq;var zq="DropdownMenuItem",nP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(xq,{...s,...i,ref:n})});nP.displayName=zq;var Lq="DropdownMenuCheckboxItem",$q=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(wq,{...s,...i,ref:n})});$q.displayName=Lq;var Iq="DropdownMenuRadioGroup",Bq=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(Sq,{...s,...i,ref:n})});Bq.displayName=Iq;var Fq="DropdownMenuRadioItem",rP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(Cq,{...s,...i,ref:n})});rP.displayName=Fq;var Hq="DropdownMenuItemIndicator",iP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(jq,{...s,...i,ref:n})});iP.displayName=Hq;var Uq="DropdownMenuSeparator",sP=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(kq,{...s,...i,ref:n})});sP.displayName=Uq;var Vq="DropdownMenuArrow",Wq=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(Eq,{...s,...i,ref:n})});Wq.displayName=Vq;var qq="DropdownMenuSubTrigger",Kq=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(Oq,{...s,...i,ref:n})});Kq.displayName=qq;var Gq="DropdownMenuSubContent",Yq=y.forwardRef((e,n)=>{const{__scopeDropdownMenu:r,...i}=e,s=bi(r);return f.jsx(Nq,{...s,...i,ref:n,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Yq.displayName=Gq;var Xq=YT,Jq=JT,Zq=ZT,oP=eP,aP=tP,lP=nP,cP=rP,Qq=iP,uP=sP;const Eu=Xq,Ou=Jq,dc=y.forwardRef(({className:e,sideOffset:n=6,...r},i)=>f.jsx(Zq,{children:f.jsx(oP,{ref:i,sideOffset:n,className:We("z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",e),...r})}));dc.displayName=oP.displayName;const Ov=y.forwardRef(({className:e,...n},r)=>f.jsx(aP,{ref:r,className:We("px-2 py-1.5 text-sm font-semibold",e),...n}));Ov.displayName=aP.displayName;const Xo=y.forwardRef(({className:e,inset:n,...r},i)=>f.jsx(lP,{ref:i,className:We("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",n&&"pl-8",e),...r}));Xo.displayName=lP.displayName;const Vo=y.forwardRef(({className:e,...n},r)=>f.jsx(uP,{ref:r,className:We("-mx-1 my-1 h-px bg-muted",e),...n}));Vo.displayName=uP.displayName;const eK=y.forwardRef(({className:e,children:n,...r},i)=>f.jsxs(cP,{ref:i,className:We("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...r,children:[f.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:f.jsx(Qq,{children:f.jsx(Rr,{className:"h-4 w-4"})})}),n]}));eK.displayName=cP.displayName;const Kr=y.forwardRef(({className:e,type:n,...r},i)=>f.jsx("input",{type:n,className:We("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:i,...r}));Kr.displayName="Input";var tK="Label",fP=y.forwardRef((e,n)=>f.jsx(mv.label,{...e,ref:n,onMouseDown:r=>{var s;r.target.closest("button, input, select, textarea")||((s=e.onMouseDown)==null||s.call(e,r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}}));fP.displayName=tK;var dP=fP;const nK=y5("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),or=y.forwardRef(({className:e,...n},r)=>f.jsx(dP,{ref:r,className:We(nK(),e),...n}));or.displayName=dP.displayName;function rK(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,iK(s,...n)]}function iK(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function sK(e){const n=oK(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(lK);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function oK(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=uK(s),c=cK(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var aK=Symbol("radix.slottable");function lK(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===aK}function cK(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function uK(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var fK=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nv=fK.reduce((e,n)=>{const r=sK(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),Tv="Tabs",[dK]=rK(Tv,[Cv]),hP=Cv(),[hK,U5]=dK(Tv),pP=y.forwardRef((e,n)=>{const{__scopeTabs:r,value:i,onValueChange:s,defaultValue:o,orientation:a="horizontal",dir:c,activationMode:d="automatic",...h}=e,g=bg(c),[p,_]=Ka({prop:i,onChange:s,defaultProp:o??"",caller:Tv});return f.jsx(hK,{scope:r,baseId:$s(),value:p,onValueChange:_,orientation:a,dir:g,activationMode:d,children:f.jsx(Nv.div,{dir:g,"data-orientation":a,...h,ref:n})})});pP.displayName=Tv;var mP="TabsList",gP=y.forwardRef((e,n)=>{const{__scopeTabs:r,loop:i=!0,...s}=e,o=U5(mP,r),a=hP(r);return f.jsx(ST,{asChild:!0,...a,orientation:o.orientation,dir:o.dir,loop:i,children:f.jsx(Nv.div,{role:"tablist","aria-orientation":o.orientation,...s,ref:n})})});gP.displayName=mP;var yP="TabsTrigger",vP=y.forwardRef((e,n)=>{const{__scopeTabs:r,value:i,disabled:s=!1,...o}=e,a=U5(yP,r),c=hP(r),d=xP(a.baseId,i),h=wP(a.baseId,i),g=i===a.value;return f.jsx(CT,{asChild:!0,...c,focusable:!s,active:g,children:f.jsx(Nv.button,{type:"button",role:"tab","aria-selected":g,"aria-controls":h,"data-state":g?"active":"inactive","data-disabled":s?"":void 0,disabled:s,id:d,...o,ref:n,onMouseDown:ot(e.onMouseDown,p=>{!s&&p.button===0&&p.ctrlKey===!1?a.onValueChange(i):p.preventDefault()}),onKeyDown:ot(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&a.onValueChange(i)}),onFocus:ot(e.onFocus,()=>{const p=a.activationMode!=="manual";!g&&!s&&p&&a.onValueChange(i)})})})});vP.displayName=yP;var _P="TabsContent",bP=y.forwardRef((e,n)=>{const{__scopeTabs:r,value:i,forceMount:s,children:o,...a}=e,c=U5(_P,r),d=xP(c.baseId,i),h=wP(c.baseId,i),g=i===c.value,p=y.useRef(g);return y.useEffect(()=>{const _=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(_)},[]),f.jsx(si,{present:s||g,children:({present:_})=>f.jsx(Nv.div,{"data-state":g?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!_,id:h,tabIndex:0,...a,ref:n,style:{...e.style,animationDuration:p.current?"0s":void 0},children:_&&o})})});bP.displayName=_P;function xP(e,n){return`${e}-trigger-${n}`}function wP(e,n){return`${e}-content-${n}`}var pK=pP,SP=gP,CP=vP,jP=bP;const V5=pK,Pv=y.forwardRef(({className:e,...n},r)=>f.jsx(SP,{ref:r,className:We("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",e),...n}));Pv.displayName=SP.displayName;const Ba=y.forwardRef(({className:e,...n},r)=>f.jsx(CP,{ref:r,className:We("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow",e),...n}));Ba.displayName=CP.displayName;const Fa=y.forwardRef(({className:e,...n},r)=>f.jsx(jP,{ref:r,className:We("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...n}));Fa.displayName=jP.displayName;function mK(e,n=[]){let r=[];function i(o,a){const c=y.createContext(a),d=r.length;r=[...r,a];const h=p=>{var S;const{scope:_,children:b,...x}=p,C=((S=_==null?void 0:_[e])==null?void 0:S[d])||c,j=y.useMemo(()=>x,Object.values(x));return f.jsx(C.Provider,{value:j,children:b})};h.displayName=o+"Provider";function g(p,_){var C;const b=((C=_==null?void 0:_[e])==null?void 0:C[d])||c,x=y.useContext(b);if(x)return x;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[h,g]}const s=()=>{const o=r.map(a=>y.createContext(a));return function(c){const d=(c==null?void 0:c[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return s.scopeName=e,[i,gK(s,...n)]}function gK(...e){const n=e[0];if(e.length===1)return n;const r=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((c,{useScope:d,scopeName:h})=>{const p=d(o)[`__scope${h}`];return{...c,...p}},{});return y.useMemo(()=>({[`__scope${n.scopeName}`]:a}),[a])}};return r.scopeName=n.scopeName,r}function yK(e){const n=vK(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(bK);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function vK(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=wK(s),c=xK(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var kP=Symbol("radix.slottable");function _K(e){const n=({children:r})=>f.jsx(f.Fragment,{children:r});return n.displayName=`${e}.Slottable`,n.__radixId=kP,n}function bK(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===kP}function xK(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function wK(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var SK=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],CK=SK.reduce((e,n)=>{const r=yK(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{});function jK(e){const n=kK(e),r=y.forwardRef((i,s)=>{const{children:o,...a}=i,c=y.Children.toArray(o),d=c.find(OK);if(d){const h=d.props.children,g=c.map(p=>p===d?y.Children.count(h)>1?y.Children.only(null):y.isValidElement(h)?h.props.children:null:p);return f.jsx(n,{...a,ref:s,children:y.isValidElement(h)?y.cloneElement(h,void 0,g):null})}return f.jsx(n,{...a,ref:s,children:o})});return r.displayName=`${e}.Slot`,r}function kK(e){const n=y.forwardRef((r,i)=>{const{children:s,...o}=r;if(y.isValidElement(s)){const a=TK(s),c=NK(o,s.props);return s.type!==y.Fragment&&(c.ref=i?lr(i,a):a),y.cloneElement(s,c)}return y.Children.count(s)>1?y.Children.only(null):null});return n.displayName=`${e}.SlotClone`,n}var EK=Symbol("radix.slottable");function OK(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===EK}function NK(e,n){const r={...n};for(const i in n){const s=e[i],o=n[i];/^on[A-Z]/.test(i)?s&&o?r[i]=(...c)=>{const d=o(...c);return s(...c),d}:s&&(r[i]=s):i==="style"?r[i]={...s,...o}:i==="className"&&(r[i]=[s,o].filter(Boolean).join(" "))}return{...e,...r}}function TK(e){var i,s;let n=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,r=n&&"isReactWarning"in n&&n.isReactWarning;return r?e.ref:(n=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,r=n&&"isReactWarning"in n&&n.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var PK=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],AK=PK.reduce((e,n)=>{const r=jK(`Primitive.${n}`),i=y.forwardRef((s,o)=>{const{asChild:a,...c}=s,d=a?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),f.jsx(d,{...c,ref:o})});return i.displayName=`Primitive.${n}`,{...e,[n]:i}},{}),EP=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),MK="VisuallyHidden",OP=y.forwardRef((e,n)=>f.jsx(AK.span,{...e,ref:n,style:{...EP,...e.style}}));OP.displayName=MK;var RK=OP,[Av]=mK("Tooltip",[pd]),Mv=pd(),NP="TooltipProvider",DK=700,Cw="tooltip.open",[zK,W5]=Av(NP),TP=e=>{const{__scopeTooltip:n,delayDuration:r=DK,skipDelayDuration:i=300,disableHoverableContent:s=!1,children:o}=e,a=y.useRef(!0),c=y.useRef(!1),d=y.useRef(0);return y.useEffect(()=>{const h=d.current;return()=>window.clearTimeout(h)},[]),f.jsx(zK,{scope:n,isOpenDelayedRef:a,delayDuration:r,onOpen:y.useCallback(()=>{window.clearTimeout(d.current),a.current=!1},[]),onClose:y.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>a.current=!0,i)},[i]),isPointerInTransitRef:c,onPointerInTransitChange:y.useCallback(h=>{c.current=h},[]),disableHoverableContent:s,children:o})};TP.displayName=NP;var Hp="Tooltip",[LK,kg]=Av(Hp),PP=e=>{const{__scopeTooltip:n,children:r,open:i,defaultOpen:s,onOpenChange:o,disableHoverableContent:a,delayDuration:c}=e,d=W5(Hp,e.__scopeTooltip),h=Mv(n),[g,p]=y.useState(null),_=$s(),b=y.useRef(0),x=a??d.disableHoverableContent,C=c??d.delayDuration,j=y.useRef(!1),[S,E]=Ka({prop:i,defaultProp:s??!1,onChange:D=>{D?(d.onOpen(),document.dispatchEvent(new CustomEvent(Cw))):d.onClose(),o==null||o(D)},caller:Hp}),O=y.useMemo(()=>S?j.current?"delayed-open":"instant-open":"closed",[S]),N=y.useCallback(()=>{window.clearTimeout(b.current),b.current=0,j.current=!1,E(!0)},[E]),T=y.useCallback(()=>{window.clearTimeout(b.current),b.current=0,E(!1)},[E]),P=y.useCallback(()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>{j.current=!0,E(!0),b.current=0},C)},[C,E]);return y.useEffect(()=>()=>{b.current&&(window.clearTimeout(b.current),b.current=0)},[]),f.jsx(A5,{...h,children:f.jsx(LK,{scope:n,contentId:_,open:S,stateAttribute:O,trigger:g,onTriggerChange:p,onTriggerEnter:y.useCallback(()=>{d.isOpenDelayedRef.current?P():N()},[d.isOpenDelayedRef,P,N]),onTriggerLeave:y.useCallback(()=>{x?T():(window.clearTimeout(b.current),b.current=0)},[T,x]),onOpen:N,onClose:T,disableHoverableContent:x,children:r})})};PP.displayName=Hp;var jw="TooltipTrigger",AP=y.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,s=kg(jw,r),o=W5(jw,r),a=Mv(r),c=y.useRef(null),d=Jt(n,c,s.onTriggerChange),h=y.useRef(!1),g=y.useRef(!1),p=y.useCallback(()=>h.current=!1,[]);return y.useEffect(()=>()=>document.removeEventListener("pointerup",p),[p]),f.jsx(M5,{asChild:!0,...a,children:f.jsx(CK.button,{"aria-describedby":s.open?s.contentId:void 0,"data-state":s.stateAttribute,...i,ref:d,onPointerMove:ot(e.onPointerMove,_=>{_.pointerType!=="touch"&&!g.current&&!o.isPointerInTransitRef.current&&(s.onTriggerEnter(),g.current=!0)}),onPointerLeave:ot(e.onPointerLeave,()=>{s.onTriggerLeave(),g.current=!1}),onPointerDown:ot(e.onPointerDown,()=>{s.open&&s.onClose(),h.current=!0,document.addEventListener("pointerup",p,{once:!0})}),onFocus:ot(e.onFocus,()=>{h.current||s.onOpen()}),onBlur:ot(e.onBlur,s.onClose),onClick:ot(e.onClick,s.onClose)})})});AP.displayName=jw;var q5="TooltipPortal",[$K,IK]=Av(q5,{forceMount:void 0}),MP=e=>{const{__scopeTooltip:n,forceMount:r,children:i,container:s}=e,o=kg(q5,n);return f.jsx($K,{scope:n,forceMount:r,children:f.jsx(si,{present:r||o.open,children:f.jsx(yg,{asChild:!0,container:s,children:i})})})};MP.displayName=q5;var ed="TooltipContent",RP=y.forwardRef((e,n)=>{const r=IK(ed,e.__scopeTooltip),{forceMount:i=r.forceMount,side:s="top",...o}=e,a=kg(ed,e.__scopeTooltip);return f.jsx(si,{present:i||a.open,children:a.disableHoverableContent?f.jsx(DP,{side:s,...o,ref:n}):f.jsx(BK,{side:s,...o,ref:n})})}),BK=y.forwardRef((e,n)=>{const r=kg(ed,e.__scopeTooltip),i=W5(ed,e.__scopeTooltip),s=y.useRef(null),o=Jt(n,s),[a,c]=y.useState(null),{trigger:d,onClose:h}=r,g=s.current,{onPointerInTransitChange:p}=i,_=y.useCallback(()=>{c(null),p(!1)},[p]),b=y.useCallback((x,C)=>{const j=x.currentTarget,S={x:x.clientX,y:x.clientY},E=WK(S,j.getBoundingClientRect()),O=qK(S,E),N=KK(C.getBoundingClientRect()),T=YK([...O,...N]);c(T),p(!0)},[p]);return y.useEffect(()=>()=>_(),[_]),y.useEffect(()=>{if(d&&g){const x=j=>b(j,g),C=j=>b(j,d);return d.addEventListener("pointerleave",x),g.addEventListener("pointerleave",C),()=>{d.removeEventListener("pointerleave",x),g.removeEventListener("pointerleave",C)}}},[d,g,b,_]),y.useEffect(()=>{if(a){const x=C=>{const j=C.target,S={x:C.clientX,y:C.clientY},E=(d==null?void 0:d.contains(j))||(g==null?void 0:g.contains(j)),O=!GK(S,a);E?_():O&&(_(),h())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[d,g,a,h,_]),f.jsx(DP,{...e,ref:o})}),[FK,HK]=Av(Hp,{isInside:!1}),UK=_K("TooltipContent"),DP=y.forwardRef((e,n)=>{const{__scopeTooltip:r,children:i,"aria-label":s,onEscapeKeyDown:o,onPointerDownOutside:a,...c}=e,d=kg(ed,r),h=Mv(r),{onClose:g}=d;return y.useEffect(()=>(document.addEventListener(Cw,g),()=>document.removeEventListener(Cw,g)),[g]),y.useEffect(()=>{if(d.trigger){const p=_=>{const b=_.target;b!=null&&b.contains(d.trigger)&&g()};return window.addEventListener("scroll",p,{capture:!0}),()=>window.removeEventListener("scroll",p,{capture:!0})}},[d.trigger,g]),f.jsx(gg,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:a,onFocusOutside:p=>p.preventDefault(),onDismiss:g,children:f.jsxs(R5,{"data-state":d.stateAttribute,...h,...c,ref:n,style:{...c.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[f.jsx(UK,{children:i}),f.jsx(FK,{scope:r,isInside:!0,children:f.jsx(RK,{id:d.contentId,role:"tooltip",children:s||i})})]})})});RP.displayName=ed;var zP="TooltipArrow",VK=y.forwardRef((e,n)=>{const{__scopeTooltip:r,...i}=e,s=Mv(r);return HK(zP,r).isInside?null:f.jsx(D5,{...s,...i,ref:n})});VK.displayName=zP;function WK(e,n){const r=Math.abs(n.top-e.y),i=Math.abs(n.bottom-e.y),s=Math.abs(n.right-e.x),o=Math.abs(n.left-e.x);switch(Math.min(r,i,s,o)){case o:return"left";case s:return"right";case r:return"top";case i:return"bottom";default:throw new Error("unreachable")}}function qK(e,n,r=5){const i=[];switch(n){case"top":i.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":i.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":i.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":i.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return i}function KK(e){const{top:n,right:r,bottom:i,left:s}=e;return[{x:s,y:n},{x:r,y:n},{x:r,y:i},{x:s,y:i}]}function GK(e,n){const{x:r,y:i}=e;let s=!1;for(let o=0,a=n.length-1;o<n.length;a=o++){const c=n[o],d=n[a],h=c.x,g=c.y,p=d.x,_=d.y;g>i!=_>i&&r<(p-h)*(i-g)/(_-g)+h&&(s=!s)}return s}function YK(e){const n=e.slice();return n.sort((r,i)=>r.x<i.x?-1:r.x>i.x?1:r.y<i.y?-1:r.y>i.y?1:0),XK(n)}function XK(e){if(e.length<=1)return e.slice();const n=[];for(let i=0;i<e.length;i++){const s=e[i];for(;n.length>=2;){const o=n[n.length-1],a=n[n.length-2];if((o.x-a.x)*(s.y-a.y)>=(o.y-a.y)*(s.x-a.x))n.pop();else break}n.push(s)}n.pop();const r=[];for(let i=e.length-1;i>=0;i--){const s=e[i];for(;r.length>=2;){const o=r[r.length-1],a=r[r.length-2];if((o.x-a.x)*(s.y-a.y)>=(o.y-a.y)*(s.x-a.x))r.pop();else break}r.push(s)}return r.pop(),n.length===1&&r.length===1&&n[0].x===r[0].x&&n[0].y===r[0].y?n:n.concat(r)}var JK=TP,ZK=PP,QK=AP,eG=MP,LP=RP;const tG=JK,dr=ZK,hr=QK,ir=y.forwardRef(({className:e,sideOffset:n=4,...r},i)=>f.jsx(eG,{children:f.jsx(LP,{ref:i,sideOffset:n,className:We("z-50 overflow-hidden rounded-md bg-foreground px-3 py-1.5 text-xs text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",e),...r})}));ir.displayName=LP.displayName;function Tf(e,n,r){let i=r.initialDeps??[],s,o=!0;function a(){var c,d,h;let g;r.key&&((c=r.debug)!=null&&c.call(r))&&(g=Date.now());const p=e();if(!(p.length!==i.length||p.some((x,C)=>i[C]!==x)))return s;i=p;let b;if(r.key&&((d=r.debug)!=null&&d.call(r))&&(b=Date.now()),s=n(...p),r.key&&((h=r.debug)!=null&&h.call(r))){const x=Math.round((Date.now()-g)*100)/100,C=Math.round((Date.now()-b)*100)/100,j=C/16,S=(E,O)=>{for(E=String(E);E.length<O;)E=" "+E;return E};console.info(`%c⏱ ${S(C,5)} /${S(x,5)} ms`,`
|
|
612
612
|
font-size: .6rem;
|
|
613
613
|
font-weight: bold;
|
|
614
614
|
color: hsl(${Math.max(0,Math.min(120-120*j,120))}deg 100% 31%);`,r==null?void 0:r.key)}return r!=null&&r.onChange&&!(o&&r.skipInitialOnChange)&&r.onChange(s),o=!1,s}return a.updateDeps=c=>{i=c},a}function cj(e,n){if(e===void 0)throw new Error("Unexpected undefined");return e}const nG=(e,n)=>Math.abs(e-n)<1.01,rG=(e,n,r)=>{let i;return function(...s){e.clearTimeout(i),i=e.setTimeout(()=>n.apply(this,s),r)}},uj=e=>{const{offsetWidth:n,offsetHeight:r}=e;return{width:n,height:r}},iG=e=>e,sG=e=>{const n=Math.max(e.startIndex-e.overscan,0),r=Math.min(e.endIndex+e.overscan,e.count-1),i=[];for(let s=n;s<=r;s++)i.push(s);return i},oG=(e,n)=>{const r=e.scrollElement;if(!r)return;const i=e.targetWindow;if(!i)return;const s=a=>{const{width:c,height:d}=a;n({width:Math.round(c),height:Math.round(d)})};if(s(uj(r)),!i.ResizeObserver)return()=>{};const o=new i.ResizeObserver(a=>{const c=()=>{const d=a[0];if(d!=null&&d.borderBoxSize){const h=d.borderBoxSize[0];if(h){s({width:h.inlineSize,height:h.blockSize});return}}s(uj(r))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(c):c()});return o.observe(r,{box:"border-box"}),()=>{o.unobserve(r)}},fj={passive:!0},dj=typeof window>"u"?!0:"onscrollend"in window,aG=(e,n)=>{const r=e.scrollElement;if(!r)return;const i=e.targetWindow;if(!i)return;let s=0;const o=e.options.useScrollendEvent&&dj?()=>{}:rG(i,()=>{n(s,!1)},e.options.isScrollingResetDelay),a=g=>()=>{const{horizontal:p,isRtl:_}=e.options;s=p?r.scrollLeft*(_&&-1||1):r.scrollTop,o(),n(s,g)},c=a(!0),d=a(!1);r.addEventListener("scroll",c,fj);const h=e.options.useScrollendEvent&&dj;return h&&r.addEventListener("scrollend",d,fj),()=>{r.removeEventListener("scroll",c),h&&r.removeEventListener("scrollend",d)}},lG=(e,n,r)=>{if(n!=null&&n.borderBoxSize){const i=n.borderBoxSize[0];if(i)return Math.round(i[r.options.horizontal?"inlineSize":"blockSize"])}return e[r.options.horizontal?"offsetWidth":"offsetHeight"]},cG=(e,{adjustments:n=0,behavior:r},i)=>{var s,o;const a=e+n;(o=(s=i.scrollElement)==null?void 0:s.scrollTo)==null||o.call(s,{[i.options.horizontal?"left":"top"]:a,behavior:r})};class uG{constructor(n){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var r,i,s;return((s=(i=(r=this.targetWindow)==null?void 0:r.performance)==null?void 0:i.now)==null?void 0:s.call(i))??Date.now()},this.observer=(()=>{let r=null;const i=()=>r||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:r=new this.targetWindow.ResizeObserver(s=>{s.forEach(o=>{const a=()=>{this._measureElement(o.target,o)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var s;(s=i())==null||s.disconnect(),r=null},observe:s=>{var o;return(o=i())==null?void 0:o.observe(s,{box:"border-box"})},unobserve:s=>{var o;return(o=i())==null?void 0:o.unobserve(s)}}})(),this.range=null,this.setOptions=r=>{Object.entries(r).forEach(([i,s])=>{typeof s>"u"&&delete r[i]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:iG,rangeExtractor:sG,onChange:()=>{},measureElement:lG,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...r}},this.notify=r=>{var i,s;(s=(i=this.options).onChange)==null||s.call(i,this,r)},this.maybeNotify=Tf(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),r=>{this.notify(r)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(r=>r()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var r;const i=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==i){if(this.cleanup(),!i){this.maybeNotify();return}this.scrollElement=i,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((r=this.scrollElement)==null?void 0:r.window)??null,this.elementsCache.forEach(s=>{this.observer.observe(s)}),this.unsubs.push(this.options.observeElementRect(this,s=>{this.scrollRect=s,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(s,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<s?"forward":"backward":null,this.scrollOffset=s,this.isScrolling=o,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(r,i)=>{const s=new Map,o=new Map;for(let a=i-1;a>=0;a--){const c=r[a];if(s.has(c.lane))continue;const d=o.get(c.lane);if(d==null||c.end>d.end?o.set(c.lane,c):c.end<d.end&&s.set(c.lane,!0),s.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((a,c)=>a.end===c.end?a.index-c.index:a.end-c.end)[0]:void 0},this.getMeasurementOptions=Tf(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(r,i,s,o,a,c)=>(this.prevLanes!==void 0&&this.prevLanes!==c&&(this.lanesChangedFlag=!0),this.prevLanes=c,this.pendingMeasuredCacheIndexes=[],{count:r,paddingStart:i,scrollMargin:s,getItemKey:o,enabled:a,lanes:c}),{key:!1}),this.getMeasurements=Tf(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:r,paddingStart:i,scrollMargin:s,getItemKey:o,enabled:a,lanes:c},d)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>r)for(const _ of this.laneAssignments.keys())_>=r&&this.laneAssignments.delete(_);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(_=>{this.itemSizeCache.set(_.key,_.size)}));const h=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===r&&(this.lanesSettling=!1);const g=this.measurementsCache.slice(0,h),p=new Array(c).fill(void 0);for(let _=0;_<h;_++){const b=g[_];b&&(p[b.lane]=_)}for(let _=h;_<r;_++){const b=o(_),x=this.laneAssignments.get(_);let C,j;if(x!==void 0&&this.options.lanes>1){C=x;const N=p[C],T=N!==void 0?g[N]:void 0;j=T?T.end+this.options.gap:i+s}else{const N=this.options.lanes===1?g[_-1]:this.getFurthestMeasurement(g,_);j=N?N.end+this.options.gap:i+s,C=N?N.lane:_%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(_,C)}const S=d.get(b),E=typeof S=="number"?S:this.options.estimateSize(_),O=j+E;g[_]={index:_,start:j,size:E,end:O,key:b,lane:C},p[C]=_}return this.measurementsCache=g,g},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Tf(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(r,i,s,o)=>this.range=r.length>0&&i>0?fG({measurements:r,outerSize:i,scrollOffset:s,lanes:o}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Tf(()=>{let r=null,i=null;const s=this.calculateRange();return s&&(r=s.startIndex,i=s.endIndex),this.maybeNotify.updateDeps([this.isScrolling,r,i]),[this.options.rangeExtractor,this.options.overscan,this.options.count,r,i]},(r,i,s,o,a)=>o===null||a===null?[]:r({startIndex:o,endIndex:a,overscan:i,count:s}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=r=>{const i=this.options.indexAttribute,s=r.getAttribute(i);return s?parseInt(s,10):(console.warn(`Missing attribute name '${i}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=r=>{var i;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const s=this.scrollState.index??((i=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:i.index);if(s!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,s-o),c=Math.min(this.options.count-1,s+o);return r>=a&&r<=c}return!0},this._measureElement=(r,i)=>{if(!r.isConnected){this.observer.unobserve(r);return}const s=this.indexFromElement(r),o=this.measurementsCache[s];if(!o)return;const a=o.key,c=this.elementsCache.get(a);c!==r&&(c&&this.observer.unobserve(c),this.observer.observe(r),this.elementsCache.set(a,r)),this.shouldMeasureDuringScroll(s)&&this.resizeItem(s,this.options.measureElement(r,i,this))},this.resizeItem=(r,i)=>{var s;const o=this.measurementsCache[r];if(!o)return;const a=this.itemSizeCache.get(o.key)??o.size,c=i-a;c!==0&&(((s=this.scrollState)==null?void 0:s.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(o,c,this):o.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=c,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(o.index),this.itemSizeCache=new Map(this.itemSizeCache.set(o.key,i)),this.notify(!1))},this.measureElement=r=>{if(!r){this.elementsCache.forEach((i,s)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(s))});return}this._measureElement(r,void 0)},this.getVirtualItems=Tf(()=>[this.getVirtualIndexes(),this.getMeasurements()],(r,i)=>{const s=[];for(let o=0,a=r.length;o<a;o++){const c=r[o],d=i[c];s.push(d)}return s},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=r=>{const i=this.getMeasurements();if(i.length!==0)return cj(i[$P(0,i.length-1,s=>cj(i[s]).start,r)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const r=this.scrollElement.document.documentElement;return this.options.horizontal?r.scrollWidth-this.scrollElement.innerWidth:r.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(r,i,s=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),a=this.getScrollOffset();i==="auto"&&(i=r>=a+o?"end":"start"),i==="center"?r+=(s-o)/2:i==="end"&&(r-=o);const c=this.getMaxScrollOffset();return Math.max(Math.min(c,r),0)},this.getOffsetForIndex=(r,i="auto")=>{r=Math.max(0,Math.min(r,this.options.count-1));const s=this.getSize(),o=this.getScrollOffset(),a=this.measurementsCache[r];if(!a)return;if(i==="auto")if(a.end>=o+s-this.options.scrollPaddingEnd)i="end";else if(a.start<=o+this.options.scrollPaddingStart)i="start";else return[o,i];if(i==="end"&&r===this.options.count-1)return[this.getMaxScrollOffset(),i];const c=i==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(c,i,a.size),i]},this.scrollToOffset=(r,{align:i="start",behavior:s="auto"}={})=>{const o=this.getOffsetForAlignment(r,i),a=this.now();this.scrollState={index:null,align:i,behavior:s,startedAt:a,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollToIndex=(r,{align:i="auto",behavior:s="auto"}={})=>{r=Math.max(0,Math.min(r,this.options.count-1));const o=this.getOffsetForIndex(r,i);if(!o)return;const[a,c]=o,d=this.now();this.scrollState={index:r,align:c,behavior:s,startedAt:d,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:s}),this.scheduleScrollReconcile()},this.scrollBy=(r,{behavior:i="auto"}={})=>{const s=this.getScrollOffset()+r,o=this.now();this.scrollState={index:null,align:"start",behavior:i,startedAt:o,lastTargetOffset:s,stableFrames:0},this._scrollToOffset(s,{adjustments:void 0,behavior:i}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var r;const i=this.getMeasurements();let s;if(i.length===0)s=this.options.paddingStart;else if(this.options.lanes===1)s=((r=i[i.length-1])==null?void 0:r.end)??0;else{const o=Array(this.options.lanes).fill(null);let a=i.length-1;for(;a>=0&&o.some(c=>c===null);){const c=i[a];o[c.lane]===null&&(o[c.lane]=c.end),a--}s=Math.max(...o.filter(c=>c!==null))}return Math.max(s-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(r,{adjustments:i,behavior:s})=>{this.options.scrollToFn(r,{behavior:s,adjustments:i},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(n)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const i=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,s=i?i[0]:this.scrollState.lastTargetOffset,o=1,a=s!==this.scrollState.lastTargetOffset;if(!a&&nG(s,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.scrollState=null;return}}else this.scrollState.stableFrames=0,a&&(this.scrollState.lastTargetOffset=s,this.scrollState.behavior="auto",this._scrollToOffset(s,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}}const $P=(e,n,r,i)=>{for(;e<=n;){const s=(e+n)/2|0,o=r(s);if(o<i)e=s+1;else if(o>i)n=s-1;else return s}return e>0?e-1:0};function fG({measurements:e,outerSize:n,scrollOffset:r,lanes:i}){const s=e.length-1,o=d=>e[d].start;if(e.length<=i)return{startIndex:0,endIndex:s};let a=$P(0,s,o,r),c=a;if(i===1)for(;c<s&&e[c].end<r+n;)c++;else if(i>1){const d=Array(i).fill(0);for(;c<s&&d.some(g=>g<r+n);){const g=e[c];d[g.lane]=g.end,c++}const h=Array(i).fill(r+n);for(;a>=0&&h.some(g=>g>=r);){const g=e[a];h[g.lane]=g.start,a--}a=Math.max(0,a-a%i),c=Math.min(s,c+(i-1-c%i))}return{startIndex:a,endIndex:c}}const hj=typeof document<"u"?y.useLayoutEffect:y.useEffect;function dG({useFlushSync:e=!0,...n}){const r=y.useReducer(()=>({}),{})[1],i={...n,onChange:(o,a)=>{var c;e&&a?Su.flushSync(r):r(),(c=n.onChange)==null||c.call(n,o,a)}},[s]=y.useState(()=>new uG(i));return s.setOptions(i),hj(()=>s._didMount(),[]),hj(()=>s._willUpdate()),s}function IP(e){return dG({observeElementRect:oG,observeElementOffset:aG,scrollToFn:cG,...e})}const hG=24;function pj({children:e,className:n,compact:r,loading:i}){const s=y.useRef(null),o=y.useMemo(()=>y.Children.toArray(e),[e]),[a,c]=y.useState(!0),[d,h]=y.useState(!0),g=y.useRef(0),p=y.useRef(i),_=y.useRef(0),b=IP({count:o.length,getScrollElement:()=>s.current,estimateSize:()=>r?180:240,overscan:6,paddingStart:24,paddingEnd:24}),x=b.getTotalSize(),C=y.useCallback(()=>{const S=s.current;if(!S)return;const E=S.scrollHeight-S.scrollTop-S.clientHeight,O=E<hG,N=S.scrollTop<_.current;_.current=S.scrollTop,c(O),h(T=>O?!0:N&&E>8?!1:T)},[]),j=y.useCallback((S="smooth")=>{o.length!==0&&b.scrollToIndex(o.length-1,{align:"end",behavior:S})},[o.length,b]);return y.useLayoutEffect(()=>{C()},[C,o.length,i]),y.useLayoutEffect(()=>{const S=o.length,E=g.current===0,O=p.current&&!i;g.current=S,p.current=i,!i&&S>0&&(E||O)&&(h(!0),j("auto"))},[o.length,i,j]),y.useLayoutEffect(()=>{if(i||o.length===0||!d)return;const S=window.requestAnimationFrame(()=>{j("auto")});return()=>window.cancelAnimationFrame(S)},[o.length,x,d,i,j]),f.jsxs("div",{className:We("relative flex-1 overflow-hidden",n),children:[i?f.jsx("div",{className:"flex h-full items-center justify-center",children:f.jsx(kt,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):f.jsx("div",{ref:s,onScroll:C,className:"h-full overflow-y-auto",children:f.jsx("div",{style:{height:`${b.getTotalSize()}px`,position:"relative",width:"100%"},children:b.getVirtualItems().map(S=>{const E=o[S.index];return f.jsx("div",{"data-index":S.index,ref:b.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${S.start}px)`},children:f.jsx("div",{className:We("mx-auto","max-w-3xl px-4"),children:E})},typeof E=="object"&&E!==null&&"key"in E?String(E.key):S.index)})})}),!i&&!a&&f.jsx($e,{variant:"outline",size:"icon",className:"absolute bottom-4 left-1/2 h-8 w-8 -translate-x-1/2 rounded-full shadow-md",onClick:()=>{h(!0),j()},children:f.jsx(AO,{className:"h-4 w-4"})})]})}const pG={};function K5(e,n){const r=pG,i=typeof r.includeImageAlt=="boolean"?r.includeImageAlt:!0,s=typeof r.includeHtml=="boolean"?r.includeHtml:!0;return BP(e,i,s)}function BP(e,n,r){if(mG(e)){if("value"in e)return e.type==="html"&&!r?"":e.value;if(n&&"alt"in e&&e.alt)return e.alt;if("children"in e)return mj(e.children,n,r)}return Array.isArray(e)?mj(e,n,r):""}function mj(e,n,r){const i=[];let s=-1;for(;++s<e.length;)i[s]=BP(e[s],n,r);return i.join("")}function mG(e){return!!(e&&typeof e=="object")}const gj=document.createElement("i");function G5(e){const n="&"+e+";";gj.innerHTML=n;const r=gj.textContent;return r.charCodeAt(r.length-1)===59&&e!=="semi"||r===n?!1:r}function ms(e,n,r,i){const s=e.length;let o=0,a;if(n<0?n=-n>s?0:s+n:n=n>s?s:n,r=r>0?r:0,i.length<1e4)a=Array.from(i),a.unshift(n,r),e.splice(...a);else for(r&&e.splice(n,r);o<i.length;)a=i.slice(o,o+1e4),a.unshift(n,0),e.splice(...a),o+=1e4,n+=1e4}function Ds(e,n){return e.length>0?(ms(e,e.length,0,n),e):n}const yj={}.hasOwnProperty;function FP(e){const n={};let r=-1;for(;++r<e.length;)gG(n,e[r]);return n}function gG(e,n){let r;for(r in n){const s=(yj.call(e,r)?e[r]:void 0)||(e[r]={}),o=n[r];let a;if(o)for(a in o){yj.call(s,a)||(s[a]=[]);const c=o[a];yG(s[a],Array.isArray(c)?c:c?[c]:[])}}}function yG(e,n){let r=-1;const i=[];for(;++r<n.length;)(n[r].add==="after"?e:i).push(n[r]);ms(e,0,0,i)}function HP(e,n){const r=Number.parseInt(e,n);return r<9||r===11||r>13&&r<32||r>126&&r<160||r>55295&&r<57344||r>64975&&r<65008||(r&65535)===65535||(r&65535)===65534||r>1114111?"�":String.fromCodePoint(r)}function yo(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const vi=hc(/[A-Za-z]/),ii=hc(/[\dA-Za-z]/),vG=hc(/[#-'*+\--9=?A-Z^-~]/);function Py(e){return e!==null&&(e<32||e===127)}const kw=hc(/\d/),_G=hc(/[\dA-Fa-f]/),bG=hc(/[!-/:-@[-`{-~]/);function Ot(e){return e!==null&&e<-2}function Pn(e){return e!==null&&(e<0||e===32)}function tn(e){return e===-2||e===-1||e===32}const Rv=hc(new RegExp("\\p{P}|\\p{S}","u")),mu=hc(/\s/);function hc(e){return n;function n(r){return r!==null&&r>-1&&e.test(String.fromCharCode(r))}}function md(e){const n=[];let r=-1,i=0,s=0;for(;++r<e.length;){const o=e.charCodeAt(r);let a="";if(o===37&&ii(e.charCodeAt(r+1))&&ii(e.charCodeAt(r+2)))s=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const c=e.charCodeAt(r+1);o<56320&&c>56319&&c<57344?(a=String.fromCharCode(o,c),s=1):a="�"}else a=String.fromCharCode(o);a&&(n.push(e.slice(i,r),encodeURIComponent(a)),i=r+s+1,a=""),s&&(r+=s,s=0)}return n.join("")+e.slice(i)}function fn(e,n,r,i){const s=i?i-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(d){return tn(d)?(e.enter(r),c(d)):n(d)}function c(d){return tn(d)&&o++<s?(e.consume(d),c):(e.exit(r),n(d))}}const xG={tokenize:wG};function wG(e){const n=e.attempt(this.parser.constructs.contentInitial,i,s);let r;return n;function i(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),fn(e,n,"linePrefix")}function s(c){return e.enter("paragraph"),o(c)}function o(c){const d=e.enter("chunkText",{contentType:"text",previous:r});return r&&(r.next=d),r=d,a(c)}function a(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return Ot(c)?(e.consume(c),e.exit("chunkText"),o):(e.consume(c),a)}}const SG={tokenize:CG},vj={tokenize:jG};function CG(e){const n=this,r=[];let i=0,s,o,a;return c;function c(O){if(i<r.length){const N=r[i];return n.containerState=N[1],e.attempt(N[0].continuation,d,h)(O)}return h(O)}function d(O){if(i++,n.containerState._closeFlow){n.containerState._closeFlow=void 0,s&&E();const N=n.events.length;let T=N,P;for(;T--;)if(n.events[T][0]==="exit"&&n.events[T][1].type==="chunkFlow"){P=n.events[T][1].end;break}S(i);let D=N;for(;D<n.events.length;)n.events[D][1].end={...P},D++;return ms(n.events,T+1,0,n.events.slice(N)),n.events.length=D,h(O)}return c(O)}function h(O){if(i===r.length){if(!s)return _(O);if(s.currentConstruct&&s.currentConstruct.concrete)return x(O);n.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return n.containerState={},e.check(vj,g,p)(O)}function g(O){return s&&E(),S(i),_(O)}function p(O){return n.parser.lazy[n.now().line]=i!==r.length,a=n.now().offset,x(O)}function _(O){return n.containerState={},e.attempt(vj,b,x)(O)}function b(O){return i++,r.push([n.currentConstruct,n.containerState]),_(O)}function x(O){if(O===null){s&&E(),S(0),e.consume(O);return}return s=s||n.parser.flow(n.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),C(O)}function C(O){if(O===null){j(e.exit("chunkFlow"),!0),S(0),e.consume(O);return}return Ot(O)?(e.consume(O),j(e.exit("chunkFlow")),i=0,n.interrupt=void 0,c):(e.consume(O),C)}function j(O,N){const T=n.sliceStream(O);if(N&&T.push(null),O.previous=o,o&&(o.next=O),o=O,s.defineSkip(O.start),s.write(T),n.parser.lazy[O.start.line]){let P=s.events.length;for(;P--;)if(s.events[P][1].start.offset<a&&(!s.events[P][1].end||s.events[P][1].end.offset>a))return;const D=n.events.length;let H=D,J,I;for(;H--;)if(n.events[H][0]==="exit"&&n.events[H][1].type==="chunkFlow"){if(J){I=n.events[H][1].end;break}J=!0}for(S(i),P=D;P<n.events.length;)n.events[P][1].end={...I},P++;ms(n.events,H+1,0,n.events.slice(D)),n.events.length=P}}function S(O){let N=r.length;for(;N-- >O;){const T=r[N];n.containerState=T[1],T[0].exit.call(n,e)}r.length=O}function E(){s.write([null]),o=void 0,s=void 0,n.containerState._closeFlow=void 0}}function jG(e,n,r){return fn(e,e.attempt(this.parser.constructs.document,n,r),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function td(e){if(e===null||Pn(e)||mu(e))return 1;if(Rv(e))return 2}function Dv(e,n,r){const i=[];let s=-1;for(;++s<e.length;){const o=e[s].resolveAll;o&&!i.includes(o)&&(n=o(n,r),i.push(o))}return n}const Ew={name:"attention",resolveAll:kG,tokenize:EG};function kG(e,n){let r=-1,i,s,o,a,c,d,h,g;for(;++r<e.length;)if(e[r][0]==="enter"&&e[r][1].type==="attentionSequence"&&e[r][1]._close){for(i=r;i--;)if(e[i][0]==="exit"&&e[i][1].type==="attentionSequence"&&e[i][1]._open&&n.sliceSerialize(e[i][1]).charCodeAt(0)===n.sliceSerialize(e[r][1]).charCodeAt(0)){if((e[i][1]._close||e[r][1]._open)&&(e[r][1].end.offset-e[r][1].start.offset)%3&&!((e[i][1].end.offset-e[i][1].start.offset+e[r][1].end.offset-e[r][1].start.offset)%3))continue;d=e[i][1].end.offset-e[i][1].start.offset>1&&e[r][1].end.offset-e[r][1].start.offset>1?2:1;const p={...e[i][1].end},_={...e[r][1].start};_j(p,-d),_j(_,d),a={type:d>1?"strongSequence":"emphasisSequence",start:p,end:{...e[i][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[r][1].start},end:_},o={type:d>1?"strongText":"emphasisText",start:{...e[i][1].end},end:{...e[r][1].start}},s={type:d>1?"strong":"emphasis",start:{...a.start},end:{...c.end}},e[i][1].end={...a.start},e[r][1].start={...c.end},h=[],e[i][1].end.offset-e[i][1].start.offset&&(h=Ds(h,[["enter",e[i][1],n],["exit",e[i][1],n]])),h=Ds(h,[["enter",s,n],["enter",a,n],["exit",a,n],["enter",o,n]]),h=Ds(h,Dv(n.parser.constructs.insideSpan.null,e.slice(i+1,r),n)),h=Ds(h,[["exit",o,n],["enter",c,n],["exit",c,n],["exit",s,n]]),e[r][1].end.offset-e[r][1].start.offset?(g=2,h=Ds(h,[["enter",e[r][1],n],["exit",e[r][1],n]])):g=0,ms(e,i-1,r-i+3,h),r=i+h.length-g-2;break}}for(r=-1;++r<e.length;)e[r][1].type==="attentionSequence"&&(e[r][1].type="data");return e}function EG(e,n){const r=this.parser.constructs.attentionMarkers.null,i=this.previous,s=td(i);let o;return a;function a(d){return o=d,e.enter("attentionSequence"),c(d)}function c(d){if(d===o)return e.consume(d),c;const h=e.exit("attentionSequence"),g=td(d),p=!g||g===2&&s||r.includes(d),_=!s||s===2&&g||r.includes(i);return h._open=!!(o===42?p:p&&(s||!_)),h._close=!!(o===42?_:_&&(g||!p)),n(d)}}function _j(e,n){e.column+=n,e.offset+=n,e._bufferIndex+=n}const OG={name:"autolink",tokenize:NG};function NG(e,n,r){let i=0;return s;function s(b){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(b){return vi(b)?(e.consume(b),a):b===64?r(b):h(b)}function a(b){return b===43||b===45||b===46||ii(b)?(i=1,c(b)):h(b)}function c(b){return b===58?(e.consume(b),i=0,d):(b===43||b===45||b===46||ii(b))&&i++<32?(e.consume(b),c):(i=0,h(b))}function d(b){return b===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):b===null||b===32||b===60||Py(b)?r(b):(e.consume(b),d)}function h(b){return b===64?(e.consume(b),g):vG(b)?(e.consume(b),h):r(b)}function g(b){return ii(b)?p(b):r(b)}function p(b){return b===46?(e.consume(b),i=0,g):b===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(b),e.exit("autolinkMarker"),e.exit("autolink"),n):_(b)}function _(b){if((b===45||ii(b))&&i++<63){const x=b===45?_:p;return e.consume(b),x}return r(b)}}const Eg={partial:!0,tokenize:TG};function TG(e,n,r){return i;function i(o){return tn(o)?fn(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||Ot(o)?n(o):r(o)}}const UP={continuation:{tokenize:AG},exit:MG,name:"blockQuote",tokenize:PG};function PG(e,n,r){const i=this;return s;function s(a){if(a===62){const c=i.containerState;return c.open||(e.enter("blockQuote",{_container:!0}),c.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return r(a)}function o(a){return tn(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),n):(e.exit("blockQuotePrefix"),n(a))}}function AG(e,n,r){const i=this;return s;function s(a){return tn(a)?fn(e,o,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(UP,n,r)(a)}}function MG(e){e.exit("blockQuote")}const VP={name:"characterEscape",tokenize:RG};function RG(e,n,r){return i;function i(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),s}function s(o){return bG(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),n):r(o)}}const WP={name:"characterReference",tokenize:DG};function DG(e,n,r){const i=this;let s=0,o,a;return c;function c(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),d}function d(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),h):(e.enter("characterReferenceValue"),o=31,a=ii,g(p))}function h(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=_G,g):(e.enter("characterReferenceValue"),o=7,a=kw,g(p))}function g(p){if(p===59&&s){const _=e.exit("characterReferenceValue");return a===ii&&!G5(i.sliceSerialize(_))?r(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),n)}return a(p)&&s++<o?(e.consume(p),g):r(p)}}const bj={partial:!0,tokenize:LG},xj={concrete:!0,name:"codeFenced",tokenize:zG};function zG(e,n,r){const i=this,s={partial:!0,tokenize:T};let o=0,a=0,c;return d;function d(P){return h(P)}function h(P){const D=i.events[i.events.length-1];return o=D&&D[1].type==="linePrefix"?D[2].sliceSerialize(D[1],!0).length:0,c=P,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),g(P)}function g(P){return P===c?(a++,e.consume(P),g):a<3?r(P):(e.exit("codeFencedFenceSequence"),tn(P)?fn(e,p,"whitespace")(P):p(P))}function p(P){return P===null||Ot(P)?(e.exit("codeFencedFence"),i.interrupt?n(P):e.check(bj,C,N)(P)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),_(P))}function _(P){return P===null||Ot(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(P)):tn(P)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),fn(e,b,"whitespace")(P)):P===96&&P===c?r(P):(e.consume(P),_)}function b(P){return P===null||Ot(P)?p(P):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),x(P))}function x(P){return P===null||Ot(P)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(P)):P===96&&P===c?r(P):(e.consume(P),x)}function C(P){return e.attempt(s,N,j)(P)}function j(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),S}function S(P){return o>0&&tn(P)?fn(e,E,"linePrefix",o+1)(P):E(P)}function E(P){return P===null||Ot(P)?e.check(bj,C,N)(P):(e.enter("codeFlowValue"),O(P))}function O(P){return P===null||Ot(P)?(e.exit("codeFlowValue"),E(P)):(e.consume(P),O)}function N(P){return e.exit("codeFenced"),n(P)}function T(P,D,H){let J=0;return I;function I(V){return P.enter("lineEnding"),P.consume(V),P.exit("lineEnding"),B}function B(V){return P.enter("codeFencedFence"),tn(V)?fn(P,F,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):F(V)}function F(V){return V===c?(P.enter("codeFencedFenceSequence"),W(V)):H(V)}function W(V){return V===c?(J++,P.consume(V),W):J>=a?(P.exit("codeFencedFenceSequence"),tn(V)?fn(P,z,"whitespace")(V):z(V)):H(V)}function z(V){return V===null||Ot(V)?(P.exit("codeFencedFence"),D(V)):H(V)}}}function LG(e,n,r){const i=this;return s;function s(a){return a===null?r(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return i.parser.lazy[i.now().line]?r(a):n(a)}}const dx={name:"codeIndented",tokenize:IG},$G={partial:!0,tokenize:BG};function IG(e,n,r){const i=this;return s;function s(h){return e.enter("codeIndented"),fn(e,o,"linePrefix",5)(h)}function o(h){const g=i.events[i.events.length-1];return g&&g[1].type==="linePrefix"&&g[2].sliceSerialize(g[1],!0).length>=4?a(h):r(h)}function a(h){return h===null?d(h):Ot(h)?e.attempt($G,a,d)(h):(e.enter("codeFlowValue"),c(h))}function c(h){return h===null||Ot(h)?(e.exit("codeFlowValue"),a(h)):(e.consume(h),c)}function d(h){return e.exit("codeIndented"),n(h)}}function BG(e,n,r){const i=this;return s;function s(a){return i.parser.lazy[i.now().line]?r(a):Ot(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):fn(e,o,"linePrefix",5)(a)}function o(a){const c=i.events[i.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?n(a):Ot(a)?s(a):r(a)}}const FG={name:"codeText",previous:UG,resolve:HG,tokenize:VG};function HG(e){let n=e.length-4,r=3,i,s;if((e[r][1].type==="lineEnding"||e[r][1].type==="space")&&(e[n][1].type==="lineEnding"||e[n][1].type==="space")){for(i=r;++i<n;)if(e[i][1].type==="codeTextData"){e[r][1].type="codeTextPadding",e[n][1].type="codeTextPadding",r+=2,n-=2;break}}for(i=r-1,n++;++i<=n;)s===void 0?i!==n&&e[i][1].type!=="lineEnding"&&(s=i):(i===n||e[i][1].type==="lineEnding")&&(e[s][1].type="codeTextData",i!==s+2&&(e[s][1].end=e[i-1][1].end,e.splice(s+2,i-s-2),n-=i-s-2,i=s+2),s=void 0);return e}function UG(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function VG(e,n,r){let i=0,s,o;return a;function a(p){return e.enter("codeText"),e.enter("codeTextSequence"),c(p)}function c(p){return p===96?(e.consume(p),i++,c):(e.exit("codeTextSequence"),d(p))}function d(p){return p===null?r(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),d):p===96?(o=e.enter("codeTextSequence"),s=0,g(p)):Ot(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("codeTextData"),h(p))}function h(p){return p===null||p===32||p===96||Ot(p)?(e.exit("codeTextData"),d(p)):(e.consume(p),h)}function g(p){return p===96?(e.consume(p),s++,g):s===i?(e.exit("codeTextSequence"),e.exit("codeText"),n(p)):(o.type="codeTextData",h(p))}}class WG{constructor(n){this.left=n?[...n]:[],this.right=[]}get(n){if(n<0||n>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+n+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return n<this.left.length?this.left[n]:this.right[this.right.length-n+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(n,r){const i=r??Number.POSITIVE_INFINITY;return i<this.left.length?this.left.slice(n,i):n>this.left.length?this.right.slice(this.right.length-i+this.left.length,this.right.length-n+this.left.length).reverse():this.left.slice(n).concat(this.right.slice(this.right.length-i+this.left.length).reverse())}splice(n,r,i){const s=r||0;this.setCursor(Math.trunc(n));const o=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return i&&Nh(this.left,i),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(n){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(n)}pushMany(n){this.setCursor(Number.POSITIVE_INFINITY),Nh(this.left,n)}unshift(n){this.setCursor(0),this.right.push(n)}unshiftMany(n){this.setCursor(0),Nh(this.right,n.reverse())}setCursor(n){if(!(n===this.left.length||n>this.left.length&&this.right.length===0||n<0&&this.left.length===0))if(n<this.left.length){const r=this.left.splice(n,Number.POSITIVE_INFINITY);Nh(this.right,r.reverse())}else{const r=this.right.splice(this.left.length+this.right.length-n,Number.POSITIVE_INFINITY);Nh(this.left,r.reverse())}}}function Nh(e,n){let r=0;if(n.length<1e4)e.push(...n);else for(;r<n.length;)e.push(...n.slice(r,r+1e4)),r+=1e4}function qP(e){const n={};let r=-1,i,s,o,a,c,d,h;const g=new WG(e);for(;++r<g.length;){for(;r in n;)r=n[r];if(i=g.get(r),r&&i[1].type==="chunkFlow"&&g.get(r-1)[1].type==="listItemPrefix"&&(d=i[1]._tokenizer.events,o=0,o<d.length&&d[o][1].type==="lineEndingBlank"&&(o+=2),o<d.length&&d[o][1].type==="content"))for(;++o<d.length&&d[o][1].type!=="content";)d[o][1].type==="chunkText"&&(d[o][1]._isInFirstContentOfListItem=!0,o++);if(i[0]==="enter")i[1].contentType&&(Object.assign(n,qG(g,r)),r=n[r],h=!0);else if(i[1]._container){for(o=r,s=void 0;o--;)if(a=g.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(g.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=o);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(i[1].end={...g.get(s)[1].start},c=g.slice(s,r),c.unshift(i),g.splice(s,r-s+1,c))}}return ms(e,0,Number.POSITIVE_INFINITY,g.slice(0)),!h}function qG(e,n){const r=e.get(n)[1],i=e.get(n)[2];let s=n-1;const o=[];let a=r._tokenizer;a||(a=i.parser[r.contentType](r.start),r._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const c=a.events,d=[],h={};let g,p,_=-1,b=r,x=0,C=0;const j=[C];for(;b;){for(;e.get(++s)[1]!==b;);o.push(s),b._tokenizer||(g=i.sliceStream(b),b.next||g.push(null),p&&a.defineSkip(b.start),b._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(g),b._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),p=b,b=b.next}for(b=r;++_<c.length;)c[_][0]==="exit"&&c[_-1][0]==="enter"&&c[_][1].type===c[_-1][1].type&&c[_][1].start.line!==c[_][1].end.line&&(C=_+1,j.push(C),b._tokenizer=void 0,b.previous=void 0,b=b.next);for(a.events=[],b?(b._tokenizer=void 0,b.previous=void 0):j.pop(),_=j.length;_--;){const S=c.slice(j[_],j[_+1]),E=o.pop();d.push([E,E+S.length-1]),e.splice(E,2,S)}for(d.reverse(),_=-1;++_<d.length;)h[x+d[_][0]]=x+d[_][1],x+=d[_][1]-d[_][0]-1;return h}const KG={resolve:YG,tokenize:XG},GG={partial:!0,tokenize:JG};function YG(e){return qP(e),e}function XG(e,n){let r;return i;function i(c){return e.enter("content"),r=e.enter("chunkContent",{contentType:"content"}),s(c)}function s(c){return c===null?o(c):Ot(c)?e.check(GG,a,o)(c):(e.consume(c),s)}function o(c){return e.exit("chunkContent"),e.exit("content"),n(c)}function a(c){return e.consume(c),e.exit("chunkContent"),r.next=e.enter("chunkContent",{contentType:"content",previous:r}),r=r.next,s}}function JG(e,n,r){const i=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),fn(e,o,"linePrefix")}function o(a){if(a===null||Ot(a))return r(a);const c=i.events[i.events.length-1];return!i.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?n(a):e.interrupt(i.parser.constructs.flow,r,n)(a)}}function KP(e,n,r,i,s,o,a,c,d){const h=d||Number.POSITIVE_INFINITY;let g=0;return p;function p(S){return S===60?(e.enter(i),e.enter(s),e.enter(o),e.consume(S),e.exit(o),_):S===null||S===32||S===41||Py(S)?r(S):(e.enter(i),e.enter(a),e.enter(c),e.enter("chunkString",{contentType:"string"}),C(S))}function _(S){return S===62?(e.enter(o),e.consume(S),e.exit(o),e.exit(s),e.exit(i),n):(e.enter(c),e.enter("chunkString",{contentType:"string"}),b(S))}function b(S){return S===62?(e.exit("chunkString"),e.exit(c),_(S)):S===null||S===60||Ot(S)?r(S):(e.consume(S),S===92?x:b)}function x(S){return S===60||S===62||S===92?(e.consume(S),b):b(S)}function C(S){return!g&&(S===null||S===41||Pn(S))?(e.exit("chunkString"),e.exit(c),e.exit(a),e.exit(i),n(S)):g<h&&S===40?(e.consume(S),g++,C):S===41?(e.consume(S),g--,C):S===null||S===32||S===40||Py(S)?r(S):(e.consume(S),S===92?j:C)}function j(S){return S===40||S===41||S===92?(e.consume(S),C):C(S)}}function GP(e,n,r,i,s,o){const a=this;let c=0,d;return h;function h(b){return e.enter(i),e.enter(s),e.consume(b),e.exit(s),e.enter(o),g}function g(b){return c>999||b===null||b===91||b===93&&!d||b===94&&!c&&"_hiddenFootnoteSupport"in a.parser.constructs?r(b):b===93?(e.exit(o),e.enter(s),e.consume(b),e.exit(s),e.exit(i),n):Ot(b)?(e.enter("lineEnding"),e.consume(b),e.exit("lineEnding"),g):(e.enter("chunkString",{contentType:"string"}),p(b))}function p(b){return b===null||b===91||b===93||Ot(b)||c++>999?(e.exit("chunkString"),g(b)):(e.consume(b),d||(d=!tn(b)),b===92?_:p)}function _(b){return b===91||b===92||b===93?(e.consume(b),c++,p):p(b)}}function YP(e,n,r,i,s,o){let a;return c;function c(_){return _===34||_===39||_===40?(e.enter(i),e.enter(s),e.consume(_),e.exit(s),a=_===40?41:_,d):r(_)}function d(_){return _===a?(e.enter(s),e.consume(_),e.exit(s),e.exit(i),n):(e.enter(o),h(_))}function h(_){return _===a?(e.exit(o),d(a)):_===null?r(_):Ot(_)?(e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),fn(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),g(_))}function g(_){return _===a||_===null||Ot(_)?(e.exit("chunkString"),h(_)):(e.consume(_),_===92?p:g)}function p(_){return _===a||_===92?(e.consume(_),g):g(_)}}function kp(e,n){let r;return i;function i(s){return Ot(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),r=!0,i):tn(s)?fn(e,i,r?"linePrefix":"lineSuffix")(s):n(s)}}const ZG={name:"definition",tokenize:eY},QG={partial:!0,tokenize:tY};function eY(e,n,r){const i=this;let s;return o;function o(b){return e.enter("definition"),a(b)}function a(b){return GP.call(i,e,c,r,"definitionLabel","definitionLabelMarker","definitionLabelString")(b)}function c(b){return s=yo(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)),b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),d):r(b)}function d(b){return Pn(b)?kp(e,h)(b):h(b)}function h(b){return KP(e,g,r,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(b)}function g(b){return e.attempt(QG,p,p)(b)}function p(b){return tn(b)?fn(e,_,"whitespace")(b):_(b)}function _(b){return b===null||Ot(b)?(e.exit("definition"),i.parser.defined.push(s),n(b)):r(b)}}function tY(e,n,r){return i;function i(c){return Pn(c)?kp(e,s)(c):r(c)}function s(c){return YP(e,o,r,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function o(c){return tn(c)?fn(e,a,"whitespace")(c):a(c)}function a(c){return c===null||Ot(c)?n(c):r(c)}}const nY={name:"hardBreakEscape",tokenize:rY};function rY(e,n,r){return i;function i(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return Ot(o)?(e.exit("hardBreakEscape"),n(o)):r(o)}}const iY={name:"headingAtx",resolve:sY,tokenize:oY};function sY(e,n){let r=e.length-2,i=3,s,o;return e[i][1].type==="whitespace"&&(i+=2),r-2>i&&e[r][1].type==="whitespace"&&(r-=2),e[r][1].type==="atxHeadingSequence"&&(i===r-1||r-4>i&&e[r-2][1].type==="whitespace")&&(r-=i+1===r?2:4),r>i&&(s={type:"atxHeadingText",start:e[i][1].start,end:e[r][1].end},o={type:"chunkText",start:e[i][1].start,end:e[r][1].end,contentType:"text"},ms(e,i,r-i+1,[["enter",s,n],["enter",o,n],["exit",o,n],["exit",s,n]])),e}function oY(e,n,r){let i=0;return s;function s(g){return e.enter("atxHeading"),o(g)}function o(g){return e.enter("atxHeadingSequence"),a(g)}function a(g){return g===35&&i++<6?(e.consume(g),a):g===null||Pn(g)?(e.exit("atxHeadingSequence"),c(g)):r(g)}function c(g){return g===35?(e.enter("atxHeadingSequence"),d(g)):g===null||Ot(g)?(e.exit("atxHeading"),n(g)):tn(g)?fn(e,c,"whitespace")(g):(e.enter("atxHeadingText"),h(g))}function d(g){return g===35?(e.consume(g),d):(e.exit("atxHeadingSequence"),c(g))}function h(g){return g===null||g===35||Pn(g)?(e.exit("atxHeadingText"),c(g)):(e.consume(g),h)}}const aY=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],wj=["pre","script","style","textarea"],lY={concrete:!0,name:"htmlFlow",resolveTo:fY,tokenize:dY},cY={partial:!0,tokenize:pY},uY={partial:!0,tokenize:hY};function fY(e){let n=e.length;for(;n--&&!(e[n][0]==="enter"&&e[n][1].type==="htmlFlow"););return n>1&&e[n-2][1].type==="linePrefix"&&(e[n][1].start=e[n-2][1].start,e[n+1][1].start=e[n-2][1].start,e.splice(n-2,2)),e}function dY(e,n,r){const i=this;let s,o,a,c,d;return h;function h(L){return g(L)}function g(L){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(L),p}function p(L){return L===33?(e.consume(L),_):L===47?(e.consume(L),o=!0,C):L===63?(e.consume(L),s=3,i.interrupt?n:$):vi(L)?(e.consume(L),a=String.fromCharCode(L),j):r(L)}function _(L){return L===45?(e.consume(L),s=2,b):L===91?(e.consume(L),s=5,c=0,x):vi(L)?(e.consume(L),s=4,i.interrupt?n:$):r(L)}function b(L){return L===45?(e.consume(L),i.interrupt?n:$):r(L)}function x(L){const Q="CDATA[";return L===Q.charCodeAt(c++)?(e.consume(L),c===Q.length?i.interrupt?n:F:x):r(L)}function C(L){return vi(L)?(e.consume(L),a=String.fromCharCode(L),j):r(L)}function j(L){if(L===null||L===47||L===62||Pn(L)){const Q=L===47,X=a.toLowerCase();return!Q&&!o&&wj.includes(X)?(s=1,i.interrupt?n(L):F(L)):aY.includes(a.toLowerCase())?(s=6,Q?(e.consume(L),S):i.interrupt?n(L):F(L)):(s=7,i.interrupt&&!i.parser.lazy[i.now().line]?r(L):o?E(L):O(L))}return L===45||ii(L)?(e.consume(L),a+=String.fromCharCode(L),j):r(L)}function S(L){return L===62?(e.consume(L),i.interrupt?n:F):r(L)}function E(L){return tn(L)?(e.consume(L),E):I(L)}function O(L){return L===47?(e.consume(L),I):L===58||L===95||vi(L)?(e.consume(L),N):tn(L)?(e.consume(L),O):I(L)}function N(L){return L===45||L===46||L===58||L===95||ii(L)?(e.consume(L),N):T(L)}function T(L){return L===61?(e.consume(L),P):tn(L)?(e.consume(L),T):O(L)}function P(L){return L===null||L===60||L===61||L===62||L===96?r(L):L===34||L===39?(e.consume(L),d=L,D):tn(L)?(e.consume(L),P):H(L)}function D(L){return L===d?(e.consume(L),d=null,J):L===null||Ot(L)?r(L):(e.consume(L),D)}function H(L){return L===null||L===34||L===39||L===47||L===60||L===61||L===62||L===96||Pn(L)?T(L):(e.consume(L),H)}function J(L){return L===47||L===62||tn(L)?O(L):r(L)}function I(L){return L===62?(e.consume(L),B):r(L)}function B(L){return L===null||Ot(L)?F(L):tn(L)?(e.consume(L),B):r(L)}function F(L){return L===45&&s===2?(e.consume(L),A):L===60&&s===1?(e.consume(L),U):L===62&&s===4?(e.consume(L),R):L===63&&s===3?(e.consume(L),$):L===93&&s===5?(e.consume(L),Y):Ot(L)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(cY,Z,W)(L)):L===null||Ot(L)?(e.exit("htmlFlowData"),W(L)):(e.consume(L),F)}function W(L){return e.check(uY,z,Z)(L)}function z(L){return e.enter("lineEnding"),e.consume(L),e.exit("lineEnding"),V}function V(L){return L===null||Ot(L)?W(L):(e.enter("htmlFlowData"),F(L))}function A(L){return L===45?(e.consume(L),$):F(L)}function U(L){return L===47?(e.consume(L),a="",K):F(L)}function K(L){if(L===62){const Q=a.toLowerCase();return wj.includes(Q)?(e.consume(L),R):F(L)}return vi(L)&&a.length<8?(e.consume(L),a+=String.fromCharCode(L),K):F(L)}function Y(L){return L===93?(e.consume(L),$):F(L)}function $(L){return L===62?(e.consume(L),R):L===45&&s===2?(e.consume(L),$):F(L)}function R(L){return L===null||Ot(L)?(e.exit("htmlFlowData"),Z(L)):(e.consume(L),R)}function Z(L){return e.exit("htmlFlow"),n(L)}}function hY(e,n,r){const i=this;return s;function s(a){return Ot(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):r(a)}function o(a){return i.parser.lazy[i.now().line]?r(a):n(a)}}function pY(e,n,r){return i;function i(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Eg,n,r)}}const mY={name:"htmlText",tokenize:gY};function gY(e,n,r){const i=this;let s,o,a;return c;function c($){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume($),d}function d($){return $===33?(e.consume($),h):$===47?(e.consume($),T):$===63?(e.consume($),O):vi($)?(e.consume($),H):r($)}function h($){return $===45?(e.consume($),g):$===91?(e.consume($),o=0,x):vi($)?(e.consume($),E):r($)}function g($){return $===45?(e.consume($),b):r($)}function p($){return $===null?r($):$===45?(e.consume($),_):Ot($)?(a=p,U($)):(e.consume($),p)}function _($){return $===45?(e.consume($),b):p($)}function b($){return $===62?A($):$===45?_($):p($)}function x($){const R="CDATA[";return $===R.charCodeAt(o++)?(e.consume($),o===R.length?C:x):r($)}function C($){return $===null?r($):$===93?(e.consume($),j):Ot($)?(a=C,U($)):(e.consume($),C)}function j($){return $===93?(e.consume($),S):C($)}function S($){return $===62?A($):$===93?(e.consume($),S):C($)}function E($){return $===null||$===62?A($):Ot($)?(a=E,U($)):(e.consume($),E)}function O($){return $===null?r($):$===63?(e.consume($),N):Ot($)?(a=O,U($)):(e.consume($),O)}function N($){return $===62?A($):O($)}function T($){return vi($)?(e.consume($),P):r($)}function P($){return $===45||ii($)?(e.consume($),P):D($)}function D($){return Ot($)?(a=D,U($)):tn($)?(e.consume($),D):A($)}function H($){return $===45||ii($)?(e.consume($),H):$===47||$===62||Pn($)?J($):r($)}function J($){return $===47?(e.consume($),A):$===58||$===95||vi($)?(e.consume($),I):Ot($)?(a=J,U($)):tn($)?(e.consume($),J):A($)}function I($){return $===45||$===46||$===58||$===95||ii($)?(e.consume($),I):B($)}function B($){return $===61?(e.consume($),F):Ot($)?(a=B,U($)):tn($)?(e.consume($),B):J($)}function F($){return $===null||$===60||$===61||$===62||$===96?r($):$===34||$===39?(e.consume($),s=$,W):Ot($)?(a=F,U($)):tn($)?(e.consume($),F):(e.consume($),z)}function W($){return $===s?(e.consume($),s=void 0,V):$===null?r($):Ot($)?(a=W,U($)):(e.consume($),W)}function z($){return $===null||$===34||$===39||$===60||$===61||$===96?r($):$===47||$===62||Pn($)?J($):(e.consume($),z)}function V($){return $===47||$===62||Pn($)?J($):r($)}function A($){return $===62?(e.consume($),e.exit("htmlTextData"),e.exit("htmlText"),n):r($)}function U($){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),K}function K($){return tn($)?fn(e,Y,"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):Y($)}function Y($){return e.enter("htmlTextData"),a($)}}const Y5={name:"labelEnd",resolveAll:bY,resolveTo:xY,tokenize:wY},yY={tokenize:SY},vY={tokenize:CY},_Y={tokenize:jY};function bY(e){let n=-1;const r=[];for(;++n<e.length;){const i=e[n][1];if(r.push(e[n]),i.type==="labelImage"||i.type==="labelLink"||i.type==="labelEnd"){const s=i.type==="labelImage"?4:2;i.type="data",n+=s}}return e.length!==r.length&&ms(e,0,e.length,r),e}function xY(e,n){let r=e.length,i=0,s,o,a,c;for(;r--;)if(s=e[r][1],o){if(s.type==="link"||s.type==="labelLink"&&s._inactive)break;e[r][0]==="enter"&&s.type==="labelLink"&&(s._inactive=!0)}else if(a){if(e[r][0]==="enter"&&(s.type==="labelImage"||s.type==="labelLink")&&!s._balanced&&(o=r,s.type!=="labelLink")){i=2;break}}else s.type==="labelEnd"&&(a=r);const d={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},h={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},g={type:"labelText",start:{...e[o+i+2][1].end},end:{...e[a-2][1].start}};return c=[["enter",d,n],["enter",h,n]],c=Ds(c,e.slice(o+1,o+i+3)),c=Ds(c,[["enter",g,n]]),c=Ds(c,Dv(n.parser.constructs.insideSpan.null,e.slice(o+i+4,a-3),n)),c=Ds(c,[["exit",g,n],e[a-2],e[a-1],["exit",h,n]]),c=Ds(c,e.slice(a+1)),c=Ds(c,[["exit",d,n]]),ms(e,o,e.length,c),e}function wY(e,n,r){const i=this;let s=i.events.length,o,a;for(;s--;)if((i.events[s][1].type==="labelImage"||i.events[s][1].type==="labelLink")&&!i.events[s][1]._balanced){o=i.events[s][1];break}return c;function c(_){return o?o._inactive?p(_):(a=i.parser.defined.includes(yo(i.sliceSerialize({start:o.end,end:i.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(_),e.exit("labelMarker"),e.exit("labelEnd"),d):r(_)}function d(_){return _===40?e.attempt(yY,g,a?g:p)(_):_===91?e.attempt(vY,g,a?h:p)(_):a?g(_):p(_)}function h(_){return e.attempt(_Y,g,p)(_)}function g(_){return n(_)}function p(_){return o._balanced=!0,r(_)}}function SY(e,n,r){return i;function i(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),s}function s(p){return Pn(p)?kp(e,o)(p):o(p)}function o(p){return p===41?g(p):KP(e,a,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function a(p){return Pn(p)?kp(e,d)(p):g(p)}function c(p){return r(p)}function d(p){return p===34||p===39||p===40?YP(e,h,r,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):g(p)}function h(p){return Pn(p)?kp(e,g)(p):g(p)}function g(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),n):r(p)}}function CY(e,n,r){const i=this;return s;function s(c){return GP.call(i,e,o,a,"reference","referenceMarker","referenceString")(c)}function o(c){return i.parser.defined.includes(yo(i.sliceSerialize(i.events[i.events.length-1][1]).slice(1,-1)))?n(c):r(c)}function a(c){return r(c)}}function jY(e,n,r){return i;function i(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),s}function s(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),n):r(o)}}const kY={name:"labelStartImage",resolveAll:Y5.resolveAll,tokenize:EY};function EY(e,n,r){const i=this;return s;function s(c){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(c),e.exit("labelImageMarker"),o}function o(c){return c===91?(e.enter("labelMarker"),e.consume(c),e.exit("labelMarker"),e.exit("labelImage"),a):r(c)}function a(c){return c===94&&"_hiddenFootnoteSupport"in i.parser.constructs?r(c):n(c)}}const OY={name:"labelStartLink",resolveAll:Y5.resolveAll,tokenize:NY};function NY(e,n,r){const i=this;return s;function s(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in i.parser.constructs?r(a):n(a)}}const hx={name:"lineEnding",tokenize:TY};function TY(e,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),fn(e,n,"linePrefix")}}const ey={name:"thematicBreak",tokenize:PY};function PY(e,n,r){let i=0,s;return o;function o(h){return e.enter("thematicBreak"),a(h)}function a(h){return s=h,c(h)}function c(h){return h===s?(e.enter("thematicBreakSequence"),d(h)):i>=3&&(h===null||Ot(h))?(e.exit("thematicBreak"),n(h)):r(h)}function d(h){return h===s?(e.consume(h),i++,d):(e.exit("thematicBreakSequence"),tn(h)?fn(e,c,"whitespace")(h):c(h))}}const Li={continuation:{tokenize:DY},exit:LY,name:"list",tokenize:RY},AY={partial:!0,tokenize:$Y},MY={partial:!0,tokenize:zY};function RY(e,n,r){const i=this,s=i.events[i.events.length-1];let o=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return c;function c(b){const x=i.containerState.type||(b===42||b===43||b===45?"listUnordered":"listOrdered");if(x==="listUnordered"?!i.containerState.marker||b===i.containerState.marker:kw(b)){if(i.containerState.type||(i.containerState.type=x,e.enter(x,{_container:!0})),x==="listUnordered")return e.enter("listItemPrefix"),b===42||b===45?e.check(ey,r,h)(b):h(b);if(!i.interrupt||b===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(b)}return r(b)}function d(b){return kw(b)&&++a<10?(e.consume(b),d):(!i.interrupt||a<2)&&(i.containerState.marker?b===i.containerState.marker:b===41||b===46)?(e.exit("listItemValue"),h(b)):r(b)}function h(b){return e.enter("listItemMarker"),e.consume(b),e.exit("listItemMarker"),i.containerState.marker=i.containerState.marker||b,e.check(Eg,i.interrupt?r:g,e.attempt(AY,_,p))}function g(b){return i.containerState.initialBlankLine=!0,o++,_(b)}function p(b){return tn(b)?(e.enter("listItemPrefixWhitespace"),e.consume(b),e.exit("listItemPrefixWhitespace"),_):r(b)}function _(b){return i.containerState.size=o+i.sliceSerialize(e.exit("listItemPrefix"),!0).length,n(b)}}function DY(e,n,r){const i=this;return i.containerState._closeFlow=void 0,e.check(Eg,s,o);function s(c){return i.containerState.furtherBlankLines=i.containerState.furtherBlankLines||i.containerState.initialBlankLine,fn(e,n,"listItemIndent",i.containerState.size+1)(c)}function o(c){return i.containerState.furtherBlankLines||!tn(c)?(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,a(c)):(i.containerState.furtherBlankLines=void 0,i.containerState.initialBlankLine=void 0,e.attempt(MY,n,a)(c))}function a(c){return i.containerState._closeFlow=!0,i.interrupt=void 0,fn(e,e.attempt(Li,n,r),"linePrefix",i.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function zY(e,n,r){const i=this;return fn(e,s,"listItemIndent",i.containerState.size+1);function s(o){const a=i.events[i.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===i.containerState.size?n(o):r(o)}}function LY(e){e.exit(this.containerState.type)}function $Y(e,n,r){const i=this;return fn(e,s,"listItemPrefixWhitespace",i.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(o){const a=i.events[i.events.length-1];return!tn(o)&&a&&a[1].type==="listItemPrefixWhitespace"?n(o):r(o)}}const Sj={name:"setextUnderline",resolveTo:IY,tokenize:BY};function IY(e,n){let r=e.length,i,s,o;for(;r--;)if(e[r][0]==="enter"){if(e[r][1].type==="content"){i=r;break}e[r][1].type==="paragraph"&&(s=r)}else e[r][1].type==="content"&&e.splice(r,1),!o&&e[r][1].type==="definition"&&(o=r);const a={type:"setextHeading",start:{...e[i][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",o?(e.splice(s,0,["enter",a,n]),e.splice(o+1,0,["exit",e[i][1],n]),e[i][1].end={...e[o][1].end}):e[i][1]=a,e.push(["exit",a,n]),e}function BY(e,n,r){const i=this;let s;return o;function o(h){let g=i.events.length,p;for(;g--;)if(i.events[g][1].type!=="lineEnding"&&i.events[g][1].type!=="linePrefix"&&i.events[g][1].type!=="content"){p=i.events[g][1].type==="paragraph";break}return!i.parser.lazy[i.now().line]&&(i.interrupt||p)?(e.enter("setextHeadingLine"),s=h,a(h)):r(h)}function a(h){return e.enter("setextHeadingLineSequence"),c(h)}function c(h){return h===s?(e.consume(h),c):(e.exit("setextHeadingLineSequence"),tn(h)?fn(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||Ot(h)?(e.exit("setextHeadingLine"),n(h)):r(h)}}const FY={tokenize:HY};function HY(e){const n=this,r=e.attempt(Eg,i,e.attempt(this.parser.constructs.flowInitial,s,fn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(KG,s)),"linePrefix")));return r;function i(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),n.currentConstruct=void 0,r}function s(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n.currentConstruct=void 0,r}}const UY={resolveAll:JP()},VY=XP("string"),WY=XP("text");function XP(e){return{resolveAll:JP(e==="text"?qY:void 0),tokenize:n};function n(r){const i=this,s=this.parser.constructs[e],o=r.attempt(s,a,c);return a;function a(g){return h(g)?o(g):c(g)}function c(g){if(g===null){r.consume(g);return}return r.enter("data"),r.consume(g),d}function d(g){return h(g)?(r.exit("data"),o(g)):(r.consume(g),d)}function h(g){if(g===null)return!0;const p=s[g];let _=-1;if(p)for(;++_<p.length;){const b=p[_];if(!b.previous||b.previous.call(i,i.previous))return!0}return!1}}}function JP(e){return n;function n(r,i){let s=-1,o;for(;++s<=r.length;)o===void 0?r[s]&&r[s][1].type==="data"&&(o=s,s++):(!r[s]||r[s][1].type!=="data")&&(s!==o+2&&(r[o][1].end=r[s-1][1].end,r.splice(o+2,s-o-2),s=o+2),o=void 0);return e?e(r,i):r}}function qY(e,n){let r=0;for(;++r<=e.length;)if((r===e.length||e[r][1].type==="lineEnding")&&e[r-1][1].type==="data"){const i=e[r-1][1],s=n.sliceStream(i);let o=s.length,a=-1,c=0,d;for(;o--;){const h=s[o];if(typeof h=="string"){for(a=h.length;h.charCodeAt(a-1)===32;)c++,a--;if(a)break;a=-1}else if(h===-2)d=!0,c++;else if(h!==-1){o++;break}}if(n._contentTypeTextTrailing&&r===e.length&&(c=0),c){const h={type:r===e.length||d||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:i.start._bufferIndex+a,_index:i.start._index+o,line:i.end.line,column:i.end.column-c,offset:i.end.offset-c},end:{...i.end}};i.end={...h.start},i.start.offset===i.end.offset?Object.assign(i,h):(e.splice(r,0,["enter",h,n],["exit",h,n]),r+=2)}r++}return e}const KY={42:Li,43:Li,45:Li,48:Li,49:Li,50:Li,51:Li,52:Li,53:Li,54:Li,55:Li,56:Li,57:Li,62:UP},GY={91:ZG},YY={[-2]:dx,[-1]:dx,32:dx},XY={35:iY,42:ey,45:[Sj,ey],60:lY,61:Sj,95:ey,96:xj,126:xj},JY={38:WP,92:VP},ZY={[-5]:hx,[-4]:hx,[-3]:hx,33:kY,38:WP,42:Ew,60:[OG,mY],91:OY,92:[nY,VP],93:Y5,95:Ew,96:FG},QY={null:[Ew,UY]},eX={null:[42,95]},tX={null:[]},nX=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:eX,contentInitial:GY,disable:tX,document:KY,flow:XY,flowInitial:YY,insideSpan:QY,string:JY,text:ZY},Symbol.toStringTag,{value:"Module"}));function rX(e,n,r){let i={_bufferIndex:-1,_index:0,line:r&&r.line||1,column:r&&r.column||1,offset:r&&r.offset||0};const s={},o=[];let a=[],c=[];const d={attempt:D(T),check:D(P),consume:E,enter:O,exit:N,interrupt:D(P,{interrupt:!0})},h={code:null,containerState:{},defineSkip:C,events:[],now:x,parser:e,previous:null,sliceSerialize:_,sliceStream:b,write:p};let g=n.tokenize.call(h,d);return n.resolveAll&&o.push(n),h;function p(B){return a=Ds(a,B),j(),a[a.length-1]!==null?[]:(H(n,0),h.events=Dv(o,h.events,h),h.events)}function _(B,F){return sX(b(B),F)}function b(B){return iX(a,B)}function x(){const{_bufferIndex:B,_index:F,line:W,column:z,offset:V}=i;return{_bufferIndex:B,_index:F,line:W,column:z,offset:V}}function C(B){s[B.line]=B.column,I()}function j(){let B;for(;i._index<a.length;){const F=a[i._index];if(typeof F=="string")for(B=i._index,i._bufferIndex<0&&(i._bufferIndex=0);i._index===B&&i._bufferIndex<F.length;)S(F.charCodeAt(i._bufferIndex));else S(F)}}function S(B){g=g(B)}function E(B){Ot(B)?(i.line++,i.column=1,i.offset+=B===-3?2:1,I()):B!==-1&&(i.column++,i.offset++),i._bufferIndex<0?i._index++:(i._bufferIndex++,i._bufferIndex===a[i._index].length&&(i._bufferIndex=-1,i._index++)),h.previous=B}function O(B,F){const W=F||{};return W.type=B,W.start=x(),h.events.push(["enter",W,h]),c.push(W),W}function N(B){const F=c.pop();return F.end=x(),h.events.push(["exit",F,h]),F}function T(B,F){H(B,F.from)}function P(B,F){F.restore()}function D(B,F){return W;function W(z,V,A){let U,K,Y,$;return Array.isArray(z)?Z(z):"tokenize"in z?Z([z]):R(z);function R(ie){return se;function se(ce){const be=ce!==null&&ie[ce],ze=ce!==null&&ie.null,fe=[...Array.isArray(be)?be:be?[be]:[],...Array.isArray(ze)?ze:ze?[ze]:[]];return Z(fe)(ce)}}function Z(ie){return U=ie,K=0,ie.length===0?A:L(ie[K])}function L(ie){return se;function se(ce){return $=J(),Y=ie,ie.partial||(h.currentConstruct=ie),ie.name&&h.parser.constructs.disable.null.includes(ie.name)?X():ie.tokenize.call(F?Object.assign(Object.create(h),F):h,d,Q,X)(ce)}}function Q(ie){return B(Y,$),V}function X(ie){return $.restore(),++K<U.length?L(U[K]):A}}}function H(B,F){B.resolveAll&&!o.includes(B)&&o.push(B),B.resolve&&ms(h.events,F,h.events.length-F,B.resolve(h.events.slice(F),h)),B.resolveTo&&(h.events=B.resolveTo(h.events,h))}function J(){const B=x(),F=h.previous,W=h.currentConstruct,z=h.events.length,V=Array.from(c);return{from:z,restore:A};function A(){i=B,h.previous=F,h.currentConstruct=W,h.events.length=z,c=V,I()}}function I(){i.line in s&&i.column<2&&(i.column=s[i.line],i.offset+=s[i.line]-1)}}function iX(e,n){const r=n.start._index,i=n.start._bufferIndex,s=n.end._index,o=n.end._bufferIndex;let a;if(r===s)a=[e[r].slice(i,o)];else{if(a=e.slice(r,s),i>-1){const c=a[0];typeof c=="string"?a[0]=c.slice(i):a.shift()}o>0&&a.push(e[s].slice(0,o))}return a}function sX(e,n){let r=-1;const i=[];let s;for(;++r<e.length;){const o=e[r];let a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
|
|
@@ -674,7 +674,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${n.do
|
|
|
674
674
|
`),r=(h=n.find(p=>p.startsWith("URL: ")))==null?void 0:h.replace("URL: ","").trim(),i=(g=n.find(p=>p.startsWith("Title: ")))==null?void 0:g.replace("Title: ","").trim(),s=n.findIndex(p=>p.trim()==="Interactive elements:"),o=s>=0?n.slice(0,s):n,a=o.findIndex(p=>p.trim()==="Text:"),c=a>=0?o.slice(a+1).join(`
|
|
675
675
|
`).trim():"",d=s>=0?n.slice(s+1).map(p=>p.trim()).filter(Boolean):[];return f.jsxs("div",{className:"space-y-2 rounded-md border bg-muted/20 p-3 text-xs",children:[f.jsxs("div",{children:[f.jsx("div",{className:"font-semibold text-foreground/90",children:"Browser snapshot"}),i?f.jsx("div",{className:"text-muted-foreground",children:i}):null,r?f.jsx("div",{className:"font-mono text-[11px] break-all",children:r}):null]}),f.jsxs("div",{children:[f.jsx("div",{className:"mb-1 text-[11px] uppercase tracking-wide text-muted-foreground",children:"Text"}),f.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded bg-background p-2 font-mono text-[11px] leading-5",children:c||"(no textual content)"})]}),f.jsxs("div",{children:[f.jsx("div",{className:"mb-1 text-[11px] uppercase tracking-wide text-muted-foreground",children:"Interactive elements"}),d.length?f.jsx("ul",{className:"max-h-40 space-y-1 overflow-auto rounded bg-background p-2 font-mono text-[11px]",children:d.map((p,_)=>f.jsx("li",{className:"break-all",children:p},`${p}-${_}`))}):f.jsx("div",{className:"rounded bg-background p-2 text-muted-foreground",children:"No interactive elements found."})]})]})}function hne({path:e}){const[n,r]=y.useState(null),[i,s]=y.useState(!1),o=e.trim(),a=(/^https?:\/\//.test(o),o);return f.jsxs("div",{className:"space-y-2 rounded-md border bg-muted/20 p-3 text-xs",children:[f.jsxs("div",{className:"text-[11px] text-muted-foreground",children:["Screenshot path: ",f.jsx("span",{className:"font-mono break-all",children:o})]}),f.jsx("div",{className:"overflow-hidden rounded border bg-background",children:f.jsx("img",{src:a,alt:"Browser screenshot",className:"max-h-80 w-full cursor-crosshair object-contain",onLoad:()=>s(!0),onError:()=>s(!1),onClick:c=>{const d=c.currentTarget.getBoundingClientRect(),h=c.clientX-d.left,g=c.clientY-d.top;r({x:Math.round(h),y:Math.round(g),xp:Math.round(h/d.width*100),yp:Math.round(g/d.height*100)})}})}),!i&&f.jsx("div",{className:"rounded bg-background p-2 text-muted-foreground",children:"Preview unavailable in browser. Open the screenshot path directly from the host environment."}),n?f.jsxs("div",{className:"rounded bg-background p-2 font-mono text-[11px]",children:["click: x=",n.x,"px y=",n.y,"px (",n.xp,"%, ",n.yp,"%)"]}):null]})}function ty(e){var i;const n=typeof e.args.terminalId=="string"?e.args.terminalId:null;if(n)return n;const r=(i=e.result)==null?void 0:i.data;if(r&&typeof r=="object"){const s=r,o=typeof s.terminalId=="string"?s.terminalId:null;if(o)return o;const a=typeof s.id=="string"?s.id:null;if(a)return a;const c=typeof s.surfaceId=="string"?s.surfaceId:null;if(c)return c}return null}function pne(e){var r;const n=So(e.tool);if(n==="surfaces.start"){if(e.args.type==="terminal")return ty(e)!==null;const i=(r=e.result)==null?void 0:r.data;return i&&typeof i=="object"&&i.type==="terminal"?ty(e)!==null:!1}return n==="execute"||n.startsWith("terminal.")?ty(e)!==null:!1}function gM(e){if(!e)return null;const n=e.match(/"command"\s*:\s*"((?:[^"\\]|\\.)*)/);return n?n[1].replace(/\\n/g,`
|
|
676
676
|
`).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):null}function Ih(e,n){if(!e)return null;const r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=new RegExp(`"${r}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)`),s=e.match(i);return s?s[1].replace(/\\n/g,`
|
|
677
|
-
`).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):null}function mne({tool:e,streamingArgs:n}){const r=So(e),i=pM[r],s=r.startsWith("terminal."),o=s?gM(n):null;return i&&s&&o?f.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center gap-1.5 text-foreground",children:[f.jsx("span",{className:"shrink-0 text-xs text-emerald-500 dark:text-emerald-400 font-mono",children:"$"}),f.jsx("code",{className:"min-w-0 truncate text-xs font-mono",children:o}),f.jsx("span",{className:"inline-block w-1 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):i?f.jsxs("span",{className:"text-blue-400",children:[i.label,f.jsx("span",{className:"inline-block w-1 h-3 bg-blue-400 animate-pulse ml-1 align-text-bottom"})]}):e?f.jsxs("span",{className:"text-blue-400",children:[f.jsx("code",{className:"text-xs font-mono",children:e}),f.jsx("span",{className:"inline-block w-1 h-3 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):f.jsx("span",{className:"text-muted-foreground",children:"Preparing..."})}function gne({tool:e,streamingArgs:n,scrollRef:r}){const i=So(e),s=i.startsWith("terminal."),o=s?gM(n):null;if(s&&o)return f.jsxs("pre",{ref:r,className:We("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground"),children:[f.jsx("span",{className:"text-emerald-400",children:"$ "}),o,f.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]});if(i==="memory.save"){const a=Ih(n,"scope")??"memory",c=Ih(n,"content");return f.jsxs("div",{className:We("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(kt,{className:"h-3 w-3 animate-spin text-blue-400"}),f.jsxs("span",{children:["Saving memory (",a,")..."]})]}),c?f.jsxs("div",{className:"mt-1 opacity-80",children:['"',Zl(c,120),'"']}):null]})}if(i==="cron.add"){const a=Ih(n,"name"),c=Ih(n,"cron"),d=Ih(n,"toolName");return f.jsxs("div",{className:We("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(kt,{className:"h-3 w-3 animate-spin text-blue-400"}),f.jsxs("span",{children:["Creating cron job",a?`: ${a}`:"..."]})]}),(c||d)&&f.jsxs("div",{className:"mt-1 opacity-80",children:[c?`schedule ${c}`:"",c&&d?" • ":"",d?`tool ${d}`:""]})]})}return n?f.jsxs("pre",{ref:r,className:We("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-36 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-muted-foreground"),children:[n,f.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):f.jsx("div",{className:We("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(kt,{className:"h-3 w-3 animate-spin text-blue-400"}),f.jsx("span",{children:"Preparing..."})]})})}function yne({path:e,onOpenDiff:n,disabled:r}){const i=mM(e),s=!!n&&!r,o=f.jsxs(f.Fragment,{children:[f.jsx(hs,{filename:i,className:"h-3.5 w-3.5 shrink-0"}),f.jsx("span",{className:"max-w-[220px] truncate",children:i})]});return s?f.jsx("button",{type:"button",className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-[12px] font-medium leading-none text-foreground transition-colors hover:bg-muted",title:`Open diff for ${e}`,onClick:a=>{a.preventDefault(),a.stopPropagation(),n(e)},children:o}):f.jsx("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-[12px] font-medium leading-none text-foreground",title:e,children:o})}function vne({call:e,onOpenTerminal:n,onOpenDiff:r}){var Y;const[i,s]=y.useState(e.status==="running"||e.status==="pending"),[o,a]=y.useState(()=>Date.now()),c=y.useRef(e.status),d=So(e.tool),h=(Y=e.result)!=null&&Y.data&&typeof e.result.data=="object"?e.result.data:void 0,g=ec(d,e.args,h),p=ene(d),_=p.icon,b=nne(d,g),x=$w(d,g),j=lne(e.result,d)||e.streamingOutput||"",S=typeof(h==null?void 0:h.snapshot)=="string"?h.snapshot:null,E=d==="browser.screenshot"&&(h!=null&&h.result)&&typeof h.result=="object"?String(h.result.path??""):null,O=d.startsWith("terminal.")||d==="execute",N=fne(e),T=pne(e),P=T?ty(e):null,D=cne(d,g),H=e.status==="pending",J=typeof g.path=="string"?g.path.trim():"",I=!!J&&tne(d),B=g7(j),F=g7(e.streamingArgs),W=Qte({tool:d,args:g,status:e.status,displayOutput:j,snapshotText:S,screenshotPath:E}),z=W==="terminal"?!!j||e.status==="running":W!=="none",V=e.status==="pending"||e.status==="running"?kt:e.status==="success"?Fs:uu,A=e.status==="pending"?"text-blue-400":e.status==="running"?"text-muted-foreground":e.status==="success"?"text-green-500":"text-red-500";y.useEffect(()=>{const $=c.current;($==="running"||$==="pending")&&e.status!=="running"&&e.status!=="pending"&&s(!1),(e.status==="pending"||e.status==="running")&&s(!0),c.current=e.status},[e.status]),y.useEffect(()=>{if(e.status!=="running"&&e.status!=="pending")return;const $=window.setInterval(()=>a(Date.now()),250);return()=>window.clearInterval($)},[e.status]);const U=f.jsxs(f.Fragment,{children:[f.jsx(V,{className:We("h-4 w-4 shrink-0",A,(e.status==="running"||e.status==="pending")&&"animate-spin")}),f.jsx(_,{className:We("h-4 w-4 shrink-0",p.color)}),f.jsx("span",{className:"text-sm font-medium text-muted-foreground truncate flex-1",children:H?f.jsx(mne,{tool:e.tool,streamingArgs:e.streamingArgs}):O?f.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center gap-1.5 text-foreground",children:[f.jsx("span",{className:"shrink-0 text-xs text-emerald-500 dark:text-emerald-400 font-mono",children:"$"}),f.jsx("code",{className:"min-w-0 truncate text-xs font-mono",title:b,children:b})]}):I?f.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2",children:[f.jsxs("span",{children:[p.label,":"]}),f.jsx(yne,{path:J,onOpenDiff:r,disabled:e.status!=="success"})]}):f.jsxs("span",{children:[p.label,": ",f.jsx("code",{className:"text-xs font-mono",children:b})]})}),f.jsx("span",{className:"text-[11px] text-muted-foreground/60 tabular-nums shrink-0",children:f.jsx(y7,{startedAt:e.startedAt,completedAt:e.completedAt,now:o})}),x&&f.jsx("span",{className:"rounded border border-blue-500/25 bg-blue-500/10 px-1.5 py-0.5 text-[10px] font-semibold tabular-nums text-blue-500 shrink-0",children:x}),N&&f.jsx("span",{className:We("rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide shrink-0",N.className),children:N.label})]}),K=W==="pending"?f.jsx(gne,{tool:e.tool,streamingArgs:e.streamingArgs,scrollRef:F}):W==="terminal"?f.jsxs("pre",{ref:B,className:We("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground",e.result&&!e.result.ok&&"text-red-500 dark:text-red-400"),children:[j,e.status==="running"&&!j&&f.jsx("span",{className:"text-muted-foreground",children:"Running..."}),e.status==="running"&&f.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-foreground animate-pulse ml-0.5 align-text-bottom"})]}):W==="browserSnapshot"?f.jsx(dne,{snapshot:S}):W==="browserScreenshot"?f.jsx(hne,{path:E}):W==="editDiff"?f.jsx(Jte,{filePath:String(g.path??""),oldText:d==="file.patch"||d==="edit"&&g.search!=null?String(g.search??""):void 0,newText:d==="file.patch"||d==="edit"&&g.replace!=null?String(g.replace??""):void 0,writtenContent:d==="file.write"||d==="edit"&&g.content!=null?String(g.content??""):void 0,isNewFile:d==="file.write"}):W==="output"?f.jsxs("pre",{className:We("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground",e.result&&!e.result.ok&&"text-red-500 dark:text-red-400"),children:[j,e.status==="running"&&f.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-foreground animate-pulse ml-0.5 align-text-bottom"})]}):W==="runningHint"?f.jsxs("div",{className:We("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(kt,{className:"h-3 w-3 animate-spin"}),f.jsx("span",{children:D})]}),f.jsxs("div",{className:"mt-1 text-[11px] opacity-75",children:["Elapsed: ",f.jsx(y7,{startedAt:e.startedAt,completedAt:e.completedAt,now:o})]})]}):null;return f.jsxs(fM,{open:z?i:!1,onOpenChange:s,children:[f.jsxs("div",{className:"group flex items-center gap-2 rounded-md px-3 py-2 hover:bg-muted/50 transition-colors",children:[z?f.jsxs(dM,{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[f.jsx(xo,{className:We("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200",i&&"rotate-90")}),U]}):f.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[f.jsx("span",{className:"h-3.5 w-3.5 shrink-0"}),U]}),T&&n&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsx($e,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:$=>{$.preventDefault(),$.stopPropagation(),n(P)},children:f.jsx(dw,{className:"h-3.5 w-3.5"})})}),f.jsx(ir,{side:"top",children:"Open terminal"})]}),W==="editDiff"&&r&&e.status==="success"&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsx($e,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:$=>{$.preventDefault(),$.stopPropagation(),r(String(g.path??""))},children:f.jsx(dw,{className:"h-3.5 w-3.5"})})}),f.jsx(ir,{side:"top",children:"Open diff in editor"})]})]}),z&&f.jsx(hM,{children:f.jsx("div",{className:"ml-[3.25rem] mr-3 mb-2",children:K})})]})}const ny=y.memo(vne);ny.displayName="ToolCallCard";const Ax=6;function _ne({calls:e,onOpenTerminal:n,onOpenDiff:r}){const[i,s]=y.useState(!1);if(e.length===0)return null;const o=e.filter(_=>_.status==="running"||_.status==="pending"),a=e.filter(_=>_.status!=="running"&&_.status!=="pending"),c=!i&&a.length>Ax,d=c?a.length-Ax:0,h=c?a.slice(-Ax):a,g=c?a.slice(0,d).filter(_=>_.status==="success").length:0,p=d-g;return f.jsxs("div",{className:"rounded-lg border bg-card my-2 divide-y",children:[c&&f.jsxs("button",{type:"button",onClick:()=>s(!0),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/50 transition-colors",children:[f.jsx(xo,{className:"h-3 w-3"}),f.jsxs("span",{children:[d," earlier tool call",d!==1?"s":"",g>0&&f.jsxs("span",{className:"text-green-500 ml-1",children:["(",g," passed)"]}),p>0&&f.jsxs("span",{className:"text-red-500 ml-1",children:["(",p," failed)"]})]})]}),i&&a.slice(0,d).map(_=>f.jsx(ny,{call:_,onOpenTerminal:n,onOpenDiff:r},_.callId)),h.map(_=>f.jsx(ny,{call:_,onOpenTerminal:n,onOpenDiff:r},_.callId)),o.map(_=>f.jsx(ny,{call:_,onOpenTerminal:n,onOpenDiff:r},_.callId))]})}function bne(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==n[r])return!1;return!0}const Iw=y.memo(_ne,(e,n)=>e.onOpenTerminal===n.onOpenTerminal&&e.onOpenDiff===n.onOpenDiff&&bne(e.calls,n.calls));Iw.displayName="ToolCallGroup";const Bw=/^[A-Za-z]:[\\/]/,xne=/^\//;function v7(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function wne(e){return Bw.test(e)||xne.test(e)}function Sne(e,n){const r=e.replace(/\\/g,"/");if(!r||r==="/")return!1;if(/^L\d+(?:C\d+)?$/i.test(n))return!0;const i=r.split("/").pop()??"";return/\.[A-Za-z0-9]+$/.test(i)}function Cne(e){if(!e)return null;const n=e.trim();if(!n)return null;let r=n,i="";try{const c=new URL(n);if(c.protocol==="http:"||c.protocol==="https:"){if(r=c.pathname,i=c.hash.startsWith("#")?c.hash.slice(1):c.hash,!Sne(r,i))return null}else{const d=n.indexOf("#");d>=0&&(r=n.slice(0,d),i=n.slice(d+1))}}catch{const c=n.indexOf("#");c>=0&&(r=n.slice(0,c),i=n.slice(c+1))}const s=decodeURIComponent(r);if(!wne(s))return null;const o={path:s},a=i.match(/^L(\d+)(?:C(\d+))?$/i);return a&&(o.line=Number.parseInt(a[1],10),a[2]&&(o.column=Number.parseInt(a[2],10))),o}function jne(e,n){if(!n)return!1;const r=v7(e),i=v7(n);if(!r||!i)return!1;const s=Bw.test(r)?r.toLowerCase():r,o=Bw.test(i)?i.toLowerCase():i;return s===o||s.startsWith(`${o}/`)}function kne(e){const n=e.replace(/\\/g,"/"),r=n.lastIndexOf("/");return r<=0?null:n.slice(0,r)}function Ene(e){const n=`
|
|
677
|
+
`).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):null}function mne({tool:e,streamingArgs:n}){const r=So(e),i=pM[r],s=r.startsWith("terminal."),o=s?gM(n):null;return i&&s&&o?f.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center gap-1.5 text-foreground",children:[f.jsx("span",{className:"shrink-0 text-xs text-emerald-500 dark:text-emerald-400 font-mono",children:"$"}),f.jsx("code",{className:"min-w-0 truncate text-xs font-mono",children:o}),f.jsx("span",{className:"inline-block w-1 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):i?f.jsxs("span",{className:"text-blue-400",children:[i.label,f.jsx("span",{className:"inline-block w-1 h-3 bg-blue-400 animate-pulse ml-1 align-text-bottom"})]}):e?f.jsxs("span",{className:"text-blue-400",children:[f.jsx("code",{className:"text-xs font-mono",children:e}),f.jsx("span",{className:"inline-block w-1 h-3 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):f.jsx("span",{className:"text-muted-foreground",children:"Preparing..."})}function gne({tool:e,streamingArgs:n,scrollRef:r}){const i=So(e),s=i.startsWith("terminal."),o=s?gM(n):null;if(s&&o)return f.jsxs("pre",{ref:r,className:We("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground"),children:[f.jsx("span",{className:"text-emerald-400",children:"$ "}),o,f.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]});if(i==="memory.save"){const a=Ih(n,"scope")??"memory",c=Ih(n,"content");return f.jsxs("div",{className:We("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(kt,{className:"h-3 w-3 animate-spin text-blue-400"}),f.jsxs("span",{children:["Saving memory (",a,")..."]})]}),c?f.jsxs("div",{className:"mt-1 opacity-80",children:['"',Zl(c,120),'"']}):null]})}if(i==="cron.add"){const a=Ih(n,"name"),c=Ih(n,"cron"),d=Ih(n,"toolName");return f.jsxs("div",{className:We("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(kt,{className:"h-3 w-3 animate-spin text-blue-400"}),f.jsxs("span",{children:["Creating cron job",a?`: ${a}`:"..."]})]}),(c||d)&&f.jsxs("div",{className:"mt-1 opacity-80",children:[c?`schedule ${c}`:"",c&&d?" • ":"",d?`tool ${d}`:""]})]})}return n?f.jsxs("pre",{ref:r,className:We("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-36 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-muted-foreground"),children:[n,f.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):f.jsx("div",{className:We("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(kt,{className:"h-3 w-3 animate-spin text-blue-400"}),f.jsx("span",{children:"Preparing..."})]})})}function yne({path:e,onOpenDiff:n,disabled:r}){const i=mM(e),s=!!n&&!r,o=f.jsxs(f.Fragment,{children:[f.jsx(hs,{filename:i,className:"h-3.5 w-3.5 shrink-0"}),f.jsx("span",{className:"max-w-[220px] truncate",children:i})]});return s?f.jsx("button",{type:"button",className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-[12px] font-medium leading-none text-foreground transition-colors hover:bg-muted",title:`Open diff for ${e}`,onClick:a=>{a.preventDefault(),a.stopPropagation(),n(e)},children:o}):f.jsx("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-[12px] font-medium leading-none text-foreground",title:e,children:o})}function vne({call:e,onOpenTerminal:n,onOpenDiff:r}){var Y;const[i,s]=y.useState(e.status==="running"||e.status==="pending"),[o,a]=y.useState(()=>Date.now()),c=y.useRef(e.status),d=So(e.tool),h=(Y=e.result)!=null&&Y.data&&typeof e.result.data=="object"?e.result.data:void 0,g=ec(d,e.args,h),p=ene(d),_=p.icon,b=nne(d,g),x=$w(d,g),j=lne(e.result,d)||e.streamingOutput||"",S=typeof(h==null?void 0:h.snapshot)=="string"?h.snapshot:null,E=d==="browser.screenshot"&&(h!=null&&h.result)&&typeof h.result=="object"?String(h.result.path??""):null,O=d.startsWith("terminal.")||d==="execute",N=fne(e),T=pne(e),P=T?ty(e):null,D=cne(d,g),H=e.status==="pending",J=typeof g.path=="string"?g.path.trim():"",I=!!J&&tne(d),B=g7(j),F=g7(e.streamingArgs),W=Qte({tool:d,args:g,status:e.status,displayOutput:j,snapshotText:S,screenshotPath:E}),z=W==="terminal"?!0:W!=="none",V=e.status==="pending"||e.status==="running"?kt:e.status==="success"?Fs:uu,A=e.status==="pending"?"text-blue-400":e.status==="running"?"text-muted-foreground":e.status==="success"?"text-green-500":"text-red-500";y.useEffect(()=>{const $=c.current;($==="running"||$==="pending")&&e.status!=="running"&&e.status!=="pending"&&s(!1),(e.status==="pending"||e.status==="running")&&s(!0),c.current=e.status},[e.status]),y.useEffect(()=>{if(e.status!=="running"&&e.status!=="pending")return;const $=window.setInterval(()=>a(Date.now()),250);return()=>window.clearInterval($)},[e.status]);const U=f.jsxs(f.Fragment,{children:[f.jsx(V,{className:We("h-4 w-4 shrink-0",A,(e.status==="running"||e.status==="pending")&&"animate-spin")}),f.jsx(_,{className:We("h-4 w-4 shrink-0",p.color)}),f.jsx("span",{className:"text-sm font-medium text-muted-foreground truncate flex-1",children:H?f.jsx(mne,{tool:e.tool,streamingArgs:e.streamingArgs}):O?f.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center gap-1.5 text-foreground",children:[f.jsx("span",{className:"shrink-0 text-xs text-emerald-500 dark:text-emerald-400 font-mono",children:"$"}),f.jsx("code",{className:"min-w-0 truncate text-xs font-mono",title:b,children:b})]}):I?f.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2",children:[f.jsxs("span",{children:[p.label,":"]}),f.jsx(yne,{path:J,onOpenDiff:r,disabled:e.status!=="success"})]}):f.jsxs("span",{children:[p.label,": ",f.jsx("code",{className:"text-xs font-mono",children:b})]})}),f.jsx("span",{className:"text-[11px] text-muted-foreground/60 tabular-nums shrink-0",children:f.jsx(y7,{startedAt:e.startedAt,completedAt:e.completedAt,now:o})}),x&&f.jsx("span",{className:"rounded border border-blue-500/25 bg-blue-500/10 px-1.5 py-0.5 text-[10px] font-semibold tabular-nums text-blue-500 shrink-0",children:x}),N&&f.jsx("span",{className:We("rounded border px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide shrink-0",N.className),children:N.label})]}),K=W==="pending"?f.jsx(gne,{tool:e.tool,streamingArgs:e.streamingArgs,scrollRef:F}):W==="terminal"?f.jsxs("pre",{ref:B,className:We("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground",e.result&&!e.result.ok&&"text-red-500 dark:text-red-400"),children:[!j&&e.status!=="running"&&f.jsxs("span",{className:"text-muted-foreground",children:[f.jsx("span",{className:"text-emerald-500 dark:text-emerald-400",children:"$ "}),b]}),j,e.status==="running"&&!j&&f.jsx("span",{className:"text-muted-foreground",children:"Running..."}),e.status==="running"&&f.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-foreground animate-pulse ml-0.5 align-text-bottom"})]}):W==="browserSnapshot"?f.jsx(dne,{snapshot:S}):W==="browserScreenshot"?f.jsx(hne,{path:E}):W==="editDiff"?f.jsx(Jte,{filePath:String(g.path??""),oldText:d==="file.patch"||d==="edit"&&g.search!=null?String(g.search??""):void 0,newText:d==="file.patch"||d==="edit"&&g.replace!=null?String(g.replace??""):void 0,writtenContent:d==="file.write"||d==="edit"&&g.content!=null?String(g.content??""):void 0,isNewFile:d==="file.write"}):W==="output"?f.jsxs("pre",{className:We("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground",e.result&&!e.result.ok&&"text-red-500 dark:text-red-400"),children:[j,e.status==="running"&&f.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-foreground animate-pulse ml-0.5 align-text-bottom"})]}):W==="runningHint"?f.jsxs("div",{className:We("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(kt,{className:"h-3 w-3 animate-spin"}),f.jsx("span",{children:D})]}),f.jsxs("div",{className:"mt-1 text-[11px] opacity-75",children:["Elapsed: ",f.jsx(y7,{startedAt:e.startedAt,completedAt:e.completedAt,now:o})]})]}):null;return f.jsxs(fM,{open:z?i:!1,onOpenChange:s,children:[f.jsxs("div",{className:"group flex items-center gap-2 rounded-md px-3 py-2 hover:bg-muted/50 transition-colors",children:[z?f.jsxs(dM,{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[f.jsx(xo,{className:We("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200",i&&"rotate-90")}),U]}):f.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[f.jsx("span",{className:"h-3.5 w-3.5 shrink-0"}),U]}),T&&n&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsx($e,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:$=>{$.preventDefault(),$.stopPropagation(),n(P)},children:f.jsx(dw,{className:"h-3.5 w-3.5"})})}),f.jsx(ir,{side:"top",children:"Open terminal"})]}),W==="editDiff"&&r&&e.status==="success"&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsx($e,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:$=>{$.preventDefault(),$.stopPropagation(),r(String(g.path??""))},children:f.jsx(dw,{className:"h-3.5 w-3.5"})})}),f.jsx(ir,{side:"top",children:"Open diff in editor"})]})]}),z&&f.jsx(hM,{children:f.jsx("div",{className:"ml-[3.25rem] mr-3 mb-2",children:K})})]})}const ny=y.memo(vne);ny.displayName="ToolCallCard";const Ax=6;function _ne({calls:e,onOpenTerminal:n,onOpenDiff:r}){const[i,s]=y.useState(!1);if(e.length===0)return null;const o=e.filter(_=>_.status==="running"||_.status==="pending"),a=e.filter(_=>_.status!=="running"&&_.status!=="pending"),c=!i&&a.length>Ax,d=c?a.length-Ax:0,h=c?a.slice(-Ax):a,g=c?a.slice(0,d).filter(_=>_.status==="success").length:0,p=d-g;return f.jsxs("div",{className:"rounded-lg border bg-card my-2 divide-y",children:[c&&f.jsxs("button",{type:"button",onClick:()=>s(!0),className:"flex w-full items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/50 transition-colors",children:[f.jsx(xo,{className:"h-3 w-3"}),f.jsxs("span",{children:[d," earlier tool call",d!==1?"s":"",g>0&&f.jsxs("span",{className:"text-green-500 ml-1",children:["(",g," passed)"]}),p>0&&f.jsxs("span",{className:"text-red-500 ml-1",children:["(",p," failed)"]})]})]}),i&&a.slice(0,d).map(_=>f.jsx(ny,{call:_,onOpenTerminal:n,onOpenDiff:r},_.callId)),h.map(_=>f.jsx(ny,{call:_,onOpenTerminal:n,onOpenDiff:r},_.callId)),o.map(_=>f.jsx(ny,{call:_,onOpenTerminal:n,onOpenDiff:r},_.callId))]})}function bne(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==n[r])return!1;return!0}const Iw=y.memo(_ne,(e,n)=>e.onOpenTerminal===n.onOpenTerminal&&e.onOpenDiff===n.onOpenDiff&&bne(e.calls,n.calls));Iw.displayName="ToolCallGroup";const Bw=/^[A-Za-z]:[\\/]/,xne=/^\//;function v7(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function wne(e){return Bw.test(e)||xne.test(e)}function Sne(e,n){const r=e.replace(/\\/g,"/");if(!r||r==="/")return!1;if(/^L\d+(?:C\d+)?$/i.test(n))return!0;const i=r.split("/").pop()??"";return/\.[A-Za-z0-9]+$/.test(i)}function Cne(e){if(!e)return null;const n=e.trim();if(!n)return null;let r=n,i="";try{const c=new URL(n);if(c.protocol==="http:"||c.protocol==="https:"){if(r=c.pathname,i=c.hash.startsWith("#")?c.hash.slice(1):c.hash,!Sne(r,i))return null}else{const d=n.indexOf("#");d>=0&&(r=n.slice(0,d),i=n.slice(d+1))}}catch{const c=n.indexOf("#");c>=0&&(r=n.slice(0,c),i=n.slice(c+1))}const s=decodeURIComponent(r);if(!wne(s))return null;const o={path:s},a=i.match(/^L(\d+)(?:C(\d+))?$/i);return a&&(o.line=Number.parseInt(a[1],10),a[2]&&(o.column=Number.parseInt(a[2],10))),o}function jne(e,n){if(!n)return!1;const r=v7(e),i=v7(n);if(!r||!i)return!1;const s=Bw.test(r)?r.toLowerCase():r,o=Bw.test(i)?i.toLowerCase():i;return s===o||s.startsWith(`${o}/`)}function kne(e){const n=e.replace(/\\/g,"/"),r=n.lastIndexOf("/");return r<=0?null:n.slice(0,r)}function Ene(e){const n=`
|
|
678
678
|
Referenced files:
|
|
679
679
|
`,r=e.indexOf(n);if(r===-1)return{text:e,files:[]};const i=e.slice(0,r).trimEnd(),s=e.slice(r+n.length),o=[];for(const a of s.split(`
|
|
680
680
|
`)){const c=a.match(/^- (.+)$/);if(c){const d=c[1].trim();o.push({path:d,name:d.split("/").pop()??d})}}return{text:i,files:o}}const _7=320,b7="min-w-[min(20rem,calc(100vw-5rem))]";function yM(e){return e?"prose dark:prose-invert max-w-none break-words [overflow-wrap:anywhere] prose-pre:bg-muted prose-pre:border prose-pre:max-w-full prose-pre:overflow-x-auto prose-code:before:content-none prose-code:after:content-none prose-sm prose-p:leading-normal":"prose dark:prose-invert max-w-none break-words [overflow-wrap:anywhere] prose-pre:bg-muted prose-pre:border prose-pre:max-w-full prose-pre:overflow-x-auto prose-code:before:content-none prose-code:after:content-none prose-base prose-p:leading-relaxed"}function One(e){const n=e.replace(/\\/g,"/"),r=n.split("/");return r[r.length-1]??n}function Nne({href:e,target:n,onOpenPath:r}){const i=One(n.path),s=n.line?`L${n.line}${n.column?`:${n.column}`:""}`:null;return f.jsxs("a",{href:e,className:We("not-prose inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 align-middle text-[12px] font-medium leading-none text-foreground no-underline transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),title:n.path,onClick:o=>{o.preventDefault(),r(n.path,n.line,n.column)},children:[f.jsx(hs,{filename:i,className:"h-3.5 w-3.5 shrink-0"}),f.jsx("span",{className:"max-w-[220px] truncate",children:i}),s?f.jsx("span",{className:"shrink-0 rounded bg-background/80 px-1 py-0.5 text-[10px] text-muted-foreground",children:s}):null]})}function vM(e){if(e)return{a:({href:n,ref:r,...i})=>{const s=Cne(n);return s?f.jsx(Nne,{href:n,target:s,onOpenPath:e}):f.jsx("a",{href:n,...i,children:i.children})}}}function Tne({content:e,compact:n,onOpenPath:r}){const i=y.useMemo(()=>vM(r),[r]);return f.jsx("div",{className:yM(n),children:f.jsx(iM,{remarkPlugins:[sM],components:i,children:e})})}function Pne({content:e,compact:n,onOpenPath:r}){const i=y.useMemo(()=>vM(r),[r]),s=({blockMatch:a})=>f.jsx(iM,{remarkPlugins:[sM],components:i,children:a.output}),{blockMatches:o}=wQ({llmOutput:e,blocks:[],fallbackBlock:{component:s,lookBack:fQ()},isStreamFinished:!1});return f.jsx("div",{className:yM(n),children:o.map((a,c)=>{const d=a.block.component;return f.jsx(d,{blockMatch:a},c)})})}const Fw=y.memo(function({content:n,compact:r,isStreaming:i,preferLlmUi:s,onOpenPath:o}){return s&&i?f.jsx(Pne,{content:n,compact:r,onOpenPath:o}):f.jsx(Tne,{content:n,compact:r,onOpenPath:o})});Fw.displayName="AssistantMarkdown";function Ane({messageId:e,messageIndex:n,messageFromEnd:r,role:i,content:s,displayContent:o,referencedFiles:a,thinking:c,thinkingDuration:d,toolCalls:h,segments:g,isStreaming:p,compact:_,preferLlmUi:b,onOpenTerminal:x,onEditMessage:C,onOpenPath:j,onOpenDiff:S}){const E=i==="user",{userDisplayText:O,userFiles:N}=y.useMemo(()=>{if(!E)return{userDisplayText:s,userFiles:[]};if(o)return{userDisplayText:o,userFiles:a??[]};const ce=Ene(s);return{userDisplayText:ce.text,userFiles:ce.files}},[E,s,o,a]),[T,P]=y.useState(!1),[D,H]=y.useState(!1),[J,I]=y.useState(O),[B,F]=y.useState(!1),[W,z]=y.useState(!1),[V,A]=y.useState(null),U=y.useRef(null),K=y.useRef(null);y.useEffect(()=>()=>{U.current!==null&&window.clearTimeout(U.current)},[]),y.useEffect(()=>{D||I(O)},[O,D]);const Y=()=>{var be;const ce=[];if(h&&h.length>0)for(const ze of h){const fe=ze.tool.replace(/_/g,"."),Ce=Object.entries(ze.args).filter(([,tt])=>tt!=null&&tt!=="").map(([tt,Ue])=>`${tt}: ${typeof Ue=="string"?Ue:JSON.stringify(Ue)}`).join(", "),me=ze.status==="success"?"✓":ze.status==="error"?"✗":"…",Ye=ze.completedAt&&ze.startedAt?`${((ze.completedAt-ze.startedAt)/1e3).toFixed(1)}s`:"";if(ce.push(`[${me} ${fe}] ${Ce}`),(be=ze.result)!=null&&be.message){const tt=ze.result.message.length>500?ze.result.message.slice(0,500)+"…":ze.result.message;ce.push(tt)}Ye&&ce.push(`Duration: ${Ye}`),ce.push("")}return s&&ce.push(s),ce.join(`
|
|
@@ -752,9 +752,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
752
752
|
}
|
|
753
753
|
`;Lxe($xe);function _3(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,i=Array(n);r<n;r++)i[r]=e[r];return i}function Ixe(e){if(Array.isArray(e))return e}function Bxe(e){if(Array.isArray(e))return _3(e)}function pE(e,n,r){if(Dz())return Reflect.construct.apply(null,arguments);var i=[null];i.push.apply(i,n);var s=new(e.bind.apply(e,i));return s}function dg(e,n,r){return(n=qxe(n))in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}function Dz(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Dz=function(){return!!e})()}function Fxe(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Hxe(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var i,s,o,a,c=[],d=!0,h=!1;try{if(o=(r=r.call(e)).next,n!==0)for(;!(d=(i=o.call(r)).done)&&(c.push(i.value),c.length!==n);d=!0);}catch(g){h=!0,s=g}finally{try{if(!d&&r.return!=null&&(a=r.return(),Object(a)!==a))return}finally{if(h)throw s}}return c}}function Uxe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
754
754
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vxe(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
755
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mE(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,i)}return r}function zf(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?mE(Object(r),!0).forEach(function(i){dg(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mE(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Dp(e,n){return Ixe(e)||Hxe(e,n)||zz(e,n)||Uxe()}function Ls(e){return Bxe(e)||Fxe(e)||zz(e)||Vxe()}function Wxe(e,n){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function qxe(e){var n=Wxe(e,"string");return typeof n=="symbol"?n:n+""}function b3(e){"@babel/helpers - typeof";return b3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},b3(e)}function zz(e,n){if(e){if(typeof e=="string")return _3(e,n);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_3(e,n):void 0}}var Kxe=Rz(zxe);function gE(e,n,r){!n||typeof r!="string"||e.filter(function(i){return!i[r]}).forEach(function(i){i[r]=Kxe(n(i))})}function Gxe(e,n){var r=e.nodes,i=e.links,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=s.nodeFilter,a=o===void 0?function(){return!0}:o,c=s.onLoopError,d=c===void 0?function(b){throw"Invalid DAG structure! Found cycle in node path: ".concat(b.join(" -> "),".")}:c,h={};r.forEach(function(b){return h[n(b)]={data:b,out:[],depth:-1,skip:!a(b)}}),i.forEach(function(b){var x=b.source,C=b.target,j=N(x),S=N(C);if(!h.hasOwnProperty(j))throw"Missing source node with id: ".concat(j);if(!h.hasOwnProperty(S))throw"Missing target node with id: ".concat(S);var E=h[j],O=h[S];E.out.push(O);function N(T){return b3(T)==="object"?n(T):T}});var g=[];_(Object.values(h));var p=Object.assign.apply(Object,[{}].concat(Ls(Object.entries(h).filter(function(b){var x=Dp(b,2),C=x[1];return!C.skip}).map(function(b){var x=Dp(b,2),C=x[0],j=x[1];return dg({},C,j.depth)}))));return p;function _(b){for(var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],C=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,j=function(){var N=b[S];if(x.indexOf(N)!==-1){var T=[].concat(Ls(x.slice(x.indexOf(N))),[N]).map(function(P){return n(P.data)});return g.some(function(P){return P.length===T.length&&P.every(function(D,H){return D===T[H]})})||(g.push(T),d(T)),1}C>N.depth&&(N.depth=C,_(N.out,[].concat(Ls(x),[N]),C+(N.skip?0:1)))},S=0,E=b.length;S<E;S++)j()}}var Yxe=2,ni=function(n,r){return r.onNeedsRedraw&&r.onNeedsRedraw()},yE=function(n,r){if(!r.isShadow){var i=vn(r.linkDirectionalParticles);r.graphData.links.forEach(function(s){var o=Math.round(Math.abs(i(s)));o?s.__photons=Ls(Array(o)).map(function(){return{}}):delete s.__photons})}},rv=XS({props:{graphData:{default:{nodes:[],links:[]},onChange:function(n,r){r.engineRunning=!1,yE(n,r)}},dagMode:{onChange:function(n,r){!n&&(r.graphData.nodes||[]).forEach(function(i){return i.fx=i.fy=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(n){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4,triggerUpdate:!1,onChange:ni},nodeId:{default:"id"},nodeVal:{default:"val",triggerUpdate:!1,onChange:ni},nodeColor:{default:"color",triggerUpdate:!1,onChange:ni},nodeAutoColorBy:{},nodeCanvasObject:{triggerUpdate:!1,onChange:ni},nodeCanvasObjectMode:{default:function(){return"replace"},triggerUpdate:!1,onChange:ni},nodeVisibility:{default:!0,triggerUpdate:!1,onChange:ni},linkSource:{default:"source"},linkTarget:{default:"target"},linkVisibility:{default:!0,triggerUpdate:!1,onChange:ni},linkColor:{default:"color",triggerUpdate:!1,onChange:ni},linkAutoColorBy:{},linkLineDash:{triggerUpdate:!1,onChange:ni},linkWidth:{default:1,triggerUpdate:!1,onChange:ni},linkCurvature:{default:0,triggerUpdate:!1,onChange:ni},linkCanvasObject:{triggerUpdate:!1,onChange:ni},linkCanvasObjectMode:{default:function(){return"replace"},triggerUpdate:!1,onChange:ni},linkDirectionalArrowLength:{default:0,triggerUpdate:!1,onChange:ni},linkDirectionalArrowColor:{triggerUpdate:!1,onChange:ni},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1,onChange:ni},linkDirectionalParticles:{default:0,triggerUpdate:!1,onChange:yE},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:4,triggerUpdate:!1},linkDirectionalParticleColor:{triggerUpdate:!1},linkDirectionalParticleCanvasObject:{triggerUpdate:!1},globalScale:{default:1,triggerUpdate:!1},d3AlphaMin:{default:0,triggerUpdate:!1},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(n,r){r.forceLayout.alphaDecay(n)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(n,r){r.forceLayout.alphaTarget(n)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(n,r){r.forceLayout.velocityDecay(n)}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1},onNeedsRedraw:{triggerUpdate:!1},isShadow:{default:!1,triggerUpdate:!1}},methods:{d3Force:function(n,r,i){return i===void 0?n.forceLayout.force(r):(n.forceLayout.force(r,i),this)},d3ReheatSimulation:function(n){return n.forceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(n){return n.cntTicks=0,n.startTickTime=new Date,n.engineRunning=!0,this},isEngineRunning:function(n){return!!n.engineRunning},tickFrame:function(n){return!n.isShadow&&r(),s(),!n.isShadow&&o(),!n.isShadow&&a(),i(),this;function r(){n.engineRunning&&(++n.cntTicks>n.cooldownTicks||new Date-n.startTickTime>n.cooldownTime||n.d3AlphaMin>0&&n.forceLayout.alpha()<n.d3AlphaMin?(n.engineRunning=!1,n.onEngineStop()):(n.forceLayout.tick(),n.onEngineTick()))}function i(){var c=vn(n.nodeVisibility),d=vn(n.nodeVal),h=vn(n.nodeColor),g=vn(n.nodeCanvasObjectMode),p=n.ctx,_=n.isShadow/n.globalScale,b=n.graphData.nodes.filter(c);p.save(),b.forEach(function(x){var C=g(x);if(n.nodeCanvasObject&&(C==="before"||C==="replace")&&(n.nodeCanvasObject(x,p,n.globalScale),C==="replace")){p.restore();return}var j=Math.sqrt(Math.max(0,d(x)||1))*n.nodeRelSize+_;p.beginPath(),p.arc(x.x,x.y,j,0,2*Math.PI,!1),p.fillStyle=h(x)||"rgba(31, 120, 180, 0.92)",p.fill(),n.nodeCanvasObject&&C==="after"&&n.nodeCanvasObject(x,n.ctx,n.globalScale)}),p.restore()}function s(){var c=vn(n.linkVisibility),d=vn(n.linkColor),h=vn(n.linkWidth),g=vn(n.linkLineDash),p=vn(n.linkCurvature),_=vn(n.linkCanvasObjectMode),b=n.ctx,x=n.isShadow*2,C=n.graphData.links.filter(c);C.forEach(P);var j=[],S=[],E=C;if(n.linkCanvasObject){var O=[],N=[];C.forEach(function(D){return({before:j,after:S,replace:O}[_(D)]||N).push(D)}),E=[].concat(Ls(j),S,N),j=j.concat(O)}b.save(),j.forEach(function(D){return n.linkCanvasObject(D,b,n.globalScale)}),b.restore();var T=Mxe(E,[d,h,g]);b.save(),Object.entries(T).forEach(function(D){var H=Dp(D,2),J=H[0],I=H[1],B=!J||J==="undefined"?"rgba(0,0,0,0.15)":J;Object.entries(I).forEach(function(F){var W=Dp(F,2),z=W[0],V=W[1],A=(z||1)/n.globalScale+x;Object.entries(V).forEach(function(U){var K=Dp(U,2);K[0];var Y=K[1],$=g(Y[0]);b.beginPath(),Y.forEach(function(R){var Z=R.source,L=R.target;if(!(!Z||!L||!Z.hasOwnProperty("x")||!L.hasOwnProperty("x"))){b.moveTo(Z.x,Z.y);var Q=R.__controlPoints;Q?b[Q.length===2?"quadraticCurveTo":"bezierCurveTo"].apply(b,Ls(Q).concat([L.x,L.y])):b.lineTo(L.x,L.y)}}),b.strokeStyle=B,b.lineWidth=A,b.setLineDash($||[]),b.stroke()})})}),b.restore(),b.save(),S.forEach(function(D){return n.linkCanvasObject(D,b,n.globalScale)}),b.restore();function P(D){var H=p(D);if(!H){D.__controlPoints=null;return}var J=D.source,I=D.target;if(!(!J||!I||!J.hasOwnProperty("x")||!I.hasOwnProperty("x"))){var B=Math.sqrt(Math.pow(I.x-J.x,2)+Math.pow(I.y-J.y,2));if(B>0){var F=Math.atan2(I.y-J.y,I.x-J.x),W=B*H,z={x:(J.x+I.x)/2+W*Math.cos(F-Math.PI/2),y:(J.y+I.y)/2+W*Math.sin(F-Math.PI/2)};D.__controlPoints=[z.x,z.y]}else{var V=H*70;D.__controlPoints=[I.x,I.y-V,I.x+V,I.y]}}}}function o(){var c=1.6,d=.2,h=vn(n.linkDirectionalArrowLength),g=vn(n.linkDirectionalArrowRelPos),p=vn(n.linkVisibility),_=vn(n.linkDirectionalArrowColor||n.linkColor),b=vn(n.nodeVal),x=n.ctx;x.save(),n.graphData.links.filter(p).forEach(function(C){var j=h(C);if(!(!j||j<0)){var S=C.source,E=C.target;if(!(!S||!E||!S.hasOwnProperty("x")||!E.hasOwnProperty("x"))){var O=Math.sqrt(Math.max(0,b(S)||1))*n.nodeRelSize,N=Math.sqrt(Math.max(0,b(E)||1))*n.nodeRelSize,T=Math.min(1,Math.max(0,g(C))),P=_(C)||"rgba(0,0,0,0.28)",D=j/c/2,H=C.__controlPoints&&pE(Ln,[S.x,S.y].concat(Ls(C.__controlPoints),[E.x,E.y])),J=H?function(A){return H.get(A)}:function(A){return{x:S.x+(E.x-S.x)*A||0,y:S.y+(E.y-S.y)*A||0}},I=H?H.length():Math.sqrt(Math.pow(E.x-S.x,2)+Math.pow(E.y-S.y,2)),B=O+j+(I-O-N-j)*T,F=J(B/I),W=J((B-j)/I),z=J((B-j*(1-d))/I),V=Math.atan2(F.y-W.y,F.x-W.x)-Math.PI/2;x.beginPath(),x.moveTo(F.x,F.y),x.lineTo(W.x+D*Math.cos(V),W.y+D*Math.sin(V)),x.lineTo(z.x,z.y),x.lineTo(W.x-D*Math.cos(V),W.y-D*Math.sin(V)),x.fillStyle=P,x.fill()}}}),x.restore()}function a(){var c=vn(n.linkDirectionalParticles),d=vn(n.linkDirectionalParticleSpeed),h=vn(n.linkDirectionalParticleOffset),g=vn(n.linkDirectionalParticleWidth),p=vn(n.linkVisibility),_=vn(n.linkDirectionalParticleColor||n.linkColor),b=n.ctx;b.save(),n.graphData.links.filter(p).forEach(function(x){var C=c(x);if(!(!x.hasOwnProperty("__photons")||!x.__photons.length)){var j=x.source,S=x.target;if(!(!j||!S||!j.hasOwnProperty("x")||!S.hasOwnProperty("x"))){var E=d(x),O=Math.abs(h(x)),N=x.__photons||[],T=Math.max(0,g(x)/2)/Math.sqrt(n.globalScale),P=_(x)||"rgba(0,0,0,0.28)";b.fillStyle=P;var D=x.__controlPoints?pE(Ln,[j.x,j.y].concat(Ls(x.__controlPoints),[S.x,S.y])):null,H=0,J=!1;N.forEach(function(I){var B=!!I.__singleHop;if(I.hasOwnProperty("__progressRatio")||(I.__progressRatio=B?0:(H+O)/C),!B&&H++,I.__progressRatio+=E,I.__progressRatio>=1)if(!B)I.__progressRatio=I.__progressRatio%1;else{J=!0;return}var F=I.__progressRatio,W=D?D.get(F):{x:j.x+(S.x-j.x)*F||0,y:j.y+(S.y-j.y)*F||0};n.linkDirectionalParticleCanvasObject?n.linkDirectionalParticleCanvasObject(W.x,W.y,x,b,n.globalScale):(b.beginPath(),b.arc(W.x,W.y,T,0,2*Math.PI,!1),b.fill())}),J&&(x.__photons=x.__photons.filter(function(I){return!I.__singleHop||I.__progressRatio<=1}))}}}),b.restore()}},emitParticle:function(n,r){return r&&(!r.__photons&&(r.__photons=[]),r.__photons.push({__singleHop:!0})),this}},stateInit:function(){return{forceLayout:fxe().force("link",rxe()).force("charge",dxe()).force("center",sbe()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(n,r){r.ctx=n},update:function(n,r){n.engineRunning=!1,n.onUpdate(),n.nodeAutoColorBy!==null&&gE(n.graphData.nodes,vn(n.nodeAutoColorBy),n.nodeColor),n.linkAutoColorBy!==null&&gE(n.graphData.links,vn(n.linkAutoColorBy),n.linkColor),n.graphData.links.forEach(function(_){_.source=_[n.linkSource],_.target=_[n.linkTarget]}),n.forceLayout.stop().alpha(1).nodes(n.graphData.nodes);var i=n.forceLayout.force("link");i&&i.id(function(_){return _[n.nodeId]}).links(n.graphData.links);var s=n.dagMode&&Gxe(n.graphData,function(_){return _[n.nodeId]},{nodeFilter:n.dagNodeFilter,onLoopError:n.onDagError||void 0}),o=Math.max.apply(Math,Ls(Object.values(s||[]))),a=n.dagLevelDistance||n.graphData.nodes.length/(o||1)*Yxe*(["radialin","radialout"].indexOf(n.dagMode)!==-1?.7:1);if(["lr","rl","td","bu"].includes(r.dagMode)){var c=["lr","rl"].includes(r.dagMode)?"fx":"fy";n.graphData.nodes.filter(n.dagNodeFilter).forEach(function(_){return delete _[c]})}if(["lr","rl","td","bu"].includes(n.dagMode)){var d=["rl","bu"].includes(n.dagMode),h=function(b){return(s[b[n.nodeId]]-o/2)*a*(d?-1:1)},g=["lr","rl"].includes(n.dagMode)?"fx":"fy";n.graphData.nodes.filter(n.dagNodeFilter).forEach(function(_){return _[g]=h(_)})}n.forceLayout.force("dagRadial",["radialin","radialout"].indexOf(n.dagMode)!==-1?hxe(function(_){var b=s[_[n.nodeId]]||-1;return(n.dagMode==="radialin"?o-b:b)*a}).strength(function(_){return n.dagNodeFilter(_)?1:0}):null);for(var p=0;p<n.warmupTicks&&!(n.d3AlphaMin>0&&n.forceLayout.alpha()<n.d3AlphaMin);p++)n.forceLayout.tick();this.resetCountdown(),n.onFinishUpdate()}});function Lz(e,n){var r=e instanceof Array?e:[e],i=new n;return i._destructor&&i._destructor(),{linkProp:function(o){return{default:i[o](),onChange:function(c,d){r.forEach(function(h){return d[h][o](c)})},triggerUpdate:!1}},linkMethod:function(o){return function(a){for(var c=arguments.length,d=new Array(c>1?c-1:0),h=1;h<c;h++)d[h-1]=arguments[h];var g=[];return r.forEach(function(p){var _=a[p],b=_[o].apply(_,d);b!==_&&g.push(b)}),g.length?g[0]:this}}}}var Xxe=800,Jxe=4,Zxe=5,$z=Lz("forceGraph",rv),Qxe=Lz(["forceGraph","shadowGraph"],rv),e2e=Object.assign.apply(Object,Ls(["nodeColor","nodeAutoColorBy","nodeCanvasObject","nodeCanvasObjectMode","linkColor","linkAutoColorBy","linkLineDash","linkWidth","linkCanvasObject","linkCanvasObjectMode","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowRelPos","linkDirectionalParticles","linkDirectionalParticleSpeed","linkDirectionalParticleOffset","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleCanvasObject","dagMode","dagLevelDistance","dagNodeFilter","onDagError","d3AlphaMin","d3AlphaDecay","d3VelocityDecay","warmupTicks","cooldownTicks","cooldownTime","onEngineTick","onEngineStop"].map(function(e){return dg({},e,$z.linkProp(e))})).concat(Ls(["nodeRelSize","nodeId","nodeVal","nodeVisibility","linkSource","linkTarget","linkVisibility","linkCurvature"].map(function(e){return dg({},e,Qxe.linkProp(e))})))),t2e=Object.assign.apply(Object,Ls(["d3Force","d3ReheatSimulation","emitParticle"].map(function(e){return dg({},e,$z.linkMethod(e))})));function I2(e){if(e.canvas){var n=e.canvas.width,r=e.canvas.height;n===300&&r===150&&(n=r=0);var i=window.devicePixelRatio;n/=i,r/=i,[e.canvas,e.shadowCanvas].forEach(function(o){o.style.width="".concat(e.width,"px"),o.style.height="".concat(e.height,"px"),o.width=e.width*i,o.height=e.height*i,!n&&!r&&o.getContext("2d").scale(i,i)});var s=Bo(e.canvas).k;e.zoom.translateBy(e.zoom.__baseElem,(e.width-n)/2/s,(e.height-r)/2/s),e.needsRedraw=!0}}function Iz(e){var n=window.devicePixelRatio;e.setTransform(n,0,0,n,0,0)}function vE(e,n,r){e.save(),Iz(e),e.clearRect(0,0,n,r),e.restore()}var n2e=XS({props:zf({width:{default:window.innerWidth,onChange:function(n,r){return I2(r)},triggerUpdate:!1},height:{default:window.innerHeight,onChange:function(n,r){return I2(r)},triggerUpdate:!1},graphData:{default:{nodes:[],links:[]},onChange:function(n,r){[n.nodes,n.links].every(function(s){return(s||[]).every(function(o){return!o.hasOwnProperty("__indexColor")})})&&r.colorTracker.reset(),[{type:"Node",objs:n.nodes},{type:"Link",objs:n.links}].forEach(i),r.forceGraph.graphData(n),r.shadowGraph.graphData(n);function i(s){var o=s.type,a=s.objs;a.filter(function(c){if(!c.hasOwnProperty("__indexColor"))return!0;var d=r.colorTracker.lookup(c.__indexColor);return!d||!d.hasOwnProperty("d")||d.d!==c}).forEach(function(c){c.__indexColor=r.colorTracker.register({type:o,d:c})})}},triggerUpdate:!1},backgroundColor:{onChange:function(n,r){r.canvas&&n&&(r.canvas.style.background=n)},triggerUpdate:!1},nodeLabel:{default:"name",triggerUpdate:!1},nodePointerAreaPaint:{onChange:function(n,r){r.shadowGraph.nodeCanvasObject(n?function(i,s,o){return n(i,i.__indexColor,s,o)}:null),r.flushShadowCanvas&&r.flushShadowCanvas()},triggerUpdate:!1},linkPointerAreaPaint:{onChange:function(n,r){r.shadowGraph.linkCanvasObject(n?function(i,s,o){return n(i,i.__indexColor,s,o)}:null),r.flushShadowCanvas&&r.flushShadowCanvas()},triggerUpdate:!1},linkLabel:{default:"name",triggerUpdate:!1},linkHoverPrecision:{default:4,triggerUpdate:!1},minZoom:{default:.01,onChange:function(n,r){r.zoom.scaleExtent([n,r.zoom.scaleExtent()[1]])},triggerUpdate:!1},maxZoom:{default:1e3,onChange:function(n,r){r.zoom.scaleExtent([r.zoom.scaleExtent()[0],n])},triggerUpdate:!1},enableNodeDrag:{default:!0,triggerUpdate:!1},enableZoomInteraction:{default:!0,triggerUpdate:!1},enablePanInteraction:{default:!0,triggerUpdate:!1},enableZoomPanInteraction:{default:!0,triggerUpdate:!1},enablePointerInteraction:{default:!0,onChange:function(n,r){r.hoverObj=null},triggerUpdate:!1},autoPauseRedraw:{default:!0,triggerUpdate:!1},onNodeDrag:{default:function(){},triggerUpdate:!1},onNodeDragEnd:{default:function(){},triggerUpdate:!1},onNodeClick:{triggerUpdate:!1},onNodeRightClick:{triggerUpdate:!1},onNodeHover:{triggerUpdate:!1},onLinkClick:{triggerUpdate:!1},onLinkRightClick:{triggerUpdate:!1},onLinkHover:{triggerUpdate:!1},onBackgroundClick:{triggerUpdate:!1},onBackgroundRightClick:{triggerUpdate:!1},showPointerCursor:{default:!0,triggerUpdate:!1},onZoom:{triggerUpdate:!1},onZoomEnd:{triggerUpdate:!1},onRenderFramePre:{triggerUpdate:!1},onRenderFramePost:{triggerUpdate:!1}},e2e),aliases:{stopAnimation:"pauseAnimation"},methods:zf({graph2ScreenCoords:function(n,r,i){var s=Bo(n.canvas);return{x:r*s.k+s.x,y:i*s.k+s.y}},screen2GraphCoords:function(n,r,i){var s=Bo(n.canvas);return{x:(r-s.x)/s.k,y:(i-s.y)/s.k}},centerAt:function(n,r,i,s){if(!n.canvas)return null;if(r!==void 0||i!==void 0){var o=Object.assign({},r!==void 0?{x:r}:{},i!==void 0?{y:i}:{});return s?n.tweenGroup.add(new F9(a()).to(o,s).easing(lu.Quadratic.Out).onUpdate(c).onComplete(function(){n.tweenGroup.remove(this)}).start()):c(o),this}return a();function a(){var d=Bo(n.canvas);return{x:(n.width/2-d.x)/d.k,y:(n.height/2-d.y)/d.k}}function c(d){var h=d.x,g=d.y;n.zoom.translateTo(n.zoom.__baseElem,h===void 0?a().x:h,g===void 0?a().y:g),n.needsRedraw=!0}},zoom:function(n,r,i){if(!n.canvas)return null;if(r!==void 0)return i?n.tweenGroup.add(new F9({k:s()}).to({k:r},i).easing(lu.Quadratic.Out).onUpdate(function(a){var c=a.k;return o(c)}).onComplete(function(){n.tweenGroup.remove(this)}).start()):o(r),this;return s();function s(){return Bo(n.canvas).k}function o(a){n.zoom.scaleTo(n.zoom.__baseElem,a),n.needsRedraw=!0}},zoomToFit:function(n){for(var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,s=arguments.length,o=new Array(s>3?s-3:0),a=3;a<s;a++)o[a-3]=arguments[a];var c=this.getGraphBbox.apply(this,o);if(c){var d={x:(c.x[0]+c.x[1])/2,y:(c.y[0]+c.y[1])/2},h=Math.max(1e-12,Math.min(1e12,(n.width-i*2)/(c.x[1]-c.x[0]),(n.height-i*2)/(c.y[1]-c.y[0])));this.centerAt(d.x,d.y,r),this.zoom(h,r)}return this},getGraphBbox:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},i=vn(n.nodeVal),s=function(c){return Math.sqrt(Math.max(0,i(c)||1))*n.nodeRelSize},o=n.graphData.nodes.filter(r).map(function(a){return{x:a.x,y:a.y,r:s(a)}});return o.length?{x:[L9(o,function(a){return a.x-a.r}),z9(o,function(a){return a.x+a.r})],y:[L9(o,function(a){return a.y-a.r}),z9(o,function(a){return a.y+a.r})]}:null},pauseAnimation:function(n){return n.animationFrameRequestId&&(cancelAnimationFrame(n.animationFrameRequestId),n.animationFrameRequestId=null),this},resumeAnimation:function(n){return n.animationFrameRequestId||this._animationCycle(),this},_destructor:function(){this.pauseAnimation(),this.graphData({nodes:[],links:[]})}},t2e),stateInit:function(){return{lastSetZoom:1,zoom:dve(),forceGraph:new rv,shadowGraph:new rv().cooldownTicks(0).nodeColor("__indexColor").linkColor("__indexColor").isShadow(!0),colorTracker:new z_e,tweenGroup:new lz}},init:function(n,r){var i=this;n.innerHTML="";var s=document.createElement("div");s.classList.add("force-graph-container"),s.style.position="relative",n.appendChild(s),r.canvas=document.createElement("canvas"),r.backgroundColor&&(r.canvas.style.background=r.backgroundColor),s.appendChild(r.canvas),r.shadowCanvas=document.createElement("canvas");var o=r.canvas.getContext("2d"),a=r.shadowCanvas.getContext("2d",{willReadFrequently:!0}),c={x:-1e12,y:-1e12},d=function(){var p=null,_=window.devicePixelRatio,b=c.x>0&&c.y>0?a.getImageData(c.x*_,c.y*_,1,1):null;return b&&(p=r.colorTracker.lookup(b.data)),p};zs(r.canvas).call(w1e().subject(function(){if(!r.enableNodeDrag)return null;var g=d();return g&&g.type==="Node"?g.d:null}).on("start",function(g){var p=g.subject;p.__initialDragPos={x:p.x,y:p.y,fx:p.fx,fy:p.fy},g.active||(p.fx=p.x,p.fy=p.y),r.canvas.classList.add("grabbable")}).on("drag",function(g){var p=g.subject,_=p.__initialDragPos,b=g,x=Bo(r.canvas).k,C={x:_.x+(b.x-_.x)/x-p.x,y:_.y+(b.y-_.y)/x-p.y};["x","y"].forEach(function(j){return p["f".concat(j)]=p[j]=_[j]+(b[j]-_[j])/x}),!(!p.__dragged&&Zxe>=Math.sqrt(gve(["x","y"].map(function(j){return Math.pow(g[j]-_[j],2)}))))&&(r.forceGraph.d3AlphaTarget(.3).resetCountdown(),r.isPointerDragging=!0,p.__dragged=!0,r.onNodeDrag(p,C))}).on("end",function(g){var p=g.subject,_=p.__initialDragPos,b={x:p.x-_.x,y:p.y-_.y};_.fx===void 0&&(p.fx=void 0),_.fy===void 0&&(p.fy=void 0),delete p.__initialDragPos,r.forceGraph.d3AlphaTarget()&&r.forceGraph.d3AlphaTarget(0).resetCountdown(),r.canvas.classList.remove("grabbable"),r.isPointerDragging=!1,p.__dragged&&(delete p.__dragged,r.onNodeDragEnd(p,b))})),r.zoom(r.zoom.__baseElem=zs(r.canvas)),r.zoom.__baseElem.on("dblclick.zoom",null),r.zoom.filter(function(g){return!g.button&&r.enableZoomPanInteraction&&(g.type!=="wheel"||vn(r.enableZoomInteraction)(g))&&(g.type==="wheel"||vn(r.enablePanInteraction)(g))}).on("zoom",function(g){var p=g.transform;[o,a].forEach(function(_){Iz(_),_.translate(p.x,p.y),_.scale(p.k,p.k)}),r.isPointerDragging=!0,r.onZoom&&r.onZoom(zf(zf({},p),i.centerAt())),r.needsRedraw=!0}).on("end",function(g){r.isPointerDragging=!1,r.onZoomEnd&&r.onZoomEnd(zf(zf({},g.transform),i.centerAt()))}),I2(r),r.forceGraph.onNeedsRedraw(function(){return r.needsRedraw=!0}).onFinishUpdate(function(){Bo(r.canvas).k===r.lastSetZoom&&r.graphData.nodes.length&&(r.zoom.scaleTo(r.zoom.__baseElem,r.lastSetZoom=Jxe/Math.cbrt(r.graphData.nodes.length)),r.needsRedraw=!0)}),r.tooltip=new ibe(s),["pointermove","pointerdown"].forEach(function(g){return s.addEventListener(g,function(p){g==="pointerdown"&&(r.isPointerPressed=!0,r.pointerDownEvent=p),!r.isPointerDragging&&p.type==="pointermove"&&r.onBackgroundClick&&(p.pressure>0||r.isPointerPressed)&&(p.pointerType==="mouse"||p.movementX===void 0||[p.movementX,p.movementY].some(function(x){return Math.abs(x)>1}))&&(r.isPointerDragging=!0);var _=b(s);c.x=p.pageX-_.left,c.y=p.pageY-_.top;function b(x){var C=x.getBoundingClientRect(),j=window.pageXOffset||document.documentElement.scrollLeft,S=window.pageYOffset||document.documentElement.scrollTop;return{top:C.top+S,left:C.left+j}}},{passive:!0})}),s.addEventListener("pointerup",function(g){if(r.isPointerPressed){if(r.isPointerPressed=!1,r.isPointerDragging){r.isPointerDragging=!1;return}var p=[g,r.pointerDownEvent];requestAnimationFrame(function(){if(g.button===0)if(r.hoverObj){var _=r["on".concat(r.hoverObj.type,"Click")];_&&_.apply(void 0,[r.hoverObj.d].concat(p))}else r.onBackgroundClick&&r.onBackgroundClick.apply(r,p);if(g.button===2)if(r.hoverObj){var b=r["on".concat(r.hoverObj.type,"RightClick")];b&&b.apply(void 0,[r.hoverObj.d].concat(p))}else r.onBackgroundRightClick&&r.onBackgroundRightClick.apply(r,p)})}},{passive:!0}),s.addEventListener("contextmenu",function(g){return!r.onBackgroundRightClick&&!r.onNodeRightClick&&!r.onLinkRightClick?!0:(g.preventDefault(),!1)}),r.forceGraph(o),r.shadowGraph(a);var h=Uve(function(){vE(a,r.width,r.height),r.shadowGraph.linkWidth(function(p){return vn(r.linkWidth)(p)+r.linkHoverPrecision});var g=Bo(r.canvas);r.shadowGraph.globalScale(g.k).tickFrame()},Xxe);r.flushShadowCanvas=h.flush,(this._animationCycle=function g(){var p=!r.autoPauseRedraw||!!r.needsRedraw||r.forceGraph.isEngineRunning()||r.graphData.links.some(function(O){return O.__photons&&O.__photons.length});if(r.needsRedraw=!1,r.enablePointerInteraction){var _=r.isPointerDragging?null:d();if(_!==r.hoverObj){var b=r.hoverObj,x=b?b.type:null,C=_?_.type:null;if(x&&x!==C){var j=r["on".concat(x,"Hover")];j&&j(null,b.d)}if(C){var S=r["on".concat(C,"Hover")];S&&S(_.d,x===C?b.d:null)}r.tooltip.content(_&&vn(r["".concat(_.type.toLowerCase(),"Label")])(_.d)||null),r.canvas.classList[(_&&r["on".concat(C,"Click")]||!_&&r.onBackgroundClick)&&vn(r.showPointerCursor)(_==null?void 0:_.d)?"add":"remove"]("clickable"),r.hoverObj=_}p&&h()}if(p){vE(o,r.width,r.height);var E=Bo(r.canvas).k;r.onRenderFramePre&&r.onRenderFramePre(o,E),r.forceGraph.globalScale(E).tickFrame(),r.onRenderFramePost&&r.onRenderFramePost(o,E)}r.tweenGroup.update(),r.animationFrameRequestId=requestAnimationFrame(g)})()},update:function(n){}}),B2={exports:{}},F2,_E;function r2e(){if(_E)return F2;_E=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return F2=e,F2}var H2,bE;function i2e(){if(bE)return H2;bE=1;var e=r2e();function n(){}function r(){}return r.resetWarningCache=n,H2=function(){function i(a,c,d,h,g,p){if(p!==e){var _=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw _.name="Invariant Violation",_}}i.isRequired=i;function s(){return i}var o={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:r,resetWarningCache:n};return o.PropTypes=o,o},H2}var xE;function s2e(){return xE||(xE=1,B2.exports=i2e()()),B2.exports}var o2e=s2e();const le=cd(o2e),n_={width:le.number,height:le.number,graphData:le.shape({nodes:le.arrayOf(le.object).isRequired,links:le.arrayOf(le.object).isRequired}),backgroundColor:le.string,nodeRelSize:le.number,nodeId:le.string,nodeLabel:le.oneOfType([le.string,le.func]),nodeVal:le.oneOfType([le.number,le.string,le.func]),nodeVisibility:le.oneOfType([le.bool,le.string,le.func]),nodeColor:le.oneOfType([le.string,le.func]),nodeAutoColorBy:le.oneOfType([le.string,le.func]),onNodeHover:le.func,onNodeClick:le.func,linkSource:le.string,linkTarget:le.string,linkLabel:le.oneOfType([le.string,le.func]),linkVisibility:le.oneOfType([le.bool,le.string,le.func]),linkColor:le.oneOfType([le.string,le.func]),linkAutoColorBy:le.oneOfType([le.string,le.func]),linkWidth:le.oneOfType([le.number,le.string,le.func]),linkCurvature:le.oneOfType([le.number,le.string,le.func]),linkDirectionalArrowLength:le.oneOfType([le.number,le.string,le.func]),linkDirectionalArrowColor:le.oneOfType([le.string,le.func]),linkDirectionalArrowRelPos:le.oneOfType([le.number,le.string,le.func]),linkDirectionalParticles:le.oneOfType([le.number,le.string,le.func]),linkDirectionalParticleSpeed:le.oneOfType([le.number,le.string,le.func]),linkDirectionalParticleOffset:le.oneOfType([le.number,le.string,le.func]),linkDirectionalParticleWidth:le.oneOfType([le.number,le.string,le.func]),linkDirectionalParticleColor:le.oneOfType([le.string,le.func]),onLinkHover:le.func,onLinkClick:le.func,dagMode:le.oneOf(["td","bu","lr","rl","zin","zout","radialin","radialout"]),dagLevelDistance:le.number,dagNodeFilter:le.func,onDagError:le.func,d3AlphaMin:le.number,d3AlphaDecay:le.number,d3VelocityDecay:le.number,warmupTicks:le.number,cooldownTicks:le.number,cooldownTime:le.number,onEngineTick:le.func,onEngineStop:le.func,getGraphBbox:le.func},Bz={zoomToFit:le.func,onNodeRightClick:le.func,onNodeDrag:le.func,onNodeDragEnd:le.func,onLinkRightClick:le.func,linkHoverPrecision:le.number,onBackgroundClick:le.func,onBackgroundRightClick:le.func,showPointerCursor:le.oneOfType([le.bool,le.func]),enablePointerInteraction:le.bool,enableNodeDrag:le.bool},i4={showNavInfo:le.bool,nodeOpacity:le.number,nodeResolution:le.number,nodeThreeObject:le.oneOfType([le.object,le.string,le.func]),nodeThreeObjectExtend:le.oneOfType([le.bool,le.string,le.func]),nodePositionUpdate:le.func,linkOpacity:le.number,linkResolution:le.number,linkCurveRotation:le.oneOfType([le.number,le.string,le.func]),linkMaterial:le.oneOfType([le.object,le.string,le.func]),linkThreeObject:le.oneOfType([le.object,le.string,le.func]),linkThreeObjectExtend:le.oneOfType([le.bool,le.string,le.func]),linkPositionUpdate:le.func,linkDirectionalArrowResolution:le.number,linkDirectionalParticleResolution:le.number,linkDirectionalParticleThreeObject:le.oneOfType([le.object,le.string,le.func]),forceEngine:le.oneOf(["d3","ngraph"]),ngraphPhysics:le.object,numDimensions:le.oneOf([1,2,3])},a2e=Object.assign({},n_,Bz,{linkLineDash:le.oneOfType([le.arrayOf(le.number),le.string,le.func]),nodeCanvasObjectMode:le.oneOfType([le.string,le.func]),nodeCanvasObject:le.func,nodePointerAreaPaint:le.func,linkCanvasObjectMode:le.oneOfType([le.string,le.func]),linkCanvasObject:le.func,linkPointerAreaPaint:le.func,linkDirectionalParticleCanvasObject:le.func,autoPauseRedraw:le.bool,minZoom:le.number,maxZoom:le.number,enableZoomInteraction:le.oneOfType([le.bool,le.func]),enablePanInteraction:le.oneOfType([le.bool,le.func]),onZoom:le.func,onZoomEnd:le.func,onRenderFramePre:le.func,onRenderFramePost:le.func});Object.assign({},n_,Bz,i4,{enableNavigationControls:le.bool,controlType:le.oneOf(["trackball","orbit","fly"]),rendererConfig:le.object,extraRenderers:le.arrayOf(le.shape({render:le.func.isRequired}))});Object.assign({},n_,i4,{nodeDesc:le.oneOfType([le.string,le.func]),linkDesc:le.oneOfType([le.string,le.func])});Object.assign({},n_,i4,{markerAttrs:le.object,yOffset:le.number,glScale:le.number});const s4=Rge(n2e,{methodNames:["emitParticle","d3Force","d3ReheatSimulation","stopAnimation","pauseAnimation","resumeAnimation","centerAt","zoom","zoomToFit","getGraphBbox","screen2GraphCoords","graph2ScreenCoords"]});s4.displayName="ForceGraph2D";s4.propTypes=a2e;const l2e={path:"M18.4395 5.5586c-.675 1.1664-1.352 2.3318-2.0274 3.498-.0366-.0155-.0742-.0286-.1113-.043-1.8249-.6957-3.484-.8-4.42-.787-1.8551.0185-3.3544.4643-4.2597.8203-.084-.1494-1.7526-3.021-2.0215-3.4864a1.1451 1.1451 0 0 0-.1406-.1914c-.3312-.364-.9054-.4859-1.379-.203-.475.282-.7136.9361-.3886 1.5019 1.9466 3.3696-.0966-.2158 1.9473 3.3593.0172.031-.4946.2642-1.3926 1.0177C2.8987 12.176.452 14.772 0 18.9902h24c-.119-1.1108-.3686-2.099-.7461-3.0683-.7438-1.9118-1.8435-3.2928-2.7402-4.1836a12.1048 12.1048 0 0 0-2.1309-1.6875c.6594-1.122 1.312-2.2559 1.9649-3.3848.2077-.3615.1886-.7956-.0079-1.1191a1.1001 1.1001 0 0 0-.8515-.5332c-.5225-.0536-.9392.3128-1.0488.5449zm-.0391 8.461c.3944.5926.324 1.3306-.1563 1.6503-.4799.3197-1.188.0985-1.582-.4941-.3944-.5927-.324-1.3307.1563-1.6504.4727-.315 1.1812-.1086 1.582.4941zM7.207 13.5273c.4803.3197.5506 1.0577.1563 1.6504-.394.5926-1.1038.8138-1.584.4941-.48-.3197-.5503-1.0577-.1563-1.6504.4008-.6021 1.1087-.8106 1.584-.4941z"},wE={path:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"},c2e={path:"M12.504 0c-.155 0-.315.008-.48.021-4.226.333-3.105 4.807-3.17 6.298-.076 1.092-.3 1.953-1.05 3.02-.885 1.051-2.127 2.75-2.716 4.521-.278.832-.41 1.684-.287 2.489a.424.424 0 00-.11.135c-.26.268-.45.6-.663.839-.199.199-.485.267-.797.4-.313.136-.658.269-.864.68-.09.189-.136.394-.132.602 0 .199.027.4.055.536.058.399.116.728.04.97-.249.68-.28 1.145-.106 1.484.174.334.535.47.94.601.81.2 1.91.135 2.774.6.926.466 1.866.67 2.616.47.526-.116.97-.464 1.208-.946.587-.003 1.23-.269 2.26-.334.699-.058 1.574.267 2.577.2.025.134.063.198.114.333l.003.003c.391.778 1.113 1.132 1.884 1.071.771-.06 1.592-.536 2.257-1.306.631-.765 1.683-1.084 2.378-1.503.348-.199.629-.469.649-.853.023-.4-.2-.811-.714-1.376v-.097l-.003-.003c-.17-.2-.25-.535-.338-.926-.085-.401-.182-.786-.492-1.046h-.003c-.059-.054-.123-.067-.188-.135a.357.357 0 00-.19-.064c.431-1.278.264-2.55-.173-3.694-.533-1.41-1.465-2.638-2.175-3.483-.796-1.005-1.576-1.957-1.56-3.368.026-2.152.236-6.133-3.544-6.139zm.529 3.405h.013c.213 0 .396.062.584.198.19.135.33.332.438.533.105.259.158.459.166.724 0-.02.006-.04.006-.06v.105a.086.086 0 01-.004-.021l-.004-.024a1.807 1.807 0 01-.15.706.953.953 0 01-.213.335.71.71 0 00-.088-.042c-.104-.045-.198-.064-.284-.133a1.312 1.312 0 00-.22-.066c.05-.06.146-.133.183-.198.053-.128.082-.264.088-.402v-.02a1.21 1.21 0 00-.061-.4c-.045-.134-.101-.2-.183-.333-.084-.066-.167-.132-.267-.132h-.016c-.093 0-.176.03-.262.132a.8.8 0 00-.205.334 1.18 1.18 0 00-.09.4v.019c.002.089.008.179.02.267-.193-.067-.438-.135-.607-.202a1.635 1.635 0 01-.018-.2v-.02a1.772 1.772 0 01.15-.768c.082-.22.232-.406.43-.533a.985.985 0 01.594-.2zm-2.962.059h.036c.142 0 .27.048.399.135.146.129.264.288.344.465.09.199.14.4.153.667v.004c.007.134.006.2-.002.266v.08c-.03.007-.056.018-.083.024-.152.055-.274.135-.393.2.012-.09.013-.18.003-.267v-.015c-.012-.133-.04-.2-.082-.333a.613.613 0 00-.166-.267.248.248 0 00-.183-.064h-.021c-.071.006-.13.04-.186.132a.552.552 0 00-.12.27.944.944 0 00-.023.33v.015c.012.135.037.2.08.334.046.134.098.2.166.268.01.009.02.018.034.024-.07.057-.117.07-.176.136a.304.304 0 01-.131.068 2.62 2.62 0 01-.275-.402 1.772 1.772 0 01-.155-.667 1.759 1.759 0 01.08-.668 1.43 1.43 0 01.283-.535c.128-.133.26-.2.418-.2zm1.37 1.706c.332 0 .733.065 1.216.399.293.2.523.269 1.052.468h.003c.255.136.405.266.478.399v-.131a.571.571 0 01.016.47c-.123.31-.516.643-1.063.842v.002c-.268.135-.501.333-.775.465-.276.135-.588.292-1.012.267a1.139 1.139 0 01-.448-.067 3.566 3.566 0 01-.322-.198c-.195-.135-.363-.332-.612-.465v-.005h-.005c-.4-.246-.616-.512-.686-.71-.07-.268-.005-.47.193-.6.224-.135.38-.271.483-.336.104-.074.143-.102.176-.131h.002v-.003c.169-.202.436-.47.839-.601.139-.036.294-.065.466-.065zm2.8 2.142c.358 1.417 1.196 3.475 1.735 4.473.286.534.855 1.659 1.102 3.024.156-.005.33.018.513.064.646-1.671-.546-3.467-1.089-3.966-.22-.2-.232-.335-.123-.335.59.534 1.365 1.572 1.646 2.757.13.535.16 1.104.021 1.67.067.028.135.06.205.067 1.032.534 1.413.938 1.23 1.537v-.043c-.06-.003-.12 0-.18 0h-.016c.151-.467-.182-.825-1.065-1.224-.915-.4-1.646-.336-1.77.465-.008.043-.013.066-.018.135-.068.023-.139.053-.209.064-.43.268-.662.669-.793 1.187-.13.533-.17 1.156-.205 1.869v.003c-.02.334-.17.838-.319 1.35-1.5 1.072-3.58 1.538-5.348.334a2.645 2.645 0 00-.402-.533 1.45 1.45 0 00-.275-.333c.182 0 .338-.03.465-.067a.615.615 0 00.314-.334c.108-.267 0-.697-.345-1.163-.345-.467-.931-.995-1.788-1.521-.63-.4-.986-.87-1.15-1.396-.165-.534-.143-1.085-.015-1.645.245-1.07.873-2.11 1.274-2.763.107-.065.037.135-.408.974-.396.751-1.14 2.497-.122 3.854a8.123 8.123 0 01.647-2.876c.564-1.278 1.743-3.504 1.836-5.268.048.036.217.135.289.202.218.133.38.333.59.465.21.201.477.335.876.335.039.003.075.006.11.006.412 0 .73-.134.997-.268.29-.134.52-.334.74-.4h.005c.467-.135.835-.402 1.044-.7zm2.185 8.958c.037.6.343 1.245.882 1.377.588.134 1.434-.333 1.791-.765l.211-.01c.315-.007.577.01.847.268l.003.003c.208.199.305.53.391.876.085.4.154.78.409 1.066.486.527.645.906.636 1.14l.003-.007v.018l-.003-.012c-.015.262-.185.396-.498.595-.63.401-1.746.712-2.457 1.57-.618.737-1.37 1.14-2.036 1.191-.664.053-1.237-.2-1.574-.898l-.005-.003c-.21-.4-.12-1.025.056-1.69.176-.668.428-1.344.463-1.897.037-.714.076-1.335.195-1.814.12-.465.308-.797.641-.984l.045-.022zm-10.814.049h.01c.053 0 .105.005.157.014.376.055.706.333 1.023.752l.91 1.664.003.003c.243.533.754 1.064 1.189 1.637.434.598.77 1.131.729 1.57v.006c-.057.744-.48 1.148-1.125 1.294-.645.135-1.52.002-2.395-.464-.968-.536-2.118-.469-2.857-.602-.369-.066-.61-.2-.723-.4-.11-.2-.113-.602.123-1.23v-.004l.002-.003c.117-.334.03-.752-.027-1.118-.055-.401-.083-.71.043-.94.16-.334.396-.4.69-.533.294-.135.64-.202.915-.47h.002v-.002c.256-.268.445-.601.668-.838.19-.201.38-.336.663-.336zm7.159-9.074c-.435.201-.945.535-1.488.535-.542 0-.97-.267-1.28-.466-.154-.134-.28-.268-.373-.335-.164-.134-.144-.333-.074-.333.109.016.129.134.199.2.096.066.215.2.36.333.292.2.68.467 1.167.467.485 0 1.053-.267 1.398-.466.195-.135.445-.334.648-.467.156-.136.149-.267.279-.267.128.016.034.134-.147.332a8.097 8.097 0 01-.69.468zm-1.082-1.583V5.64c-.006-.02.013-.042.029-.05.074-.043.18-.027.26.004.063 0 .16.067.15.135-.006.049-.085.066-.135.066-.055 0-.092-.043-.141-.068-.052-.018-.146-.008-.163-.065zm-.551 0c-.02.058-.113.049-.166.066-.047.025-.086.068-.14.068-.05 0-.13-.02-.136-.068-.01-.066.088-.133.15-.133.08-.031.184-.047.259-.005.019.009.036.03.03.05v.02h.003z"},x3=Wn(),Hf={gateway:"#22c55e",device:"#3b82f6",mesh:"#a855f7",host:"#6b7280"},SE={gateway:14,device:10,mesh:10,host:8},u2e="M0 3.449L9.75 2.1V11.551H0zm10.949-1.564L24 0v11.551H10.949zM0 12.449h9.75v9.451L0 20.551zm10.949-.898H24V24l-13.051-1.869z";function Jh(e,n,r="0 0 24 24"){const i=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${r}" fill="${n}"><path d="${e}"/></svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`}function Zh(e){const n=new Image;return n.src=e,n}const I1={windows:Zh(Jh(u2e,"#ffffff")),macos:Zh(Jh(wE.path,"#ffffff")),linux:Zh(Jh(c2e.path,"#ffffff")),android:Zh(Jh(l2e.path,"#ffffff")),ios:Zh(Jh(wE.path,"#ffffff"))};function f2e(e){if(!e)return null;const n=e.toLowerCase();return n.includes("windows")?"windows":n.includes("macos")||n.includes("mac os")||n.includes("darwin")?"macos":n.includes("android")?"android":n.includes("ios")||n.includes("iphone")||n.includes("ipad")?"ios":n.includes("linux")||n.includes("ubuntu")||n.includes("debian")||n.includes("fedora")||n.includes("arch")||n.includes("centos")||n.includes("rhel")||n.includes("mint")||n.includes("manjaro")||n.includes("suse")||n.includes("alpine")?"linux":null}function d2e(e){if("platform"in e&&typeof e.platform=="string"&&I1[e.platform])return I1[e.platform];if("osVersion"in e){const n=f2e(e.osVersion);if(n&&I1[n])return I1[n]}return null}function h2e({node:e,onClose:n,onDeploy:r}){if(!e)return null;const i=e.type==="gateway"?Ms:e.type==="device"?"platform"in e&&(e.platform==="android"||e.platform==="ios")?p5:gs:e.type==="mesh"?kr:"isRouter"in e&&e.isRouter?pv:gs,s=Hf[e.type]??"#6b7280",o="sshReachable"in e&&e.sshReachable&&"agentStatus"in e&&e.agentStatus!=="running"&&"ip"in e;return f.jsx(Cu,{open:!!e,onOpenChange:a=>!a&&n(),children:f.jsxs(fc,{className:"sm:max-w-md",children:[f.jsx(Ga,{children:f.jsxs(Ya,{className:"flex items-center gap-2",children:[f.jsx("div",{className:"h-8 w-8 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${s}22`,color:s},children:f.jsx(i,{className:"h-4 w-4"})}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate",children:e.name}),f.jsx("div",{className:"text-xs font-normal text-muted-foreground capitalize",children:"isRouter"in e&&e.isRouter?"router":e.type})]})]})}),f.jsxs("div",{className:"space-y-3 text-sm",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${e.online?"bg-green-500":"bg-red-500"}`}),f.jsx("span",{children:e.online?"Online":"Offline"})]}),"platform"in e&&e.platform&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"Platform"}),f.jsx("span",{className:"flex items-center gap-1.5 capitalize",children:e.platform})]}),"ip"in e&&e.ip&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"IP Address"}),f.jsx("code",{className:"text-xs bg-muted px-2 py-0.5 rounded",children:e.ip})]}),"isRouter"in e&&e.isRouter&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"Role"}),f.jsx(ln,{variant:"secondary",className:"text-[10px]",children:"Router"})]}),"version"in e&&e.version&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"Version"}),f.jsxs(ln,{variant:"secondary",className:"font-mono text-[10px]",children:["v",e.version]})]}),"osVersion"in e&&e.osVersion&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"OS"}),f.jsx("span",{className:"text-xs",children:e.osVersion})]}),"mac"in e&&e.mac&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"MAC Address"}),f.jsx("code",{className:"text-xs bg-muted px-2 py-0.5 rounded",children:e.mac})]}),"providers"in e&&e.providers.length>0&&f.jsxs("div",{children:[f.jsx("span",{className:"text-muted-foreground block mb-1.5",children:"Providers"}),f.jsx("div",{className:"flex flex-wrap gap-1",children:e.providers.map(a=>f.jsxs(ln,{variant:"outline",className:"text-[10px]",children:[f.jsx(su,{className:"h-2.5 w-2.5 mr-1"}),a]},a))})]}),"openPorts"in e&&e.openPorts.length>0&&f.jsxs("div",{children:[f.jsx("span",{className:"text-muted-foreground block mb-1.5",children:"Open Ports"}),f.jsx("div",{className:"flex flex-wrap gap-1",children:e.openPorts.map(a=>f.jsx(ln,{variant:"outline",className:"text-[10px] font-mono",children:a},a))})]}),"sshReachable"in e&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"SSH"}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(h5,{className:"h-3 w-3"}),e.sshReachable?"Reachable":"Not reachable"]})]}),"agentStatus"in e&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"Agent"}),f.jsx(ln,{variant:e.agentStatus==="running"?"default":"secondary",className:"text-[10px]",children:e.agentStatus})]}),"registeredAt"in e&&e.registeredAt&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"Connected"}),f.jsx("span",{className:"text-xs",children:new Date(e.registeredAt).toLocaleString()})]}),"agentStatus"in e&&e.agentStatus==="running"&&"ip"in e&&f.jsx($e,{size:"sm",variant:"outline",className:"w-full mt-2",asChild:!0,children:f.jsxs("a",{href:`http://${e.ip}:8000`,target:"_blank",rel:"noopener noreferrer",children:[f.jsx(kr,{className:"h-3.5 w-3.5 mr-1.5"}),"Open Dashboard"]})}),o&&r&&f.jsxs($e,{size:"sm",variant:"default",className:"w-full mt-2",onClick:()=>{r(e.ip),n()},children:[f.jsx(hw,{className:"h-3.5 w-3.5 mr-1.5"}),"Deploy Node"]})]})]})})}function p2e({ip:e,token:n,onClose:r}){const[i,s]=y.useState(""),[o,a]=y.useState("password"),[c,d]=y.useState(null),[h,g]=y.useState(!1);if(!e)return null;const p=async()=>{g(!0);try{const _={"Content-Type":"application/json"};n&&(_.Authorization=`Bearer ${n}`);const b=await fetch(`${x3}/api/network/deploy`,{method:"POST",headers:_,body:JSON.stringify({ip:e,username:i,authMethod:o})});if(b.ok){const x=await b.json();d(x)}}catch{}finally{g(!1)}};return f.jsx(Cu,{open:!!e,onOpenChange:_=>{_||(d(null),s(""),r())},children:f.jsxs(fc,{className:"sm:max-w-lg",children:[f.jsx(Ga,{children:f.jsxs(Ya,{className:"flex items-center gap-2",children:[f.jsx(hw,{className:"h-4 w-4"}),"Deploy Jait Node to ",e]})}),c?f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("span",{className:"text-sm font-medium",children:"Instructions"}),f.jsx("ol",{className:"text-sm text-muted-foreground space-y-1 list-decimal list-inside",children:c.instructions.map((_,b)=>f.jsx("li",{children:_},b))})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("span",{className:"text-sm font-medium",children:"SSH Command"}),f.jsx("pre",{className:"text-xs bg-muted p-3 rounded-md overflow-x-auto whitespace-pre-wrap break-all",children:c.sshCommand})]}),f.jsx($e,{variant:"outline",className:"w-full",onClick:()=>{navigator.clipboard.writeText(c.sshCommand)},children:"Copy Command"})]}):f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("label",{className:"text-sm text-muted-foreground",children:"SSH Username"}),f.jsx("input",{type:"text",value:i,onChange:_=>s(_.target.value),placeholder:"e.g. pi, ubuntu, root",className:"w-full px-3 py-2 text-sm rounded-md border bg-background"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("label",{className:"text-sm text-muted-foreground",children:"Auth Method"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx($e,{size:"sm",variant:o==="password"?"default":"outline",onClick:()=>a("password"),children:"Password"}),f.jsx($e,{size:"sm",variant:o==="key"?"default":"outline",onClick:()=>a("key"),children:"SSH Key"})]})]}),f.jsxs($e,{className:"w-full",onClick:()=>void p(),disabled:!i.trim()||h,children:[h?f.jsx(kt,{className:"h-4 w-4 mr-2 animate-spin"}):f.jsx(hw,{className:"h-4 w-4 mr-2"}),"Generate Deploy Script"]})]})]})})}function m2e({token:e}){const n=y.useRef(null),r=y.useRef(void 0),[i,s]=y.useState({width:800,height:600}),[o,a]=y.useState(null),[c,d]=y.useState(!1),[h,g]=y.useState(null),[p,_]=y.useState(null),[b,x]=y.useState(null),[C,j]=y.useState(null),S=y.useCallback(()=>{const B=r.current;if(!B||i.width<=0||i.height<=0)return;const F=Math.max(48,Math.min(96,Math.min(i.width,i.height)*.08)),W=i.width<768?.95:.85;B.zoomToFit(250,F),setTimeout(()=>{const z=B.zoom();typeof z=="number"&&z<W&&B.zoom(W,250)},300)},[i.height,i.width]),E=y.useCallback(()=>{const B={};return e&&(B.Authorization=`Bearer ${e}`),B},[e]),O=y.useRef(""),N=y.useCallback(async()=>{try{const B=await fetch(`${x3}/api/network/topology`,{headers:E()});if(B.ok){const F=await B.text();F!==O.current&&(O.current=F,a(JSON.parse(F))),_(null)}}catch(B){_(B instanceof Error?B.message:"Failed to fetch topology")}},[E]),T=y.useCallback(async()=>{d(!0),_(null);try{const B=await fetch(`${x3}/api/network/scan`,{method:"POST",headers:{...E(),"Content-Type":"application/json"},body:JSON.stringify({deep:!0})});if(!B.ok)throw new Error(`Scan failed: ${B.status}`);await N()}catch(B){_(B instanceof Error?B.message:"Scan failed")}finally{d(!1)}},[E,N]);y.useEffect(()=>{N();const B=setInterval(()=>void N(),15e3);return()=>clearInterval(B)},[N]),y.useEffect(()=>{const B=n.current;if(!B)return;const F=new ResizeObserver(([W])=>{W&&s({width:W.contentRect.width,height:W.contentRect.height})});return F.observe(B),()=>F.disconnect()},[]);const P=y.useMemo(()=>{if(!o)return{nodes:[],links:[]};const B=[],F=[];B.push({id:o.gateway.id,data:o.gateway});for(const W of o.devices)B.push({id:W.id,data:W}),F.push({source:W.id,target:"gateway",type:"connected"});for(const W of o.meshNodes)B.push({id:W.id,data:W}),F.push({source:W.id,target:"gateway",type:"connected"});for(const W of o.hosts)W.ip!==o.gateway.ip&&(B.push({id:W.id,data:W}),F.push({source:W.id,target:"gateway",type:"scanned"}));return{nodes:B,links:F}},[o]),D=y.useRef(!1);y.useEffect(()=>{r.current&&P.nodes.length>0&&!D.current&&(D.current=!0,setTimeout(()=>{S()},1500))},[S,P.nodes.length]);const H=y.useCallback((B,F,W)=>{const{data:z}=B,V=B.x??0,A=B.y??0,U=SE[z.type]??8,K=Hf[z.type]??"#6b7280",Y=b===B.id,$=(h==null?void 0:h.id)===z.id;z.type==="gateway"&&(F.beginPath(),F.arc(V,A,U+4,0,2*Math.PI),F.fillStyle=`${K}33`,F.fill()),z.type==="host"&&"sshReachable"in z&&z.sshReachable&&(F.beginPath(),F.arc(V,A,U+3,0,2*Math.PI),F.strokeStyle="#f59e0b55",F.lineWidth=1.5/W,F.stroke()),(Y||$)&&(F.beginPath(),F.arc(V,A,U+2.5,0,2*Math.PI),F.strokeStyle=K,F.lineWidth=1.5/W,F.stroke()),F.beginPath(),F.arc(V,A,U,0,2*Math.PI),F.fillStyle=K,F.fill(),z.online&&(F.beginPath(),F.arc(V+U*.65,A-U*.65,2.5,0,2*Math.PI),F.fillStyle="#22c55e",F.fill(),F.strokeStyle="#0a0a0a",F.lineWidth=.5,F.stroke());const R=d2e(z);if(R!=null&&R.complete&&R.naturalWidth>0){const X=U*1.1;F.drawImage(R,V-X/2,A-X/2,X,X)}const Z=Math.max(3.5,10/W);F.font=`${Z}px -apple-system, BlinkMacSystemFont, sans-serif`,F.textAlign="center",F.textBaseline="top",F.fillStyle=Y?"#ffffff":"#a1a1aa";const L=z.name.length>20?z.name.slice(0,18)+"…":z.name;F.fillText(L,V,A+U+3),z.type==="gateway"?(F.font=`bold ${Math.max(3,8/W)}px -apple-system, BlinkMacSystemFont, sans-serif`,F.fillStyle="#22c55e",F.fillText("GATEWAY",V,A+U+3+Z+2)):z.type==="host"&&"isRouter"in z&&z.isRouter&&(F.font=`bold ${Math.max(3,8/W)}px -apple-system, BlinkMacSystemFont, sans-serif`,F.fillStyle="#f59e0b",F.fillText("ROUTER",V,A+U+3+Z+2));const Q="providers"in z&&Array.isArray(z.providers)?z.providers:[];if(Q.length>0){const X=Math.max(2.5,7/W);F.font=`${X}px -apple-system, BlinkMacSystemFont, sans-serif`,F.fillStyle="#a855f7";const ie=z.type==="gateway"?Z*2+6:Z+5;F.fillText(Q.join(" · "),V,A+U+3+ie)}if(z.type==="host"&&"openPorts"in z&&z.openPorts.length>0){const X=z.openPorts.length,ie=Math.max(2.5,7/W);F.font=`bold ${ie}px -apple-system, BlinkMacSystemFont, sans-serif`,F.fillStyle="#3b82f6",F.textAlign="center",F.textBaseline="middle";const se=V-U*.65,ce=A-U*.65;F.beginPath(),F.arc(se,ce,3.5,0,2*Math.PI),F.fillStyle="#3b82f6",F.fill(),F.fillStyle="#ffffff",F.fillText(String(X),se,ce)}},[b,h]),J=y.useCallback((B,F)=>{const W=B.source,z=B.target;!(W!=null&&W.x)||!(z!=null&&z.x)||(F.beginPath(),F.moveTo(W.x,W.y),F.lineTo(z.x,z.y),B.type==="connected"?(F.strokeStyle="#3b82f644",F.lineWidth=1.5,F.setLineDash([])):(F.strokeStyle="#6b728033",F.lineWidth=.5,F.setLineDash([4,4])),F.stroke(),F.setLineDash([]))},[]),I=o?1+o.devices.length+o.meshNodes.length+o.hosts.length:0;return f.jsxs("div",{className:"h-full flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 border-b px-4 py-3 shrink-0",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx(pv,{className:"h-4 w-4 text-primary"}),f.jsx("h2",{className:"text-sm font-semibold",children:"Network"}),I>0&&f.jsxs(ln,{variant:"secondary",className:"w-[4.75rem] justify-center px-1 text-[10px] tabular-nums",children:[I," ",I===1?"node":"nodes"]}),(o==null?void 0:o.scannedAt)&&f.jsxs("span",{className:"text-[10px] text-muted-foreground hidden sm:inline",children:["Last scan: ",new Date(o.scannedAt).toLocaleTimeString()]})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[f.jsxs($e,{size:"sm",variant:"outline",className:"h-7 px-2 text-xs sm:px-2.5",onClick:()=>void N(),children:[f.jsx(du,{className:"h-3 w-3 sm:mr-1"}),f.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),f.jsx($e,{size:"sm",variant:"default",className:"h-7 px-2 text-xs sm:px-2.5",onClick:()=>void T(),disabled:c,children:c?f.jsxs(f.Fragment,{children:[f.jsx(kt,{className:"h-3 w-3 animate-spin sm:mr-1"}),f.jsx("span",{className:"hidden sm:inline",children:"Scanning..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(Lp,{className:"h-3 w-3 sm:mr-1"}),f.jsx("span",{className:"hidden sm:inline",children:o!=null&&o.scannedAt?"Rescan Network":"Discover Devices"})]})})]})]}),p&&f.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-500 bg-red-500/10 px-4 py-2",children:[f.jsx(Mr,{className:"h-3.5 w-3.5 shrink-0"}),p]}),f.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 border-b text-[10px] text-muted-foreground shrink-0 flex-wrap",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Hf.gateway}}),"Gateway"]}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Hf.device}}),"Connected Device"]}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Hf.mesh}}),"Mesh Node"]}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Hf.host}}),"Network Host"]}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"h-2.5 w-2.5 rounded-full border border-amber-500/50",style:{backgroundColor:"transparent"}}),"SSH Available"]})]}),f.jsx("div",{ref:n,className:"flex-1 min-h-0 relative bg-background",children:P.nodes.length>0?f.jsx(s4,{ref:r,width:i.width,height:i.height,graphData:P,nodeId:"id",nodeCanvasObject:H,nodePointerAreaPaint:(B,F,W)=>{const z=SE[B.data.type]??6;W.beginPath(),W.arc(B.x??0,B.y??0,z+4,0,2*Math.PI),W.fillStyle=F,W.fill()},linkCanvasObject:J,onNodeClick:B=>g(B.data),onNodeHover:B=>x((B==null?void 0:B.id)??null),cooldownTicks:80,d3VelocityDecay:.3,d3AlphaDecay:.02,minZoom:.65,maxZoom:3,enableNodeDrag:!0,enableZoomInteraction:!0,enablePanInteraction:!0,backgroundColor:"transparent"}):o?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[f.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center",children:f.jsx(gs,{className:"h-6 w-6 text-muted-foreground"})}),f.jsx("div",{className:"text-sm font-medium",children:"No devices found"}),f.jsx("div",{className:"text-xs text-muted-foreground max-w-xs text-center",children:"Run a network scan to discover devices on your local network."}),f.jsxs($e,{size:"sm",onClick:()=>void T(),className:"mt-2",children:[f.jsx(Lp,{className:"h-3.5 w-3.5 mr-1.5"}),"Discover Devices"]})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[f.jsx(kt,{className:"h-8 w-8 animate-spin text-muted-foreground"}),f.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading network topology..."})]})}),f.jsx(h2e,{node:h,onClose:()=>g(null),onDeploy:B=>j(B)}),f.jsx(p2e,{ip:C,token:e,onClose:()=>j(null)})]})}function g2e({platform:e,className:n}){switch(e){case"electron":return f.jsx(gs,{className:n??"h-4 w-4"});case"react-native":return f.jsx(p5,{className:n??"h-4 w-4"});default:return f.jsx(kr,{className:n??"h-4 w-4"})}}function CE({device:e,isLocal:n,isConnected:r,isLoading:i,onConnect:s}){const o=!n&&e.capabilities.includes("screen-share");return f.jsxs("div",{className:`flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm transition-colors
|
|
755
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mE(e,n){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);n&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,i)}return r}function zf(e){for(var n=1;n<arguments.length;n++){var r=arguments[n]!=null?arguments[n]:{};n%2?mE(Object(r),!0).forEach(function(i){dg(e,i,r[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mE(Object(r)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(r,i))})}return e}function Dp(e,n){return Ixe(e)||Hxe(e,n)||zz(e,n)||Uxe()}function Ls(e){return Bxe(e)||Fxe(e)||zz(e)||Vxe()}function Wxe(e,n){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,n);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(e)}function qxe(e){var n=Wxe(e,"string");return typeof n=="symbol"?n:n+""}function b3(e){"@babel/helpers - typeof";return b3=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},b3(e)}function zz(e,n){if(e){if(typeof e=="string")return _3(e,n);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_3(e,n):void 0}}var Kxe=Rz(zxe);function gE(e,n,r){!n||typeof r!="string"||e.filter(function(i){return!i[r]}).forEach(function(i){i[r]=Kxe(n(i))})}function Gxe(e,n){var r=e.nodes,i=e.links,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=s.nodeFilter,a=o===void 0?function(){return!0}:o,c=s.onLoopError,d=c===void 0?function(b){throw"Invalid DAG structure! Found cycle in node path: ".concat(b.join(" -> "),".")}:c,h={};r.forEach(function(b){return h[n(b)]={data:b,out:[],depth:-1,skip:!a(b)}}),i.forEach(function(b){var x=b.source,C=b.target,j=N(x),S=N(C);if(!h.hasOwnProperty(j))throw"Missing source node with id: ".concat(j);if(!h.hasOwnProperty(S))throw"Missing target node with id: ".concat(S);var E=h[j],O=h[S];E.out.push(O);function N(T){return b3(T)==="object"?n(T):T}});var g=[];_(Object.values(h));var p=Object.assign.apply(Object,[{}].concat(Ls(Object.entries(h).filter(function(b){var x=Dp(b,2),C=x[1];return!C.skip}).map(function(b){var x=Dp(b,2),C=x[0],j=x[1];return dg({},C,j.depth)}))));return p;function _(b){for(var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],C=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,j=function(){var N=b[S];if(x.indexOf(N)!==-1){var T=[].concat(Ls(x.slice(x.indexOf(N))),[N]).map(function(P){return n(P.data)});return g.some(function(P){return P.length===T.length&&P.every(function(D,H){return D===T[H]})})||(g.push(T),d(T)),1}C>N.depth&&(N.depth=C,_(N.out,[].concat(Ls(x),[N]),C+(N.skip?0:1)))},S=0,E=b.length;S<E;S++)j()}}var Yxe=2,ni=function(n,r){return r.onNeedsRedraw&&r.onNeedsRedraw()},yE=function(n,r){if(!r.isShadow){var i=vn(r.linkDirectionalParticles);r.graphData.links.forEach(function(s){var o=Math.round(Math.abs(i(s)));o?s.__photons=Ls(Array(o)).map(function(){return{}}):delete s.__photons})}},rv=XS({props:{graphData:{default:{nodes:[],links:[]},onChange:function(n,r){r.engineRunning=!1,yE(n,r)}},dagMode:{onChange:function(n,r){!n&&(r.graphData.nodes||[]).forEach(function(i){return i.fx=i.fy=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(n){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4,triggerUpdate:!1,onChange:ni},nodeId:{default:"id"},nodeVal:{default:"val",triggerUpdate:!1,onChange:ni},nodeColor:{default:"color",triggerUpdate:!1,onChange:ni},nodeAutoColorBy:{},nodeCanvasObject:{triggerUpdate:!1,onChange:ni},nodeCanvasObjectMode:{default:function(){return"replace"},triggerUpdate:!1,onChange:ni},nodeVisibility:{default:!0,triggerUpdate:!1,onChange:ni},linkSource:{default:"source"},linkTarget:{default:"target"},linkVisibility:{default:!0,triggerUpdate:!1,onChange:ni},linkColor:{default:"color",triggerUpdate:!1,onChange:ni},linkAutoColorBy:{},linkLineDash:{triggerUpdate:!1,onChange:ni},linkWidth:{default:1,triggerUpdate:!1,onChange:ni},linkCurvature:{default:0,triggerUpdate:!1,onChange:ni},linkCanvasObject:{triggerUpdate:!1,onChange:ni},linkCanvasObjectMode:{default:function(){return"replace"},triggerUpdate:!1,onChange:ni},linkDirectionalArrowLength:{default:0,triggerUpdate:!1,onChange:ni},linkDirectionalArrowColor:{triggerUpdate:!1,onChange:ni},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1,onChange:ni},linkDirectionalParticles:{default:0,triggerUpdate:!1,onChange:yE},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:4,triggerUpdate:!1},linkDirectionalParticleColor:{triggerUpdate:!1},linkDirectionalParticleCanvasObject:{triggerUpdate:!1},globalScale:{default:1,triggerUpdate:!1},d3AlphaMin:{default:0,triggerUpdate:!1},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(n,r){r.forceLayout.alphaDecay(n)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(n,r){r.forceLayout.alphaTarget(n)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(n,r){r.forceLayout.velocityDecay(n)}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1},onNeedsRedraw:{triggerUpdate:!1},isShadow:{default:!1,triggerUpdate:!1}},methods:{d3Force:function(n,r,i){return i===void 0?n.forceLayout.force(r):(n.forceLayout.force(r,i),this)},d3ReheatSimulation:function(n){return n.forceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(n){return n.cntTicks=0,n.startTickTime=new Date,n.engineRunning=!0,this},isEngineRunning:function(n){return!!n.engineRunning},tickFrame:function(n){return!n.isShadow&&r(),s(),!n.isShadow&&o(),!n.isShadow&&a(),i(),this;function r(){n.engineRunning&&(++n.cntTicks>n.cooldownTicks||new Date-n.startTickTime>n.cooldownTime||n.d3AlphaMin>0&&n.forceLayout.alpha()<n.d3AlphaMin?(n.engineRunning=!1,n.onEngineStop()):(n.forceLayout.tick(),n.onEngineTick()))}function i(){var c=vn(n.nodeVisibility),d=vn(n.nodeVal),h=vn(n.nodeColor),g=vn(n.nodeCanvasObjectMode),p=n.ctx,_=n.isShadow/n.globalScale,b=n.graphData.nodes.filter(c);p.save(),b.forEach(function(x){var C=g(x);if(n.nodeCanvasObject&&(C==="before"||C==="replace")&&(n.nodeCanvasObject(x,p,n.globalScale),C==="replace")){p.restore();return}var j=Math.sqrt(Math.max(0,d(x)||1))*n.nodeRelSize+_;p.beginPath(),p.arc(x.x,x.y,j,0,2*Math.PI,!1),p.fillStyle=h(x)||"rgba(31, 120, 180, 0.92)",p.fill(),n.nodeCanvasObject&&C==="after"&&n.nodeCanvasObject(x,n.ctx,n.globalScale)}),p.restore()}function s(){var c=vn(n.linkVisibility),d=vn(n.linkColor),h=vn(n.linkWidth),g=vn(n.linkLineDash),p=vn(n.linkCurvature),_=vn(n.linkCanvasObjectMode),b=n.ctx,x=n.isShadow*2,C=n.graphData.links.filter(c);C.forEach(P);var j=[],S=[],E=C;if(n.linkCanvasObject){var O=[],N=[];C.forEach(function(D){return({before:j,after:S,replace:O}[_(D)]||N).push(D)}),E=[].concat(Ls(j),S,N),j=j.concat(O)}b.save(),j.forEach(function(D){return n.linkCanvasObject(D,b,n.globalScale)}),b.restore();var T=Mxe(E,[d,h,g]);b.save(),Object.entries(T).forEach(function(D){var H=Dp(D,2),J=H[0],I=H[1],B=!J||J==="undefined"?"rgba(0,0,0,0.15)":J;Object.entries(I).forEach(function(F){var W=Dp(F,2),z=W[0],V=W[1],A=(z||1)/n.globalScale+x;Object.entries(V).forEach(function(U){var K=Dp(U,2);K[0];var Y=K[1],$=g(Y[0]);b.beginPath(),Y.forEach(function(R){var Z=R.source,L=R.target;if(!(!Z||!L||!Z.hasOwnProperty("x")||!L.hasOwnProperty("x"))){b.moveTo(Z.x,Z.y);var Q=R.__controlPoints;Q?b[Q.length===2?"quadraticCurveTo":"bezierCurveTo"].apply(b,Ls(Q).concat([L.x,L.y])):b.lineTo(L.x,L.y)}}),b.strokeStyle=B,b.lineWidth=A,b.setLineDash($||[]),b.stroke()})})}),b.restore(),b.save(),S.forEach(function(D){return n.linkCanvasObject(D,b,n.globalScale)}),b.restore();function P(D){var H=p(D);if(!H){D.__controlPoints=null;return}var J=D.source,I=D.target;if(!(!J||!I||!J.hasOwnProperty("x")||!I.hasOwnProperty("x"))){var B=Math.sqrt(Math.pow(I.x-J.x,2)+Math.pow(I.y-J.y,2));if(B>0){var F=Math.atan2(I.y-J.y,I.x-J.x),W=B*H,z={x:(J.x+I.x)/2+W*Math.cos(F-Math.PI/2),y:(J.y+I.y)/2+W*Math.sin(F-Math.PI/2)};D.__controlPoints=[z.x,z.y]}else{var V=H*70;D.__controlPoints=[I.x,I.y-V,I.x+V,I.y]}}}}function o(){var c=1.6,d=.2,h=vn(n.linkDirectionalArrowLength),g=vn(n.linkDirectionalArrowRelPos),p=vn(n.linkVisibility),_=vn(n.linkDirectionalArrowColor||n.linkColor),b=vn(n.nodeVal),x=n.ctx;x.save(),n.graphData.links.filter(p).forEach(function(C){var j=h(C);if(!(!j||j<0)){var S=C.source,E=C.target;if(!(!S||!E||!S.hasOwnProperty("x")||!E.hasOwnProperty("x"))){var O=Math.sqrt(Math.max(0,b(S)||1))*n.nodeRelSize,N=Math.sqrt(Math.max(0,b(E)||1))*n.nodeRelSize,T=Math.min(1,Math.max(0,g(C))),P=_(C)||"rgba(0,0,0,0.28)",D=j/c/2,H=C.__controlPoints&&pE(Ln,[S.x,S.y].concat(Ls(C.__controlPoints),[E.x,E.y])),J=H?function(A){return H.get(A)}:function(A){return{x:S.x+(E.x-S.x)*A||0,y:S.y+(E.y-S.y)*A||0}},I=H?H.length():Math.sqrt(Math.pow(E.x-S.x,2)+Math.pow(E.y-S.y,2)),B=O+j+(I-O-N-j)*T,F=J(B/I),W=J((B-j)/I),z=J((B-j*(1-d))/I),V=Math.atan2(F.y-W.y,F.x-W.x)-Math.PI/2;x.beginPath(),x.moveTo(F.x,F.y),x.lineTo(W.x+D*Math.cos(V),W.y+D*Math.sin(V)),x.lineTo(z.x,z.y),x.lineTo(W.x-D*Math.cos(V),W.y-D*Math.sin(V)),x.fillStyle=P,x.fill()}}}),x.restore()}function a(){var c=vn(n.linkDirectionalParticles),d=vn(n.linkDirectionalParticleSpeed),h=vn(n.linkDirectionalParticleOffset),g=vn(n.linkDirectionalParticleWidth),p=vn(n.linkVisibility),_=vn(n.linkDirectionalParticleColor||n.linkColor),b=n.ctx;b.save(),n.graphData.links.filter(p).forEach(function(x){var C=c(x);if(!(!x.hasOwnProperty("__photons")||!x.__photons.length)){var j=x.source,S=x.target;if(!(!j||!S||!j.hasOwnProperty("x")||!S.hasOwnProperty("x"))){var E=d(x),O=Math.abs(h(x)),N=x.__photons||[],T=Math.max(0,g(x)/2)/Math.sqrt(n.globalScale),P=_(x)||"rgba(0,0,0,0.28)";b.fillStyle=P;var D=x.__controlPoints?pE(Ln,[j.x,j.y].concat(Ls(x.__controlPoints),[S.x,S.y])):null,H=0,J=!1;N.forEach(function(I){var B=!!I.__singleHop;if(I.hasOwnProperty("__progressRatio")||(I.__progressRatio=B?0:(H+O)/C),!B&&H++,I.__progressRatio+=E,I.__progressRatio>=1)if(!B)I.__progressRatio=I.__progressRatio%1;else{J=!0;return}var F=I.__progressRatio,W=D?D.get(F):{x:j.x+(S.x-j.x)*F||0,y:j.y+(S.y-j.y)*F||0};n.linkDirectionalParticleCanvasObject?n.linkDirectionalParticleCanvasObject(W.x,W.y,x,b,n.globalScale):(b.beginPath(),b.arc(W.x,W.y,T,0,2*Math.PI,!1),b.fill())}),J&&(x.__photons=x.__photons.filter(function(I){return!I.__singleHop||I.__progressRatio<=1}))}}}),b.restore()}},emitParticle:function(n,r){return r&&(!r.__photons&&(r.__photons=[]),r.__photons.push({__singleHop:!0})),this}},stateInit:function(){return{forceLayout:fxe().force("link",rxe()).force("charge",dxe()).force("center",sbe()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(n,r){r.ctx=n},update:function(n,r){n.engineRunning=!1,n.onUpdate(),n.nodeAutoColorBy!==null&&gE(n.graphData.nodes,vn(n.nodeAutoColorBy),n.nodeColor),n.linkAutoColorBy!==null&&gE(n.graphData.links,vn(n.linkAutoColorBy),n.linkColor),n.graphData.links.forEach(function(_){_.source=_[n.linkSource],_.target=_[n.linkTarget]}),n.forceLayout.stop().alpha(1).nodes(n.graphData.nodes);var i=n.forceLayout.force("link");i&&i.id(function(_){return _[n.nodeId]}).links(n.graphData.links);var s=n.dagMode&&Gxe(n.graphData,function(_){return _[n.nodeId]},{nodeFilter:n.dagNodeFilter,onLoopError:n.onDagError||void 0}),o=Math.max.apply(Math,Ls(Object.values(s||[]))),a=n.dagLevelDistance||n.graphData.nodes.length/(o||1)*Yxe*(["radialin","radialout"].indexOf(n.dagMode)!==-1?.7:1);if(["lr","rl","td","bu"].includes(r.dagMode)){var c=["lr","rl"].includes(r.dagMode)?"fx":"fy";n.graphData.nodes.filter(n.dagNodeFilter).forEach(function(_){return delete _[c]})}if(["lr","rl","td","bu"].includes(n.dagMode)){var d=["rl","bu"].includes(n.dagMode),h=function(b){return(s[b[n.nodeId]]-o/2)*a*(d?-1:1)},g=["lr","rl"].includes(n.dagMode)?"fx":"fy";n.graphData.nodes.filter(n.dagNodeFilter).forEach(function(_){return _[g]=h(_)})}n.forceLayout.force("dagRadial",["radialin","radialout"].indexOf(n.dagMode)!==-1?hxe(function(_){var b=s[_[n.nodeId]]||-1;return(n.dagMode==="radialin"?o-b:b)*a}).strength(function(_){return n.dagNodeFilter(_)?1:0}):null);for(var p=0;p<n.warmupTicks&&!(n.d3AlphaMin>0&&n.forceLayout.alpha()<n.d3AlphaMin);p++)n.forceLayout.tick();this.resetCountdown(),n.onFinishUpdate()}});function Lz(e,n){var r=e instanceof Array?e:[e],i=new n;return i._destructor&&i._destructor(),{linkProp:function(o){return{default:i[o](),onChange:function(c,d){r.forEach(function(h){return d[h][o](c)})},triggerUpdate:!1}},linkMethod:function(o){return function(a){for(var c=arguments.length,d=new Array(c>1?c-1:0),h=1;h<c;h++)d[h-1]=arguments[h];var g=[];return r.forEach(function(p){var _=a[p],b=_[o].apply(_,d);b!==_&&g.push(b)}),g.length?g[0]:this}}}}var Xxe=800,Jxe=4,Zxe=5,$z=Lz("forceGraph",rv),Qxe=Lz(["forceGraph","shadowGraph"],rv),e2e=Object.assign.apply(Object,Ls(["nodeColor","nodeAutoColorBy","nodeCanvasObject","nodeCanvasObjectMode","linkColor","linkAutoColorBy","linkLineDash","linkWidth","linkCanvasObject","linkCanvasObjectMode","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowRelPos","linkDirectionalParticles","linkDirectionalParticleSpeed","linkDirectionalParticleOffset","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleCanvasObject","dagMode","dagLevelDistance","dagNodeFilter","onDagError","d3AlphaMin","d3AlphaDecay","d3VelocityDecay","warmupTicks","cooldownTicks","cooldownTime","onEngineTick","onEngineStop"].map(function(e){return dg({},e,$z.linkProp(e))})).concat(Ls(["nodeRelSize","nodeId","nodeVal","nodeVisibility","linkSource","linkTarget","linkVisibility","linkCurvature"].map(function(e){return dg({},e,Qxe.linkProp(e))})))),t2e=Object.assign.apply(Object,Ls(["d3Force","d3ReheatSimulation","emitParticle"].map(function(e){return dg({},e,$z.linkMethod(e))})));function I2(e){if(e.canvas){var n=e.canvas.width,r=e.canvas.height;n===300&&r===150&&(n=r=0);var i=window.devicePixelRatio;n/=i,r/=i,[e.canvas,e.shadowCanvas].forEach(function(o){o.style.width="".concat(e.width,"px"),o.style.height="".concat(e.height,"px"),o.width=e.width*i,o.height=e.height*i,!n&&!r&&o.getContext("2d").scale(i,i)});var s=Bo(e.canvas).k;e.zoom.translateBy(e.zoom.__baseElem,(e.width-n)/2/s,(e.height-r)/2/s),e.needsRedraw=!0}}function Iz(e){var n=window.devicePixelRatio;e.setTransform(n,0,0,n,0,0)}function vE(e,n,r){e.save(),Iz(e),e.clearRect(0,0,n,r),e.restore()}var n2e=XS({props:zf({width:{default:window.innerWidth,onChange:function(n,r){return I2(r)},triggerUpdate:!1},height:{default:window.innerHeight,onChange:function(n,r){return I2(r)},triggerUpdate:!1},graphData:{default:{nodes:[],links:[]},onChange:function(n,r){[n.nodes,n.links].every(function(s){return(s||[]).every(function(o){return!o.hasOwnProperty("__indexColor")})})&&r.colorTracker.reset(),[{type:"Node",objs:n.nodes},{type:"Link",objs:n.links}].forEach(i),r.forceGraph.graphData(n),r.shadowGraph.graphData(n);function i(s){var o=s.type,a=s.objs;a.filter(function(c){if(!c.hasOwnProperty("__indexColor"))return!0;var d=r.colorTracker.lookup(c.__indexColor);return!d||!d.hasOwnProperty("d")||d.d!==c}).forEach(function(c){c.__indexColor=r.colorTracker.register({type:o,d:c})})}},triggerUpdate:!1},backgroundColor:{onChange:function(n,r){r.canvas&&n&&(r.canvas.style.background=n)},triggerUpdate:!1},nodeLabel:{default:"name",triggerUpdate:!1},nodePointerAreaPaint:{onChange:function(n,r){r.shadowGraph.nodeCanvasObject(n?function(i,s,o){return n(i,i.__indexColor,s,o)}:null),r.flushShadowCanvas&&r.flushShadowCanvas()},triggerUpdate:!1},linkPointerAreaPaint:{onChange:function(n,r){r.shadowGraph.linkCanvasObject(n?function(i,s,o){return n(i,i.__indexColor,s,o)}:null),r.flushShadowCanvas&&r.flushShadowCanvas()},triggerUpdate:!1},linkLabel:{default:"name",triggerUpdate:!1},linkHoverPrecision:{default:4,triggerUpdate:!1},minZoom:{default:.01,onChange:function(n,r){r.zoom.scaleExtent([n,r.zoom.scaleExtent()[1]])},triggerUpdate:!1},maxZoom:{default:1e3,onChange:function(n,r){r.zoom.scaleExtent([r.zoom.scaleExtent()[0],n])},triggerUpdate:!1},enableNodeDrag:{default:!0,triggerUpdate:!1},enableZoomInteraction:{default:!0,triggerUpdate:!1},enablePanInteraction:{default:!0,triggerUpdate:!1},enableZoomPanInteraction:{default:!0,triggerUpdate:!1},enablePointerInteraction:{default:!0,onChange:function(n,r){r.hoverObj=null},triggerUpdate:!1},autoPauseRedraw:{default:!0,triggerUpdate:!1},onNodeDrag:{default:function(){},triggerUpdate:!1},onNodeDragEnd:{default:function(){},triggerUpdate:!1},onNodeClick:{triggerUpdate:!1},onNodeRightClick:{triggerUpdate:!1},onNodeHover:{triggerUpdate:!1},onLinkClick:{triggerUpdate:!1},onLinkRightClick:{triggerUpdate:!1},onLinkHover:{triggerUpdate:!1},onBackgroundClick:{triggerUpdate:!1},onBackgroundRightClick:{triggerUpdate:!1},showPointerCursor:{default:!0,triggerUpdate:!1},onZoom:{triggerUpdate:!1},onZoomEnd:{triggerUpdate:!1},onRenderFramePre:{triggerUpdate:!1},onRenderFramePost:{triggerUpdate:!1}},e2e),aliases:{stopAnimation:"pauseAnimation"},methods:zf({graph2ScreenCoords:function(n,r,i){var s=Bo(n.canvas);return{x:r*s.k+s.x,y:i*s.k+s.y}},screen2GraphCoords:function(n,r,i){var s=Bo(n.canvas);return{x:(r-s.x)/s.k,y:(i-s.y)/s.k}},centerAt:function(n,r,i,s){if(!n.canvas)return null;if(r!==void 0||i!==void 0){var o=Object.assign({},r!==void 0?{x:r}:{},i!==void 0?{y:i}:{});return s?n.tweenGroup.add(new F9(a()).to(o,s).easing(lu.Quadratic.Out).onUpdate(c).onComplete(function(){n.tweenGroup.remove(this)}).start()):c(o),this}return a();function a(){var d=Bo(n.canvas);return{x:(n.width/2-d.x)/d.k,y:(n.height/2-d.y)/d.k}}function c(d){var h=d.x,g=d.y;n.zoom.translateTo(n.zoom.__baseElem,h===void 0?a().x:h,g===void 0?a().y:g),n.needsRedraw=!0}},zoom:function(n,r,i){if(!n.canvas)return null;if(r!==void 0)return i?n.tweenGroup.add(new F9({k:s()}).to({k:r},i).easing(lu.Quadratic.Out).onUpdate(function(a){var c=a.k;return o(c)}).onComplete(function(){n.tweenGroup.remove(this)}).start()):o(r),this;return s();function s(){return Bo(n.canvas).k}function o(a){n.zoom.scaleTo(n.zoom.__baseElem,a),n.needsRedraw=!0}},zoomToFit:function(n){for(var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,s=arguments.length,o=new Array(s>3?s-3:0),a=3;a<s;a++)o[a-3]=arguments[a];var c=this.getGraphBbox.apply(this,o);if(c){var d={x:(c.x[0]+c.x[1])/2,y:(c.y[0]+c.y[1])/2},h=Math.max(1e-12,Math.min(1e12,(n.width-i*2)/(c.x[1]-c.x[0]),(n.height-i*2)/(c.y[1]-c.y[0])));this.centerAt(d.x,d.y,r),this.zoom(h,r)}return this},getGraphBbox:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},i=vn(n.nodeVal),s=function(c){return Math.sqrt(Math.max(0,i(c)||1))*n.nodeRelSize},o=n.graphData.nodes.filter(r).map(function(a){return{x:a.x,y:a.y,r:s(a)}});return o.length?{x:[L9(o,function(a){return a.x-a.r}),z9(o,function(a){return a.x+a.r})],y:[L9(o,function(a){return a.y-a.r}),z9(o,function(a){return a.y+a.r})]}:null},pauseAnimation:function(n){return n.animationFrameRequestId&&(cancelAnimationFrame(n.animationFrameRequestId),n.animationFrameRequestId=null),this},resumeAnimation:function(n){return n.animationFrameRequestId||this._animationCycle(),this},_destructor:function(){this.pauseAnimation(),this.graphData({nodes:[],links:[]})}},t2e),stateInit:function(){return{lastSetZoom:1,zoom:dve(),forceGraph:new rv,shadowGraph:new rv().cooldownTicks(0).nodeColor("__indexColor").linkColor("__indexColor").isShadow(!0),colorTracker:new z_e,tweenGroup:new lz}},init:function(n,r){var i=this;n.innerHTML="";var s=document.createElement("div");s.classList.add("force-graph-container"),s.style.position="relative",n.appendChild(s),r.canvas=document.createElement("canvas"),r.backgroundColor&&(r.canvas.style.background=r.backgroundColor),s.appendChild(r.canvas),r.shadowCanvas=document.createElement("canvas");var o=r.canvas.getContext("2d"),a=r.shadowCanvas.getContext("2d",{willReadFrequently:!0}),c={x:-1e12,y:-1e12},d=function(){var p=null,_=window.devicePixelRatio,b=c.x>0&&c.y>0?a.getImageData(c.x*_,c.y*_,1,1):null;return b&&(p=r.colorTracker.lookup(b.data)),p};zs(r.canvas).call(w1e().subject(function(){if(!r.enableNodeDrag)return null;var g=d();return g&&g.type==="Node"?g.d:null}).on("start",function(g){var p=g.subject;p.__initialDragPos={x:p.x,y:p.y,fx:p.fx,fy:p.fy},g.active||(p.fx=p.x,p.fy=p.y),r.canvas.classList.add("grabbable")}).on("drag",function(g){var p=g.subject,_=p.__initialDragPos,b=g,x=Bo(r.canvas).k,C={x:_.x+(b.x-_.x)/x-p.x,y:_.y+(b.y-_.y)/x-p.y};["x","y"].forEach(function(j){return p["f".concat(j)]=p[j]=_[j]+(b[j]-_[j])/x}),!(!p.__dragged&&Zxe>=Math.sqrt(gve(["x","y"].map(function(j){return Math.pow(g[j]-_[j],2)}))))&&(r.forceGraph.d3AlphaTarget(.3).resetCountdown(),r.isPointerDragging=!0,p.__dragged=!0,r.onNodeDrag(p,C))}).on("end",function(g){var p=g.subject,_=p.__initialDragPos,b={x:p.x-_.x,y:p.y-_.y};_.fx===void 0&&(p.fx=void 0),_.fy===void 0&&(p.fy=void 0),delete p.__initialDragPos,r.forceGraph.d3AlphaTarget()&&r.forceGraph.d3AlphaTarget(0).resetCountdown(),r.canvas.classList.remove("grabbable"),r.isPointerDragging=!1,p.__dragged&&(delete p.__dragged,r.onNodeDragEnd(p,b))})),r.zoom(r.zoom.__baseElem=zs(r.canvas)),r.zoom.__baseElem.on("dblclick.zoom",null),r.zoom.filter(function(g){return!g.button&&r.enableZoomPanInteraction&&(g.type!=="wheel"||vn(r.enableZoomInteraction)(g))&&(g.type==="wheel"||vn(r.enablePanInteraction)(g))}).on("zoom",function(g){var p=g.transform;[o,a].forEach(function(_){Iz(_),_.translate(p.x,p.y),_.scale(p.k,p.k)}),r.isPointerDragging=!0,r.onZoom&&r.onZoom(zf(zf({},p),i.centerAt())),r.needsRedraw=!0}).on("end",function(g){r.isPointerDragging=!1,r.onZoomEnd&&r.onZoomEnd(zf(zf({},g.transform),i.centerAt()))}),I2(r),r.forceGraph.onNeedsRedraw(function(){return r.needsRedraw=!0}).onFinishUpdate(function(){Bo(r.canvas).k===r.lastSetZoom&&r.graphData.nodes.length&&(r.zoom.scaleTo(r.zoom.__baseElem,r.lastSetZoom=Jxe/Math.cbrt(r.graphData.nodes.length)),r.needsRedraw=!0)}),r.tooltip=new ibe(s),["pointermove","pointerdown"].forEach(function(g){return s.addEventListener(g,function(p){g==="pointerdown"&&(r.isPointerPressed=!0,r.pointerDownEvent=p),!r.isPointerDragging&&p.type==="pointermove"&&r.onBackgroundClick&&(p.pressure>0||r.isPointerPressed)&&(p.pointerType==="mouse"||p.movementX===void 0||[p.movementX,p.movementY].some(function(x){return Math.abs(x)>1}))&&(r.isPointerDragging=!0);var _=b(s);c.x=p.pageX-_.left,c.y=p.pageY-_.top;function b(x){var C=x.getBoundingClientRect(),j=window.pageXOffset||document.documentElement.scrollLeft,S=window.pageYOffset||document.documentElement.scrollTop;return{top:C.top+S,left:C.left+j}}},{passive:!0})}),s.addEventListener("pointerup",function(g){if(r.isPointerPressed){if(r.isPointerPressed=!1,r.isPointerDragging){r.isPointerDragging=!1;return}var p=[g,r.pointerDownEvent];requestAnimationFrame(function(){if(g.button===0)if(r.hoverObj){var _=r["on".concat(r.hoverObj.type,"Click")];_&&_.apply(void 0,[r.hoverObj.d].concat(p))}else r.onBackgroundClick&&r.onBackgroundClick.apply(r,p);if(g.button===2)if(r.hoverObj){var b=r["on".concat(r.hoverObj.type,"RightClick")];b&&b.apply(void 0,[r.hoverObj.d].concat(p))}else r.onBackgroundRightClick&&r.onBackgroundRightClick.apply(r,p)})}},{passive:!0}),s.addEventListener("contextmenu",function(g){return!r.onBackgroundRightClick&&!r.onNodeRightClick&&!r.onLinkRightClick?!0:(g.preventDefault(),!1)}),r.forceGraph(o),r.shadowGraph(a);var h=Uve(function(){vE(a,r.width,r.height),r.shadowGraph.linkWidth(function(p){return vn(r.linkWidth)(p)+r.linkHoverPrecision});var g=Bo(r.canvas);r.shadowGraph.globalScale(g.k).tickFrame()},Xxe);r.flushShadowCanvas=h.flush,(this._animationCycle=function g(){var p=!r.autoPauseRedraw||!!r.needsRedraw||r.forceGraph.isEngineRunning()||r.graphData.links.some(function(O){return O.__photons&&O.__photons.length});if(r.needsRedraw=!1,r.enablePointerInteraction){var _=r.isPointerDragging?null:d();if(_!==r.hoverObj){var b=r.hoverObj,x=b?b.type:null,C=_?_.type:null;if(x&&x!==C){var j=r["on".concat(x,"Hover")];j&&j(null,b.d)}if(C){var S=r["on".concat(C,"Hover")];S&&S(_.d,x===C?b.d:null)}r.tooltip.content(_&&vn(r["".concat(_.type.toLowerCase(),"Label")])(_.d)||null),r.canvas.classList[(_&&r["on".concat(C,"Click")]||!_&&r.onBackgroundClick)&&vn(r.showPointerCursor)(_==null?void 0:_.d)?"add":"remove"]("clickable"),r.hoverObj=_}p&&h()}if(p){vE(o,r.width,r.height);var E=Bo(r.canvas).k;r.onRenderFramePre&&r.onRenderFramePre(o,E),r.forceGraph.globalScale(E).tickFrame(),r.onRenderFramePost&&r.onRenderFramePost(o,E)}r.tweenGroup.update(),r.animationFrameRequestId=requestAnimationFrame(g)})()},update:function(n){}}),B2={exports:{}},F2,_E;function r2e(){if(_E)return F2;_E=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return F2=e,F2}var H2,bE;function i2e(){if(bE)return H2;bE=1;var e=r2e();function n(){}function r(){}return r.resetWarningCache=n,H2=function(){function i(a,c,d,h,g,p){if(p!==e){var _=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw _.name="Invariant Violation",_}}i.isRequired=i;function s(){return i}var o={array:i,bigint:i,bool:i,func:i,number:i,object:i,string:i,symbol:i,any:i,arrayOf:s,element:i,elementType:i,instanceOf:s,node:i,objectOf:s,oneOf:s,oneOfType:s,shape:s,exact:s,checkPropTypes:r,resetWarningCache:n};return o.PropTypes=o,o},H2}var xE;function s2e(){return xE||(xE=1,B2.exports=i2e()()),B2.exports}var o2e=s2e();const le=cd(o2e),n_={width:le.number,height:le.number,graphData:le.shape({nodes:le.arrayOf(le.object).isRequired,links:le.arrayOf(le.object).isRequired}),backgroundColor:le.string,nodeRelSize:le.number,nodeId:le.string,nodeLabel:le.oneOfType([le.string,le.func]),nodeVal:le.oneOfType([le.number,le.string,le.func]),nodeVisibility:le.oneOfType([le.bool,le.string,le.func]),nodeColor:le.oneOfType([le.string,le.func]),nodeAutoColorBy:le.oneOfType([le.string,le.func]),onNodeHover:le.func,onNodeClick:le.func,linkSource:le.string,linkTarget:le.string,linkLabel:le.oneOfType([le.string,le.func]),linkVisibility:le.oneOfType([le.bool,le.string,le.func]),linkColor:le.oneOfType([le.string,le.func]),linkAutoColorBy:le.oneOfType([le.string,le.func]),linkWidth:le.oneOfType([le.number,le.string,le.func]),linkCurvature:le.oneOfType([le.number,le.string,le.func]),linkDirectionalArrowLength:le.oneOfType([le.number,le.string,le.func]),linkDirectionalArrowColor:le.oneOfType([le.string,le.func]),linkDirectionalArrowRelPos:le.oneOfType([le.number,le.string,le.func]),linkDirectionalParticles:le.oneOfType([le.number,le.string,le.func]),linkDirectionalParticleSpeed:le.oneOfType([le.number,le.string,le.func]),linkDirectionalParticleOffset:le.oneOfType([le.number,le.string,le.func]),linkDirectionalParticleWidth:le.oneOfType([le.number,le.string,le.func]),linkDirectionalParticleColor:le.oneOfType([le.string,le.func]),onLinkHover:le.func,onLinkClick:le.func,dagMode:le.oneOf(["td","bu","lr","rl","zin","zout","radialin","radialout"]),dagLevelDistance:le.number,dagNodeFilter:le.func,onDagError:le.func,d3AlphaMin:le.number,d3AlphaDecay:le.number,d3VelocityDecay:le.number,warmupTicks:le.number,cooldownTicks:le.number,cooldownTime:le.number,onEngineTick:le.func,onEngineStop:le.func,getGraphBbox:le.func},Bz={zoomToFit:le.func,onNodeRightClick:le.func,onNodeDrag:le.func,onNodeDragEnd:le.func,onLinkRightClick:le.func,linkHoverPrecision:le.number,onBackgroundClick:le.func,onBackgroundRightClick:le.func,showPointerCursor:le.oneOfType([le.bool,le.func]),enablePointerInteraction:le.bool,enableNodeDrag:le.bool},i4={showNavInfo:le.bool,nodeOpacity:le.number,nodeResolution:le.number,nodeThreeObject:le.oneOfType([le.object,le.string,le.func]),nodeThreeObjectExtend:le.oneOfType([le.bool,le.string,le.func]),nodePositionUpdate:le.func,linkOpacity:le.number,linkResolution:le.number,linkCurveRotation:le.oneOfType([le.number,le.string,le.func]),linkMaterial:le.oneOfType([le.object,le.string,le.func]),linkThreeObject:le.oneOfType([le.object,le.string,le.func]),linkThreeObjectExtend:le.oneOfType([le.bool,le.string,le.func]),linkPositionUpdate:le.func,linkDirectionalArrowResolution:le.number,linkDirectionalParticleResolution:le.number,linkDirectionalParticleThreeObject:le.oneOfType([le.object,le.string,le.func]),forceEngine:le.oneOf(["d3","ngraph"]),ngraphPhysics:le.object,numDimensions:le.oneOf([1,2,3])},a2e=Object.assign({},n_,Bz,{linkLineDash:le.oneOfType([le.arrayOf(le.number),le.string,le.func]),nodeCanvasObjectMode:le.oneOfType([le.string,le.func]),nodeCanvasObject:le.func,nodePointerAreaPaint:le.func,linkCanvasObjectMode:le.oneOfType([le.string,le.func]),linkCanvasObject:le.func,linkPointerAreaPaint:le.func,linkDirectionalParticleCanvasObject:le.func,autoPauseRedraw:le.bool,minZoom:le.number,maxZoom:le.number,enableZoomInteraction:le.oneOfType([le.bool,le.func]),enablePanInteraction:le.oneOfType([le.bool,le.func]),onZoom:le.func,onZoomEnd:le.func,onRenderFramePre:le.func,onRenderFramePost:le.func});Object.assign({},n_,Bz,i4,{enableNavigationControls:le.bool,controlType:le.oneOf(["trackball","orbit","fly"]),rendererConfig:le.object,extraRenderers:le.arrayOf(le.shape({render:le.func.isRequired}))});Object.assign({},n_,i4,{nodeDesc:le.oneOfType([le.string,le.func]),linkDesc:le.oneOfType([le.string,le.func])});Object.assign({},n_,i4,{markerAttrs:le.object,yOffset:le.number,glScale:le.number});const s4=Rge(n2e,{methodNames:["emitParticle","d3Force","d3ReheatSimulation","stopAnimation","pauseAnimation","resumeAnimation","centerAt","zoom","zoomToFit","getGraphBbox","screen2GraphCoords","graph2ScreenCoords"]});s4.displayName="ForceGraph2D";s4.propTypes=a2e;const l2e={path:"M18.4395 5.5586c-.675 1.1664-1.352 2.3318-2.0274 3.498-.0366-.0155-.0742-.0286-.1113-.043-1.8249-.6957-3.484-.8-4.42-.787-1.8551.0185-3.3544.4643-4.2597.8203-.084-.1494-1.7526-3.021-2.0215-3.4864a1.1451 1.1451 0 0 0-.1406-.1914c-.3312-.364-.9054-.4859-1.379-.203-.475.282-.7136.9361-.3886 1.5019 1.9466 3.3696-.0966-.2158 1.9473 3.3593.0172.031-.4946.2642-1.3926 1.0177C2.8987 12.176.452 14.772 0 18.9902h24c-.119-1.1108-.3686-2.099-.7461-3.0683-.7438-1.9118-1.8435-3.2928-2.7402-4.1836a12.1048 12.1048 0 0 0-2.1309-1.6875c.6594-1.122 1.312-2.2559 1.9649-3.3848.2077-.3615.1886-.7956-.0079-1.1191a1.1001 1.1001 0 0 0-.8515-.5332c-.5225-.0536-.9392.3128-1.0488.5449zm-.0391 8.461c.3944.5926.324 1.3306-.1563 1.6503-.4799.3197-1.188.0985-1.582-.4941-.3944-.5927-.324-1.3307.1563-1.6504.4727-.315 1.1812-.1086 1.582.4941zM7.207 13.5273c.4803.3197.5506 1.0577.1563 1.6504-.394.5926-1.1038.8138-1.584.4941-.48-.3197-.5503-1.0577-.1563-1.6504.4008-.6021 1.1087-.8106 1.584-.4941z"},wE={path:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"},c2e={path:"M12.504 0c-.155 0-.315.008-.48.021-4.226.333-3.105 4.807-3.17 6.298-.076 1.092-.3 1.953-1.05 3.02-.885 1.051-2.127 2.75-2.716 4.521-.278.832-.41 1.684-.287 2.489a.424.424 0 00-.11.135c-.26.268-.45.6-.663.839-.199.199-.485.267-.797.4-.313.136-.658.269-.864.68-.09.189-.136.394-.132.602 0 .199.027.4.055.536.058.399.116.728.04.97-.249.68-.28 1.145-.106 1.484.174.334.535.47.94.601.81.2 1.91.135 2.774.6.926.466 1.866.67 2.616.47.526-.116.97-.464 1.208-.946.587-.003 1.23-.269 2.26-.334.699-.058 1.574.267 2.577.2.025.134.063.198.114.333l.003.003c.391.778 1.113 1.132 1.884 1.071.771-.06 1.592-.536 2.257-1.306.631-.765 1.683-1.084 2.378-1.503.348-.199.629-.469.649-.853.023-.4-.2-.811-.714-1.376v-.097l-.003-.003c-.17-.2-.25-.535-.338-.926-.085-.401-.182-.786-.492-1.046h-.003c-.059-.054-.123-.067-.188-.135a.357.357 0 00-.19-.064c.431-1.278.264-2.55-.173-3.694-.533-1.41-1.465-2.638-2.175-3.483-.796-1.005-1.576-1.957-1.56-3.368.026-2.152.236-6.133-3.544-6.139zm.529 3.405h.013c.213 0 .396.062.584.198.19.135.33.332.438.533.105.259.158.459.166.724 0-.02.006-.04.006-.06v.105a.086.086 0 01-.004-.021l-.004-.024a1.807 1.807 0 01-.15.706.953.953 0 01-.213.335.71.71 0 00-.088-.042c-.104-.045-.198-.064-.284-.133a1.312 1.312 0 00-.22-.066c.05-.06.146-.133.183-.198.053-.128.082-.264.088-.402v-.02a1.21 1.21 0 00-.061-.4c-.045-.134-.101-.2-.183-.333-.084-.066-.167-.132-.267-.132h-.016c-.093 0-.176.03-.262.132a.8.8 0 00-.205.334 1.18 1.18 0 00-.09.4v.019c.002.089.008.179.02.267-.193-.067-.438-.135-.607-.202a1.635 1.635 0 01-.018-.2v-.02a1.772 1.772 0 01.15-.768c.082-.22.232-.406.43-.533a.985.985 0 01.594-.2zm-2.962.059h.036c.142 0 .27.048.399.135.146.129.264.288.344.465.09.199.14.4.153.667v.004c.007.134.006.2-.002.266v.08c-.03.007-.056.018-.083.024-.152.055-.274.135-.393.2.012-.09.013-.18.003-.267v-.015c-.012-.133-.04-.2-.082-.333a.613.613 0 00-.166-.267.248.248 0 00-.183-.064h-.021c-.071.006-.13.04-.186.132a.552.552 0 00-.12.27.944.944 0 00-.023.33v.015c.012.135.037.2.08.334.046.134.098.2.166.268.01.009.02.018.034.024-.07.057-.117.07-.176.136a.304.304 0 01-.131.068 2.62 2.62 0 01-.275-.402 1.772 1.772 0 01-.155-.667 1.759 1.759 0 01.08-.668 1.43 1.43 0 01.283-.535c.128-.133.26-.2.418-.2zm1.37 1.706c.332 0 .733.065 1.216.399.293.2.523.269 1.052.468h.003c.255.136.405.266.478.399v-.131a.571.571 0 01.016.47c-.123.31-.516.643-1.063.842v.002c-.268.135-.501.333-.775.465-.276.135-.588.292-1.012.267a1.139 1.139 0 01-.448-.067 3.566 3.566 0 01-.322-.198c-.195-.135-.363-.332-.612-.465v-.005h-.005c-.4-.246-.616-.512-.686-.71-.07-.268-.005-.47.193-.6.224-.135.38-.271.483-.336.104-.074.143-.102.176-.131h.002v-.003c.169-.202.436-.47.839-.601.139-.036.294-.065.466-.065zm2.8 2.142c.358 1.417 1.196 3.475 1.735 4.473.286.534.855 1.659 1.102 3.024.156-.005.33.018.513.064.646-1.671-.546-3.467-1.089-3.966-.22-.2-.232-.335-.123-.335.59.534 1.365 1.572 1.646 2.757.13.535.16 1.104.021 1.67.067.028.135.06.205.067 1.032.534 1.413.938 1.23 1.537v-.043c-.06-.003-.12 0-.18 0h-.016c.151-.467-.182-.825-1.065-1.224-.915-.4-1.646-.336-1.77.465-.008.043-.013.066-.018.135-.068.023-.139.053-.209.064-.43.268-.662.669-.793 1.187-.13.533-.17 1.156-.205 1.869v.003c-.02.334-.17.838-.319 1.35-1.5 1.072-3.58 1.538-5.348.334a2.645 2.645 0 00-.402-.533 1.45 1.45 0 00-.275-.333c.182 0 .338-.03.465-.067a.615.615 0 00.314-.334c.108-.267 0-.697-.345-1.163-.345-.467-.931-.995-1.788-1.521-.63-.4-.986-.87-1.15-1.396-.165-.534-.143-1.085-.015-1.645.245-1.07.873-2.11 1.274-2.763.107-.065.037.135-.408.974-.396.751-1.14 2.497-.122 3.854a8.123 8.123 0 01.647-2.876c.564-1.278 1.743-3.504 1.836-5.268.048.036.217.135.289.202.218.133.38.333.59.465.21.201.477.335.876.335.039.003.075.006.11.006.412 0 .73-.134.997-.268.29-.134.52-.334.74-.4h.005c.467-.135.835-.402 1.044-.7zm2.185 8.958c.037.6.343 1.245.882 1.377.588.134 1.434-.333 1.791-.765l.211-.01c.315-.007.577.01.847.268l.003.003c.208.199.305.53.391.876.085.4.154.78.409 1.066.486.527.645.906.636 1.14l.003-.007v.018l-.003-.012c-.015.262-.185.396-.498.595-.63.401-1.746.712-2.457 1.57-.618.737-1.37 1.14-2.036 1.191-.664.053-1.237-.2-1.574-.898l-.005-.003c-.21-.4-.12-1.025.056-1.69.176-.668.428-1.344.463-1.897.037-.714.076-1.335.195-1.814.12-.465.308-.797.641-.984l.045-.022zm-10.814.049h.01c.053 0 .105.005.157.014.376.055.706.333 1.023.752l.91 1.664.003.003c.243.533.754 1.064 1.189 1.637.434.598.77 1.131.729 1.57v.006c-.057.744-.48 1.148-1.125 1.294-.645.135-1.52.002-2.395-.464-.968-.536-2.118-.469-2.857-.602-.369-.066-.61-.2-.723-.4-.11-.2-.113-.602.123-1.23v-.004l.002-.003c.117-.334.03-.752-.027-1.118-.055-.401-.083-.71.043-.94.16-.334.396-.4.69-.533.294-.135.64-.202.915-.47h.002v-.002c.256-.268.445-.601.668-.838.19-.201.38-.336.663-.336zm7.159-9.074c-.435.201-.945.535-1.488.535-.542 0-.97-.267-1.28-.466-.154-.134-.28-.268-.373-.335-.164-.134-.144-.333-.074-.333.109.016.129.134.199.2.096.066.215.2.36.333.292.2.68.467 1.167.467.485 0 1.053-.267 1.398-.466.195-.135.445-.334.648-.467.156-.136.149-.267.279-.267.128.016.034.134-.147.332a8.097 8.097 0 01-.69.468zm-1.082-1.583V5.64c-.006-.02.013-.042.029-.05.074-.043.18-.027.26.004.063 0 .16.067.15.135-.006.049-.085.066-.135.066-.055 0-.092-.043-.141-.068-.052-.018-.146-.008-.163-.065zm-.551 0c-.02.058-.113.049-.166.066-.047.025-.086.068-.14.068-.05 0-.13-.02-.136-.068-.01-.066.088-.133.15-.133.08-.031.184-.047.259-.005.019.009.036.03.03.05v.02h.003z"},x3=Wn(),Hf={gateway:"#22c55e",device:"#3b82f6",mesh:"#a855f7",host:"#6b7280"},SE={gateway:14,device:10,mesh:10,host:8};function u2e(e){if(e.length===0)return e;const n=[{type:"device",radius:120},{type:"mesh",radius:190},{type:"host",radius:265}],r=e.map(i=>i.data.type==="gateway"?{...i,x:0,y:0,fx:0,fy:0}:{...i});for(const{type:i,radius:s}of n){const o=r.filter(c=>c.data.type===i),a=o.length;a!==0&&o.forEach((c,d)=>{const h=-Math.PI/2+Math.PI*2/a*d;c.x=Math.cos(h)*s,c.y=Math.sin(h)*s})}return r}const f2e="M0 3.449L9.75 2.1V11.551H0zm10.949-1.564L24 0v11.551H10.949zM0 12.449h9.75v9.451L0 20.551zm10.949-.898H24V24l-13.051-1.869z";function Jh(e,n,r="0 0 24 24"){const i=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${r}" fill="${n}"><path d="${e}"/></svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`}function Zh(e){const n=new Image;return n.src=e,n}const I1={windows:Zh(Jh(f2e,"#ffffff")),macos:Zh(Jh(wE.path,"#ffffff")),linux:Zh(Jh(c2e.path,"#ffffff")),android:Zh(Jh(l2e.path,"#ffffff")),ios:Zh(Jh(wE.path,"#ffffff"))};function d2e(e){if(!e)return null;const n=e.toLowerCase();return n.includes("windows")?"windows":n.includes("macos")||n.includes("mac os")||n.includes("darwin")?"macos":n.includes("android")?"android":n.includes("ios")||n.includes("iphone")||n.includes("ipad")?"ios":n.includes("linux")||n.includes("ubuntu")||n.includes("debian")||n.includes("fedora")||n.includes("arch")||n.includes("centos")||n.includes("rhel")||n.includes("mint")||n.includes("manjaro")||n.includes("suse")||n.includes("alpine")?"linux":null}function h2e(e){if("platform"in e&&typeof e.platform=="string"&&I1[e.platform])return I1[e.platform];if("osVersion"in e){const n=d2e(e.osVersion);if(n&&I1[n])return I1[n]}return null}function p2e({node:e,onClose:n,onDeploy:r}){if(!e)return null;const i=e.type==="gateway"?Ms:e.type==="device"?"platform"in e&&(e.platform==="android"||e.platform==="ios")?p5:gs:e.type==="mesh"?kr:"isRouter"in e&&e.isRouter?pv:gs,s=Hf[e.type]??"#6b7280",o="sshReachable"in e&&e.sshReachable&&"agentStatus"in e&&e.agentStatus!=="running"&&"ip"in e;return f.jsx(Cu,{open:!!e,onOpenChange:a=>!a&&n(),children:f.jsxs(fc,{className:"sm:max-w-md",children:[f.jsx(Ga,{children:f.jsxs(Ya,{className:"flex items-center gap-2",children:[f.jsx("div",{className:"h-8 w-8 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${s}22`,color:s},children:f.jsx(i,{className:"h-4 w-4"})}),f.jsxs("div",{className:"min-w-0",children:[f.jsx("div",{className:"truncate",children:e.name}),f.jsx("div",{className:"text-xs font-normal text-muted-foreground capitalize",children:"isRouter"in e&&e.isRouter?"router":e.type})]})]})}),f.jsxs("div",{className:"space-y-3 text-sm",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${e.online?"bg-green-500":"bg-red-500"}`}),f.jsx("span",{children:e.online?"Online":"Offline"})]}),"platform"in e&&e.platform&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"Platform"}),f.jsx("span",{className:"flex items-center gap-1.5 capitalize",children:e.platform})]}),"ip"in e&&e.ip&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"IP Address"}),f.jsx("code",{className:"text-xs bg-muted px-2 py-0.5 rounded",children:e.ip})]}),"isRouter"in e&&e.isRouter&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"Role"}),f.jsx(ln,{variant:"secondary",className:"text-[10px]",children:"Router"})]}),"version"in e&&e.version&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"Version"}),f.jsxs(ln,{variant:"secondary",className:"font-mono text-[10px]",children:["v",e.version]})]}),"osVersion"in e&&e.osVersion&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"OS"}),f.jsx("span",{className:"text-xs",children:e.osVersion})]}),"mac"in e&&e.mac&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"MAC Address"}),f.jsx("code",{className:"text-xs bg-muted px-2 py-0.5 rounded",children:e.mac})]}),"providers"in e&&e.providers.length>0&&f.jsxs("div",{children:[f.jsx("span",{className:"text-muted-foreground block mb-1.5",children:"Providers"}),f.jsx("div",{className:"flex flex-wrap gap-1",children:e.providers.map(a=>f.jsxs(ln,{variant:"outline",className:"text-[10px]",children:[f.jsx(su,{className:"h-2.5 w-2.5 mr-1"}),a]},a))})]}),"openPorts"in e&&e.openPorts.length>0&&f.jsxs("div",{children:[f.jsx("span",{className:"text-muted-foreground block mb-1.5",children:"Open Ports"}),f.jsx("div",{className:"flex flex-wrap gap-1",children:e.openPorts.map(a=>f.jsx(ln,{variant:"outline",className:"text-[10px] font-mono",children:a},a))})]}),"sshReachable"in e&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"SSH"}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx(h5,{className:"h-3 w-3"}),e.sshReachable?"Reachable":"Not reachable"]})]}),"agentStatus"in e&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"Agent"}),f.jsx(ln,{variant:e.agentStatus==="running"?"default":"secondary",className:"text-[10px]",children:e.agentStatus})]}),"registeredAt"in e&&e.registeredAt&&f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("span",{className:"text-muted-foreground",children:"Connected"}),f.jsx("span",{className:"text-xs",children:new Date(e.registeredAt).toLocaleString()})]}),"agentStatus"in e&&e.agentStatus==="running"&&"ip"in e&&f.jsx($e,{size:"sm",variant:"outline",className:"w-full mt-2",asChild:!0,children:f.jsxs("a",{href:`http://${e.ip}:8000`,target:"_blank",rel:"noopener noreferrer",children:[f.jsx(kr,{className:"h-3.5 w-3.5 mr-1.5"}),"Open Dashboard"]})}),o&&r&&f.jsxs($e,{size:"sm",variant:"default",className:"w-full mt-2",onClick:()=>{r(e.ip),n()},children:[f.jsx(hw,{className:"h-3.5 w-3.5 mr-1.5"}),"Deploy Node"]})]})]})})}function m2e({ip:e,token:n,onClose:r}){const[i,s]=y.useState(""),[o,a]=y.useState("password"),[c,d]=y.useState(null),[h,g]=y.useState(!1);if(!e)return null;const p=async()=>{g(!0);try{const _={"Content-Type":"application/json"};n&&(_.Authorization=`Bearer ${n}`);const b=await fetch(`${x3}/api/network/deploy`,{method:"POST",headers:_,body:JSON.stringify({ip:e,username:i,authMethod:o})});if(b.ok){const x=await b.json();d(x)}}catch{}finally{g(!1)}};return f.jsx(Cu,{open:!!e,onOpenChange:_=>{_||(d(null),s(""),r())},children:f.jsxs(fc,{className:"sm:max-w-lg",children:[f.jsx(Ga,{children:f.jsxs(Ya,{className:"flex items-center gap-2",children:[f.jsx(hw,{className:"h-4 w-4"}),"Deploy Jait Node to ",e]})}),c?f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("span",{className:"text-sm font-medium",children:"Instructions"}),f.jsx("ol",{className:"text-sm text-muted-foreground space-y-1 list-decimal list-inside",children:c.instructions.map((_,b)=>f.jsx("li",{children:_},b))})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("span",{className:"text-sm font-medium",children:"SSH Command"}),f.jsx("pre",{className:"text-xs bg-muted p-3 rounded-md overflow-x-auto whitespace-pre-wrap break-all",children:c.sshCommand})]}),f.jsx($e,{variant:"outline",className:"w-full",onClick:()=>{navigator.clipboard.writeText(c.sshCommand)},children:"Copy Command"})]}):f.jsxs("div",{className:"space-y-4",children:[f.jsxs("div",{className:"space-y-2",children:[f.jsx("label",{className:"text-sm text-muted-foreground",children:"SSH Username"}),f.jsx("input",{type:"text",value:i,onChange:_=>s(_.target.value),placeholder:"e.g. pi, ubuntu, root",className:"w-full px-3 py-2 text-sm rounded-md border bg-background"})]}),f.jsxs("div",{className:"space-y-2",children:[f.jsx("label",{className:"text-sm text-muted-foreground",children:"Auth Method"}),f.jsxs("div",{className:"flex gap-2",children:[f.jsx($e,{size:"sm",variant:o==="password"?"default":"outline",onClick:()=>a("password"),children:"Password"}),f.jsx($e,{size:"sm",variant:o==="key"?"default":"outline",onClick:()=>a("key"),children:"SSH Key"})]})]}),f.jsxs($e,{className:"w-full",onClick:()=>void p(),disabled:!i.trim()||h,children:[h?f.jsx(kt,{className:"h-4 w-4 mr-2 animate-spin"}):f.jsx(hw,{className:"h-4 w-4 mr-2"}),"Generate Deploy Script"]})]})]})})}function g2e({token:e}){const n=y.useRef(null),r=y.useRef(void 0),[i,s]=y.useState({width:0,height:0}),[o,a]=y.useState(null),[c,d]=y.useState(!1),[h,g]=y.useState(null),[p,_]=y.useState(null),[b,x]=y.useState(null),[C,j]=y.useState(null),S=y.useCallback(()=>{const B=r.current;if(!B||i.width<=0||i.height<=0)return;const F=Math.max(48,Math.min(96,Math.min(i.width,i.height)*.08)),W=i.width<768?.95:.85;B.zoomToFit(250,F),setTimeout(()=>{const z=B.zoom();typeof z=="number"&&z<W&&B.zoom(W,250)},300)},[i.height,i.width]),E=y.useCallback(()=>{const B={};return e&&(B.Authorization=`Bearer ${e}`),B},[e]),O=y.useRef(""),N=y.useCallback(async()=>{try{const B=await fetch(`${x3}/api/network/topology`,{headers:E()});if(B.ok){const F=await B.text();F!==O.current&&(O.current=F,a(JSON.parse(F))),_(null)}}catch(B){_(B instanceof Error?B.message:"Failed to fetch topology")}},[E]),T=y.useCallback(async()=>{d(!0),_(null);try{const B=await fetch(`${x3}/api/network/scan`,{method:"POST",headers:{...E(),"Content-Type":"application/json"},body:JSON.stringify({deep:!0})});if(!B.ok)throw new Error(`Scan failed: ${B.status}`);await N()}catch(B){_(B instanceof Error?B.message:"Scan failed")}finally{d(!1)}},[E,N]);y.useEffect(()=>{N();const B=setInterval(()=>void N(),15e3);return()=>clearInterval(B)},[N]),y.useEffect(()=>{const B=n.current;if(!B)return;const F=new ResizeObserver(([W])=>{W&&s({width:W.contentRect.width,height:W.contentRect.height})});return F.observe(B),()=>F.disconnect()},[]);const P=y.useMemo(()=>{if(!o)return{nodes:[],links:[]};const B=[],F=[];B.push({id:o.gateway.id,data:o.gateway});for(const W of o.devices)B.push({id:W.id,data:W}),F.push({source:W.id,target:"gateway",type:"connected"});for(const W of o.meshNodes)B.push({id:W.id,data:W}),F.push({source:W.id,target:"gateway",type:"connected"});for(const W of o.hosts)W.ip!==o.gateway.ip&&(B.push({id:W.id,data:W}),F.push({source:W.id,target:"gateway",type:"scanned"}));return{nodes:u2e(B),links:F}},[o]),D=y.useRef(!1);y.useEffect(()=>{r.current&&P.nodes.length>0&&i.width>0&&i.height>0&&!D.current&&(D.current=!0,requestAnimationFrame(()=>{S()}))},[i.height,i.width,S,P.nodes.length]);const H=y.useCallback((B,F,W)=>{const{data:z}=B,V=B.x??0,A=B.y??0,U=SE[z.type]??8,K=Hf[z.type]??"#6b7280",Y=b===B.id,$=(h==null?void 0:h.id)===z.id;z.type==="gateway"&&(F.beginPath(),F.arc(V,A,U+4,0,2*Math.PI),F.fillStyle=`${K}33`,F.fill()),z.type==="host"&&"sshReachable"in z&&z.sshReachable&&(F.beginPath(),F.arc(V,A,U+3,0,2*Math.PI),F.strokeStyle="#f59e0b55",F.lineWidth=1.5/W,F.stroke()),(Y||$)&&(F.beginPath(),F.arc(V,A,U+2.5,0,2*Math.PI),F.strokeStyle=K,F.lineWidth=1.5/W,F.stroke()),F.beginPath(),F.arc(V,A,U,0,2*Math.PI),F.fillStyle=K,F.fill(),z.online&&(F.beginPath(),F.arc(V+U*.65,A-U*.65,2.5,0,2*Math.PI),F.fillStyle="#22c55e",F.fill(),F.strokeStyle="#0a0a0a",F.lineWidth=.5,F.stroke());const R=h2e(z);if(R!=null&&R.complete&&R.naturalWidth>0){const X=U*1.1;F.drawImage(R,V-X/2,A-X/2,X,X)}const Z=Math.max(3.5,10/W);F.font=`${Z}px -apple-system, BlinkMacSystemFont, sans-serif`,F.textAlign="center",F.textBaseline="top",F.fillStyle=Y?"#ffffff":"#a1a1aa";const L=z.name.length>20?z.name.slice(0,18)+"…":z.name;F.fillText(L,V,A+U+3),z.type==="gateway"?(F.font=`bold ${Math.max(3,8/W)}px -apple-system, BlinkMacSystemFont, sans-serif`,F.fillStyle="#22c55e",F.fillText("GATEWAY",V,A+U+3+Z+2)):z.type==="host"&&"isRouter"in z&&z.isRouter&&(F.font=`bold ${Math.max(3,8/W)}px -apple-system, BlinkMacSystemFont, sans-serif`,F.fillStyle="#f59e0b",F.fillText("ROUTER",V,A+U+3+Z+2));const Q="providers"in z&&Array.isArray(z.providers)?z.providers:[];if(Q.length>0){const X=Math.max(2.5,7/W);F.font=`${X}px -apple-system, BlinkMacSystemFont, sans-serif`,F.fillStyle="#a855f7";const ie=z.type==="gateway"?Z*2+6:Z+5;F.fillText(Q.join(" · "),V,A+U+3+ie)}if(z.type==="host"&&"openPorts"in z&&z.openPorts.length>0){const X=z.openPorts.length,ie=Math.max(2.5,7/W);F.font=`bold ${ie}px -apple-system, BlinkMacSystemFont, sans-serif`,F.fillStyle="#3b82f6",F.textAlign="center",F.textBaseline="middle";const se=V-U*.65,ce=A-U*.65;F.beginPath(),F.arc(se,ce,3.5,0,2*Math.PI),F.fillStyle="#3b82f6",F.fill(),F.fillStyle="#ffffff",F.fillText(String(X),se,ce)}},[b,h]),J=y.useCallback((B,F)=>{const W=B.source,z=B.target;!(W!=null&&W.x)||!(z!=null&&z.x)||(F.beginPath(),F.moveTo(W.x,W.y),F.lineTo(z.x,z.y),B.type==="connected"?(F.strokeStyle="#3b82f644",F.lineWidth=1.5,F.setLineDash([])):(F.strokeStyle="#6b728033",F.lineWidth=.5,F.setLineDash([4,4])),F.stroke(),F.setLineDash([]))},[]),I=o?1+o.devices.length+o.meshNodes.length+o.hosts.length:0;return f.jsxs("div",{className:"h-full flex flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between gap-2 border-b px-4 py-3 shrink-0",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx(pv,{className:"h-4 w-4 text-primary"}),f.jsx("h2",{className:"text-sm font-semibold",children:"Network"}),I>0&&f.jsxs(ln,{variant:"secondary",className:"w-[4.75rem] justify-center px-1 text-[10px] tabular-nums",children:[I," ",I===1?"node":"nodes"]}),(o==null?void 0:o.scannedAt)&&f.jsxs("span",{className:"text-[10px] text-muted-foreground hidden sm:inline",children:["Last scan: ",new Date(o.scannedAt).toLocaleTimeString()]})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[f.jsxs($e,{size:"sm",variant:"outline",className:"h-7 px-2 text-xs sm:px-2.5",onClick:()=>void N(),children:[f.jsx(du,{className:"h-3 w-3 sm:mr-1"}),f.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),f.jsx($e,{size:"sm",variant:"default",className:"h-7 px-2 text-xs sm:px-2.5",onClick:()=>void T(),disabled:c,children:c?f.jsxs(f.Fragment,{children:[f.jsx(kt,{className:"h-3 w-3 animate-spin sm:mr-1"}),f.jsx("span",{className:"hidden sm:inline",children:"Scanning..."})]}):f.jsxs(f.Fragment,{children:[f.jsx(Lp,{className:"h-3 w-3 sm:mr-1"}),f.jsx("span",{className:"hidden sm:inline",children:o!=null&&o.scannedAt?"Rescan Network":"Discover Devices"})]})})]})]}),p&&f.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-500 bg-red-500/10 px-4 py-2",children:[f.jsx(Mr,{className:"h-3.5 w-3.5 shrink-0"}),p]}),f.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 border-b text-[10px] text-muted-foreground shrink-0 flex-wrap",children:[f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Hf.gateway}}),"Gateway"]}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Hf.device}}),"Connected Device"]}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Hf.mesh}}),"Mesh Node"]}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:Hf.host}}),"Network Host"]}),f.jsxs("span",{className:"flex items-center gap-1.5",children:[f.jsx("span",{className:"h-2.5 w-2.5 rounded-full border border-amber-500/50",style:{backgroundColor:"transparent"}}),"SSH Available"]})]}),f.jsx("div",{ref:n,className:"flex-1 min-h-0 relative bg-background",children:P.nodes.length>0&&i.width>0&&i.height>0?f.jsx(s4,{ref:r,width:i.width,height:i.height,graphData:P,nodeId:"id",nodeCanvasObject:H,nodePointerAreaPaint:(B,F,W)=>{const z=SE[B.data.type]??6;W.beginPath(),W.arc(B.x??0,B.y??0,z+4,0,2*Math.PI),W.fillStyle=F,W.fill()},linkCanvasObject:J,onNodeClick:B=>g(B.data),onNodeHover:B=>x((B==null?void 0:B.id)??null),cooldownTicks:80,d3VelocityDecay:.3,d3AlphaDecay:.02,minZoom:.65,maxZoom:3,enableNodeDrag:!0,enableZoomInteraction:!0,enablePanInteraction:!0,backgroundColor:"transparent"}):o?f.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[f.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center",children:f.jsx(gs,{className:"h-6 w-6 text-muted-foreground"})}),f.jsx("div",{className:"text-sm font-medium",children:"No devices found"}),f.jsx("div",{className:"text-xs text-muted-foreground max-w-xs text-center",children:"Run a network scan to discover devices on your local network."}),f.jsxs($e,{size:"sm",onClick:()=>void T(),className:"mt-2",children:[f.jsx(Lp,{className:"h-3.5 w-3.5 mr-1.5"}),"Discover Devices"]})]}):f.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[f.jsx(kt,{className:"h-8 w-8 animate-spin text-muted-foreground"}),f.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading network topology..."})]})}),f.jsx(p2e,{node:h,onClose:()=>g(null),onDeploy:B=>j(B)}),f.jsx(m2e,{ip:C,token:e,onClose:()=>j(null)})]})}function y2e({platform:e,className:n}){switch(e){case"electron":return f.jsx(gs,{className:n??"h-4 w-4"});case"react-native":return f.jsx(p5,{className:n??"h-4 w-4"});default:return f.jsx(kr,{className:n??"h-4 w-4"})}}function CE({device:e,isLocal:n,isConnected:r,isLoading:i,onConnect:s}){const o=!n&&e.capabilities.includes("screen-share");return f.jsxs("div",{className:`flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm transition-colors
|
|
756
756
|
${r?"bg-green-500/10 border border-green-500/30":"bg-muted/50 hover:bg-muted/80"}`,children:[f.jsx("div",{className:`h-9 w-9 rounded-lg flex items-center justify-center shrink-0
|
|
757
|
-
${r?"bg-green-500/15 text-green-500":n?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:f.jsx(g2e,{platform:e.platform,className:"h-4.5 w-4.5"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"font-medium truncate text-[13px]",children:[e.name,n&&f.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(you)"})]}),f.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:[e.platform,r&&f.jsx("span",{className:"text-green-500 ml-1",children:"· connected"})]})]}),o&&!r&&f.jsx($e,{size:"sm",variant:"outline",className:"h-7 text-xs px-2.5 shrink-0",onClick:s,disabled:i,children:i?f.jsx(kt,{className:"h-3 w-3 animate-spin"}):f.jsxs(f.Fragment,{children:[f.jsx(fB,{className:"h-3 w-3 mr-1"}),"Connect"]})}),r&&f.jsxs(ln,{className:"bg-green-500/15 text-green-500 border-green-500/30 shrink-0 text-[10px]",children:[f.jsx(uB,{className:"h-2.5 w-2.5 mr-0.5"})," live"]})]})}function y2e({stream:e}){const n=y.useRef(null),r=y.useRef(null),[i,s]=y.useState(!1);y.useEffect(()=>{console.log(`[screen-share] RemoteScreen: stream=${!!e} tracks=${e==null?void 0:e.getTracks().map(a=>`${a.kind}:${a.readyState}`).join(",")} videoRef=${!!n.current}`),n.current&&e&&(n.current.srcObject=e)},[e]);const o=y.useCallback(()=>{const a=r.current;a&&(document.fullscreenElement?(document.exitFullscreen(),s(!1)):(a.requestFullscreen(),s(!0)))},[]);return y.useEffect(()=>{const a=()=>s(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",a),()=>document.removeEventListener("fullscreenchange",a)},[]),e?f.jsxs("div",{ref:r,className:"relative flex-1 group bg-black rounded-lg overflow-hidden",children:[f.jsx("video",{ref:n,autoPlay:!0,playsInline:!0,muted:!0,className:"w-full h-full object-contain bg-black"}),f.jsx("button",{onClick:o,className:"absolute top-2 right-2 p-1.5 rounded bg-black/60 text-white opacity-0 group-hover:opacity-100 transition-opacity",children:i?f.jsx(oB,{className:"h-3.5 w-3.5"}):f.jsx(rB,{className:"h-3.5 w-3.5"})})]}):f.jsx("div",{className:"flex-1 bg-black/20 rounded-lg flex items-center justify-center text-muted-foreground",children:f.jsxs("div",{className:"text-center",children:[f.jsx(lB,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),f.jsx("p",{className:"text-sm font-medium",children:"Waiting for remote screen…"}),f.jsx("p",{className:"text-xs mt-1 opacity-60",children:"The remote device is preparing to share"})]})})}function v2e({screenShare:e}){var o;const n=e.session,r=e.isViewer||e.isHost;console.log(`[screen-share] Panel render: isHost=${e.isHost} isViewer=${e.isViewer} isConnected=${r} remoteStream=${!!e.remoteStream} localStream=${!!e.localStream}`);const i=e.devices.filter(a=>a.id!==e.localDeviceId),s=e.devices.find(a=>a.id===e.localDeviceId);return f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.pendingShareRequest&&!r&&f.jsx("div",{className:"p-3 border-b bg-amber-500/5",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"h-9 w-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0 mt-0.5",children:f.jsx(O8,{className:"h-4.5 w-4.5"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-sm font-medium",children:"Screen share requested"}),f.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"A remote device wants to view your screen."}),f.jsxs("div",{className:"flex gap-2 mt-2",children:[f.jsxs($e,{size:"sm",className:"h-7 text-xs px-3",onClick:()=>e.acceptPendingShare(),children:[f.jsx(O8,{className:"h-3 w-3 mr-1"}),"Share Screen"]}),f.jsx($e,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2 text-muted-foreground",onClick:()=>e.rejectPendingShare(),children:"Decline"})]})]})]})}),r?f.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[f.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b bg-muted/20 shrink-0",children:[f.jsxs(ln,{className:"bg-green-500/15 text-green-500 border-green-500/30 text-[10px]",children:[f.jsx(pv,{className:"h-2.5 w-2.5 mr-1"})," Live"]}),f.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:e.connectedDeviceId?((o=e.devices.find(a=>a.id===e.connectedDeviceId))==null?void 0:o.name)??e.connectedDeviceId:"Connected"}),n&&f.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[n.transport.routeMode.toUpperCase()," · ",n.transport.avgLatencyMs,"ms"]}),f.jsxs($e,{variant:"ghost",size:"sm",className:"h-6 text-xs px-2 text-destructive hover:text-destructive",onClick:()=>e.disconnect(),children:[f.jsx(Mr,{className:"h-3 w-3 mr-1"}),"Disconnect"]})]}),e.error&&f.jsx("div",{className:"mx-2 p-2 rounded-md bg-red-500/10 text-red-500 text-xs border border-red-500/20",children:e.error}),e.isHost?f.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:f.jsxs("div",{className:"text-center",children:[f.jsx(jp,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),f.jsx("p",{className:"text-sm font-medium",children:"Sharing your screen"}),f.jsx("p",{className:"text-xs mt-1 opacity-60",children:"A remote device is viewing this screen"}),n&&f.jsxs("p",{className:"text-xs mt-2 opacity-50",children:[f.jsx(mw,{className:"h-3 w-3 inline mr-0.5"}),n.viewers.length," viewer",n.viewers.length!==1?"s":""]})]})}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex-1 min-h-0 p-2",children:f.jsx(y2e,{stream:e.remoteStream})}),n&&f.jsxs("div",{className:"flex items-center gap-3 px-3 py-1.5 border-t text-[10px] text-muted-foreground shrink-0",children:[f.jsxs("span",{children:["Session ",n.id.slice(0,8)]}),f.jsx("span",{children:"·"}),f.jsxs("span",{children:["ICE: ",n.transport.iceConnectionState]}),f.jsx("span",{children:"·"}),f.jsxs("span",{children:[f.jsx(mw,{className:"h-2.5 w-2.5 inline mr-0.5"}),n.viewers.length," viewer",n.viewers.length!==1?"s":""]})]})]})]}):f.jsxs("div",{className:"flex flex-col gap-3 p-3 overflow-y-auto",children:[e.error&&f.jsx("div",{className:"p-2.5 rounded-md bg-red-500/10 text-red-500 text-xs border border-red-500/20",children:e.error}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Remote Devices"}),f.jsx($e,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>e.refreshState(),children:f.jsx(du,{className:"h-3 w-3"})})]}),i.length===0?f.jsxs("div",{className:"py-6 text-center",children:[f.jsx(jp,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/40"}),f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"No remote devices found"}),f.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1 max-w-[200px] mx-auto",children:"Open Jait on another device (desktop app or mobile) to connect to it"})]}):f.jsx("div",{className:"space-y-1.5",children:i.map(a=>f.jsx(CE,{device:a,isLocal:!1,isConnected:!1,isLoading:e.loading&&e.connectedDeviceId===a.id,onConnect:()=>e.requestRemoteShare(a.id)},a.id))})]}),s&&f.jsxs("div",{className:"space-y-1.5",children:[f.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"This Device"}),f.jsx(CE,{device:s,isLocal:!0,isConnected:!1,isLoading:!1,onConnect:()=>{}})]}),f.jsxs("div",{className:"px-2 py-2 rounded-md bg-muted/30 text-[11px] text-muted-foreground",children:[f.jsx("strong",{children:"Tip:"})," Ask your agent to connect to a device — e.g. “Show me my desktop screen”"]})]})]})}function qr(){return typeof window<"u"&&window.jaitDesktop?"electron":typeof window<"u"&&"Capacitor"in window?"capacitor":"web"}let fo=null;function w3(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}async function _2e(){var o;if(fo)return fo;const e=qr(),n=`jait-device-id-${e}`,r="deviceId";if(e==="electron"&&((o=window.jaitDesktop)!=null&&o.getSetting)){const a=window.jaitDesktop,c=await a.getSetting(r,null);if(c)return fo=c,localStorage.setItem(n,c),c;const d=localStorage.getItem(n);if(d)return fo=d,await a.setSetting(r,d),d;const h=w3(e);return fo=h,localStorage.setItem(n,h),await a.setSetting(r,h),h}const i=localStorage.getItem(n);if(i)return fo=i,i;const s=w3(e);return fo=s,localStorage.setItem(n,s),s}function o4(){if(fo)return fo;const e=qr(),n=`jait-device-id-${e}`,r=localStorage.getItem(n);if(r)return fo=r,r;const i=w3(e);return fo=i,localStorage.setItem(n,i),i}const Qh=Wn(),b2e=Pg(),Fz="jait-screen-share-auto-approve";function Hz(){try{const e=localStorage.getItem(Fz);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}function x2e(e){const n=Hz();n.add(e),localStorage.setItem(Fz,JSON.stringify([...n]))}function w2e(){const e=qr(),n=navigator.userAgent;return e==="electron"?`Jait Desktop (${navigator.platform})`:e==="capacitor"?"Jait Mobile":n.includes("Chrome")?`Chrome (${navigator.platform})`:n.includes("Firefox")?`Firefox (${navigator.platform})`:n.includes("Safari")?`Safari (${navigator.platform})`:`Browser (${navigator.platform})`}const S2e=[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}];function C2e(e={}){const{token:n}=e,[r,i]=y.useState({session:null,devices:[],localDeviceId:null,isHost:!1,isViewer:!1,isActive:!1,loading:!1,error:null,connectedDeviceId:null,pendingShareRequest:null}),s=y.useRef(null),o=y.useRef(null),a=y.useRef(null),c=y.useRef(null),d=y.useRef(o4()),h=y.useRef(null),g=y.useCallback(()=>{const N={"Content-Type":"application/json"};return n&&(N.Authorization=`Bearer ${n}`),N},[n]),p=y.useCallback(async()=>{const N=d.current,T=qr(),P=w2e(),D=["screen-view"];T==="electron"&&D.push("screen-share","remote-input"),T==="web"&&D.push("screen-share");try{(await fetch(`${Qh}/api/screen-share/devices/register`,{method:"POST",headers:g(),body:JSON.stringify({id:N,name:P,platform:T,capabilities:D})})).ok&&i(J=>({...J,localDeviceId:N}))}catch(H){console.error("Failed to register screen-share device:",H)}},[g]),_=y.useCallback(async()=>{try{const N=await fetch(`${Qh}/api/screen-share/state`,{headers:g()});if(!N.ok)return;const T=await N.json();i(P=>{var D;return{...P,session:T.activeSession??P.session,devices:T.devices,isActive:((D=T.activeSession)==null?void 0:D.status)==="sharing"}})}catch(N){console.error("Failed to refresh screen-share state:",N)}},[g]),b=y.useCallback((N,T,P)=>{var H;console.log(`[screen-share] setupPeerConnection: isHost=${T} session=${P.slice(0,8)} prevPC=${!!s.current} stream=${!!N} device=${d.current}`),(H=s.current)==null||H.close();const D=new RTCPeerConnection({iceServers:S2e});if(s.current=D,T&&N){const J=N.getTracks();console.log(`[screen-share] Adding ${J.length} track(s):`,J.map(I=>`${I.kind}:${I.label}:${I.readyState}`)),J.forEach(I=>D.addTrack(I,N))}if(D.ontrack=J=>{const[I]=J.streams;console.log(`[screen-share] ontrack: streams=${J.streams.length} tracks=${I==null?void 0:I.getTracks().map(B=>`${B.kind}:${B.readyState}`).join(",")}`),I&&(a.current=I,console.log("[screen-share] remoteStreamRef set, triggering re-render"),i(B=>({...B})))},D.onicecandidate=J=>{var I;J.candidate&&((I=c.current)==null?void 0:I.readyState)===WebSocket.OPEN&&c.current.send(JSON.stringify({type:"screen-share:ice-candidate",payload:{sessionId:P,fromDeviceId:d.current,candidate:J.candidate.candidate,sdpMid:J.candidate.sdpMid,sdpMLineIndex:J.candidate.sdpMLineIndex}}))},D.oniceconnectionstatechange=()=>{console.log("[screen-share] ICE state:",D.iceConnectionState),(D.iceConnectionState==="disconnected"||D.iceConnectionState==="failed")&&i(J=>({...J,error:`Connection ${D.iceConnectionState}`}))},T&&D.createOffer().then(J=>{var I;D.setLocalDescription(J),console.log("[screen-share] Sending offer via WS"),(I=c.current)==null||I.send(JSON.stringify({type:"screen-share:offer",payload:{sessionId:P,hostDeviceId:d.current,sdp:J.sdp}}))}),!T&&h.current){const J=h.current;h.current=null,console.log("[screen-share] Processing queued offer"),D.setRemoteDescription(new RTCSessionDescription({type:"offer",sdp:J.sdp})).then(()=>D.createAnswer()).then(I=>{var B;D.setLocalDescription(I),(B=c.current)==null||B.send(JSON.stringify({type:"screen-share:answer",payload:{sessionId:J.sessionId,viewerDeviceId:d.current,sdp:I.sdp}}))}).catch(I=>console.error("[screen-share] Failed to process queued offer:",I))}},[]),x=y.useCallback(async N=>{var T,P;i(D=>({...D,loading:!0,error:null}));try{let D;if(!((T=navigator.mediaDevices)!=null&&T.getDisplayMedia))throw new Error("Screen sharing is not supported on this device. Use a desktop browser or the Electron app.");if(console.log("[screen-share] Requesting screen capture via getDisplayMedia..."),D=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:15,max:30}},audio:!1}),console.log("[screen-share] Screen capture obtained:",(P=D.getVideoTracks()[0])==null?void 0:P.label),o.current=D,!N){await p();const H=await fetch(`${Qh}/api/screen-share/start`,{method:"POST",headers:g(),body:JSON.stringify({hostDeviceId:d.current})});if(!H.ok){const I=await H.json();throw new Error(I.error)}const J=await H.json();N=J.session.id,i(I=>({...I,session:J.session}))}i(H=>({...H,isHost:!0,isViewer:!1,isActive:!0,loading:!1})),console.log("[screen-share] Host capturing — setting up peer connection for session:",N),b(D,!0,N??"")}catch(D){console.error("[screen-share] Capture failed:",D),i(H=>({...H,loading:!1,isHost:!1,error:D instanceof Error?D.message:"Failed to start screen capture"}))}},[p,g,b]),C=y.useCallback(async N=>{i(T=>({...T,loading:!0,error:null,connectedDeviceId:N}));try{await p();const T=await fetch(`${Qh}/api/screen-share/start`,{method:"POST",headers:g(),body:JSON.stringify({hostDeviceId:N,viewerDeviceIds:[d.current]})});if(!T.ok){const D=await T.json();throw new Error(D.error)}const{session:P}=await T.json();i(D=>({...D,session:P,isViewer:!0,isActive:!0,loading:!1})),console.log(`[screen-share] requestRemoteShare: HTTP done, session=${P.id.slice(0,8)} pcRef=${!!s.current}`),s.current?console.log("[screen-share] requestRemoteShare: PC already exists, skipping creation"):(console.log("[screen-share] requestRemoteShare: creating viewer PC (no WS-created PC yet)"),b(null,!1,P.id))}catch(T){i(P=>({...P,loading:!1,connectedDeviceId:null,error:T instanceof Error?T.message:"Failed to connect to remote device"}))}},[p,g,b]),j=y.useCallback(async()=>{var N,T;(N=o.current)==null||N.getTracks().forEach(P=>P.stop()),o.current=null,a.current=null,(T=s.current)==null||T.close(),s.current=null;try{await fetch(`${Qh}/api/screen-share/stop`,{method:"POST",headers:g(),body:JSON.stringify({})})}catch{}i(P=>({...P,session:null,isHost:!1,isViewer:!1,isActive:!1,connectedDeviceId:null,pendingShareRequest:null}))},[g]),S=y.useCallback(()=>{const N=r.pendingShareRequest;N&&(i(T=>({...T,pendingShareRequest:null})),x(N.sessionId))},[r.pendingShareRequest,x]),E=y.useCallback(()=>{i(N=>({...N,pendingShareRequest:null}))},[]),O=y.useCallback(async()=>{if(!window.jaitDesktop)return[];try{return await window.jaitDesktop.getDesktopSources()}catch{return[]}},[]);return y.useEffect(()=>{let N=!0,T=null;const P=()=>{if(!N)return;const D=`${b2e}${n?`?token=${n}`:""}`,H=new WebSocket(D);c.current=H,H.onopen=()=>{console.log("[screen-share] WS connected"),H.send(JSON.stringify({type:"subscribe",deviceId:d.current}))},H.onmessage=J=>{var I,B,F,W,z,V,A;try{const U=JSON.parse(J.data);switch(U.type.startsWith("screen-share:")&&console.log(`[screen-share] WS recv: ${U.type}`,JSON.stringify(U.payload).slice(0,300)),U.type){case"screen-share:state-update":{const K=U.payload;K.status==="idle"?((I=o.current)==null||I.getTracks().forEach(Y=>Y.stop()),o.current=null,a.current=null,(B=s.current)==null||B.close(),s.current=null,i(Y=>({...Y,session:null,isHost:!1,isViewer:!1,isActive:!1,connectedDeviceId:null,pendingShareRequest:null}))):i(Y=>({...Y,session:K,isActive:K.status==="sharing"}));break}case"screen-share:start-request":{const K=U.payload;if(console.log(`[screen-share] start-request: host=${K.hostDeviceId} local=${d.current} viewers=[${(F=K.viewerDeviceIds)==null?void 0:F.join(",")}] isHostMatch=${K.hostDeviceId===d.current} pcRef=${!!s.current}`),K.hostDeviceId===d.current){const Y=((W=K.viewerDeviceIds)==null?void 0:W[0])??"unknown",$=Hz();if($.has(Y)||$.has("*")){console.log("[screen-share] Auto-approved share request from",Y),x(K.sessionId);break}qr()==="electron"&&((z=window.jaitDesktop)==null||z.notify({title:"Screen Share Request",body:"A remote device wants to view your screen."}).catch(()=>{}));const Z=Pr("Screen share requested",{description:"A remote device wants to view your screen.",duration:1/0,action:{label:"Always Allow",onClick:()=>{console.log("[screen-share] User accepted + enabled always-approve"),x2e("*"),x(K.sessionId),Pr.dismiss(Z)}},cancel:{label:"Share Once",onClick:()=>{console.log("[screen-share] User accepted share request (once)"),x(K.sessionId),Pr.dismiss(Z)}}})}else if(!K.viewerDeviceIds||K.viewerDeviceIds.length===0||K.viewerDeviceIds.includes(d.current)){if(s.current){console.log("[screen-share] Viewer PC already set up, skipping duplicate start-request");break}o.current&&(o.current.getTracks().forEach(Y=>Y.stop()),o.current=null),console.log("[screen-share] Setting up as viewer for session:",K.sessionId,"host:",K.hostDeviceId),i(Y=>({...Y,isViewer:!0,isHost:!1,isActive:!0,connectedDeviceId:K.hostDeviceId})),b(null,!1,K.sessionId)}break}case"screen-share:offer":{const K=U.payload;if(K.hostDeviceId===d.current){console.log("[screen-share] Ignoring own offer (we are the host)");break}console.log(`[screen-share] Received offer from host=${K.hostDeviceId} pcRef=${!!s.current}`);const Y=s.current;Y?Y.setRemoteDescription(new RTCSessionDescription({type:"offer",sdp:K.sdp})).then(()=>Y.createAnswer()).then($=>{var R;Y.setLocalDescription($),console.log("[screen-share] Sending answer"),(R=c.current)==null||R.send(JSON.stringify({type:"screen-share:answer",payload:{sessionId:K.sessionId,viewerDeviceId:d.current,sdp:$.sdp}}))}).catch($=>console.error("[screen-share] Offer handling failed:",$)):(console.log("[screen-share] PC not ready, queuing offer"),h.current=K);break}case"screen-share:answer":{const K=U.payload;if(K.viewerDeviceId===d.current){console.log("[screen-share] Ignoring own answer (we are the viewer)");break}console.log(`[screen-share] Received answer from viewer=${K.viewerDeviceId}`),(V=s.current)==null||V.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:K.sdp}));break}case"screen-share:ice-candidate":{const K=U.payload;if(K.fromDeviceId===d.current)break;console.log(`[screen-share] ICE candidate from=${K.fromDeviceId} pcRef=${!!s.current}`),(A=s.current)==null||A.addIceCandidate(new RTCIceCandidate({candidate:K.candidate,sdpMid:K.sdpMid,sdpMLineIndex:K.sdpMLineIndex}));break}}}catch{}},H.onclose=()=>{c.current=null,N&&(T=setTimeout(P,2e3))},H.onerror=()=>{}};return P(),()=>{var D;N=!1,T&&clearTimeout(T),(D=c.current)==null||D.close(),c.current=null}},[n]),y.useEffect(()=>{p(),_()},[p,_]),y.useEffect(()=>{window.jaitDesktop&&(window.jaitDesktop.onScreenShareStart(()=>x()),window.jaitDesktop.onScreenShareStop(()=>j()))},[x,j]),{...r,requestRemoteShare:C,startHosting:x,disconnect:j,acceptPendingShare:S,rejectPendingShare:E,getDesktopSources:O,refreshState:_,localStream:o.current,remoteStream:a.current}}/**
|
|
757
|
+
${r?"bg-green-500/15 text-green-500":n?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:f.jsx(y2e,{platform:e.platform,className:"h-4.5 w-4.5"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"font-medium truncate text-[13px]",children:[e.name,n&&f.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(you)"})]}),f.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:[e.platform,r&&f.jsx("span",{className:"text-green-500 ml-1",children:"· connected"})]})]}),o&&!r&&f.jsx($e,{size:"sm",variant:"outline",className:"h-7 text-xs px-2.5 shrink-0",onClick:s,disabled:i,children:i?f.jsx(kt,{className:"h-3 w-3 animate-spin"}):f.jsxs(f.Fragment,{children:[f.jsx(fB,{className:"h-3 w-3 mr-1"}),"Connect"]})}),r&&f.jsxs(ln,{className:"bg-green-500/15 text-green-500 border-green-500/30 shrink-0 text-[10px]",children:[f.jsx(uB,{className:"h-2.5 w-2.5 mr-0.5"})," live"]})]})}function v2e({stream:e}){const n=y.useRef(null),r=y.useRef(null),[i,s]=y.useState(!1);y.useEffect(()=>{console.log(`[screen-share] RemoteScreen: stream=${!!e} tracks=${e==null?void 0:e.getTracks().map(a=>`${a.kind}:${a.readyState}`).join(",")} videoRef=${!!n.current}`),n.current&&e&&(n.current.srcObject=e)},[e]);const o=y.useCallback(()=>{const a=r.current;a&&(document.fullscreenElement?(document.exitFullscreen(),s(!1)):(a.requestFullscreen(),s(!0)))},[]);return y.useEffect(()=>{const a=()=>s(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",a),()=>document.removeEventListener("fullscreenchange",a)},[]),e?f.jsxs("div",{ref:r,className:"relative flex-1 group bg-black rounded-lg overflow-hidden",children:[f.jsx("video",{ref:n,autoPlay:!0,playsInline:!0,muted:!0,className:"w-full h-full object-contain bg-black"}),f.jsx("button",{onClick:o,className:"absolute top-2 right-2 p-1.5 rounded bg-black/60 text-white opacity-0 group-hover:opacity-100 transition-opacity",children:i?f.jsx(oB,{className:"h-3.5 w-3.5"}):f.jsx(rB,{className:"h-3.5 w-3.5"})})]}):f.jsx("div",{className:"flex-1 bg-black/20 rounded-lg flex items-center justify-center text-muted-foreground",children:f.jsxs("div",{className:"text-center",children:[f.jsx(lB,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),f.jsx("p",{className:"text-sm font-medium",children:"Waiting for remote screen…"}),f.jsx("p",{className:"text-xs mt-1 opacity-60",children:"The remote device is preparing to share"})]})})}function _2e({screenShare:e}){var o;const n=e.session,r=e.isViewer||e.isHost;console.log(`[screen-share] Panel render: isHost=${e.isHost} isViewer=${e.isViewer} isConnected=${r} remoteStream=${!!e.remoteStream} localStream=${!!e.localStream}`);const i=e.devices.filter(a=>a.id!==e.localDeviceId),s=e.devices.find(a=>a.id===e.localDeviceId);return f.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.pendingShareRequest&&!r&&f.jsx("div",{className:"p-3 border-b bg-amber-500/5",children:f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("div",{className:"h-9 w-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0 mt-0.5",children:f.jsx(O8,{className:"h-4.5 w-4.5"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsx("p",{className:"text-sm font-medium",children:"Screen share requested"}),f.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"A remote device wants to view your screen."}),f.jsxs("div",{className:"flex gap-2 mt-2",children:[f.jsxs($e,{size:"sm",className:"h-7 text-xs px-3",onClick:()=>e.acceptPendingShare(),children:[f.jsx(O8,{className:"h-3 w-3 mr-1"}),"Share Screen"]}),f.jsx($e,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2 text-muted-foreground",onClick:()=>e.rejectPendingShare(),children:"Decline"})]})]})]})}),r?f.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[f.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b bg-muted/20 shrink-0",children:[f.jsxs(ln,{className:"bg-green-500/15 text-green-500 border-green-500/30 text-[10px]",children:[f.jsx(pv,{className:"h-2.5 w-2.5 mr-1"})," Live"]}),f.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:e.connectedDeviceId?((o=e.devices.find(a=>a.id===e.connectedDeviceId))==null?void 0:o.name)??e.connectedDeviceId:"Connected"}),n&&f.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[n.transport.routeMode.toUpperCase()," · ",n.transport.avgLatencyMs,"ms"]}),f.jsxs($e,{variant:"ghost",size:"sm",className:"h-6 text-xs px-2 text-destructive hover:text-destructive",onClick:()=>e.disconnect(),children:[f.jsx(Mr,{className:"h-3 w-3 mr-1"}),"Disconnect"]})]}),e.error&&f.jsx("div",{className:"mx-2 p-2 rounded-md bg-red-500/10 text-red-500 text-xs border border-red-500/20",children:e.error}),e.isHost?f.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:f.jsxs("div",{className:"text-center",children:[f.jsx(jp,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),f.jsx("p",{className:"text-sm font-medium",children:"Sharing your screen"}),f.jsx("p",{className:"text-xs mt-1 opacity-60",children:"A remote device is viewing this screen"}),n&&f.jsxs("p",{className:"text-xs mt-2 opacity-50",children:[f.jsx(mw,{className:"h-3 w-3 inline mr-0.5"}),n.viewers.length," viewer",n.viewers.length!==1?"s":""]})]})}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"flex-1 min-h-0 p-2",children:f.jsx(v2e,{stream:e.remoteStream})}),n&&f.jsxs("div",{className:"flex items-center gap-3 px-3 py-1.5 border-t text-[10px] text-muted-foreground shrink-0",children:[f.jsxs("span",{children:["Session ",n.id.slice(0,8)]}),f.jsx("span",{children:"·"}),f.jsxs("span",{children:["ICE: ",n.transport.iceConnectionState]}),f.jsx("span",{children:"·"}),f.jsxs("span",{children:[f.jsx(mw,{className:"h-2.5 w-2.5 inline mr-0.5"}),n.viewers.length," viewer",n.viewers.length!==1?"s":""]})]})]})]}):f.jsxs("div",{className:"flex flex-col gap-3 p-3 overflow-y-auto",children:[e.error&&f.jsx("div",{className:"p-2.5 rounded-md bg-red-500/10 text-red-500 text-xs border border-red-500/20",children:e.error}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsxs("div",{className:"flex items-center justify-between",children:[f.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Remote Devices"}),f.jsx($e,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>e.refreshState(),children:f.jsx(du,{className:"h-3 w-3"})})]}),i.length===0?f.jsxs("div",{className:"py-6 text-center",children:[f.jsx(jp,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/40"}),f.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"No remote devices found"}),f.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1 max-w-[200px] mx-auto",children:"Open Jait on another device (desktop app or mobile) to connect to it"})]}):f.jsx("div",{className:"space-y-1.5",children:i.map(a=>f.jsx(CE,{device:a,isLocal:!1,isConnected:!1,isLoading:e.loading&&e.connectedDeviceId===a.id,onConnect:()=>e.requestRemoteShare(a.id)},a.id))})]}),s&&f.jsxs("div",{className:"space-y-1.5",children:[f.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"This Device"}),f.jsx(CE,{device:s,isLocal:!0,isConnected:!1,isLoading:!1,onConnect:()=>{}})]}),f.jsxs("div",{className:"px-2 py-2 rounded-md bg-muted/30 text-[11px] text-muted-foreground",children:[f.jsx("strong",{children:"Tip:"})," Ask your agent to connect to a device — e.g. “Show me my desktop screen”"]})]})]})}function qr(){return typeof window<"u"&&window.jaitDesktop?"electron":typeof window<"u"&&"Capacitor"in window?"capacitor":"web"}let fo=null;function w3(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}async function b2e(){var o;if(fo)return fo;const e=qr(),n=`jait-device-id-${e}`,r="deviceId";if(e==="electron"&&((o=window.jaitDesktop)!=null&&o.getSetting)){const a=window.jaitDesktop,c=await a.getSetting(r,null);if(c)return fo=c,localStorage.setItem(n,c),c;const d=localStorage.getItem(n);if(d)return fo=d,await a.setSetting(r,d),d;const h=w3(e);return fo=h,localStorage.setItem(n,h),await a.setSetting(r,h),h}const i=localStorage.getItem(n);if(i)return fo=i,i;const s=w3(e);return fo=s,localStorage.setItem(n,s),s}function o4(){if(fo)return fo;const e=qr(),n=`jait-device-id-${e}`,r=localStorage.getItem(n);if(r)return fo=r,r;const i=w3(e);return fo=i,localStorage.setItem(n,i),i}const Qh=Wn(),x2e=Pg(),Fz="jait-screen-share-auto-approve";function Hz(){try{const e=localStorage.getItem(Fz);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}function w2e(e){const n=Hz();n.add(e),localStorage.setItem(Fz,JSON.stringify([...n]))}function S2e(){const e=qr(),n=navigator.userAgent;return e==="electron"?`Jait Desktop (${navigator.platform})`:e==="capacitor"?"Jait Mobile":n.includes("Chrome")?`Chrome (${navigator.platform})`:n.includes("Firefox")?`Firefox (${navigator.platform})`:n.includes("Safari")?`Safari (${navigator.platform})`:`Browser (${navigator.platform})`}const C2e=[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}];function j2e(e={}){const{token:n}=e,[r,i]=y.useState({session:null,devices:[],localDeviceId:null,isHost:!1,isViewer:!1,isActive:!1,loading:!1,error:null,connectedDeviceId:null,pendingShareRequest:null}),s=y.useRef(null),o=y.useRef(null),a=y.useRef(null),c=y.useRef(null),d=y.useRef(o4()),h=y.useRef(null),g=y.useCallback(()=>{const N={"Content-Type":"application/json"};return n&&(N.Authorization=`Bearer ${n}`),N},[n]),p=y.useCallback(async()=>{const N=d.current,T=qr(),P=S2e(),D=["screen-view"];T==="electron"&&D.push("screen-share","remote-input"),T==="web"&&D.push("screen-share");try{(await fetch(`${Qh}/api/screen-share/devices/register`,{method:"POST",headers:g(),body:JSON.stringify({id:N,name:P,platform:T,capabilities:D})})).ok&&i(J=>({...J,localDeviceId:N}))}catch(H){console.error("Failed to register screen-share device:",H)}},[g]),_=y.useCallback(async()=>{try{const N=await fetch(`${Qh}/api/screen-share/state`,{headers:g()});if(!N.ok)return;const T=await N.json();i(P=>{var D;return{...P,session:T.activeSession??P.session,devices:T.devices,isActive:((D=T.activeSession)==null?void 0:D.status)==="sharing"}})}catch(N){console.error("Failed to refresh screen-share state:",N)}},[g]),b=y.useCallback((N,T,P)=>{var H;console.log(`[screen-share] setupPeerConnection: isHost=${T} session=${P.slice(0,8)} prevPC=${!!s.current} stream=${!!N} device=${d.current}`),(H=s.current)==null||H.close();const D=new RTCPeerConnection({iceServers:C2e});if(s.current=D,T&&N){const J=N.getTracks();console.log(`[screen-share] Adding ${J.length} track(s):`,J.map(I=>`${I.kind}:${I.label}:${I.readyState}`)),J.forEach(I=>D.addTrack(I,N))}if(D.ontrack=J=>{const[I]=J.streams;console.log(`[screen-share] ontrack: streams=${J.streams.length} tracks=${I==null?void 0:I.getTracks().map(B=>`${B.kind}:${B.readyState}`).join(",")}`),I&&(a.current=I,console.log("[screen-share] remoteStreamRef set, triggering re-render"),i(B=>({...B})))},D.onicecandidate=J=>{var I;J.candidate&&((I=c.current)==null?void 0:I.readyState)===WebSocket.OPEN&&c.current.send(JSON.stringify({type:"screen-share:ice-candidate",payload:{sessionId:P,fromDeviceId:d.current,candidate:J.candidate.candidate,sdpMid:J.candidate.sdpMid,sdpMLineIndex:J.candidate.sdpMLineIndex}}))},D.oniceconnectionstatechange=()=>{console.log("[screen-share] ICE state:",D.iceConnectionState),(D.iceConnectionState==="disconnected"||D.iceConnectionState==="failed")&&i(J=>({...J,error:`Connection ${D.iceConnectionState}`}))},T&&D.createOffer().then(J=>{var I;D.setLocalDescription(J),console.log("[screen-share] Sending offer via WS"),(I=c.current)==null||I.send(JSON.stringify({type:"screen-share:offer",payload:{sessionId:P,hostDeviceId:d.current,sdp:J.sdp}}))}),!T&&h.current){const J=h.current;h.current=null,console.log("[screen-share] Processing queued offer"),D.setRemoteDescription(new RTCSessionDescription({type:"offer",sdp:J.sdp})).then(()=>D.createAnswer()).then(I=>{var B;D.setLocalDescription(I),(B=c.current)==null||B.send(JSON.stringify({type:"screen-share:answer",payload:{sessionId:J.sessionId,viewerDeviceId:d.current,sdp:I.sdp}}))}).catch(I=>console.error("[screen-share] Failed to process queued offer:",I))}},[]),x=y.useCallback(async N=>{var T,P;i(D=>({...D,loading:!0,error:null}));try{let D;if(!((T=navigator.mediaDevices)!=null&&T.getDisplayMedia))throw new Error("Screen sharing is not supported on this device. Use a desktop browser or the Electron app.");if(console.log("[screen-share] Requesting screen capture via getDisplayMedia..."),D=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:15,max:30}},audio:!1}),console.log("[screen-share] Screen capture obtained:",(P=D.getVideoTracks()[0])==null?void 0:P.label),o.current=D,!N){await p();const H=await fetch(`${Qh}/api/screen-share/start`,{method:"POST",headers:g(),body:JSON.stringify({hostDeviceId:d.current})});if(!H.ok){const I=await H.json();throw new Error(I.error)}const J=await H.json();N=J.session.id,i(I=>({...I,session:J.session}))}i(H=>({...H,isHost:!0,isViewer:!1,isActive:!0,loading:!1})),console.log("[screen-share] Host capturing — setting up peer connection for session:",N),b(D,!0,N??"")}catch(D){console.error("[screen-share] Capture failed:",D),i(H=>({...H,loading:!1,isHost:!1,error:D instanceof Error?D.message:"Failed to start screen capture"}))}},[p,g,b]),C=y.useCallback(async N=>{i(T=>({...T,loading:!0,error:null,connectedDeviceId:N}));try{await p();const T=await fetch(`${Qh}/api/screen-share/start`,{method:"POST",headers:g(),body:JSON.stringify({hostDeviceId:N,viewerDeviceIds:[d.current]})});if(!T.ok){const D=await T.json();throw new Error(D.error)}const{session:P}=await T.json();i(D=>({...D,session:P,isViewer:!0,isActive:!0,loading:!1})),console.log(`[screen-share] requestRemoteShare: HTTP done, session=${P.id.slice(0,8)} pcRef=${!!s.current}`),s.current?console.log("[screen-share] requestRemoteShare: PC already exists, skipping creation"):(console.log("[screen-share] requestRemoteShare: creating viewer PC (no WS-created PC yet)"),b(null,!1,P.id))}catch(T){i(P=>({...P,loading:!1,connectedDeviceId:null,error:T instanceof Error?T.message:"Failed to connect to remote device"}))}},[p,g,b]),j=y.useCallback(async()=>{var N,T;(N=o.current)==null||N.getTracks().forEach(P=>P.stop()),o.current=null,a.current=null,(T=s.current)==null||T.close(),s.current=null;try{await fetch(`${Qh}/api/screen-share/stop`,{method:"POST",headers:g(),body:JSON.stringify({})})}catch{}i(P=>({...P,session:null,isHost:!1,isViewer:!1,isActive:!1,connectedDeviceId:null,pendingShareRequest:null}))},[g]),S=y.useCallback(()=>{const N=r.pendingShareRequest;N&&(i(T=>({...T,pendingShareRequest:null})),x(N.sessionId))},[r.pendingShareRequest,x]),E=y.useCallback(()=>{i(N=>({...N,pendingShareRequest:null}))},[]),O=y.useCallback(async()=>{if(!window.jaitDesktop)return[];try{return await window.jaitDesktop.getDesktopSources()}catch{return[]}},[]);return y.useEffect(()=>{let N=!0,T=null;const P=()=>{if(!N)return;const D=`${x2e}${n?`?token=${n}`:""}`,H=new WebSocket(D);c.current=H,H.onopen=()=>{console.log("[screen-share] WS connected"),H.send(JSON.stringify({type:"subscribe",deviceId:d.current}))},H.onmessage=J=>{var I,B,F,W,z,V,A;try{const U=JSON.parse(J.data);switch(U.type.startsWith("screen-share:")&&console.log(`[screen-share] WS recv: ${U.type}`,JSON.stringify(U.payload).slice(0,300)),U.type){case"screen-share:state-update":{const K=U.payload;K.status==="idle"?((I=o.current)==null||I.getTracks().forEach(Y=>Y.stop()),o.current=null,a.current=null,(B=s.current)==null||B.close(),s.current=null,i(Y=>({...Y,session:null,isHost:!1,isViewer:!1,isActive:!1,connectedDeviceId:null,pendingShareRequest:null}))):i(Y=>({...Y,session:K,isActive:K.status==="sharing"}));break}case"screen-share:start-request":{const K=U.payload;if(console.log(`[screen-share] start-request: host=${K.hostDeviceId} local=${d.current} viewers=[${(F=K.viewerDeviceIds)==null?void 0:F.join(",")}] isHostMatch=${K.hostDeviceId===d.current} pcRef=${!!s.current}`),K.hostDeviceId===d.current){const Y=((W=K.viewerDeviceIds)==null?void 0:W[0])??"unknown",$=Hz();if($.has(Y)||$.has("*")){console.log("[screen-share] Auto-approved share request from",Y),x(K.sessionId);break}qr()==="electron"&&((z=window.jaitDesktop)==null||z.notify({title:"Screen Share Request",body:"A remote device wants to view your screen."}).catch(()=>{}));const Z=Pr("Screen share requested",{description:"A remote device wants to view your screen.",duration:1/0,action:{label:"Always Allow",onClick:()=>{console.log("[screen-share] User accepted + enabled always-approve"),w2e("*"),x(K.sessionId),Pr.dismiss(Z)}},cancel:{label:"Share Once",onClick:()=>{console.log("[screen-share] User accepted share request (once)"),x(K.sessionId),Pr.dismiss(Z)}}})}else if(!K.viewerDeviceIds||K.viewerDeviceIds.length===0||K.viewerDeviceIds.includes(d.current)){if(s.current){console.log("[screen-share] Viewer PC already set up, skipping duplicate start-request");break}o.current&&(o.current.getTracks().forEach(Y=>Y.stop()),o.current=null),console.log("[screen-share] Setting up as viewer for session:",K.sessionId,"host:",K.hostDeviceId),i(Y=>({...Y,isViewer:!0,isHost:!1,isActive:!0,connectedDeviceId:K.hostDeviceId})),b(null,!1,K.sessionId)}break}case"screen-share:offer":{const K=U.payload;if(K.hostDeviceId===d.current){console.log("[screen-share] Ignoring own offer (we are the host)");break}console.log(`[screen-share] Received offer from host=${K.hostDeviceId} pcRef=${!!s.current}`);const Y=s.current;Y?Y.setRemoteDescription(new RTCSessionDescription({type:"offer",sdp:K.sdp})).then(()=>Y.createAnswer()).then($=>{var R;Y.setLocalDescription($),console.log("[screen-share] Sending answer"),(R=c.current)==null||R.send(JSON.stringify({type:"screen-share:answer",payload:{sessionId:K.sessionId,viewerDeviceId:d.current,sdp:$.sdp}}))}).catch($=>console.error("[screen-share] Offer handling failed:",$)):(console.log("[screen-share] PC not ready, queuing offer"),h.current=K);break}case"screen-share:answer":{const K=U.payload;if(K.viewerDeviceId===d.current){console.log("[screen-share] Ignoring own answer (we are the viewer)");break}console.log(`[screen-share] Received answer from viewer=${K.viewerDeviceId}`),(V=s.current)==null||V.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:K.sdp}));break}case"screen-share:ice-candidate":{const K=U.payload;if(K.fromDeviceId===d.current)break;console.log(`[screen-share] ICE candidate from=${K.fromDeviceId} pcRef=${!!s.current}`),(A=s.current)==null||A.addIceCandidate(new RTCIceCandidate({candidate:K.candidate,sdpMid:K.sdpMid,sdpMLineIndex:K.sdpMLineIndex}));break}}}catch{}},H.onclose=()=>{c.current=null,N&&(T=setTimeout(P,2e3))},H.onerror=()=>{}};return P(),()=>{var D;N=!1,T&&clearTimeout(T),(D=c.current)==null||D.close(),c.current=null}},[n]),y.useEffect(()=>{p(),_()},[p,_]),y.useEffect(()=>{window.jaitDesktop&&(window.jaitDesktop.onScreenShareStart(()=>x()),window.jaitDesktop.onScreenShareStop(()=>j()))},[x,j]),{...r,requestRemoteShare:C,startHosting:x,disconnect:j,acceptPendingShare:S,rejectPendingShare:E,getDesktopSources:O,refreshState:_,localStream:o.current,remoteStream:a.current}}/**
|
|
758
758
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
759
759
|
* @license MIT
|
|
760
760
|
*
|
|
@@ -765,21 +765,21 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
765
765
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
766
766
|
* http://bellard.org/jslinux/
|
|
767
767
|
* Copyright (c) 2011 Fabrice Bellard
|
|
768
|
-
*/var Uz=Object.defineProperty,
|
|
768
|
+
*/var Uz=Object.defineProperty,k2e=Object.getOwnPropertyDescriptor,E2e=(e,n)=>{for(var r in n)Uz(e,r,{get:n[r],enumerable:!0})},Zn=(e,n,r,i)=>{for(var s=i>1?void 0:i?k2e(n,r):n,o=e.length-1,a;o>=0;o--)(a=e[o])&&(s=(i?a(n,r,s):a(s))||s);return i&&s&&Uz(n,r,s),s},ct=(e,n)=>(r,i)=>n(r,i,e),jE="Terminal input",S3={get:()=>jE,set:e=>jE=e},kE="Too much output to announce, navigate to rows manually to read",C3={get:()=>kE,set:e=>kE=e};function O2e(e){return e.replace(/\r?\n/g,"\r")}function N2e(e,n){return n?"\x1B[200~"+e+"\x1B[201~":e}function T2e(e,n){e.clipboardData&&e.clipboardData.setData("text/plain",n.selectionText),e.preventDefault()}function P2e(e,n,r,i){if(e.stopPropagation(),e.clipboardData){let s=e.clipboardData.getData("text/plain");Vz(s,n,r,i)}}function Vz(e,n,r,i){e=O2e(e),e=N2e(e,r.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),r.triggerDataEvent(e,!0),n.value=""}function Wz(e,n,r){let i=r.getBoundingClientRect(),s=e.clientX-i.left-10,o=e.clientY-i.top-10;n.style.width="20px",n.style.height="20px",n.style.left=`${s}px`,n.style.top=`${o}px`,n.style.zIndex="1000",n.focus()}function EE(e,n,r,i,s){Wz(e,n,r),s&&i.rightClickSelect(e),n.value=i.selectionText,n.select()}function Jl(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function r_(e,n=0,r=e.length){let i="";for(let s=n;s<r;++s){let o=e[s];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var A2e=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,n){let r=e.length;if(!r)return 0;let i=0,s=0;if(this._interim){let o=e.charCodeAt(s++);56320<=o&&o<=57343?n[i++]=(this._interim-55296)*1024+o-56320+65536:(n[i++]=this._interim,n[i++]=o),this._interim=0}for(let o=s;o<r;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=r)return this._interim=a,i;let c=e.charCodeAt(o);56320<=c&&c<=57343?n[i++]=(a-55296)*1024+c-56320+65536:(n[i++]=a,n[i++]=c);continue}a!==65279&&(n[i++]=a)}return i}},M2e=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,n){let r=e.length;if(!r)return 0;let i=0,s,o,a,c,d=0,h=0;if(this.interim[0]){let _=!1,b=this.interim[0];b&=(b&224)===192?31:(b&240)===224?15:7;let x=0,C;for(;(C=this.interim[++x]&63)&&x<4;)b<<=6,b|=C;let j=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,S=j-x;for(;h<S;){if(h>=r)return 0;if(C=e[h++],(C&192)!==128){h--,_=!0;break}else this.interim[x++]=C,b<<=6,b|=C&63}_||(j===2?b<128?h--:n[i++]=b:j===3?b<2048||b>=55296&&b<=57343||b===65279||(n[i++]=b):b<65536||b>1114111||(n[i++]=b)),this.interim.fill(0)}let g=r-4,p=h;for(;p<r;){for(;p<g&&!((s=e[p])&128)&&!((o=e[p+1])&128)&&!((a=e[p+2])&128)&&!((c=e[p+3])&128);)n[i++]=s,n[i++]=o,n[i++]=a,n[i++]=c,p+=4;if(s=e[p++],s<128)n[i++]=s;else if((s&224)===192){if(p>=r)return this.interim[0]=s,i;if(o=e[p++],(o&192)!==128){p--;continue}if(d=(s&31)<<6|o&63,d<128){p--;continue}n[i++]=d}else if((s&240)===224){if(p>=r)return this.interim[0]=s,i;if(o=e[p++],(o&192)!==128){p--;continue}if(p>=r)return this.interim[0]=s,this.interim[1]=o,i;if(a=e[p++],(a&192)!==128){p--;continue}if(d=(s&15)<<12|(o&63)<<6|a&63,d<2048||d>=55296&&d<=57343||d===65279)continue;n[i++]=d}else if((s&248)===240){if(p>=r)return this.interim[0]=s,i;if(o=e[p++],(o&192)!==128){p--;continue}if(p>=r)return this.interim[0]=s,this.interim[1]=o,i;if(a=e[p++],(a&192)!==128){p--;continue}if(p>=r)return this.interim[0]=s,this.interim[1]=o,this.interim[2]=a,i;if(c=e[p++],(c&192)!==128){p--;continue}if(d=(s&7)<<18|(o&63)<<12|(a&63)<<6|c&63,d<65536||d>1114111)continue;n[i++]=d}}return i}},qz="",nc=" ",Ug=class Kz{constructor(){this.fg=0,this.bg=0,this.extended=new iv}static toColorRGB(n){return[n>>>16&255,n>>>8&255,n&255]}static fromColorRGB(n){return(n[0]&255)<<16|(n[1]&255)<<8|n[2]&255}clone(){let n=new Kz;return n.fg=this.fg,n.bg=this.bg,n.extended=this.extended.clone(),n}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},iv=class Gz{constructor(n=0,r=0){this._ext=0,this._urlId=0,this._ext=n,this._urlId=r}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(n){this._ext=n}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(n){this._ext&=-469762049,this._ext|=n<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(n){this._ext&=-67108864,this._ext|=n&67108863}get urlId(){return this._urlId}set urlId(n){this._urlId=n}get underlineVariantOffset(){let n=(this._ext&3758096384)>>29;return n<0?n^4294967288:n}set underlineVariantOffset(n){this._ext&=536870911,this._ext|=n<<29&3758096384}clone(){return new Gz(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Bs=class Yz extends Ug{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new iv,this.combinedData=""}static fromCharData(n){let r=new Yz;return r.setFromCharData(n),r}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Jl(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(n){this.fg=n[0],this.bg=0;let r=!1;if(n[1].length>2)r=!0;else if(n[1].length===2){let i=n[1].charCodeAt(0);if(55296<=i&&i<=56319){let s=n[1].charCodeAt(1);56320<=s&&s<=57343?this.content=(i-55296)*1024+s-56320+65536|n[2]<<22:r=!0}else r=!0}else this.content=n[1].charCodeAt(0)|n[2]<<22;r&&(this.combinedData=n[1],this.content=2097152|n[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},OE="di$target",j3="di$dependencies",U2=new Map;function R2e(e){return e[j3]||[]}function Dr(e){if(U2.has(e))return U2.get(e);let n=function(r,i,s){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");D2e(n,r,s)};return n._id=e,U2.set(e,n),n}function D2e(e,n,r){n[OE]===n?n[j3].push({id:e,index:r}):(n[j3]=[{id:e,index:r}],n[OE]=n)}var wi=Dr("BufferService"),Xz=Dr("CoreMouseService"),Mu=Dr("CoreService"),z2e=Dr("CharsetService"),a4=Dr("InstantiationService"),Jz=Dr("LogService"),Si=Dr("OptionsService"),Zz=Dr("OscLinkService"),L2e=Dr("UnicodeService"),Vg=Dr("DecorationService"),k3=class{constructor(e,n,r){this._bufferService=e,this._optionsService=n,this._oscLinkService=r}provideLinks(e,n){var g;let r=this._bufferService.buffer.lines.get(e-1);if(!r){n(void 0);return}let i=[],s=this._optionsService.rawOptions.linkHandler,o=new Bs,a=r.getTrimmedLength(),c=-1,d=-1,h=!1;for(let p=0;p<a;p++)if(!(d===-1&&!r.hasContent(p))){if(r.loadCell(p,o),o.hasExtendedAttrs()&&o.extended.urlId)if(d===-1){d=p,c=o.extended.urlId;continue}else h=o.extended.urlId!==c;else d!==-1&&(h=!0);if(h||d!==-1&&p===a-1){let _=(g=this._oscLinkService.getLinkData(c))==null?void 0:g.uri;if(_){let b={start:{x:d+1,y:e},end:{x:p+(!h&&p===a-1?1:0),y:e}},x=!1;if(!(s!=null&&s.allowNonHttpProtocols))try{let C=new URL(_);["http:","https:"].includes(C.protocol)||(x=!0)}catch{x=!0}x||i.push({text:_,range:b,activate:(C,j)=>s?s.activate(C,j,b):$2e(C,j),hover:(C,j)=>{var S;return(S=s==null?void 0:s.hover)==null?void 0:S.call(s,C,j,b)},leave:(C,j)=>{var S;return(S=s==null?void 0:s.leave)==null?void 0:S.call(s,C,j,b)}})}h=!1,o.hasExtendedAttrs()&&o.extended.urlId?(d=p,c=o.extended.urlId):(d=-1,c=-1)}}n(i)}};k3=Zn([ct(0,wi),ct(1,Si),ct(2,Zz)],k3);function $2e(e,n){if(confirm(`Do you want to navigate to ${n}?
|
|
769
769
|
|
|
770
|
-
WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}}var i_=Dr("CharSizeService"),nl=Dr("CoreBrowserService"),l4=Dr("MouseService"),rl=Dr("RenderService")
|
|
770
|
+
WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}}var i_=Dr("CharSizeService"),nl=Dr("CoreBrowserService"),l4=Dr("MouseService"),rl=Dr("RenderService"),I2e=Dr("SelectionService"),Qz=Dr("CharacterJoinerService"),Ed=Dr("ThemeService"),eL=Dr("LinkProviderService"),B2e=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?NE.isErrorNoTelemetry(e)?new NE(e.message+`
|
|
771
771
|
|
|
772
772
|
`+e.stack):new Error(e.message+`
|
|
773
773
|
|
|
774
|
-
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(n=>{n(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},B2e=new I2e;function fy(e){F2e(e)||B2e.onUnexpectedError(e)}var E3="Canceled";function F2e(e){return e instanceof H2e?!0:e instanceof Error&&e.name===E3&&e.message===E3}var H2e=class extends Error{constructor(){super(E3),this.name=this.message}};function U2e(e){return new Error(`Illegal argument: ${e}`)}var NE=class O3 extends Error{constructor(n){super(n),this.name="CodeExpectedError"}static fromError(n){if(n instanceof O3)return n;let r=new O3;return r.message=n.message,r.stack=n.stack,r}static isErrorNoTelemetry(n){return n.name==="CodeExpectedError"}},N3=class tL extends Error{constructor(n){super(n||"An unexpected bug occurred."),Object.setPrototypeOf(this,tL.prototype)}};function as(e,n=0){return e[e.length-(1+n)]}var V2e;(e=>{function n(o){return o<0}e.isLessThan=n;function r(o){return o<=0}e.isLessThanOrEqual=r;function i(o){return o>0}e.isGreaterThan=i;function s(o){return o===0}e.isNeitherLessOrGreaterThan=s,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(V2e||(V2e={}));function W2e(e,n){let r=this,i=!1,s;return function(){return i||(i=!0,n||(s=e.apply(r,arguments))),s}}var nL;(e=>{function n(N){return N&&typeof N=="object"&&typeof N[Symbol.iterator]=="function"}e.is=n;let r=Object.freeze([]);function i(){return r}e.empty=i;function*s(N){yield N}e.single=s;function o(N){return n(N)?N:s(N)}e.wrap=o;function a(N){return N||r}e.from=a;function*c(N){for(let T=N.length-1;T>=0;T--)yield N[T]}e.reverse=c;function d(N){return!N||N[Symbol.iterator]().next().done===!0}e.isEmpty=d;function h(N){return N[Symbol.iterator]().next().value}e.first=h;function g(N,T){let P=0;for(let D of N)if(T(D,P++))return!0;return!1}e.some=g;function p(N,T){for(let P of N)if(T(P))return P}e.find=p;function*_(N,T){for(let P of N)T(P)&&(yield P)}e.filter=_;function*b(N,T){let P=0;for(let D of N)yield T(D,P++)}e.map=b;function*x(N,T){let P=0;for(let D of N)yield*T(D,P++)}e.flatMap=x;function*C(...N){for(let T of N)yield*T}e.concat=C;function j(N,T,P){let D=P;for(let H of N)D=T(D,H);return D}e.reduce=j;function*S(N,T,P=N.length){for(T<0&&(T+=N.length),P<0?P+=N.length:P>N.length&&(P=N.length);T<P;T++)yield N[T]}e.slice=S;function E(N,T=Number.POSITIVE_INFINITY){let P=[];if(T===0)return[P,N];let D=N[Symbol.iterator]();for(let H=0;H<T;H++){let J=D.next();if(J.done)return[P,e.empty()];P.push(J.value)}return[P,{[Symbol.iterator](){return D}}]}e.consume=E;async function O(N){let T=[];for await(let P of N)T.push(P);return Promise.resolve(T)}e.asyncToArray=O})(nL||(nL={}));function xu(e){if(nL.is(e)){let n=[];for(let r of e)if(r)try{r.dispose()}catch(i){n.push(i)}if(n.length===1)throw n[0];if(n.length>1)throw new AggregateError(n,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function q2e(...e){return qn(()=>xu(e))}function qn(e){return{dispose:W2e(()=>{e()})}}var rL=class iL{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{xu(this._toDispose)}finally{this._toDispose.clear()}}add(n){if(!n)return n;if(n===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?iL.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(n),n}delete(n){if(n){if(n===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(n),n.dispose()}}deleteAndLeak(n){n&&this._toDispose.has(n)&&(this._toDispose.delete(n),void 0)}};rL.DISABLE_DISPOSED_WARNING=!1;var oc=rL,Xt=class{constructor(){this._store=new oc,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Xt.None=Object.freeze({dispose(){}});var ld=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var n;this._isDisposed||e===this._value||((n=this._value)==null||n.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Va=typeof window=="object"?window:globalThis,T3=class P3{constructor(n){this.element=n,this.next=P3.Undefined,this.prev=P3.Undefined}};T3.Undefined=new T3(void 0);var Kn=T3,TE=class{constructor(){this._first=Kn.Undefined,this._last=Kn.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Kn.Undefined}clear(){let e=this._first;for(;e!==Kn.Undefined;){let n=e.next;e.prev=Kn.Undefined,e.next=Kn.Undefined,e=n}this._first=Kn.Undefined,this._last=Kn.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,n){let r=new Kn(e);if(this._first===Kn.Undefined)this._first=r,this._last=r;else if(n){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(r))}}shift(){if(this._first!==Kn.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Kn.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Kn.Undefined&&e.next!==Kn.Undefined){let n=e.prev;n.next=e.next,e.next.prev=n}else e.prev===Kn.Undefined&&e.next===Kn.Undefined?(this._first=Kn.Undefined,this._last=Kn.Undefined):e.next===Kn.Undefined?(this._last=this._last.prev,this._last.next=Kn.Undefined):e.prev===Kn.Undefined&&(this._first=this._first.next,this._first.prev=Kn.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Kn.Undefined;)yield e.element,e=e.next}},K2e=globalThis.performance&&typeof globalThis.performance.now=="function",G2e=class sL{static create(n){return new sL(n)}constructor(n){this._now=K2e&&n===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Gr;(e=>{e.None=()=>Xt.None;function n(F,W){return p(F,()=>{},0,void 0,!0,void 0,W)}e.defer=n;function r(F){return(W,z=null,V)=>{let A=!1,U;return U=F(K=>{if(!A)return U?U.dispose():A=!0,W.call(z,K)},null,V),A&&U.dispose(),U}}e.once=r;function i(F,W,z){return h((V,A=null,U)=>F(K=>V.call(A,W(K)),null,U),z)}e.map=i;function s(F,W,z){return h((V,A=null,U)=>F(K=>{W(K),V.call(A,K)},null,U),z)}e.forEach=s;function o(F,W,z){return h((V,A=null,U)=>F(K=>W(K)&&V.call(A,K),null,U),z)}e.filter=o;function a(F){return F}e.signal=a;function c(...F){return(W,z=null,V)=>{let A=q2e(...F.map(U=>U(K=>W.call(z,K))));return g(A,V)}}e.any=c;function d(F,W,z,V){let A=z;return i(F,U=>(A=W(A,U),A),V)}e.reduce=d;function h(F,W){let z,V={onWillAddFirstListener(){z=F(A.fire,A)},onDidRemoveLastListener(){z==null||z.dispose()}},A=new nt(V);return W==null||W.add(A),A.event}function g(F,W){return W instanceof Array?W.push(F):W&&W.add(F),F}function p(F,W,z=100,V=!1,A=!1,U,K){let Y,$,R,Z=0,L,Q={leakWarningThreshold:U,onWillAddFirstListener(){Y=F(ie=>{Z++,$=W($,ie),V&&!R&&(X.fire($),$=void 0),L=()=>{let se=$;$=void 0,R=void 0,(!V||Z>1)&&X.fire(se),Z=0},typeof z=="number"?(clearTimeout(R),R=setTimeout(L,z)):R===void 0&&(R=0,queueMicrotask(L))})},onWillRemoveListener(){A&&Z>0&&(L==null||L())},onDidRemoveLastListener(){L=void 0,Y.dispose()}},X=new nt(Q);return K==null||K.add(X),X.event}e.debounce=p;function _(F,W=0,z){return e.debounce(F,(V,A)=>V?(V.push(A),V):[A],W,void 0,!0,void 0,z)}e.accumulate=_;function b(F,W=(V,A)=>V===A,z){let V=!0,A;return o(F,U=>{let K=V||!W(U,A);return V=!1,A=U,K},z)}e.latch=b;function x(F,W,z){return[e.filter(F,W,z),e.filter(F,V=>!W(V),z)]}e.split=x;function C(F,W=!1,z=[],V){let A=z.slice(),U=F($=>{A?A.push($):Y.fire($)});V&&V.add(U);let K=()=>{A==null||A.forEach($=>Y.fire($)),A=null},Y=new nt({onWillAddFirstListener(){U||(U=F($=>Y.fire($)),V&&V.add(U))},onDidAddFirstListener(){A&&(W?setTimeout(K):K())},onDidRemoveLastListener(){U&&U.dispose(),U=null}});return V&&V.add(Y),Y.event}e.buffer=C;function j(F,W){return(z,V,A)=>{let U=W(new E);return F(function(K){let Y=U.evaluate(K);Y!==S&&z.call(V,Y)},void 0,A)}}e.chain=j;let S=Symbol("HaltChainable");class E{constructor(){this.steps=[]}map(W){return this.steps.push(W),this}forEach(W){return this.steps.push(z=>(W(z),z)),this}filter(W){return this.steps.push(z=>W(z)?z:S),this}reduce(W,z){let V=z;return this.steps.push(A=>(V=W(V,A),V)),this}latch(W=(z,V)=>z===V){let z=!0,V;return this.steps.push(A=>{let U=z||!W(A,V);return z=!1,V=A,U?A:S}),this}evaluate(W){for(let z of this.steps)if(W=z(W),W===S)break;return W}}function O(F,W,z=V=>V){let V=(...Y)=>K.fire(z(...Y)),A=()=>F.on(W,V),U=()=>F.removeListener(W,V),K=new nt({onWillAddFirstListener:A,onDidRemoveLastListener:U});return K.event}e.fromNodeEventEmitter=O;function N(F,W,z=V=>V){let V=(...Y)=>K.fire(z(...Y)),A=()=>F.addEventListener(W,V),U=()=>F.removeEventListener(W,V),K=new nt({onWillAddFirstListener:A,onDidRemoveLastListener:U});return K.event}e.fromDOMEventEmitter=N;function T(F){return new Promise(W=>r(F)(W))}e.toPromise=T;function P(F){let W=new nt;return F.then(z=>{W.fire(z)},()=>{W.fire(void 0)}).finally(()=>{W.dispose()}),W.event}e.fromPromise=P;function D(F,W){return F(z=>W.fire(z))}e.forward=D;function H(F,W,z){return W(z),F(V=>W(V))}e.runAndSubscribe=H;class J{constructor(W,z){this._observable=W,this._counter=0,this._hasChanged=!1;let V={onWillAddFirstListener:()=>{W.addObserver(this)},onDidRemoveLastListener:()=>{W.removeObserver(this)}};this.emitter=new nt(V),z&&z.add(this.emitter)}beginUpdate(W){this._counter++}handlePossibleChange(W){}handleChange(W,z){this._hasChanged=!0}endUpdate(W){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function I(F,W){return new J(F,W).emitter.event}e.fromObservable=I;function B(F){return(W,z,V)=>{let A=0,U=!1,K={beginUpdate(){A++},endUpdate(){A--,A===0&&(F.reportChanges(),U&&(U=!1,W.call(z)))},handlePossibleChange(){},handleChange(){U=!0}};F.addObserver(K),F.reportChanges();let Y={dispose(){F.removeObserver(K)}};return V instanceof oc?V.add(Y):Array.isArray(V)&&V.push(Y),Y}}e.fromObservableLight=B})(Gr||(Gr={}));var A3=class M3{constructor(n){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${n}_${M3._idPool++}`,M3.all.add(this)}start(n){this._stopWatch=new G2e,this.listenerCount=n}stop(){if(this._stopWatch){let n=this._stopWatch.elapsed();this.durations.push(n),this.elapsedOverall+=n,this.invocationCount+=1,this._stopWatch=void 0}}};A3.all=new Set,A3._idPool=0;var Y2e=A3,X2e=-1,oL=class aL{constructor(n,r,i=(aL._idPool++).toString(16).padStart(3,"0")){this._errorHandler=n,this.threshold=r,this.name=i,this._warnCountdown=0}dispose(){var n;(n=this._stacks)==null||n.clear()}check(n,r){let i=this.threshold;if(i<=0||r<i)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(n.value)||0;if(this._stacks.set(n.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),c=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${a}):`;console.warn(c),console.warn(o);let d=new Q2e(c,o);this._errorHandler(d)}return()=>{let o=this._stacks.get(n.value)||0;this._stacks.set(n.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let n,r=0;for(let[i,s]of this._stacks)(!n||r<s)&&(n=[i,s],r=s);return n}};oL._idPool=1;var J2e=oL,Z2e=class lL{constructor(n){this.value=n}static create(){let n=new Error;return new lL(n.stack??"")}print(){console.warn(this.value.split(`
|
|
774
|
+
`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(n=>{n(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},F2e=new B2e;function fy(e){H2e(e)||F2e.onUnexpectedError(e)}var E3="Canceled";function H2e(e){return e instanceof U2e?!0:e instanceof Error&&e.name===E3&&e.message===E3}var U2e=class extends Error{constructor(){super(E3),this.name=this.message}};function V2e(e){return new Error(`Illegal argument: ${e}`)}var NE=class O3 extends Error{constructor(n){super(n),this.name="CodeExpectedError"}static fromError(n){if(n instanceof O3)return n;let r=new O3;return r.message=n.message,r.stack=n.stack,r}static isErrorNoTelemetry(n){return n.name==="CodeExpectedError"}},N3=class tL extends Error{constructor(n){super(n||"An unexpected bug occurred."),Object.setPrototypeOf(this,tL.prototype)}};function as(e,n=0){return e[e.length-(1+n)]}var W2e;(e=>{function n(o){return o<0}e.isLessThan=n;function r(o){return o<=0}e.isLessThanOrEqual=r;function i(o){return o>0}e.isGreaterThan=i;function s(o){return o===0}e.isNeitherLessOrGreaterThan=s,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(W2e||(W2e={}));function q2e(e,n){let r=this,i=!1,s;return function(){return i||(i=!0,n||(s=e.apply(r,arguments))),s}}var nL;(e=>{function n(N){return N&&typeof N=="object"&&typeof N[Symbol.iterator]=="function"}e.is=n;let r=Object.freeze([]);function i(){return r}e.empty=i;function*s(N){yield N}e.single=s;function o(N){return n(N)?N:s(N)}e.wrap=o;function a(N){return N||r}e.from=a;function*c(N){for(let T=N.length-1;T>=0;T--)yield N[T]}e.reverse=c;function d(N){return!N||N[Symbol.iterator]().next().done===!0}e.isEmpty=d;function h(N){return N[Symbol.iterator]().next().value}e.first=h;function g(N,T){let P=0;for(let D of N)if(T(D,P++))return!0;return!1}e.some=g;function p(N,T){for(let P of N)if(T(P))return P}e.find=p;function*_(N,T){for(let P of N)T(P)&&(yield P)}e.filter=_;function*b(N,T){let P=0;for(let D of N)yield T(D,P++)}e.map=b;function*x(N,T){let P=0;for(let D of N)yield*T(D,P++)}e.flatMap=x;function*C(...N){for(let T of N)yield*T}e.concat=C;function j(N,T,P){let D=P;for(let H of N)D=T(D,H);return D}e.reduce=j;function*S(N,T,P=N.length){for(T<0&&(T+=N.length),P<0?P+=N.length:P>N.length&&(P=N.length);T<P;T++)yield N[T]}e.slice=S;function E(N,T=Number.POSITIVE_INFINITY){let P=[];if(T===0)return[P,N];let D=N[Symbol.iterator]();for(let H=0;H<T;H++){let J=D.next();if(J.done)return[P,e.empty()];P.push(J.value)}return[P,{[Symbol.iterator](){return D}}]}e.consume=E;async function O(N){let T=[];for await(let P of N)T.push(P);return Promise.resolve(T)}e.asyncToArray=O})(nL||(nL={}));function xu(e){if(nL.is(e)){let n=[];for(let r of e)if(r)try{r.dispose()}catch(i){n.push(i)}if(n.length===1)throw n[0];if(n.length>1)throw new AggregateError(n,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function K2e(...e){return qn(()=>xu(e))}function qn(e){return{dispose:q2e(()=>{e()})}}var rL=class iL{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{xu(this._toDispose)}finally{this._toDispose.clear()}}add(n){if(!n)return n;if(n===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?iL.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(n),n}delete(n){if(n){if(n===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(n),n.dispose()}}deleteAndLeak(n){n&&this._toDispose.has(n)&&(this._toDispose.delete(n),void 0)}};rL.DISABLE_DISPOSED_WARNING=!1;var oc=rL,Xt=class{constructor(){this._store=new oc,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};Xt.None=Object.freeze({dispose(){}});var ld=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var n;this._isDisposed||e===this._value||((n=this._value)==null||n.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Va=typeof window=="object"?window:globalThis,T3=class P3{constructor(n){this.element=n,this.next=P3.Undefined,this.prev=P3.Undefined}};T3.Undefined=new T3(void 0);var Kn=T3,TE=class{constructor(){this._first=Kn.Undefined,this._last=Kn.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===Kn.Undefined}clear(){let e=this._first;for(;e!==Kn.Undefined;){let n=e.next;e.prev=Kn.Undefined,e.next=Kn.Undefined,e=n}this._first=Kn.Undefined,this._last=Kn.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,n){let r=new Kn(e);if(this._first===Kn.Undefined)this._first=r,this._last=r;else if(n){let s=this._last;this._last=r,r.prev=s,s.next=r}else{let s=this._first;this._first=r,r.next=s,s.prev=r}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(r))}}shift(){if(this._first!==Kn.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==Kn.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==Kn.Undefined&&e.next!==Kn.Undefined){let n=e.prev;n.next=e.next,e.next.prev=n}else e.prev===Kn.Undefined&&e.next===Kn.Undefined?(this._first=Kn.Undefined,this._last=Kn.Undefined):e.next===Kn.Undefined?(this._last=this._last.prev,this._last.next=Kn.Undefined):e.prev===Kn.Undefined&&(this._first=this._first.next,this._first.prev=Kn.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==Kn.Undefined;)yield e.element,e=e.next}},G2e=globalThis.performance&&typeof globalThis.performance.now=="function",Y2e=class sL{static create(n){return new sL(n)}constructor(n){this._now=G2e&&n===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Gr;(e=>{e.None=()=>Xt.None;function n(F,W){return p(F,()=>{},0,void 0,!0,void 0,W)}e.defer=n;function r(F){return(W,z=null,V)=>{let A=!1,U;return U=F(K=>{if(!A)return U?U.dispose():A=!0,W.call(z,K)},null,V),A&&U.dispose(),U}}e.once=r;function i(F,W,z){return h((V,A=null,U)=>F(K=>V.call(A,W(K)),null,U),z)}e.map=i;function s(F,W,z){return h((V,A=null,U)=>F(K=>{W(K),V.call(A,K)},null,U),z)}e.forEach=s;function o(F,W,z){return h((V,A=null,U)=>F(K=>W(K)&&V.call(A,K),null,U),z)}e.filter=o;function a(F){return F}e.signal=a;function c(...F){return(W,z=null,V)=>{let A=K2e(...F.map(U=>U(K=>W.call(z,K))));return g(A,V)}}e.any=c;function d(F,W,z,V){let A=z;return i(F,U=>(A=W(A,U),A),V)}e.reduce=d;function h(F,W){let z,V={onWillAddFirstListener(){z=F(A.fire,A)},onDidRemoveLastListener(){z==null||z.dispose()}},A=new nt(V);return W==null||W.add(A),A.event}function g(F,W){return W instanceof Array?W.push(F):W&&W.add(F),F}function p(F,W,z=100,V=!1,A=!1,U,K){let Y,$,R,Z=0,L,Q={leakWarningThreshold:U,onWillAddFirstListener(){Y=F(ie=>{Z++,$=W($,ie),V&&!R&&(X.fire($),$=void 0),L=()=>{let se=$;$=void 0,R=void 0,(!V||Z>1)&&X.fire(se),Z=0},typeof z=="number"?(clearTimeout(R),R=setTimeout(L,z)):R===void 0&&(R=0,queueMicrotask(L))})},onWillRemoveListener(){A&&Z>0&&(L==null||L())},onDidRemoveLastListener(){L=void 0,Y.dispose()}},X=new nt(Q);return K==null||K.add(X),X.event}e.debounce=p;function _(F,W=0,z){return e.debounce(F,(V,A)=>V?(V.push(A),V):[A],W,void 0,!0,void 0,z)}e.accumulate=_;function b(F,W=(V,A)=>V===A,z){let V=!0,A;return o(F,U=>{let K=V||!W(U,A);return V=!1,A=U,K},z)}e.latch=b;function x(F,W,z){return[e.filter(F,W,z),e.filter(F,V=>!W(V),z)]}e.split=x;function C(F,W=!1,z=[],V){let A=z.slice(),U=F($=>{A?A.push($):Y.fire($)});V&&V.add(U);let K=()=>{A==null||A.forEach($=>Y.fire($)),A=null},Y=new nt({onWillAddFirstListener(){U||(U=F($=>Y.fire($)),V&&V.add(U))},onDidAddFirstListener(){A&&(W?setTimeout(K):K())},onDidRemoveLastListener(){U&&U.dispose(),U=null}});return V&&V.add(Y),Y.event}e.buffer=C;function j(F,W){return(z,V,A)=>{let U=W(new E);return F(function(K){let Y=U.evaluate(K);Y!==S&&z.call(V,Y)},void 0,A)}}e.chain=j;let S=Symbol("HaltChainable");class E{constructor(){this.steps=[]}map(W){return this.steps.push(W),this}forEach(W){return this.steps.push(z=>(W(z),z)),this}filter(W){return this.steps.push(z=>W(z)?z:S),this}reduce(W,z){let V=z;return this.steps.push(A=>(V=W(V,A),V)),this}latch(W=(z,V)=>z===V){let z=!0,V;return this.steps.push(A=>{let U=z||!W(A,V);return z=!1,V=A,U?A:S}),this}evaluate(W){for(let z of this.steps)if(W=z(W),W===S)break;return W}}function O(F,W,z=V=>V){let V=(...Y)=>K.fire(z(...Y)),A=()=>F.on(W,V),U=()=>F.removeListener(W,V),K=new nt({onWillAddFirstListener:A,onDidRemoveLastListener:U});return K.event}e.fromNodeEventEmitter=O;function N(F,W,z=V=>V){let V=(...Y)=>K.fire(z(...Y)),A=()=>F.addEventListener(W,V),U=()=>F.removeEventListener(W,V),K=new nt({onWillAddFirstListener:A,onDidRemoveLastListener:U});return K.event}e.fromDOMEventEmitter=N;function T(F){return new Promise(W=>r(F)(W))}e.toPromise=T;function P(F){let W=new nt;return F.then(z=>{W.fire(z)},()=>{W.fire(void 0)}).finally(()=>{W.dispose()}),W.event}e.fromPromise=P;function D(F,W){return F(z=>W.fire(z))}e.forward=D;function H(F,W,z){return W(z),F(V=>W(V))}e.runAndSubscribe=H;class J{constructor(W,z){this._observable=W,this._counter=0,this._hasChanged=!1;let V={onWillAddFirstListener:()=>{W.addObserver(this)},onDidRemoveLastListener:()=>{W.removeObserver(this)}};this.emitter=new nt(V),z&&z.add(this.emitter)}beginUpdate(W){this._counter++}handlePossibleChange(W){}handleChange(W,z){this._hasChanged=!0}endUpdate(W){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function I(F,W){return new J(F,W).emitter.event}e.fromObservable=I;function B(F){return(W,z,V)=>{let A=0,U=!1,K={beginUpdate(){A++},endUpdate(){A--,A===0&&(F.reportChanges(),U&&(U=!1,W.call(z)))},handlePossibleChange(){},handleChange(){U=!0}};F.addObserver(K),F.reportChanges();let Y={dispose(){F.removeObserver(K)}};return V instanceof oc?V.add(Y):Array.isArray(V)&&V.push(Y),Y}}e.fromObservableLight=B})(Gr||(Gr={}));var A3=class M3{constructor(n){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${n}_${M3._idPool++}`,M3.all.add(this)}start(n){this._stopWatch=new Y2e,this.listenerCount=n}stop(){if(this._stopWatch){let n=this._stopWatch.elapsed();this.durations.push(n),this.elapsedOverall+=n,this.invocationCount+=1,this._stopWatch=void 0}}};A3.all=new Set,A3._idPool=0;var X2e=A3,J2e=-1,oL=class aL{constructor(n,r,i=(aL._idPool++).toString(16).padStart(3,"0")){this._errorHandler=n,this.threshold=r,this.name=i,this._warnCountdown=0}dispose(){var n;(n=this._stacks)==null||n.clear()}check(n,r){let i=this.threshold;if(i<=0||r<i)return;this._stacks||(this._stacks=new Map);let s=this._stacks.get(n.value)||0;if(this._stacks.set(n.value,s+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),c=`[${this.name}] potential listener LEAK detected, having ${r} listeners already. MOST frequent listener (${a}):`;console.warn(c),console.warn(o);let d=new ewe(c,o);this._errorHandler(d)}return()=>{let o=this._stacks.get(n.value)||0;this._stacks.set(n.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let n,r=0;for(let[i,s]of this._stacks)(!n||r<s)&&(n=[i,s],r=s);return n}};oL._idPool=1;var Z2e=oL,Q2e=class lL{constructor(n){this.value=n}static create(){let n=new Error;return new lL(n.stack??"")}print(){console.warn(this.value.split(`
|
|
775
775
|
`).slice(2).join(`
|
|
776
|
-
`))}},Q2e=class extends Error{constructor(e,n){super(e),this.name="ListenerLeakError",this.stack=n}},ewe=class extends Error{constructor(e,n){super(e),this.name="ListenerRefusalError",this.stack=n}},twe=0,V2=class{constructor(e){this.value=e,this.id=twe++}},nwe=2,rwe,nt=class{constructor(n){var r,i,s,o;this._size=0,this._options=n,this._leakageMon=(r=this._options)!=null&&r.leakWarningThreshold?new J2e((n==null?void 0:n.onListenerError)??fy,((i=this._options)==null?void 0:i.leakWarningThreshold)??X2e):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new Y2e(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var n,r,i,s;this._disposed||(this._disposed=!0,((n=this._deliveryQueue)==null?void 0:n.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(r=this._options)==null?void 0:r.onDidRemoveLastListener)==null||i.call(r),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(n,r,i)=>{var c,d,h,g,p;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let _=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(_);let b=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],x=new ewe(`${_}. HINT: Stack shows most frequent listener (${b[1]}-times)`,b[0]);return(((c=this._options)==null?void 0:c.onListenerError)||fy)(x),Xt.None}if(this._disposed)return Xt.None;r&&(n=n.bind(r));let s=new V2(n),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Z2e.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof V2?(this._deliveryQueue??(this._deliveryQueue=new iwe),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||h.call(d,this),this._listeners=s,(p=(g=this._options)==null?void 0:g.onDidAddFirstListener)==null||p.call(g,this)),this._size++;let a=qn(()=>{o==null||o(),this._removeListener(s)});return i instanceof oc?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(n){var o,a,c,d;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||d.call(c,this),this._size=0;return}let r=this._listeners,i=r.indexOf(n);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,r[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*nwe<=r.length){let h=0;for(let g=0;g<r.length;g++)r[g]?r[h++]=r[g]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);r.length=h}}_deliver(n,r){var s;if(!n)return;let i=((s=this._options)==null?void 0:s.onListenerError)||fy;if(!i){n.value(r);return}try{n.value(r)}catch(o){i(o)}}_deliverQueue(n){let r=n.current._listeners;for(;n.i<n.end;)this._deliver(r[n.i++],n.value);n.reset()}fire(n){var r,i,s,o;if((r=this._deliveryQueue)!=null&&r.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof V2)this._deliver(this._listeners,n);else{let a=this._deliveryQueue;a.enqueue(this,n,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},iwe=class{constructor(){this.i=-1,this.end=0}enqueue(e,n,r){this.i=0,this.end=r,this.current=e,this.value=n}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},R3=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new nt,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new nt,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(n){return this.mapWindowIdToZoomLevel.get(this.getWindowId(n))??0}setZoomLevel(n,r){if(this.getZoomLevel(r)===n)return;let i=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(i,n),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(n){return this.mapWindowIdToZoomFactor.get(this.getWindowId(n))??1}setZoomFactor(n,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),n)}setFullscreen(n,r){if(this.isFullscreen(r)===n)return;let i=this.getWindowId(r);this.mapWindowIdToFullScreen.set(i,n),this._onDidChangeFullscreen.fire(i)}isFullscreen(n){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(n))}getWindowId(n){return n.vscodeWindowId}};R3.INSTANCE=new R3;var c4=R3;function swe(e,n,r){typeof n=="string"&&(n=e.matchMedia(n)),n.addEventListener("change",r)}c4.INSTANCE.onDidChangeZoomLevel;function owe(e){return c4.INSTANCE.getZoomFactor(e)}c4.INSTANCE.onDidChangeFullscreen;var Od=typeof navigator=="object"?navigator.userAgent:"",D3=Od.indexOf("Firefox")>=0,awe=Od.indexOf("AppleWebKit")>=0,u4=Od.indexOf("Chrome")>=0,lwe=!u4&&Od.indexOf("Safari")>=0;Od.indexOf("Electron/")>=0;Od.indexOf("Android")>=0;var W2=!1;if(typeof Va.matchMedia=="function"){let e=Va.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),n=Va.matchMedia("(display-mode: fullscreen)");W2=e.matches,swe(Va,e,({matches:r})=>{W2&&n.matches||(W2=r)})}var Wf="en",z3=!1,L3=!1,dy=!1,cL=!1,B1,hy=Wf,PE=Wf,cwe,co,cu=globalThis,Wr,kO;typeof cu.vscode<"u"&&typeof cu.vscode.process<"u"?Wr=cu.vscode.process:typeof process<"u"&&typeof((kO=process==null?void 0:process.versions)==null?void 0:kO.node)=="string"&&(Wr=process);var EO,uwe=typeof((EO=Wr==null?void 0:Wr.versions)==null?void 0:EO.electron)=="string",fwe=uwe&&(Wr==null?void 0:Wr.type)==="renderer",OO;if(typeof Wr=="object"){z3=Wr.platform==="win32",L3=Wr.platform==="darwin",dy=Wr.platform==="linux",dy&&Wr.env.SNAP&&Wr.env.SNAP_REVISION,Wr.env.CI||Wr.env.BUILD_ARTIFACTSTAGINGDIRECTORY,B1=Wf,hy=Wf;let e=Wr.env.VSCODE_NLS_CONFIG;if(e)try{let n=JSON.parse(e);B1=n.userLocale,PE=n.osLocale,hy=n.resolvedLanguage||Wf,cwe=(OO=n.languagePack)==null?void 0:OO.translationsConfigFile}catch{}cL=!0}else typeof navigator=="object"&&!fwe?(co=navigator.userAgent,z3=co.indexOf("Windows")>=0,L3=co.indexOf("Macintosh")>=0,(co.indexOf("Macintosh")>=0||co.indexOf("iPad")>=0||co.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,dy=co.indexOf("Linux")>=0,(co==null?void 0:co.indexOf("Mobi"))>=0,hy=globalThis._VSCODE_NLS_LANGUAGE||Wf,B1=navigator.language.toLowerCase(),PE=B1):console.error("Unable to resolve platform.");var uL=z3,Yo=L3,dwe=dy,AE=cL,Qo=co,Vl=hy,hwe;(e=>{function n(){return Vl}e.value=n;function r(){return Vl.length===2?Vl==="en":Vl.length>=3?Vl[0]==="e"&&Vl[1]==="n"&&Vl[2]==="-":!1}e.isDefaultVariant=r;function i(){return Vl==="en"}e.isDefault=i})(hwe||(hwe={}));var pwe=typeof cu.postMessage=="function"&&!cu.importScripts;(()=>{if(pwe){let e=[];cu.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let i=0,s=e.length;i<s;i++){let o=e[i];if(o.id===r.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let n=0;return r=>{let i=++n;e.push({id:i,callback:r}),cu.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var mwe=!!(Qo&&Qo.indexOf("Chrome")>=0);Qo&&Qo.indexOf("Firefox")>=0;!mwe&&Qo&&Qo.indexOf("Safari")>=0;Qo&&Qo.indexOf("Edg/")>=0;Qo&&Qo.indexOf("Android")>=0;var Lf=typeof navigator=="object"?navigator:{};AE||document.queryCommandSupported&&document.queryCommandSupported("copy")||Lf&&Lf.clipboard&&Lf.clipboard.writeText,AE||Lf&&Lf.clipboard&&Lf.clipboard.readText;var f4=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,n){this._keyCodeToStr[e]=n,this._strToKeyCode[n.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},q2=new f4,ME=new f4,RE=new f4,gwe=new Array(230),fL;(e=>{function n(c){return q2.keyCodeToStr(c)}e.toString=n;function r(c){return q2.strToKeyCode(c)}e.fromString=r;function i(c){return ME.keyCodeToStr(c)}e.toUserSettingsUS=i;function s(c){return RE.keyCodeToStr(c)}e.toUserSettingsGeneral=s;function o(c){return ME.strToKeyCode(c)||RE.strToKeyCode(c)}e.fromUserSettings=o;function a(c){if(c>=98&&c<=113)return null;switch(c){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return q2.keyCodeToStr(c)}e.toElectronAccelerator=a})(fL||(fL={}));var ywe=class dL{constructor(n,r,i,s,o){this.ctrlKey=n,this.shiftKey=r,this.altKey=i,this.metaKey=s,this.keyCode=o}equals(n){return n instanceof dL&&this.ctrlKey===n.ctrlKey&&this.shiftKey===n.shiftKey&&this.altKey===n.altKey&&this.metaKey===n.metaKey&&this.keyCode===n.keyCode}getHashCode(){let n=this.ctrlKey?"1":"0",r=this.shiftKey?"1":"0",i=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${n}${r}${i}${s}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new vwe([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},vwe=class{constructor(e){if(e.length===0)throw U2e("chords");this.chords=e}getHashCode(){let e="";for(let n=0,r=this.chords.length;n<r;n++)n!==0&&(e+=";"),e+=this.chords[n].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let n=0;n<this.chords.length;n++)if(!this.chords[n].equals(e.chords[n]))return!1;return!0}};function _we(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return fL.fromString(r)}let n=e.keyCode;if(n===3)return 7;if(D3)switch(n){case 59:return 85;case 60:if(dwe)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Yo)return 57;break}else if(awe&&(Yo&&n===93||!Yo&&n===92))return 57;return gwe[n]||0}var bwe=Yo?256:2048,xwe=512,wwe=1024,Swe=Yo?2048:256,DE=class{constructor(e){var r;this._standardKeyboardEventBrand=!0;let n=e;this.browserEvent=n,this.target=n.target,this.ctrlKey=n.ctrlKey,this.shiftKey=n.shiftKey,this.altKey=n.altKey,this.metaKey=n.metaKey,this.altGraphKey=(r=n.getModifierState)==null?void 0:r.call(n,"AltGraph"),this.keyCode=_we(n),this.code=n.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let n=0;return this.ctrlKey&&(n|=bwe),this.altKey&&(n|=xwe),this.shiftKey&&(n|=wwe),this.metaKey&&(n|=Swe),n|=e,n}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new ywe(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},zE=new WeakMap;function Cwe(e){if(!e.parent||e.parent===e)return null;try{let n=e.location,r=e.parent.location;if(n.origin!=="null"&&r.origin!=="null"&&n.origin!==r.origin)return null}catch{return null}return e.parent}var jwe=class{static getSameOriginWindowChain(e){let n=zE.get(e);if(!n){n=[],zE.set(e,n);let r=e,i;do i=Cwe(r),i?n.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):n.push({window:new WeakRef(r),iframeElement:null}),r=i;while(r)}return n.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,n){if(!n||e===n)return{top:0,left:0};let r=0,i=0,s=this.getSameOriginWindowChain(e);for(let o of s){let a=o.window.deref();if(r+=(a==null?void 0:a.scrollY)??0,i+=(a==null?void 0:a.scrollX)??0,a===n||!o.iframeElement)break;let c=o.iframeElement.getBoundingClientRect();r+=c.top,i+=c.left}return{top:r,left:i}}},F1=class{constructor(e,n){this.timestamp=Date.now(),this.browserEvent=n,this.leftButton=n.button===0,this.middleButton=n.button===1,this.rightButton=n.button===2,this.buttons=n.buttons,this.target=n.target,this.detail=n.detail||1,n.type==="dblclick"&&(this.detail=2),this.ctrlKey=n.ctrlKey,this.shiftKey=n.shiftKey,this.altKey=n.altKey,this.metaKey=n.metaKey,typeof n.pageX=="number"?(this.posx=n.pageX,this.posy=n.pageY):(this.posx=n.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=n.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let r=jwe.getPositionOfChildWindowRelativeToAncestorWindow(e,n.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},LE=class{constructor(e,n=0,r=0){var s;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=n;let i=!1;if(u4){let o=navigator.userAgent.match(/Chrome\/(\d+)/);i=(o?parseInt(o[1]):123)<=122}if(e){let o=e,a=e,c=((s=e.view)==null?void 0:s.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")i?this.deltaY=o.wheelDeltaY/(120*c):this.deltaY=o.wheelDeltaY/120;else if(typeof a.VERTICAL_AXIS<"u"&&a.axis===a.VERTICAL_AXIS)this.deltaY=-a.detail/3;else if(e.type==="wheel"){let d=e;d.deltaMode===d.DOM_DELTA_LINE?D3&&!Yo?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")lwe&&uL?this.deltaX=-(o.wheelDeltaX/120):i?this.deltaX=o.wheelDeltaX/(120*c):this.deltaX=o.wheelDeltaX/120;else if(typeof a.HORIZONTAL_AXIS<"u"&&a.axis===a.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let d=e;d.deltaMode===d.DOM_DELTA_LINE?D3&&!Yo?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*c):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},hL=Object.freeze(function(e,n){let r=setTimeout(e.bind(n),0);return{dispose(){clearTimeout(r)}}}),kwe;(e=>{function n(r){return r===e.None||r===e.Cancelled||r instanceof Ewe?!0:!r||typeof r!="object"?!1:typeof r.isCancellationRequested=="boolean"&&typeof r.onCancellationRequested=="function"}e.isCancellationToken=n,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Gr.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:hL})})(kwe||(kwe={}));var Ewe=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?hL:(this._emitter||(this._emitter=new nt),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},d4=class{constructor(e,n){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof n=="number"&&this.setIfNotSet(e,n)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,n){if(this._isDisposed)throw new N3("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},n)}setIfNotSet(e,n){if(this._isDisposed)throw new N3("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},n))}},Owe=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,n,r=globalThis){if(this.isDisposed)throw new N3("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=r.setInterval(()=>{e()},n);this.disposable=qn(()=>{r.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Nwe;(e=>{async function n(i){let s,o=await Promise.all(i.map(a=>a.then(c=>c,c=>{s||(s=c)})));if(typeof s<"u")throw s;return o}e.settled=n;function r(i){return new Promise(async(s,o)=>{try{await i(s,o)}catch(a){o(a)}})}e.withAsyncBody=r})(Nwe||(Nwe={}));var $E=class Ts{static fromArray(n){return new Ts(r=>{r.emitMany(n)})}static fromPromise(n){return new Ts(async r=>{r.emitMany(await n)})}static fromPromises(n){return new Ts(async r=>{await Promise.all(n.map(async i=>r.emitOne(await i)))})}static merge(n){return new Ts(async r=>{await Promise.all(n.map(async i=>{for await(let s of i)r.emitOne(s)}))})}constructor(n,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new nt,queueMicrotask(async()=>{let i={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(n(i)),this.resolve()}catch(s){this.reject(s)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let n=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(n<this._results.length)return{done:!1,value:this._results[n++]};if(this._state===1)return{done:!0,value:void 0};await Gr.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var r;return(r=this._onReturn)==null||r.call(this),{done:!0,value:void 0}}}}static map(n,r){return new Ts(async i=>{for await(let s of n)i.emitOne(r(s))})}map(n){return Ts.map(this,n)}static filter(n,r){return new Ts(async i=>{for await(let s of n)r(s)&&i.emitOne(s)})}filter(n){return Ts.filter(this,n)}static coalesce(n){return Ts.filter(n,r=>!!r)}coalesce(){return Ts.coalesce(this)}static async toPromise(n){let r=[];for await(let i of n)r.push(i);return r}toPromise(){return Ts.toPromise(this)}emitOne(n){this._state===0&&(this._results.push(n),this._onStateChanged.fire())}emitMany(n){this._state===0&&(this._results=this._results.concat(n),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(n){this._state===0&&(this._state=2,this._error=n,this._onStateChanged.fire())}};$E.EMPTY=$E.fromArray([]);var{getWindow:qo,getWindowId:Twe,onDidRegisterWindow:Pwe}=(function(){let e=new Map,n={window:Va,disposables:new oc};e.set(Va.vscodeWindowId,n);let r=new nt,i=new nt,s=new nt;function o(a,c){return(typeof a=="number"?e.get(a):void 0)??(c?n:void 0)}return{onDidRegisterWindow:r.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return Xt.None;let c=new oc,d={window:a,disposables:c.add(new oc)};return e.set(a.vscodeWindowId,d),c.add(qn(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),c.add(Rt(a,Er.BEFORE_UNLOAD,()=>{s.fire(a)})),r.fire(d),c},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var h;let c=a;if((h=c==null?void 0:c.ownerDocument)!=null&&h.defaultView)return c.ownerDocument.defaultView.window;let d=a;return d!=null&&d.view?d.view.window:Va},getDocument(a){return qo(a).document}}})(),Awe=class{constructor(e,n,r,i){this._node=e,this._type=n,this._handler=r,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Rt(e,n,r,i){return new Awe(e,n,r,i)}var IE=function(e,n,r,i){return Rt(e,n,r,i)},h4,Mwe=class extends Owe{constructor(e){super(),this.defaultTarget=e&&qo(e)}cancelAndSet(e,n,r){return super.cancelAndSet(e,n,r??this.defaultTarget)}},BE=class{constructor(e,n=0){this._runner=e,this.priority=n,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){fy(e)}}static sort(e,n){return n.priority-e.priority}};(function(){let e=new Map,n=new Map,r=new Map,i=new Map,s=o=>{r.set(o,!1);let a=e.get(o)??[];for(n.set(o,a),e.set(o,[]),i.set(o,!0);a.length>0;)a.sort(BE.sort),a.shift().execute();i.set(o,!1)};h4=(o,a,c=0)=>{let d=Twe(o),h=new BE(a,c),g=e.get(d);return g||(g=[],e.set(d,g)),g.push(h),r.get(d)||(r.set(d,!0),o.requestAnimationFrame(()=>s(d))),h}})();function Rwe(e){let n=e.getBoundingClientRect(),r=qo(e);return{left:n.left+r.scrollX,top:n.top+r.scrollY,width:n.width,height:n.height}}var Er={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Dwe=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let n=zi(e);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let n=zi(e);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(e){let n=zi(e);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(e){let n=zi(e);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(e){let n=zi(e);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(e){let n=zi(e);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(e){let n=zi(e);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(e){let n=zi(e);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let n=zi(e);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let n=zi(e);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let n=zi(e);this._paddingRight!==n&&(this._paddingRight=n,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let n=zi(e);this._fontSize!==n&&(this._fontSize=n,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let n=zi(e);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let n=zi(e);this._letterSpacing!==n&&(this._letterSpacing=n,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,n){this.domNode.classList.toggle(e,n),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,n){this.domNode.setAttribute(e,n)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function zi(e){return typeof e=="number"?`${e}px`:e}function zp(e){return new Dwe(e)}var pL=class{constructor(){this._hooks=new oc,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,n){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(n)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,n,r,i,s){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=s;let o=e;try{e.setPointerCapture(n),this._hooks.add(qn(()=>{try{e.releasePointerCapture(n)}catch{}}))}catch{o=qo(e)}this._hooks.add(Rt(o,Er.POINTER_MOVE,a=>{if(a.buttons!==r){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(Rt(o,Er.POINTER_UP,a=>this.stopMonitoring(!0)))}};function zwe(e,n,r){let i=null,s=null;if(typeof r.value=="function"?(i="value",s=r.value,s.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof r.get=="function"&&(i="get",s=r.get),!s)throw new Error("not supported");let o=`$memoize$${n}`;r[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:s.apply(this,a)}),this[o]}}var $o;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))($o||($o={}));var _p=class ri extends Xt{constructor(){super(),this.dispatched=!1,this.targets=new TE,this.ignoreTargets=new TE,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Gr.runAndSubscribe(Pwe,({window:n,disposables:r})=>{r.add(Rt(n.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),r.add(Rt(n.document,"touchend",i=>this.onTouchEnd(n,i))),r.add(Rt(n.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Va,disposables:this._store}))}static addTarget(n){if(!ri.isTouchDevice())return Xt.None;ri.INSTANCE||(ri.INSTANCE=new ri);let r=ri.INSTANCE.targets.push(n);return qn(r)}static ignoreTarget(n){if(!ri.isTouchDevice())return Xt.None;ri.INSTANCE||(ri.INSTANCE=new ri);let r=ri.INSTANCE.ignoreTargets.push(n);return qn(r)}static isTouchDevice(){return"ontouchstart"in Va||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(n){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,s=n.targetTouches.length;i<s;i++){let o=n.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:r,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[r],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent($o.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}onTouchEnd(n,r){let i=Date.now(),s=Object.keys(this.activeTouches).length;for(let o=0,a=r.changedTouches.length;o<a;o++){let c=r.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("move of an UNKNOWN touch",c);continue}let d=this.activeTouches[c.identifier],h=Date.now()-d.initialTimeStamp;if(h<ri.HOLD_DELAY&&Math.abs(d.initialPageX-as(d.rollingPageX))<30&&Math.abs(d.initialPageY-as(d.rollingPageY))<30){let g=this.newGestureEvent($o.Tap,d.initialTarget);g.pageX=as(d.rollingPageX),g.pageY=as(d.rollingPageY),this.dispatchEvent(g)}else if(h>=ri.HOLD_DELAY&&Math.abs(d.initialPageX-as(d.rollingPageX))<30&&Math.abs(d.initialPageY-as(d.rollingPageY))<30){let g=this.newGestureEvent($o.Contextmenu,d.initialTarget);g.pageX=as(d.rollingPageX),g.pageY=as(d.rollingPageY),this.dispatchEvent(g)}else if(s===1){let g=as(d.rollingPageX),p=as(d.rollingPageY),_=as(d.rollingTimestamps)-d.rollingTimestamps[0],b=g-d.rollingPageX[0],x=p-d.rollingPageY[0],C=[...this.targets].filter(j=>d.initialTarget instanceof Node&&j.contains(d.initialTarget));this.inertia(n,C,i,Math.abs(b)/_,b>0?1:-1,g,Math.abs(x)/_,x>0?1:-1,p)}this.dispatchEvent(this.newGestureEvent($o.End,d.initialTarget)),delete this.activeTouches[c.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(n,r){let i=document.createEvent("CustomEvent");return i.initEvent(n,!1,!0),i.initialTarget=r,i.tapCount=0,i}dispatchEvent(n){if(n.type===$o.Tap){let r=new Date().getTime(),i=0;r-this._lastSetTapCountTime>ri.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=r,n.tapCount=i}else(n.type===$o.Change||n.type===$o.Contextmenu)&&(this._lastSetTapCountTime=0);if(n.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(n.initialTarget))return;let r=[];for(let i of this.targets)if(i.contains(n.initialTarget)){let s=0,o=n.initialTarget;for(;o&&o!==i;)s++,o=o.parentElement;r.push([s,i])}r.sort((i,s)=>i[0]-s[0]);for(let[i,s]of r)s.dispatchEvent(n),this.dispatched=!0}}inertia(n,r,i,s,o,a,c,d,h){this.handle=h4(n,()=>{let g=Date.now(),p=g-i,_=0,b=0,x=!0;s+=ri.SCROLL_FRICTION*p,c+=ri.SCROLL_FRICTION*p,s>0&&(x=!1,_=o*s*p),c>0&&(x=!1,b=d*c*p);let C=this.newGestureEvent($o.Change);C.translationX=_,C.translationY=b,r.forEach(j=>j.dispatchEvent(C)),x||this.inertia(n,r,g,s,o,a+_,c,d,h+b)})}onTouchMove(n){let r=Date.now();for(let i=0,s=n.changedTouches.length;i<s;i++){let o=n.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],c=this.newGestureEvent($o.Change,a.initialTarget);c.translationX=o.pageX-as(a.rollingPageX),c.translationY=o.pageY-as(a.rollingPageY),c.pageX=o.pageX,c.pageY=o.pageY,this.dispatchEvent(c),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(r)}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}};_p.SCROLL_FRICTION=-.005,_p.HOLD_DELAY=700,_p.CLEAR_TAP_COUNT_TIME=400,Zn([zwe],_p,"isTouchDevice",1);var Lwe=_p,p4=class extends Xt{onclick(e,n){this._register(Rt(e,Er.CLICK,r=>n(new F1(qo(e),r))))}onmousedown(e,n){this._register(Rt(e,Er.MOUSE_DOWN,r=>n(new F1(qo(e),r))))}onmouseover(e,n){this._register(Rt(e,Er.MOUSE_OVER,r=>n(new F1(qo(e),r))))}onmouseleave(e,n){this._register(Rt(e,Er.MOUSE_LEAVE,r=>n(new F1(qo(e),r))))}onkeydown(e,n){this._register(Rt(e,Er.KEY_DOWN,r=>n(new DE(r))))}onkeyup(e,n){this._register(Rt(e,Er.KEY_UP,r=>n(new DE(r))))}oninput(e,n){this._register(Rt(e,Er.INPUT,n))}onblur(e,n){this._register(Rt(e,Er.BLUR,n))}onfocus(e,n){this._register(Rt(e,Er.FOCUS,n))}onchange(e,n){this._register(Rt(e,Er.CHANGE,n))}ignoreGesture(e){return Lwe.ignoreTarget(e)}},FE=11,$we=class extends p4{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=FE+"px",this.domNode.style.height=FE+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new pL),this._register(IE(this.bgDomNode,Er.POINTER_DOWN,n=>this._arrowPointerDown(n))),this._register(IE(this.domNode,Er.POINTER_DOWN,n=>this._arrowPointerDown(n))),this._pointerdownRepeatTimer=this._register(new Mwe),this._pointerdownScheduleRepeatTimer=this._register(new d4)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let n=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,qo(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(n,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Iwe=class $3{constructor(n,r,i,s,o,a,c){this._forceIntegerValues=n,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r=r|0,i=i|0,s=s|0,o=o|0,a=a|0,c=c|0),this.rawScrollLeft=s,this.rawScrollTop=c,r<0&&(r=0),s+r>i&&(s=i-r),s<0&&(s=0),o<0&&(o=0),c+o>a&&(c=a-o),c<0&&(c=0),this.width=r,this.scrollWidth=i,this.scrollLeft=s,this.height=o,this.scrollHeight=a,this.scrollTop=c}equals(n){return this.rawScrollLeft===n.rawScrollLeft&&this.rawScrollTop===n.rawScrollTop&&this.width===n.width&&this.scrollWidth===n.scrollWidth&&this.scrollLeft===n.scrollLeft&&this.height===n.height&&this.scrollHeight===n.scrollHeight&&this.scrollTop===n.scrollTop}withScrollDimensions(n,r){return new $3(this._forceIntegerValues,typeof n.width<"u"?n.width:this.width,typeof n.scrollWidth<"u"?n.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,typeof n.height<"u"?n.height:this.height,typeof n.scrollHeight<"u"?n.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(n){return new $3(this._forceIntegerValues,this.width,this.scrollWidth,typeof n.scrollLeft<"u"?n.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof n.scrollTop<"u"?n.scrollTop:this.rawScrollTop)}createScrollEvent(n,r){let i=this.width!==n.width,s=this.scrollWidth!==n.scrollWidth,o=this.scrollLeft!==n.scrollLeft,a=this.height!==n.height,c=this.scrollHeight!==n.scrollHeight,d=this.scrollTop!==n.scrollTop;return{inSmoothScrolling:r,oldWidth:n.width,oldScrollWidth:n.scrollWidth,oldScrollLeft:n.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:n.height,oldScrollHeight:n.scrollHeight,oldScrollTop:n.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:s,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:c,scrollTopChanged:d}}},Bwe=class extends Xt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Iwe(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,n){var i;let r=this._state.withScrollDimensions(e,n);this._setState(r,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let n=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(n,!1)}setScrollPositionSmooth(e,n){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;let i;n?i=new UE(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=UE.start(this._state,r,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),n=this._state.withScrollPosition(e);if(this._setState(n,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,n){let r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,n)))}},HE=class{constructor(e,n,r){this.scrollLeft=e,this.scrollTop=n,this.isDone=r}};function K2(e,n){let r=n-e;return function(i){return e+r*Uwe(i)}}function Fwe(e,n,r){return function(i){return i<r?e(i/r):n((i-r)/(1-r))}}var UE=class I3{constructor(n,r,i,s){this.from=n,this.to=r,this.duration=s,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(n,r,i){if(Math.abs(n-r)>2.5*i){let s,o;return n<r?(s=n+.75*i,o=r-.75*i):(s=n-.75*i,o=r+.75*i),Fwe(K2(n,s),K2(o,r),.33)}return K2(n,r)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(n){this.to=n.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(n){let r=(n-this.startTime)/this.duration;if(r<1){let i=this.scrollLeft(r),s=this.scrollTop(r);return new HE(i,s,!1)}return new HE(this.to.scrollLeft,this.to.scrollTop,!0)}combine(n,r,i){return I3.start(n,r,i)}static start(n,r,i){i=i+10;let s=Date.now()-10;return new I3(n,r,s,i)}};function Hwe(e){return Math.pow(e,3)}function Uwe(e){return 1-Hwe(1-e)}var Vwe=class extends Xt{constructor(e,n,r){super(),this._visibility=e,this._visibleClassName=n,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new d4)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var n;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(n=this._domNode)==null||n.setClassName(this._invisibleClassName+(e?" fade":"")))}},Wwe=140,mL=class extends p4{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Vwe(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new pL),this._shouldRender=!0,this.domNode=zp(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Rt(this.domNode.domNode,Er.POINTER_DOWN,n=>this._domNodePointerDown(n)))}_createArrow(e){let n=this._register(new $we(e));this.domNode.domNode.appendChild(n.bgDomNode),this.domNode.domNode.appendChild(n.domNode)}_createSlider(e,n,r,i){this.slider=zp(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(n),typeof r=="number"&&this.slider.setWidth(r),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Rt(this.slider.domNode,Er.POINTER_DOWN,s=>{s.button===0&&(s.preventDefault(),this._sliderPointerDown(s))})),this.onclick(this.slider.domNode,s=>{s.leftButton&&s.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let n=this.domNode.domNode.getClientRects()[0].top,r=n+this._scrollbarState.getSliderPosition(),i=n+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),s=this._sliderPointerPosition(e);r<=s&&s<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let n,r;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")n=e.offsetX,r=e.offsetY;else{let s=Rwe(this.domNode.domNode);n=e.pageX-s.left,r=e.pageY-s.top}let i=this._pointerDownRelativePosition(n,r);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let n=this._sliderPointerPosition(e),r=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{let o=this._sliderOrthogonalPointerPosition(s),a=Math.abs(o-r);if(uL&&a>Wwe){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let c=this._sliderPointerPosition(s)-n;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(c))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let n={};this.writeScrollPosition(n,e),this._scrollable.setScrollPositionNow(n)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},gL=class B3{constructor(n,r,i,s,o,a){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(n),this._visibleSize=s,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new B3(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(n){let r=Math.round(n);return this._visibleSize!==r?(this._visibleSize=r,this._refreshComputedValues(),!0):!1}setScrollSize(n){let r=Math.round(n);return this._scrollSize!==r?(this._scrollSize=r,this._refreshComputedValues(),!0):!1}setScrollPosition(n){let r=Math.round(n);return this._scrollPosition!==r?(this._scrollPosition=r,this._refreshComputedValues(),!0):!1}setScrollbarSize(n){this._scrollbarSize=Math.round(n)}setOppositeScrollbarSize(n){this._oppositeScrollbarSize=Math.round(n)}static _computeValues(n,r,i,s,o){let a=Math.max(0,i-n),c=Math.max(0,a-2*r),d=s>0&&s>i;if(!d)return{computedAvailableSize:Math.round(a),computedIsNeeded:d,computedSliderSize:Math.round(c),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(i*c/s))),g=(c-h)/(s-i),p=o*g;return{computedAvailableSize:Math.round(a),computedIsNeeded:d,computedSliderSize:Math.round(h),computedSliderRatio:g,computedSliderPosition:Math.round(p)}}_refreshComputedValues(){let n=B3._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=n.computedAvailableSize,this._computedIsNeeded=n.computedIsNeeded,this._computedSliderSize=n.computedSliderSize,this._computedSliderRatio=n.computedSliderRatio,this._computedSliderPosition=n.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(n){if(!this._computedIsNeeded)return 0;let r=n-this._arrowSize-this._computedSliderSize/2;return Math.round(r/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(n){if(!this._computedIsNeeded)return 0;let r=n-this._arrowSize,i=this._scrollPosition;return r<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(n){if(!this._computedIsNeeded)return 0;let r=this._computedSliderPosition+n;return Math.round(r/this._computedSliderRatio)}},qwe=class extends mL{constructor(e,n,r){let i=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:n.lazyRender,host:r,scrollbarState:new gL(n.horizontalHasArrows?n.arrowSize:0,n.horizontal===2?0:n.horizontalScrollbarSize,n.vertical===2?0:n.verticalScrollbarSize,i.width,i.scrollWidth,s.scrollLeft),visibility:n.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:n.scrollByPage}),n.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((n.horizontalScrollbarSize-n.horizontalSliderSize)/2),0,void 0,n.horizontalSliderSize)}_updateSlider(e,n){this.slider.setWidth(e),this.slider.setLeft(n)}_renderDomNode(e,n){this.domNode.setWidth(e),this.domNode.setHeight(n),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,n){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,n){e.scrollLeft=n}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Kwe=class extends mL{constructor(e,n,r){let i=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:n.lazyRender,host:r,scrollbarState:new gL(n.verticalHasArrows?n.arrowSize:0,n.vertical===2?0:n.verticalScrollbarSize,0,i.height,i.scrollHeight,s.scrollTop),visibility:n.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:n.scrollByPage}),n.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((n.verticalScrollbarSize-n.verticalSliderSize)/2),n.verticalSliderSize,void 0)}_updateSlider(e,n){this.slider.setHeight(e),this.slider.setTop(n)}_renderDomNode(e,n){this.domNode.setWidth(n),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,n){return n}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,n){e.scrollTop=n}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},Gwe=500,VE=50,Ywe=class{constructor(e,n,r){this.timestamp=e,this.deltaX=n,this.deltaY=r,this.score=0}},F3=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let n=1,r=0,i=1,s=this._rear;do{let o=s===this._front?n:Math.pow(2,-i);if(n-=o,r+=this._memory[s].score*o,s===this._front)break;s=(this._capacity+s-1)%this._capacity,i++}while(!0);return r<=.5}acceptStandardWheelEvent(n){if(u4){let r=qo(n.browserEvent),i=owe(r);this.accept(Date.now(),n.deltaX*i,n.deltaY*i)}else this.accept(Date.now(),n.deltaX,n.deltaY)}accept(n,r,i){let s=null,o=new Ywe(n,r,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(s=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,s)}_computeScore(n,r){if(Math.abs(n.deltaX)>0&&Math.abs(n.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(n.deltaX)||!this._isAlmostInt(n.deltaY))&&(i+=.25),r){let s=Math.abs(n.deltaX),o=Math.abs(n.deltaY),a=Math.abs(r.deltaX),c=Math.abs(r.deltaY),d=Math.max(Math.min(s,a),1),h=Math.max(Math.min(o,c),1),g=Math.max(s,a),p=Math.max(o,c);g%d===0&&p%h===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(n){return Math.abs(Math.round(n)-n)<.01}};F3.INSTANCE=new F3;var Xwe=F3,Jwe=class extends p4{constructor(e,n,r){super(),this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new nt),this.onWillScroll=this._onWillScroll.event,this._options=Qwe(n),this._scrollable=r,this._register(this._scrollable.onScroll(s=>{this._onWillScroll.fire(s),this._onDidScroll(s),this._onScroll.fire(s)}));let i={onMouseWheel:s=>this._onMouseWheel(s),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Kwe(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new qwe(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=zp(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=zp(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=zp(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,s=>this._onMouseOver(s)),this.onmouseleave(this._listenOnDomNode,s=>this._onMouseLeave(s)),this._hideTimeout=this._register(new d4),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=xu(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Yo&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new LE(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=xu(this._mouseWheelToDispose),e)){let n=r=>{this._onMouseWheel(new LE(r))};this._mouseWheelToDispose.push(Rt(this._listenOnDomNode,Er.MOUSE_WHEEL,n,{passive:!1}))}}_onMouseWheel(e){var s;if((s=e.browserEvent)!=null&&s.defaultPrevented)return;let n=Xwe.INSTANCE;n.acceptStandardWheelEvent(e);let r=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let c=!Yo&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||c)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let d=this._scrollable.getFutureScrollPosition(),h={};if(o){let g=VE*o,p=d.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(h,p)}if(a){let g=VE*a,p=d.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(h,p)}h=this._scrollable.validateScrollPosition(h),(d.scrollLeft!==h.scrollLeft||d.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&n.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),r=!0)}let i=r;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),n=e.scrollTop>0,r=e.scrollLeft>0,i=r?" left":"",s=n?" top":"",o=r||n?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${s}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${s}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Gwe)}},Zwe=class extends Jwe{constructor(e,n,r){super(e,n,r)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Qwe(e){let n={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return n.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:n.horizontalScrollbarSize,n.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:n.verticalScrollbarSize,Yo&&(n.className+=" mac"),n}var H3=class extends Xt{constructor(e,n,r,i,s,o,a,c){super(),this._bufferService=r,this._optionsService=a,this._renderService=c,this._onRequestScrollLines=this._register(new nt),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let d=this._register(new Bwe({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>h4(i.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{d.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Zwe(n,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},d)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(s.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Gr.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(qn(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),n.appendChild(this._styleElement),this._register(qn(()=>this._styleElement.remove())),this._register(Gr.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
777
|
-
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let n=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:n.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,n){n&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!n,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let n=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),r=n-this._bufferService.buffer.ydisp;r!==0&&(this._latestYDisp=n,this._onRequestScrollLines.fire(r)),this._isHandlingScroll=!1}};H3=Zn([ct(2,wi),ct(3,nl),ct(4,Xz),ct(5,Ed),ct(6,Si),ct(7,rl)],H3);var U3=class extends Xt{constructor(e,n,r,i,s){super(),this._screenElement=e,this._bufferService=n,this._coreBrowserService=r,this._decorationService=i,this._renderService=s,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(qn(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var i;let n=this._coreBrowserService.mainDocument.createElement("div");n.classList.add("xterm-decoration"),n.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let r=e.options.x??0;return r&&r>this._bufferService.cols&&(n.style.display="none"),this._refreshXPosition(e,n),n}_refreshStyle(e){let n=e.marker.line-this._bufferService.buffers.active.ydisp;if(n<0||n>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let r=this._decorationElements.get(e);r||(r=this._createElement(e),e.element=r,this._decorationElements.set(e,r),this._container.appendChild(r),e.onDispose(()=>{this._decorationElements.delete(e),r.remove()})),r.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${n*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(r)}}_refreshXPosition(e,n=e.element){if(!n)return;let r=e.options.x??0;(e.options.anchor||"left")==="right"?n.style.right=r?`${r*this._renderService.dimensions.css.cell.width}px`:"":n.style.left=r?`${r*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var n;(n=this._decorationElements.get(e))==null||n.remove(),this._decorationElements.delete(e),e.dispose()}};U3=Zn([ct(1,wi),ct(2,nl),ct(3,Vg),ct(4,rl)],U3);var e3e=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let n of this._zones)if(n.color===e.options.overviewRulerOptions.color&&n.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(n,e.marker.line))return;if(this._lineAdjacentToZone(n,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(n,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,n){return n>=e.startBufferLine&&n<=e.endBufferLine}_lineAdjacentToZone(e,n,r){return n>=e.startBufferLine-this._linePadding[r||"full"]&&n<=e.endBufferLine+this._linePadding[r||"full"]}_addLineToZone(e,n){e.startBufferLine=Math.min(e.startBufferLine,n),e.endBufferLine=Math.max(e.endBufferLine,n)}},Do={full:0,left:0,center:0,right:0},Wl={full:0,left:0,center:0,right:0},ep={full:0,left:0,center:0,right:0},sv=class extends Xt{constructor(e,n,r,i,s,o,a,c){var h;super(),this._viewportElement=e,this._screenElement=n,this._bufferService=r,this._decorationService=i,this._renderService=s,this._optionsService=o,this._themeService=a,this._coreBrowserService=c,this._colorZoneStore=new e3e,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(qn(()=>{var g;return(g=this._canvas)==null?void 0:g.remove()}));let d=this._canvas.getContext("2d");if(d)this._ctx=d;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),n=Math.ceil((this._canvas.width-1)/3);Wl.full=this._canvas.width,Wl.left=e,Wl.center=n,Wl.right=e,this._refreshDrawHeightConstants(),ep.full=1,ep.left=1,ep.center=1+Wl.left,ep.right=1+Wl.left+Wl.center}_refreshDrawHeightConstants(){Do.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,n=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Do.left=n,Do.center=n,Do.right=n}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Do.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Do.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Do.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Do.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let n of this._decorationService.decorations)this._colorZoneStore.addDecoration(n);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let n of e)n.position!=="full"&&this._renderColorZone(n);for(let n of e)n.position==="full"&&this._renderColorZone(n);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(ep[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Do[e.position||"full"]/2),Wl[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Do[e.position||"full"]))}_queueRefresh(e,n){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=n||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};sv=Zn([ct(2,wi),ct(3,Vg),ct(4,rl),ct(5,Si),ct(6,Ed),ct(7,nl)],sv);var He;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
778
|
-
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(He||(He={}));var py;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(py||(py={}));var yL;(e=>e.ST=`${He.ESC}\\`)(yL||(yL={}));var V3=class{constructor(e,n,r,i,s,o){this._textarea=e,this._compositionView=n,this._bufferService=r,this._optionsService=i,this._coreService=s,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let r;n.start+=this._dataAlreadySent.length,this._isComposing?r=this._textarea.value.substring(n.start,this._compositionPosition.start):r=this._textarea.value.substring(n.start),r.length>0&&this._coreService.triggerDataEvent(r,!0)}},0)}else{this._isSendingComposition=!1;let n=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(n,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let n=this._textarea.value,r=n.replace(e,"");this._dataAlreadySent=r,n.length>e.length?this._coreService.triggerDataEvent(r,!0):n.length<e.length?this._coreService.triggerDataEvent(`${He.DEL}`,!0):n.length===e.length&&n!==e&&this._coreService.triggerDataEvent(n,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let n=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),r=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};V3=Zn([ct(2,wi),ct(3,Si),ct(4,Mu),ct(5,rl)],V3);var Or=0,Nr=0,Tr=0,Jn=0,WE={css:"#00000000",rgba:0},gr;(e=>{function n(s,o,a,c){return c!==void 0?`#${Jc(s)}${Jc(o)}${Jc(a)}${Jc(c)}`:`#${Jc(s)}${Jc(o)}${Jc(a)}`}e.toCss=n;function r(s,o,a,c=255){return(s<<24|o<<16|a<<8|c)>>>0}e.toRgba=r;function i(s,o,a,c){return{css:e.toCss(s,o,a,c),rgba:e.toRgba(s,o,a,c)}}e.toColor=i})(gr||(gr={}));var $n;(e=>{function n(d,h){if(Jn=(h.rgba&255)/255,Jn===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,p=h.rgba>>16&255,_=h.rgba>>8&255,b=d.rgba>>24&255,x=d.rgba>>16&255,C=d.rgba>>8&255;Or=b+Math.round((g-b)*Jn),Nr=x+Math.round((p-x)*Jn),Tr=C+Math.round((_-C)*Jn);let j=gr.toCss(Or,Nr,Tr),S=gr.toRgba(Or,Nr,Tr);return{css:j,rgba:S}}e.blend=n;function r(d){return(d.rgba&255)===255}e.isOpaque=r;function i(d,h,g){let p=my.ensureContrastRatio(d.rgba,h.rgba,g);if(p)return gr.toColor(p>>24&255,p>>16&255,p>>8&255)}e.ensureContrastRatio=i;function s(d){let h=(d.rgba|255)>>>0;return[Or,Nr,Tr]=my.toChannels(h),{css:gr.toCss(Or,Nr,Tr),rgba:h}}e.opaque=s;function o(d,h){return Jn=Math.round(h*255),[Or,Nr,Tr]=my.toChannels(d.rgba),{css:gr.toCss(Or,Nr,Tr,Jn),rgba:gr.toRgba(Or,Nr,Tr,Jn)}}e.opacity=o;function a(d,h){return Jn=d.rgba&255,o(d,Jn*h/255)}e.multiplyOpacity=a;function c(d){return[d.rgba>>24&255,d.rgba>>16&255,d.rgba>>8&255]}e.toColorRGB=c})($n||($n={}));var Gn;(e=>{let n,r;try{let s=document.createElement("canvas");s.width=1,s.height=1;let o=s.getContext("2d",{willReadFrequently:!0});o&&(n=o,n.globalCompositeOperation="copy",r=n.createLinearGradient(0,0,1,1))}catch{}function i(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return Or=parseInt(s.slice(1,2).repeat(2),16),Nr=parseInt(s.slice(2,3).repeat(2),16),Tr=parseInt(s.slice(3,4).repeat(2),16),gr.toColor(Or,Nr,Tr);case 5:return Or=parseInt(s.slice(1,2).repeat(2),16),Nr=parseInt(s.slice(2,3).repeat(2),16),Tr=parseInt(s.slice(3,4).repeat(2),16),Jn=parseInt(s.slice(4,5).repeat(2),16),gr.toColor(Or,Nr,Tr,Jn);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let o=s.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Or=parseInt(o[1]),Nr=parseInt(o[2]),Tr=parseInt(o[3]),Jn=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),gr.toColor(Or,Nr,Tr,Jn);if(!n||!r)throw new Error("css.toColor: Unsupported css format");if(n.fillStyle=r,n.fillStyle=s,typeof n.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(n.fillRect(0,0,1,1),[Or,Nr,Tr,Jn]=n.getImageData(0,0,1,1).data,Jn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:gr.toRgba(Or,Nr,Tr,Jn),css:s}}e.toColor=i})(Gn||(Gn={}));var yi;(e=>{function n(i){return r(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=n;function r(i,s,o){let a=i/255,c=s/255,d=o/255,h=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),g=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),p=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4);return h*.2126+g*.7152+p*.0722}e.relativeLuminance2=r})(yi||(yi={}));var my;(e=>{function n(a,c){if(Jn=(c&255)/255,Jn===1)return c;let d=c>>24&255,h=c>>16&255,g=c>>8&255,p=a>>24&255,_=a>>16&255,b=a>>8&255;return Or=p+Math.round((d-p)*Jn),Nr=_+Math.round((h-_)*Jn),Tr=b+Math.round((g-b)*Jn),gr.toRgba(Or,Nr,Tr)}e.blend=n;function r(a,c,d){let h=yi.relativeLuminance(a>>8),g=yi.relativeLuminance(c>>8);if($a(h,g)<d){if(g<h){let b=i(a,c,d),x=$a(h,yi.relativeLuminance(b>>8));if(x<d){let C=s(a,c,d),j=$a(h,yi.relativeLuminance(C>>8));return x>j?b:C}return b}let p=s(a,c,d),_=$a(h,yi.relativeLuminance(p>>8));if(_<d){let b=i(a,c,d),x=$a(h,yi.relativeLuminance(b>>8));return _>x?p:b}return p}}e.ensureContrastRatio=r;function i(a,c,d){let h=a>>24&255,g=a>>16&255,p=a>>8&255,_=c>>24&255,b=c>>16&255,x=c>>8&255,C=$a(yi.relativeLuminance2(_,b,x),yi.relativeLuminance2(h,g,p));for(;C<d&&(_>0||b>0||x>0);)_-=Math.max(0,Math.ceil(_*.1)),b-=Math.max(0,Math.ceil(b*.1)),x-=Math.max(0,Math.ceil(x*.1)),C=$a(yi.relativeLuminance2(_,b,x),yi.relativeLuminance2(h,g,p));return(_<<24|b<<16|x<<8|255)>>>0}e.reduceLuminance=i;function s(a,c,d){let h=a>>24&255,g=a>>16&255,p=a>>8&255,_=c>>24&255,b=c>>16&255,x=c>>8&255,C=$a(yi.relativeLuminance2(_,b,x),yi.relativeLuminance2(h,g,p));for(;C<d&&(_<255||b<255||x<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),C=$a(yi.relativeLuminance2(_,b,x),yi.relativeLuminance2(h,g,p));return(_<<24|b<<16|x<<8|255)>>>0}e.increaseLuminance=s;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(my||(my={}));function Jc(e){let n=e.toString(16);return n.length<2?"0"+n:n}function $a(e,n){return e<n?(n+.05)/(e+.05):(e+.05)/(n+.05)}var t3e=class extends Ug{constructor(e,n,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=n,this._width=r}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ov=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Bs}register(e){let n={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(n),n.id}deregister(e){for(let n=0;n<this._characterJoiners.length;n++)if(this._characterJoiners[n].id===e)return this._characterJoiners.splice(n,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let n=this._bufferService.buffer.lines.get(e);if(!n||n.length===0)return[];let r=[],i=n.translateToString(!0),s=0,o=0,a=0,c=n.getFg(0),d=n.getBg(0);for(let h=0;h<n.getTrimmedLength();h++)if(n.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==c||this._workCell.bg!==d){if(h-s>1){let g=this._getJoinedRanges(i,a,o,n,s);for(let p=0;p<g.length;p++)r.push(g[p])}s=h,a=o,c=this._workCell.fg,d=this._workCell.bg}o+=this._workCell.getChars().length||nc.length}if(this._bufferService.cols-s>1){let h=this._getJoinedRanges(i,a,o,n,s);for(let g=0;g<h.length;g++)r.push(h[g])}return r}_getJoinedRanges(e,n,r,i,s){let o=e.substring(n,r),a=[];try{a=this._characterJoiners[0].handler(o)}catch(c){console.error(c)}for(let c=1;c<this._characterJoiners.length;c++)try{let d=this._characterJoiners[c].handler(o);for(let h=0;h<d.length;h++)ov._mergeRanges(a,d[h])}catch(d){console.error(d)}return this._stringRangesToCellRanges(a,i,s),a}_stringRangesToCellRanges(e,n,r){let i=0,s=!1,o=0,a=e[i];if(a){for(let c=r;c<this._bufferService.cols;c++){let d=n.getWidth(c),h=n.getString(c).length||nc.length;if(d!==0){if(!s&&a[0]<=o&&(a[0]=c,s=!0),a[1]<=o){if(a[1]=c,a=e[++i],!a)break;a[0]<=o?(a[0]=c,s=!0):s=!1}o+=h}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,n){let r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(r){if(n[1]<=s[0])return e[i-1][1]=n[1],e;if(n[1]<=s[1])return e[i-1][1]=Math.max(n[1],s[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(n[1]<=s[0])return e.splice(i,0,n),e;if(n[1]<=s[1])return s[0]=Math.min(n[0],s[0]),e;n[0]<s[1]&&(s[0]=Math.min(n[0],s[0]),r=!0);continue}}return r?e[e.length-1][1]=n[1]:e.push(n),e}};ov=Zn([ct(0,wi)],ov);function n3e(e){return 57508<=e&&e<=57558}function r3e(e){return 9472<=e&&e<=9631}function i3e(e){return n3e(e)||r3e(e)}function s3e(){return{css:{canvas:H1(),cell:H1()},device:{canvas:H1(),cell:H1(),char:{width:0,height:0,left:0,top:0}}}}function H1(){return{width:0,height:0}}var W3=class{constructor(e,n,r,i,s,o,a){this._document=e,this._characterJoinerService=n,this._optionsService=r,this._coreBrowserService=i,this._coreService=s,this._decorationService=o,this._themeService=a,this._workCell=new Bs,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,n,r){this._selectionStart=e,this._selectionEnd=n,this._columnSelectMode=r}createRow(e,n,r,i,s,o,a,c,d,h,g){let p=[],_=this._characterJoinerService.getJoinedCharacters(n),b=this._themeService.colors,x=e.getNoBgTrimmedLength();r&&x<o+1&&(x=o+1);let C,j=0,S="",E=0,O=0,N=0,T=0,P=!1,D=0,H=!1,J=0,I=0,B=[],F=h!==-1&&g!==-1;for(let W=0;W<x;W++){e.loadCell(W,this._workCell);let z=this._workCell.getWidth();if(z===0)continue;let V=!1,A=W>=I,U=W,K=this._workCell;if(_.length>0&&W===_[0][0]&&A){let me=_.shift(),Ye=this._isCellInSelection(me[0],n);for(E=me[0]+1;E<me[1];E++)A&&(A=Ye===this._isCellInSelection(E,n));A&&(A=!r||o<me[0]||o>=me[1]),A?(V=!0,K=new t3e(this._workCell,e.translateToString(!0,me[0],me[1]),me[1]-me[0]),U=me[1]-1,z=K.getWidth()):I=me[1]}let Y=this._isCellInSelection(W,n),$=r&&W===o,R=F&&W>=h&&W<=g,Z=!1;this._decorationService.forEachDecorationAtCell(W,n,void 0,me=>{Z=!0});let L=K.getChars()||nc;if(L===" "&&(K.isUnderline()||K.isOverline())&&(L=" "),J=z*c-d.get(L,K.isBold(),K.isItalic()),!C)C=this._document.createElement("span");else if(j&&(Y&&H||!Y&&!H&&K.bg===O)&&(Y&&H&&b.selectionForeground||K.fg===N)&&K.extended.ext===T&&R===P&&J===D&&!$&&!V&&!Z&&A){K.isInvisible()?S+=nc:S+=L,j++;continue}else j&&(C.textContent=S),C=this._document.createElement("span"),j=0,S="";if(O=K.bg,N=K.fg,T=K.extended.ext,P=R,D=J,H=Y,V&&o>=W&&o<=U&&(o=W),!this._coreService.isCursorHidden&&$&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&B.push("xterm-cursor-blink"),B.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(s)switch(s){case"outline":B.push("xterm-cursor-outline");break;case"block":B.push("xterm-cursor-block");break;case"bar":B.push("xterm-cursor-bar");break;case"underline":B.push("xterm-cursor-underline");break}}if(K.isBold()&&B.push("xterm-bold"),K.isItalic()&&B.push("xterm-italic"),K.isDim()&&B.push("xterm-dim"),K.isInvisible()?S=nc:S=K.getChars()||nc,K.isUnderline()&&(B.push(`xterm-underline-${K.extended.underlineStyle}`),S===" "&&(S=" "),!K.isUnderlineColorDefault()))if(K.isUnderlineColorRGB())C.style.textDecorationColor=`rgb(${Ug.toColorRGB(K.getUnderlineColor()).join(",")})`;else{let me=K.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&K.isBold()&&me<8&&(me+=8),C.style.textDecorationColor=b.ansi[me].css}K.isOverline()&&(B.push("xterm-overline"),S===" "&&(S=" ")),K.isStrikethrough()&&B.push("xterm-strikethrough"),R&&(C.style.textDecoration="underline");let Q=K.getFgColor(),X=K.getFgColorMode(),ie=K.getBgColor(),se=K.getBgColorMode(),ce=!!K.isInverse();if(ce){let me=Q;Q=ie,ie=me;let Ye=X;X=se,se=Ye}let be,ze,fe=!1;this._decorationService.forEachDecorationAtCell(W,n,void 0,me=>{me.options.layer!=="top"&&fe||(me.backgroundColorRGB&&(se=50331648,ie=me.backgroundColorRGB.rgba>>8&16777215,be=me.backgroundColorRGB),me.foregroundColorRGB&&(X=50331648,Q=me.foregroundColorRGB.rgba>>8&16777215,ze=me.foregroundColorRGB),fe=me.options.layer==="top")}),!fe&&Y&&(be=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,ie=be.rgba>>8&16777215,se=50331648,fe=!0,b.selectionForeground&&(X=50331648,Q=b.selectionForeground.rgba>>8&16777215,ze=b.selectionForeground)),fe&&B.push("xterm-decoration-top");let Ce;switch(se){case 16777216:case 33554432:Ce=b.ansi[ie],B.push(`xterm-bg-${ie}`);break;case 50331648:Ce=gr.toColor(ie>>16,ie>>8&255,ie&255),this._addStyle(C,`background-color:#${qE((ie>>>0).toString(16),"0",6)}`);break;case 0:default:ce?(Ce=b.foreground,B.push("xterm-bg-257")):Ce=b.background}switch(be||K.isDim()&&(be=$n.multiplyOpacity(Ce,.5)),X){case 16777216:case 33554432:K.isBold()&&Q<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Q+=8),this._applyMinimumContrast(C,Ce,b.ansi[Q],K,be,void 0)||B.push(`xterm-fg-${Q}`);break;case 50331648:let me=gr.toColor(Q>>16&255,Q>>8&255,Q&255);this._applyMinimumContrast(C,Ce,me,K,be,ze)||this._addStyle(C,`color:#${qE(Q.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(C,Ce,b.foreground,K,be,ze)||ce&&B.push("xterm-fg-257")}B.length&&(C.className=B.join(" "),B.length=0),!$&&!V&&!Z&&A?j++:C.textContent=S,J!==this.defaultSpacing&&(C.style.letterSpacing=`${J}px`),p.push(C),W=U}return C&&j&&(C.textContent=S),p}_applyMinimumContrast(e,n,r,i,s,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||i3e(i.getCode()))return!1;let a=this._getContrastCache(i),c;if(!s&&!o&&(c=a.getColor(n.rgba,r.rgba)),c===void 0){let d=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);c=$n.ensureContrastRatio(s||n,o||r,d),a.setColor((s||n).rgba,(o||r).rgba,c??null)}return c?(this._addStyle(e,`color:${c.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,n){e.setAttribute("style",`${e.getAttribute("style")||""}${n};`)}_isCellInSelection(e,n){let r=this._selectionStart,i=this._selectionEnd;return!r||!i?!1:this._columnSelectMode?r[0]<=i[0]?e>=r[0]&&n>=r[1]&&e<i[0]&&n<=i[1]:e<r[0]&&n>=r[1]&&e>=i[0]&&n<=i[1]:n>r[1]&&n<i[1]||r[1]===i[1]&&n===r[1]&&e>=r[0]&&e<i[0]||r[1]<i[1]&&n===i[1]&&e<i[0]||r[1]<i[1]&&n===r[1]&&e>=r[0]}};W3=Zn([ct(1,Qz),ct(2,Si),ct(3,nl),ct(4,Mu),ct(5,Vg),ct(6,Ed)],W3);function qE(e,n,r){for(;e.length<r;)e=n+e;return e}var o3e=class{constructor(e,n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let r=e.createElement("span");r.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[r,i,s,o],this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(o),n.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,n,r,i){e===this._font&&n===this._fontSize&&r===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=n,this._weight=r,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,n,r){let i=0;if(!n&&!r&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(e,0);return a>0&&(this._flat[i]=a),a}let s=e;n&&(s+="B"),r&&(s+="I");let o=this._holey.get(s);if(o===void 0){let a=0;n&&(a|=1),r&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(s,o)}return o}_measure(e,n){let r=this._measureElements[n];return r.textContent=e.repeat(32),r.offsetWidth/32}},a3e=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,n,r,i=!1){if(this.selectionStart=n,this.selectionEnd=r,!n||!r||n[0]===r[0]&&n[1]===r[1]){this.clear();return}let s=e.buffers.active.ydisp,o=n[1]-s,a=r[1]-s,c=Math.max(o,0),d=Math.min(a,e.rows-1);if(c>=e.rows||d<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=c,this.viewportCappedEndRow=d,this.startCol=n[0],this.endCol=r[0]}isCellSelected(e,n,r){return this.hasSelection?(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?n>=this.startCol&&r>=this.viewportCappedStartRow&&n<this.endCol&&r<=this.viewportCappedEndRow:n<this.startCol&&r>=this.viewportCappedStartRow&&n>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&n>=this.startCol&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&n>=this.startCol):!1}};function l3e(){return new a3e}var G2="xterm-dom-renderer-owner-",Ns="xterm-rows",U1="xterm-fg-",KE="xterm-bg-",tp="xterm-focus",V1="xterm-selection",c3e=1,q3=class extends Xt{constructor(e,n,r,i,s,o,a,c,d,h,g,p,_,b){super(),this._terminal=e,this._document=n,this._element=r,this._screenElement=i,this._viewportElement=s,this._helperContainer=o,this._linkifier2=a,this._charSizeService=d,this._optionsService=h,this._bufferService=g,this._coreService=p,this._coreBrowserService=_,this._themeService=b,this._terminalClass=c3e++,this._rowElements=[],this._selectionRenderModel=l3e(),this.onRequestRedraw=this._register(new nt).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ns),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(V1),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=s3e(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=c.createInstance(W3,document),this._element.classList.add(G2+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(qn(()=>{this._element.classList.remove(G2+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new o3e(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let r of this._rowElements)r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let n=`${this._terminalSelector} .${Ns} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=n,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let n=`${this._terminalSelector} .${Ns} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;n+=`${this._terminalSelector} .${Ns} .xterm-dim { color: ${$n.multiplyOpacity(e.foreground,.5).css};}`,n+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let r=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,s=`blink_block_${this._terminalClass}`;n+=`@keyframes ${r} { 50% { border-bottom-style: hidden; }}`,n+=`@keyframes ${i} { 50% { box-shadow: none; }}`,n+=`@keyframes ${s} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,n+=`${this._terminalSelector} .${Ns}.${tp} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ns}.${tp} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ns}.${tp} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,n+=`${this._terminalSelector} .${V1} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${V1} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${V1} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())n+=`${this._terminalSelector} .${U1}${o} { color: ${a.css}; }${this._terminalSelector} .${U1}${o}.xterm-dim { color: ${$n.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${KE}${o} { background-color: ${a.css}; }`;n+=`${this._terminalSelector} .${U1}257 { color: ${$n.opaque(e.background).css}; }${this._terminalSelector} .${U1}257.xterm-dim { color: ${$n.multiplyOpacity($n.opaque(e.background),.5).css}; }${this._terminalSelector} .${KE}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=n}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,n){for(let r=this._rowElements.length;r<=n;r++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>n;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,n){this._refreshRowElements(e,n),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(tp),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(tp),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,n,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,n,r),this.renderRows(0,this._bufferService.rows-1),!e||!n||(this._selectionRenderModel.update(this._terminal,e,n,r),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,s=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,c=this._document.createDocumentFragment();if(r){let d=e[0]>n[0];c.appendChild(this._createSelectionElement(o,d?n[0]:e[0],d?e[0]:n[0],a-o+1))}else{let d=i===o?e[0]:0,h=o===s?n[0]:this._bufferService.cols;c.appendChild(this._createSelectionElement(o,d,h));let g=a-o-1;if(c.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,g)),o!==a){let p=s===a?n[0]:this._bufferService.cols;c.appendChild(this._createSelectionElement(a,0,p))}}this._selectionContainer.appendChild(c)}_createSelectionElement(e,n,r,i=1){let s=this._document.createElement("div"),o=n*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(r-n);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),s.style.height=`${i*this.dimensions.css.cell.height}px`,s.style.top=`${e*this.dimensions.css.cell.height}px`,s.style.left=`${o}px`,s.style.width=`${a}px`,s}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,n){let r=this._bufferService.buffer,i=r.ybase+r.y,s=Math.min(r.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,c=this._optionsService.rawOptions.cursorInactiveStyle;for(let d=e;d<=n;d++){let h=d+r.ydisp,g=this._rowElements[d],p=r.lines.get(h);if(!g||!p)break;g.replaceChildren(...this._rowFactory.createRow(p,h,h===i,a,c,s,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${G2}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,n,r,i,s,o){r<0&&(e=0),i<0&&(n=0);let a=this._bufferService.rows-1;r=Math.max(Math.min(r,a),0),i=Math.max(Math.min(i,a),0),s=Math.min(s,this._bufferService.cols);let c=this._bufferService.buffer,d=c.ybase+c.y,h=Math.min(c.x,s-1),g=this._optionsService.rawOptions.cursorBlink,p=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let b=r;b<=i;++b){let x=b+c.ydisp,C=this._rowElements[b],j=c.lines.get(x);if(!C||!j)break;C.replaceChildren(...this._rowFactory.createRow(j,x,x===d,p,_,h,g,this.dimensions.css.cell.width,this._widthCache,o?b===r?e:0:-1,o?(b===i?n:s)-1:-1))}}};q3=Zn([ct(7,a4),ct(8,i_),ct(9,Si),ct(10,wi),ct(11,Mu),ct(12,nl),ct(13,Ed)],q3);var K3=class extends Xt{constructor(e,n,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new nt),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new f3e(this._optionsService))}catch{this._measureStrategy=this._register(new u3e(e,n,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};K3=Zn([ct(2,Si)],K3);var vL=class extends Xt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,n){e!==void 0&&e>0&&n!==void 0&&n>0&&(this._result.width=e,this._result.height=n)}},u3e=class extends vL{constructor(e,n,r){super(),this._document=e,this._parentElement=n,this._optionsService=r,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},f3e=class extends vL{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let n=this._ctx.measureText("W");if(!("width"in n&&"fontBoundingBoxAscent"in n&&"fontBoundingBoxDescent"in n))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},d3e=class extends Xt{constructor(e,n,r){super(),this._textarea=e,this._window=n,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new h3e(this._window)),this._onDprChange=this._register(new nt),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new nt),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(Gr.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Rt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Rt(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},h3e=class extends Xt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ld),this._onDprChange=this._register(new nt),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(qn(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Rt(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},p3e=class extends Xt{constructor(){super(),this.linkProviders=[],this._register(qn(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let n=this.linkProviders.indexOf(e);n!==-1&&this.linkProviders.splice(n,1)}}}};function m4(e,n,r){let i=r.getBoundingClientRect(),s=e.getComputedStyle(r),o=parseInt(s.getPropertyValue("padding-left")),a=parseInt(s.getPropertyValue("padding-top"));return[n.clientX-i.left-o,n.clientY-i.top-a]}function m3e(e,n,r,i,s,o,a,c,d){if(!o)return;let h=m4(e,n,r);if(h)return h[0]=Math.ceil((h[0]+(d?a/2:0))/a),h[1]=Math.ceil(h[1]/c),h[0]=Math.min(Math.max(h[0],1),i+(d?1:0)),h[1]=Math.min(Math.max(h[1],1),s),h}var G3=class{constructor(e,n){this._renderService=e,this._charSizeService=n}getCoords(e,n,r,i,s){return m3e(window,e,n,r,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,s)}getMouseReportCoords(e,n){let r=m4(window,e,n);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};G3=Zn([ct(0,rl),ct(1,i_)],G3);var g3e=class{constructor(e,n){this._renderCallback=e,this._coreBrowserService=n,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,n,r){this._rowCount=r,e=e!==void 0?e:0,n=n!==void 0?n:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,n):n,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),n=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,n),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},_L={};k2e(_L,{getSafariVersion:()=>v3e,isChromeOS:()=>SL,isFirefox:()=>bL,isIpad:()=>_3e,isIphone:()=>b3e,isLegacyEdge:()=>y3e,isLinux:()=>g4,isMac:()=>av,isNode:()=>s_,isSafari:()=>xL,isWindows:()=>wL});var s_=typeof process<"u"&&"title"in process,Wg=s_?"node":navigator.userAgent,qg=s_?"node":navigator.platform,bL=Wg.includes("Firefox"),y3e=Wg.includes("Edge"),xL=/^((?!chrome|android).)*safari/i.test(Wg);function v3e(){if(!xL)return 0;let e=Wg.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var av=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(qg),_3e=qg==="iPad",b3e=qg==="iPhone",wL=["Windows","Win16","Win32","WinCE"].includes(qg),g4=qg.indexOf("Linux")>=0,SL=/\bCrOS\b/.test(Wg),CL=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),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(e){this._idleCallback=void 0;let n=0,r=0,i=e.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(n=performance.now(),this._tasks[this._i]()||this._i++,n=Math.max(1,performance.now()-n),r=Math.max(n,r),s=e.timeRemaining(),r*1.5>s){i-n<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-n))}ms`),this._start();return}i=s}this.clear()}},x3e=class extends CL{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let n=performance.now()+e;return{timeRemaining:()=>Math.max(0,n-performance.now())}}},w3e=class extends CL{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},lv=!s_&&"requestIdleCallback"in window?w3e:x3e,S3e=class{constructor(){this._queue=new lv}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Y3=class extends Xt{constructor(e,n,r,i,s,o,a,c,d){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=i,this._coreService=s,this._coreBrowserService=c,this._renderer=this._register(new ld),this._pausedResizeTask=new S3e,this._observerDisposable=this._register(new ld),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new nt),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new nt),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new nt),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new nt),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g3e((h,g)=>this._renderRows(h,g),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new C3e(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(qn(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(d.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,n),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,n)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,n){if("IntersectionObserver"in e){let r=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});r.observe(n),this._observerDisposable.value=qn(()=>r.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,n,r=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,n);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),n=Math.max(n,i.end)),r||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,n,this._rowCount)}_renderRows(e,n){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,n);return}e=Math.min(e,this._rowCount-1),n=Math.min(n,this._rowCount-1),this._renderer.value.renderRows(e,n),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:n}),this._onRender.fire({start:e,end:n}),this._isNextRenderRedrawOnly=!0}}resize(e,n){this._rowCount=n,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(n=>this.refreshRows(n.start,n.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,n;this._renderer.value&&((n=(e=this._renderer.value).clearTextureAtlas)==null||n.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,n){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var r;return(r=this._renderer.value)==null?void 0:r.handleResize(e,n)}):this._renderer.value.handleResize(e,n),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,n,r){var i;this._selectionState.start=e,this._selectionState.end=n,this._selectionState.columnSelectMode=r,(i=this._renderer.value)==null||i.handleSelectionChanged(e,n,r)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Y3=Zn([ct(2,Si),ct(3,i_),ct(4,Mu),ct(5,Vg),ct(6,wi),ct(7,nl),ct(8,Ed)],Y3);var C3e=class{constructor(e,n,r){this._coreBrowserService=e,this._coreService=n,this._onTimeout=r,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,n){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,n)):(this._start=e,this._end=n,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function j3e(e,n,r,i){let s=r.buffer.x,o=r.buffer.y;if(!r.buffer.hasScrollback)return O3e(s,o,e,n,r,i)+o_(o,n,r,i)+N3e(s,o,e,n,r,i);let a;if(o===n)return a=s>e?"D":"C",pg(Math.abs(s-e),hg(a,i));a=o>n?"D":"C";let c=Math.abs(o-n),d=E3e(o>n?e:s,r)+(c-1)*r.cols+1+k3e(o>n?s:e);return pg(d,hg(a,i))}function k3e(e,n){return e-1}function E3e(e,n){return n.cols-e}function O3e(e,n,r,i,s,o){return o_(n,i,s,o).length===0?"":pg(kL(e,n,e,n-wu(n,s),!1,s).length,hg("D",o))}function o_(e,n,r,i){let s=e-wu(e,r),o=n-wu(n,r),a=Math.abs(s-o)-T3e(e,n,r);return pg(a,hg(jL(e,n),i))}function N3e(e,n,r,i,s,o){let a;o_(n,i,s,o).length>0?a=i-wu(i,s):a=n;let c=i,d=P3e(e,n,r,i,s,o);return pg(kL(e,a,r,c,d==="C",s).length,hg(d,o))}function T3e(e,n,r){var a;let i=0,s=e-wu(e,r),o=n-wu(n,r);for(let c=0;c<Math.abs(s-o);c++){let d=jL(e,n)==="A"?-1:1;(a=r.buffer.lines.get(s+d*c))!=null&&a.isWrapped&&i++}return i}function wu(e,n){let r=0,i=n.buffer.lines.get(e),s=i==null?void 0:i.isWrapped;for(;s&&e>=0&&e<n.rows;)r++,i=n.buffer.lines.get(--e),s=i==null?void 0:i.isWrapped;return r}function P3e(e,n,r,i,s,o){let a;return o_(r,i,s,o).length>0?a=i-wu(i,s):a=n,e<r&&a<=i||e>=r&&a<i?"C":"D"}function jL(e,n){return e>n?"A":"B"}function kL(e,n,r,i,s,o){let a=e,c=n,d="";for(;(a!==r||c!==i)&&c>=0&&c<o.buffer.lines.length;)a+=s?1:-1,s&&a>o.cols-1?(d+=o.buffer.translateBufferLineToString(c,!1,e,a),a=0,e=0,c++):!s&&a<0&&(d+=o.buffer.translateBufferLineToString(c,!1,0,e+1),a=o.cols-1,e=a,c--);return d+o.buffer.translateBufferLineToString(c,!1,e,a)}function hg(e,n){let r=n?"O":"[";return He.ESC+r+e}function pg(e,n){e=Math.floor(e);let r="";for(let i=0;i<e;i++)r+=n;return r}var A3e=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,n=this.selectionEnd;return!e||!n?!1:e[1]>n[1]||e[1]===n[1]&&e[0]>n[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function GE(e,n){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return n*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Y2=50,M3e=15,R3e=50,D3e=500,z3e=" ",L3e=new RegExp(z3e,"g"),X3=class extends Xt{constructor(e,n,r,i,s,o,a,c,d){super(),this._element=e,this._screenElement=n,this._linkifier=r,this._bufferService=i,this._coreService=s,this._mouseService=o,this._optionsService=a,this._renderService=c,this._coreBrowserService=d,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Bs,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new nt),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new nt),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new nt),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new nt),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new A3e(this._bufferService),this._activeSelectionMode=0,this._register(qn(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!e||!n?!1:e[0]!==n[0]||e[1]!==n[1]}get selectionText(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;if(!e||!n)return"";let r=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===n[0])return"";let s=e[0]<n[0]?e[0]:n[0],o=e[0]<n[0]?n[0]:e[0];for(let a=e[1];a<=n[1];a++){let c=r.translateBufferLineToString(a,!0,s,o);i.push(c)}}else{let s=e[1]===n[1]?n[0]:void 0;i.push(r.translateBufferLineToString(e[1],!0,e[0],s));for(let o=e[1]+1;o<=n[1]-1;o++){let a=r.lines.get(o),c=r.translateBufferLineToString(o,!0);a!=null&&a.isWrapped?i[i.length-1]+=c:i.push(c)}if(e[1]!==n[1]){let o=r.lines.get(n[1]),a=r.translateBufferLineToString(n[1],!0,0,n[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(s=>s.replace(L3e," ")).join(wL?`\r
|
|
776
|
+
`))}},ewe=class extends Error{constructor(e,n){super(e),this.name="ListenerLeakError",this.stack=n}},twe=class extends Error{constructor(e,n){super(e),this.name="ListenerRefusalError",this.stack=n}},nwe=0,V2=class{constructor(e){this.value=e,this.id=nwe++}},rwe=2,iwe,nt=class{constructor(n){var r,i,s,o;this._size=0,this._options=n,this._leakageMon=(r=this._options)!=null&&r.leakWarningThreshold?new Z2e((n==null?void 0:n.onListenerError)??fy,((i=this._options)==null?void 0:i.leakWarningThreshold)??J2e):void 0,this._perfMon=(s=this._options)!=null&&s._profName?new X2e(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var n,r,i,s;this._disposed||(this._disposed=!0,((n=this._deliveryQueue)==null?void 0:n.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(r=this._options)==null?void 0:r.onDidRemoveLastListener)==null||i.call(r),(s=this._leakageMon)==null||s.dispose())}get event(){return this._event??(this._event=(n,r,i)=>{var c,d,h,g,p;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let _=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(_);let b=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],x=new twe(`${_}. HINT: Stack shows most frequent listener (${b[1]}-times)`,b[0]);return(((c=this._options)==null?void 0:c.onListenerError)||fy)(x),Xt.None}if(this._disposed)return Xt.None;r&&(n=n.bind(r));let s=new V2(n),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(s.stack=Q2e.create(),o=this._leakageMon.check(s.stack,this._size+1)),this._listeners?this._listeners instanceof V2?(this._deliveryQueue??(this._deliveryQueue=new swe),this._listeners=[this._listeners,s]):this._listeners.push(s):((h=(d=this._options)==null?void 0:d.onWillAddFirstListener)==null||h.call(d,this),this._listeners=s,(p=(g=this._options)==null?void 0:g.onDidAddFirstListener)==null||p.call(g,this)),this._size++;let a=qn(()=>{o==null||o(),this._removeListener(s)});return i instanceof oc?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(n){var o,a,c,d;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(d=(c=this._options)==null?void 0:c.onDidRemoveLastListener)==null||d.call(c,this),this._size=0;return}let r=this._listeners,i=r.indexOf(n);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,r[i]=void 0;let s=this._deliveryQueue.current===this;if(this._size*rwe<=r.length){let h=0;for(let g=0;g<r.length;g++)r[g]?r[h++]=r[g]:s&&(this._deliveryQueue.end--,h<this._deliveryQueue.i&&this._deliveryQueue.i--);r.length=h}}_deliver(n,r){var s;if(!n)return;let i=((s=this._options)==null?void 0:s.onListenerError)||fy;if(!i){n.value(r);return}try{n.value(r)}catch(o){i(o)}}_deliverQueue(n){let r=n.current._listeners;for(;n.i<n.end;)this._deliver(r[n.i++],n.value);n.reset()}fire(n){var r,i,s,o;if((r=this._deliveryQueue)!=null&&r.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(s=this._perfMon)==null||s.start(this._size),this._listeners)if(this._listeners instanceof V2)this._deliver(this._listeners,n);else{let a=this._deliveryQueue;a.enqueue(this,n,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},swe=class{constructor(){this.i=-1,this.end=0}enqueue(e,n,r){this.i=0,this.end=r,this.current=e,this.value=n}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},R3=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new nt,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new nt,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(n){return this.mapWindowIdToZoomLevel.get(this.getWindowId(n))??0}setZoomLevel(n,r){if(this.getZoomLevel(r)===n)return;let i=this.getWindowId(r);this.mapWindowIdToZoomLevel.set(i,n),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(n){return this.mapWindowIdToZoomFactor.get(this.getWindowId(n))??1}setZoomFactor(n,r){this.mapWindowIdToZoomFactor.set(this.getWindowId(r),n)}setFullscreen(n,r){if(this.isFullscreen(r)===n)return;let i=this.getWindowId(r);this.mapWindowIdToFullScreen.set(i,n),this._onDidChangeFullscreen.fire(i)}isFullscreen(n){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(n))}getWindowId(n){return n.vscodeWindowId}};R3.INSTANCE=new R3;var c4=R3;function owe(e,n,r){typeof n=="string"&&(n=e.matchMedia(n)),n.addEventListener("change",r)}c4.INSTANCE.onDidChangeZoomLevel;function awe(e){return c4.INSTANCE.getZoomFactor(e)}c4.INSTANCE.onDidChangeFullscreen;var Od=typeof navigator=="object"?navigator.userAgent:"",D3=Od.indexOf("Firefox")>=0,lwe=Od.indexOf("AppleWebKit")>=0,u4=Od.indexOf("Chrome")>=0,cwe=!u4&&Od.indexOf("Safari")>=0;Od.indexOf("Electron/")>=0;Od.indexOf("Android")>=0;var W2=!1;if(typeof Va.matchMedia=="function"){let e=Va.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),n=Va.matchMedia("(display-mode: fullscreen)");W2=e.matches,owe(Va,e,({matches:r})=>{W2&&n.matches||(W2=r)})}var Wf="en",z3=!1,L3=!1,dy=!1,cL=!1,B1,hy=Wf,PE=Wf,uwe,co,cu=globalThis,Wr,kO;typeof cu.vscode<"u"&&typeof cu.vscode.process<"u"?Wr=cu.vscode.process:typeof process<"u"&&typeof((kO=process==null?void 0:process.versions)==null?void 0:kO.node)=="string"&&(Wr=process);var EO,fwe=typeof((EO=Wr==null?void 0:Wr.versions)==null?void 0:EO.electron)=="string",dwe=fwe&&(Wr==null?void 0:Wr.type)==="renderer",OO;if(typeof Wr=="object"){z3=Wr.platform==="win32",L3=Wr.platform==="darwin",dy=Wr.platform==="linux",dy&&Wr.env.SNAP&&Wr.env.SNAP_REVISION,Wr.env.CI||Wr.env.BUILD_ARTIFACTSTAGINGDIRECTORY,B1=Wf,hy=Wf;let e=Wr.env.VSCODE_NLS_CONFIG;if(e)try{let n=JSON.parse(e);B1=n.userLocale,PE=n.osLocale,hy=n.resolvedLanguage||Wf,uwe=(OO=n.languagePack)==null?void 0:OO.translationsConfigFile}catch{}cL=!0}else typeof navigator=="object"&&!dwe?(co=navigator.userAgent,z3=co.indexOf("Windows")>=0,L3=co.indexOf("Macintosh")>=0,(co.indexOf("Macintosh")>=0||co.indexOf("iPad")>=0||co.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,dy=co.indexOf("Linux")>=0,(co==null?void 0:co.indexOf("Mobi"))>=0,hy=globalThis._VSCODE_NLS_LANGUAGE||Wf,B1=navigator.language.toLowerCase(),PE=B1):console.error("Unable to resolve platform.");var uL=z3,Yo=L3,hwe=dy,AE=cL,Qo=co,Vl=hy,pwe;(e=>{function n(){return Vl}e.value=n;function r(){return Vl.length===2?Vl==="en":Vl.length>=3?Vl[0]==="e"&&Vl[1]==="n"&&Vl[2]==="-":!1}e.isDefaultVariant=r;function i(){return Vl==="en"}e.isDefault=i})(pwe||(pwe={}));var mwe=typeof cu.postMessage=="function"&&!cu.importScripts;(()=>{if(mwe){let e=[];cu.addEventListener("message",r=>{if(r.data&&r.data.vscodeScheduleAsyncWork)for(let i=0,s=e.length;i<s;i++){let o=e[i];if(o.id===r.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let n=0;return r=>{let i=++n;e.push({id:i,callback:r}),cu.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var gwe=!!(Qo&&Qo.indexOf("Chrome")>=0);Qo&&Qo.indexOf("Firefox")>=0;!gwe&&Qo&&Qo.indexOf("Safari")>=0;Qo&&Qo.indexOf("Edg/")>=0;Qo&&Qo.indexOf("Android")>=0;var Lf=typeof navigator=="object"?navigator:{};AE||document.queryCommandSupported&&document.queryCommandSupported("copy")||Lf&&Lf.clipboard&&Lf.clipboard.writeText,AE||Lf&&Lf.clipboard&&Lf.clipboard.readText;var f4=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,n){this._keyCodeToStr[e]=n,this._strToKeyCode[n.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},q2=new f4,ME=new f4,RE=new f4,ywe=new Array(230),fL;(e=>{function n(c){return q2.keyCodeToStr(c)}e.toString=n;function r(c){return q2.strToKeyCode(c)}e.fromString=r;function i(c){return ME.keyCodeToStr(c)}e.toUserSettingsUS=i;function s(c){return RE.keyCodeToStr(c)}e.toUserSettingsGeneral=s;function o(c){return ME.strToKeyCode(c)||RE.strToKeyCode(c)}e.fromUserSettings=o;function a(c){if(c>=98&&c<=113)return null;switch(c){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return q2.keyCodeToStr(c)}e.toElectronAccelerator=a})(fL||(fL={}));var vwe=class dL{constructor(n,r,i,s,o){this.ctrlKey=n,this.shiftKey=r,this.altKey=i,this.metaKey=s,this.keyCode=o}equals(n){return n instanceof dL&&this.ctrlKey===n.ctrlKey&&this.shiftKey===n.shiftKey&&this.altKey===n.altKey&&this.metaKey===n.metaKey&&this.keyCode===n.keyCode}getHashCode(){let n=this.ctrlKey?"1":"0",r=this.shiftKey?"1":"0",i=this.altKey?"1":"0",s=this.metaKey?"1":"0";return`K${n}${r}${i}${s}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new _we([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},_we=class{constructor(e){if(e.length===0)throw V2e("chords");this.chords=e}getHashCode(){let e="";for(let n=0,r=this.chords.length;n<r;n++)n!==0&&(e+=";"),e+=this.chords[n].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let n=0;n<this.chords.length;n++)if(!this.chords[n].equals(e.chords[n]))return!1;return!0}};function bwe(e){if(e.charCode){let r=String.fromCharCode(e.charCode).toUpperCase();return fL.fromString(r)}let n=e.keyCode;if(n===3)return 7;if(D3)switch(n){case 59:return 85;case 60:if(hwe)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(Yo)return 57;break}else if(lwe&&(Yo&&n===93||!Yo&&n===92))return 57;return ywe[n]||0}var xwe=Yo?256:2048,wwe=512,Swe=1024,Cwe=Yo?2048:256,DE=class{constructor(e){var r;this._standardKeyboardEventBrand=!0;let n=e;this.browserEvent=n,this.target=n.target,this.ctrlKey=n.ctrlKey,this.shiftKey=n.shiftKey,this.altKey=n.altKey,this.metaKey=n.metaKey,this.altGraphKey=(r=n.getModifierState)==null?void 0:r.call(n,"AltGraph"),this.keyCode=bwe(n),this.code=n.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let n=0;return this.ctrlKey&&(n|=xwe),this.altKey&&(n|=wwe),this.shiftKey&&(n|=Swe),this.metaKey&&(n|=Cwe),n|=e,n}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new vwe(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},zE=new WeakMap;function jwe(e){if(!e.parent||e.parent===e)return null;try{let n=e.location,r=e.parent.location;if(n.origin!=="null"&&r.origin!=="null"&&n.origin!==r.origin)return null}catch{return null}return e.parent}var kwe=class{static getSameOriginWindowChain(e){let n=zE.get(e);if(!n){n=[],zE.set(e,n);let r=e,i;do i=jwe(r),i?n.push({window:new WeakRef(r),iframeElement:r.frameElement||null}):n.push({window:new WeakRef(r),iframeElement:null}),r=i;while(r)}return n.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,n){if(!n||e===n)return{top:0,left:0};let r=0,i=0,s=this.getSameOriginWindowChain(e);for(let o of s){let a=o.window.deref();if(r+=(a==null?void 0:a.scrollY)??0,i+=(a==null?void 0:a.scrollX)??0,a===n||!o.iframeElement)break;let c=o.iframeElement.getBoundingClientRect();r+=c.top,i+=c.left}return{top:r,left:i}}},F1=class{constructor(e,n){this.timestamp=Date.now(),this.browserEvent=n,this.leftButton=n.button===0,this.middleButton=n.button===1,this.rightButton=n.button===2,this.buttons=n.buttons,this.target=n.target,this.detail=n.detail||1,n.type==="dblclick"&&(this.detail=2),this.ctrlKey=n.ctrlKey,this.shiftKey=n.shiftKey,this.altKey=n.altKey,this.metaKey=n.metaKey,typeof n.pageX=="number"?(this.posx=n.pageX,this.posy=n.pageY):(this.posx=n.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=n.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let r=kwe.getPositionOfChildWindowRelativeToAncestorWindow(e,n.view);this.posx-=r.left,this.posy-=r.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},LE=class{constructor(e,n=0,r=0){var s;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=r,this.deltaX=n;let i=!1;if(u4){let o=navigator.userAgent.match(/Chrome\/(\d+)/);i=(o?parseInt(o[1]):123)<=122}if(e){let o=e,a=e,c=((s=e.view)==null?void 0:s.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")i?this.deltaY=o.wheelDeltaY/(120*c):this.deltaY=o.wheelDeltaY/120;else if(typeof a.VERTICAL_AXIS<"u"&&a.axis===a.VERTICAL_AXIS)this.deltaY=-a.detail/3;else if(e.type==="wheel"){let d=e;d.deltaMode===d.DOM_DELTA_LINE?D3&&!Yo?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")cwe&&uL?this.deltaX=-(o.wheelDeltaX/120):i?this.deltaX=o.wheelDeltaX/(120*c):this.deltaX=o.wheelDeltaX/120;else if(typeof a.HORIZONTAL_AXIS<"u"&&a.axis===a.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let d=e;d.deltaMode===d.DOM_DELTA_LINE?D3&&!Yo?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*c):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},hL=Object.freeze(function(e,n){let r=setTimeout(e.bind(n),0);return{dispose(){clearTimeout(r)}}}),Ewe;(e=>{function n(r){return r===e.None||r===e.Cancelled||r instanceof Owe?!0:!r||typeof r!="object"?!1:typeof r.isCancellationRequested=="boolean"&&typeof r.onCancellationRequested=="function"}e.isCancellationToken=n,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Gr.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:hL})})(Ewe||(Ewe={}));var Owe=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?hL:(this._emitter||(this._emitter=new nt),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},d4=class{constructor(e,n){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof n=="number"&&this.setIfNotSet(e,n)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,n){if(this._isDisposed)throw new N3("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},n)}setIfNotSet(e,n){if(this._isDisposed)throw new N3("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},n))}},Nwe=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,n,r=globalThis){if(this.isDisposed)throw new N3("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=r.setInterval(()=>{e()},n);this.disposable=qn(()=>{r.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Twe;(e=>{async function n(i){let s,o=await Promise.all(i.map(a=>a.then(c=>c,c=>{s||(s=c)})));if(typeof s<"u")throw s;return o}e.settled=n;function r(i){return new Promise(async(s,o)=>{try{await i(s,o)}catch(a){o(a)}})}e.withAsyncBody=r})(Twe||(Twe={}));var $E=class Ts{static fromArray(n){return new Ts(r=>{r.emitMany(n)})}static fromPromise(n){return new Ts(async r=>{r.emitMany(await n)})}static fromPromises(n){return new Ts(async r=>{await Promise.all(n.map(async i=>r.emitOne(await i)))})}static merge(n){return new Ts(async r=>{await Promise.all(n.map(async i=>{for await(let s of i)r.emitOne(s)}))})}constructor(n,r){this._state=0,this._results=[],this._error=null,this._onReturn=r,this._onStateChanged=new nt,queueMicrotask(async()=>{let i={emitOne:s=>this.emitOne(s),emitMany:s=>this.emitMany(s),reject:s=>this.reject(s)};try{await Promise.resolve(n(i)),this.resolve()}catch(s){this.reject(s)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let n=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(n<this._results.length)return{done:!1,value:this._results[n++]};if(this._state===1)return{done:!0,value:void 0};await Gr.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var r;return(r=this._onReturn)==null||r.call(this),{done:!0,value:void 0}}}}static map(n,r){return new Ts(async i=>{for await(let s of n)i.emitOne(r(s))})}map(n){return Ts.map(this,n)}static filter(n,r){return new Ts(async i=>{for await(let s of n)r(s)&&i.emitOne(s)})}filter(n){return Ts.filter(this,n)}static coalesce(n){return Ts.filter(n,r=>!!r)}coalesce(){return Ts.coalesce(this)}static async toPromise(n){let r=[];for await(let i of n)r.push(i);return r}toPromise(){return Ts.toPromise(this)}emitOne(n){this._state===0&&(this._results.push(n),this._onStateChanged.fire())}emitMany(n){this._state===0&&(this._results=this._results.concat(n),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(n){this._state===0&&(this._state=2,this._error=n,this._onStateChanged.fire())}};$E.EMPTY=$E.fromArray([]);var{getWindow:qo,getWindowId:Pwe,onDidRegisterWindow:Awe}=(function(){let e=new Map,n={window:Va,disposables:new oc};e.set(Va.vscodeWindowId,n);let r=new nt,i=new nt,s=new nt;function o(a,c){return(typeof a=="number"?e.get(a):void 0)??(c?n:void 0)}return{onDidRegisterWindow:r.event,onWillUnregisterWindow:s.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return Xt.None;let c=new oc,d={window:a,disposables:c.add(new oc)};return e.set(a.vscodeWindowId,d),c.add(qn(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),c.add(Rt(a,Er.BEFORE_UNLOAD,()=>{s.fire(a)})),r.fire(d),c},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var h;let c=a;if((h=c==null?void 0:c.ownerDocument)!=null&&h.defaultView)return c.ownerDocument.defaultView.window;let d=a;return d!=null&&d.view?d.view.window:Va},getDocument(a){return qo(a).document}}})(),Mwe=class{constructor(e,n,r,i){this._node=e,this._type=n,this._handler=r,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function Rt(e,n,r,i){return new Mwe(e,n,r,i)}var IE=function(e,n,r,i){return Rt(e,n,r,i)},h4,Rwe=class extends Nwe{constructor(e){super(),this.defaultTarget=e&&qo(e)}cancelAndSet(e,n,r){return super.cancelAndSet(e,n,r??this.defaultTarget)}},BE=class{constructor(e,n=0){this._runner=e,this.priority=n,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){fy(e)}}static sort(e,n){return n.priority-e.priority}};(function(){let e=new Map,n=new Map,r=new Map,i=new Map,s=o=>{r.set(o,!1);let a=e.get(o)??[];for(n.set(o,a),e.set(o,[]),i.set(o,!0);a.length>0;)a.sort(BE.sort),a.shift().execute();i.set(o,!1)};h4=(o,a,c=0)=>{let d=Pwe(o),h=new BE(a,c),g=e.get(d);return g||(g=[],e.set(d,g)),g.push(h),r.get(d)||(r.set(d,!0),o.requestAnimationFrame(()=>s(d))),h}})();function Dwe(e){let n=e.getBoundingClientRect(),r=qo(e);return{left:n.left+r.scrollX,top:n.top+r.scrollY,width:n.width,height:n.height}}var Er={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},zwe=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let n=zi(e);this._maxWidth!==n&&(this._maxWidth=n,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let n=zi(e);this._width!==n&&(this._width=n,this.domNode.style.width=this._width)}setHeight(e){let n=zi(e);this._height!==n&&(this._height=n,this.domNode.style.height=this._height)}setTop(e){let n=zi(e);this._top!==n&&(this._top=n,this.domNode.style.top=this._top)}setLeft(e){let n=zi(e);this._left!==n&&(this._left=n,this.domNode.style.left=this._left)}setBottom(e){let n=zi(e);this._bottom!==n&&(this._bottom=n,this.domNode.style.bottom=this._bottom)}setRight(e){let n=zi(e);this._right!==n&&(this._right=n,this.domNode.style.right=this._right)}setPaddingTop(e){let n=zi(e);this._paddingTop!==n&&(this._paddingTop=n,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let n=zi(e);this._paddingLeft!==n&&(this._paddingLeft=n,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let n=zi(e);this._paddingBottom!==n&&(this._paddingBottom=n,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let n=zi(e);this._paddingRight!==n&&(this._paddingRight=n,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let n=zi(e);this._fontSize!==n&&(this._fontSize=n,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let n=zi(e);this._lineHeight!==n&&(this._lineHeight=n,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let n=zi(e);this._letterSpacing!==n&&(this._letterSpacing=n,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,n){this.domNode.classList.toggle(e,n),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,n){this.domNode.setAttribute(e,n)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function zi(e){return typeof e=="number"?`${e}px`:e}function zp(e){return new zwe(e)}var pL=class{constructor(){this._hooks=new oc,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,n){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let r=this._onStopCallback;this._onStopCallback=null,e&&r&&r(n)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,n,r,i,s){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=s;let o=e;try{e.setPointerCapture(n),this._hooks.add(qn(()=>{try{e.releasePointerCapture(n)}catch{}}))}catch{o=qo(e)}this._hooks.add(Rt(o,Er.POINTER_MOVE,a=>{if(a.buttons!==r){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(Rt(o,Er.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Lwe(e,n,r){let i=null,s=null;if(typeof r.value=="function"?(i="value",s=r.value,s.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof r.get=="function"&&(i="get",s=r.get),!s)throw new Error("not supported");let o=`$memoize$${n}`;r[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:s.apply(this,a)}),this[o]}}var $o;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))($o||($o={}));var _p=class ri extends Xt{constructor(){super(),this.dispatched=!1,this.targets=new TE,this.ignoreTargets=new TE,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Gr.runAndSubscribe(Awe,({window:n,disposables:r})=>{r.add(Rt(n.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),r.add(Rt(n.document,"touchend",i=>this.onTouchEnd(n,i))),r.add(Rt(n.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Va,disposables:this._store}))}static addTarget(n){if(!ri.isTouchDevice())return Xt.None;ri.INSTANCE||(ri.INSTANCE=new ri);let r=ri.INSTANCE.targets.push(n);return qn(r)}static ignoreTarget(n){if(!ri.isTouchDevice())return Xt.None;ri.INSTANCE||(ri.INSTANCE=new ri);let r=ri.INSTANCE.ignoreTargets.push(n);return qn(r)}static isTouchDevice(){return"ontouchstart"in Va||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(n){let r=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,s=n.targetTouches.length;i<s;i++){let o=n.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:r,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[r],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent($o.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}onTouchEnd(n,r){let i=Date.now(),s=Object.keys(this.activeTouches).length;for(let o=0,a=r.changedTouches.length;o<a;o++){let c=r.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(c.identifier))){console.warn("move of an UNKNOWN touch",c);continue}let d=this.activeTouches[c.identifier],h=Date.now()-d.initialTimeStamp;if(h<ri.HOLD_DELAY&&Math.abs(d.initialPageX-as(d.rollingPageX))<30&&Math.abs(d.initialPageY-as(d.rollingPageY))<30){let g=this.newGestureEvent($o.Tap,d.initialTarget);g.pageX=as(d.rollingPageX),g.pageY=as(d.rollingPageY),this.dispatchEvent(g)}else if(h>=ri.HOLD_DELAY&&Math.abs(d.initialPageX-as(d.rollingPageX))<30&&Math.abs(d.initialPageY-as(d.rollingPageY))<30){let g=this.newGestureEvent($o.Contextmenu,d.initialTarget);g.pageX=as(d.rollingPageX),g.pageY=as(d.rollingPageY),this.dispatchEvent(g)}else if(s===1){let g=as(d.rollingPageX),p=as(d.rollingPageY),_=as(d.rollingTimestamps)-d.rollingTimestamps[0],b=g-d.rollingPageX[0],x=p-d.rollingPageY[0],C=[...this.targets].filter(j=>d.initialTarget instanceof Node&&j.contains(d.initialTarget));this.inertia(n,C,i,Math.abs(b)/_,b>0?1:-1,g,Math.abs(x)/_,x>0?1:-1,p)}this.dispatchEvent(this.newGestureEvent($o.End,d.initialTarget)),delete this.activeTouches[c.identifier]}this.dispatched&&(r.preventDefault(),r.stopPropagation(),this.dispatched=!1)}newGestureEvent(n,r){let i=document.createEvent("CustomEvent");return i.initEvent(n,!1,!0),i.initialTarget=r,i.tapCount=0,i}dispatchEvent(n){if(n.type===$o.Tap){let r=new Date().getTime(),i=0;r-this._lastSetTapCountTime>ri.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=r,n.tapCount=i}else(n.type===$o.Change||n.type===$o.Contextmenu)&&(this._lastSetTapCountTime=0);if(n.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(n.initialTarget))return;let r=[];for(let i of this.targets)if(i.contains(n.initialTarget)){let s=0,o=n.initialTarget;for(;o&&o!==i;)s++,o=o.parentElement;r.push([s,i])}r.sort((i,s)=>i[0]-s[0]);for(let[i,s]of r)s.dispatchEvent(n),this.dispatched=!0}}inertia(n,r,i,s,o,a,c,d,h){this.handle=h4(n,()=>{let g=Date.now(),p=g-i,_=0,b=0,x=!0;s+=ri.SCROLL_FRICTION*p,c+=ri.SCROLL_FRICTION*p,s>0&&(x=!1,_=o*s*p),c>0&&(x=!1,b=d*c*p);let C=this.newGestureEvent($o.Change);C.translationX=_,C.translationY=b,r.forEach(j=>j.dispatchEvent(C)),x||this.inertia(n,r,g,s,o,a+_,c,d,h+b)})}onTouchMove(n){let r=Date.now();for(let i=0,s=n.changedTouches.length;i<s;i++){let o=n.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],c=this.newGestureEvent($o.Change,a.initialTarget);c.translationX=o.pageX-as(a.rollingPageX),c.translationY=o.pageY-as(a.rollingPageY),c.pageX=o.pageX,c.pageY=o.pageY,this.dispatchEvent(c),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(r)}this.dispatched&&(n.preventDefault(),n.stopPropagation(),this.dispatched=!1)}};_p.SCROLL_FRICTION=-.005,_p.HOLD_DELAY=700,_p.CLEAR_TAP_COUNT_TIME=400,Zn([Lwe],_p,"isTouchDevice",1);var $we=_p,p4=class extends Xt{onclick(e,n){this._register(Rt(e,Er.CLICK,r=>n(new F1(qo(e),r))))}onmousedown(e,n){this._register(Rt(e,Er.MOUSE_DOWN,r=>n(new F1(qo(e),r))))}onmouseover(e,n){this._register(Rt(e,Er.MOUSE_OVER,r=>n(new F1(qo(e),r))))}onmouseleave(e,n){this._register(Rt(e,Er.MOUSE_LEAVE,r=>n(new F1(qo(e),r))))}onkeydown(e,n){this._register(Rt(e,Er.KEY_DOWN,r=>n(new DE(r))))}onkeyup(e,n){this._register(Rt(e,Er.KEY_UP,r=>n(new DE(r))))}oninput(e,n){this._register(Rt(e,Er.INPUT,n))}onblur(e,n){this._register(Rt(e,Er.BLUR,n))}onfocus(e,n){this._register(Rt(e,Er.FOCUS,n))}onchange(e,n){this._register(Rt(e,Er.CHANGE,n))}ignoreGesture(e){return $we.ignoreTarget(e)}},FE=11,Iwe=class extends p4{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=FE+"px",this.domNode.style.height=FE+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new pL),this._register(IE(this.bgDomNode,Er.POINTER_DOWN,n=>this._arrowPointerDown(n))),this._register(IE(this.domNode,Er.POINTER_DOWN,n=>this._arrowPointerDown(n))),this._pointerdownRepeatTimer=this._register(new Rwe),this._pointerdownScheduleRepeatTimer=this._register(new d4)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let n=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,qo(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(n,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Bwe=class $3{constructor(n,r,i,s,o,a,c){this._forceIntegerValues=n,this._scrollStateBrand=void 0,this._forceIntegerValues&&(r=r|0,i=i|0,s=s|0,o=o|0,a=a|0,c=c|0),this.rawScrollLeft=s,this.rawScrollTop=c,r<0&&(r=0),s+r>i&&(s=i-r),s<0&&(s=0),o<0&&(o=0),c+o>a&&(c=a-o),c<0&&(c=0),this.width=r,this.scrollWidth=i,this.scrollLeft=s,this.height=o,this.scrollHeight=a,this.scrollTop=c}equals(n){return this.rawScrollLeft===n.rawScrollLeft&&this.rawScrollTop===n.rawScrollTop&&this.width===n.width&&this.scrollWidth===n.scrollWidth&&this.scrollLeft===n.scrollLeft&&this.height===n.height&&this.scrollHeight===n.scrollHeight&&this.scrollTop===n.scrollTop}withScrollDimensions(n,r){return new $3(this._forceIntegerValues,typeof n.width<"u"?n.width:this.width,typeof n.scrollWidth<"u"?n.scrollWidth:this.scrollWidth,r?this.rawScrollLeft:this.scrollLeft,typeof n.height<"u"?n.height:this.height,typeof n.scrollHeight<"u"?n.scrollHeight:this.scrollHeight,r?this.rawScrollTop:this.scrollTop)}withScrollPosition(n){return new $3(this._forceIntegerValues,this.width,this.scrollWidth,typeof n.scrollLeft<"u"?n.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof n.scrollTop<"u"?n.scrollTop:this.rawScrollTop)}createScrollEvent(n,r){let i=this.width!==n.width,s=this.scrollWidth!==n.scrollWidth,o=this.scrollLeft!==n.scrollLeft,a=this.height!==n.height,c=this.scrollHeight!==n.scrollHeight,d=this.scrollTop!==n.scrollTop;return{inSmoothScrolling:r,oldWidth:n.width,oldScrollWidth:n.scrollWidth,oldScrollLeft:n.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:n.height,oldScrollHeight:n.scrollHeight,oldScrollTop:n.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:s,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:c,scrollTopChanged:d}}},Fwe=class extends Xt{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Bwe(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,n){var i;let r=this._state.withScrollDimensions(e,n);this._setState(r,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let n=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(n,!1)}setScrollPositionSmooth(e,n){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let r=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===r.scrollLeft&&this._smoothScrolling.to.scrollTop===r.scrollTop)return;let i;n?i=new UE(this._smoothScrolling.from,r,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,r,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let r=this._state.withScrollPosition(e);this._smoothScrolling=UE.start(this._state,r,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),n=this._state.withScrollPosition(e);if(this._setState(n,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,n){let r=this._state;r.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(r,n)))}},HE=class{constructor(e,n,r){this.scrollLeft=e,this.scrollTop=n,this.isDone=r}};function K2(e,n){let r=n-e;return function(i){return e+r*Vwe(i)}}function Hwe(e,n,r){return function(i){return i<r?e(i/r):n((i-r)/(1-r))}}var UE=class I3{constructor(n,r,i,s){this.from=n,this.to=r,this.duration=s,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(n,r,i){if(Math.abs(n-r)>2.5*i){let s,o;return n<r?(s=n+.75*i,o=r-.75*i):(s=n-.75*i,o=r+.75*i),Hwe(K2(n,s),K2(o,r),.33)}return K2(n,r)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(n){this.to=n.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(n){let r=(n-this.startTime)/this.duration;if(r<1){let i=this.scrollLeft(r),s=this.scrollTop(r);return new HE(i,s,!1)}return new HE(this.to.scrollLeft,this.to.scrollTop,!0)}combine(n,r,i){return I3.start(n,r,i)}static start(n,r,i){i=i+10;let s=Date.now()-10;return new I3(n,r,s,i)}};function Uwe(e){return Math.pow(e,3)}function Vwe(e){return 1-Uwe(1-e)}var Wwe=class extends Xt{constructor(e,n,r){super(),this._visibility=e,this._visibleClassName=n,this._invisibleClassName=r,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new d4)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var n;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(n=this._domNode)==null||n.setClassName(this._invisibleClassName+(e?" fade":"")))}},qwe=140,mL=class extends p4{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Wwe(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new pL),this._shouldRender=!0,this.domNode=zp(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(Rt(this.domNode.domNode,Er.POINTER_DOWN,n=>this._domNodePointerDown(n)))}_createArrow(e){let n=this._register(new Iwe(e));this.domNode.domNode.appendChild(n.bgDomNode),this.domNode.domNode.appendChild(n.domNode)}_createSlider(e,n,r,i){this.slider=zp(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(n),typeof r=="number"&&this.slider.setWidth(r),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(Rt(this.slider.domNode,Er.POINTER_DOWN,s=>{s.button===0&&(s.preventDefault(),this._sliderPointerDown(s))})),this.onclick(this.slider.domNode,s=>{s.leftButton&&s.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let n=this.domNode.domNode.getClientRects()[0].top,r=n+this._scrollbarState.getSliderPosition(),i=n+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),s=this._sliderPointerPosition(e);r<=s&&s<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let n,r;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")n=e.offsetX,r=e.offsetY;else{let s=Dwe(this.domNode.domNode);n=e.pageX-s.left,r=e.pageY-s.top}let i=this._pointerDownRelativePosition(n,r);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let n=this._sliderPointerPosition(e),r=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{let o=this._sliderOrthogonalPointerPosition(s),a=Math.abs(o-r);if(uL&&a>qwe){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let c=this._sliderPointerPosition(s)-n;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(c))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let n={};this.writeScrollPosition(n,e),this._scrollable.setScrollPositionNow(n)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},gL=class B3{constructor(n,r,i,s,o,a){this._scrollbarSize=Math.round(r),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(n),this._visibleSize=s,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new B3(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(n){let r=Math.round(n);return this._visibleSize!==r?(this._visibleSize=r,this._refreshComputedValues(),!0):!1}setScrollSize(n){let r=Math.round(n);return this._scrollSize!==r?(this._scrollSize=r,this._refreshComputedValues(),!0):!1}setScrollPosition(n){let r=Math.round(n);return this._scrollPosition!==r?(this._scrollPosition=r,this._refreshComputedValues(),!0):!1}setScrollbarSize(n){this._scrollbarSize=Math.round(n)}setOppositeScrollbarSize(n){this._oppositeScrollbarSize=Math.round(n)}static _computeValues(n,r,i,s,o){let a=Math.max(0,i-n),c=Math.max(0,a-2*r),d=s>0&&s>i;if(!d)return{computedAvailableSize:Math.round(a),computedIsNeeded:d,computedSliderSize:Math.round(c),computedSliderRatio:0,computedSliderPosition:0};let h=Math.round(Math.max(20,Math.floor(i*c/s))),g=(c-h)/(s-i),p=o*g;return{computedAvailableSize:Math.round(a),computedIsNeeded:d,computedSliderSize:Math.round(h),computedSliderRatio:g,computedSliderPosition:Math.round(p)}}_refreshComputedValues(){let n=B3._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=n.computedAvailableSize,this._computedIsNeeded=n.computedIsNeeded,this._computedSliderSize=n.computedSliderSize,this._computedSliderRatio=n.computedSliderRatio,this._computedSliderPosition=n.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(n){if(!this._computedIsNeeded)return 0;let r=n-this._arrowSize-this._computedSliderSize/2;return Math.round(r/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(n){if(!this._computedIsNeeded)return 0;let r=n-this._arrowSize,i=this._scrollPosition;return r<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(n){if(!this._computedIsNeeded)return 0;let r=this._computedSliderPosition+n;return Math.round(r/this._computedSliderRatio)}},Kwe=class extends mL{constructor(e,n,r){let i=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:n.lazyRender,host:r,scrollbarState:new gL(n.horizontalHasArrows?n.arrowSize:0,n.horizontal===2?0:n.horizontalScrollbarSize,n.vertical===2?0:n.verticalScrollbarSize,i.width,i.scrollWidth,s.scrollLeft),visibility:n.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:n.scrollByPage}),n.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((n.horizontalScrollbarSize-n.horizontalSliderSize)/2),0,void 0,n.horizontalSliderSize)}_updateSlider(e,n){this.slider.setWidth(e),this.slider.setLeft(n)}_renderDomNode(e,n){this.domNode.setWidth(e),this.domNode.setHeight(n),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,n){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,n){e.scrollLeft=n}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Gwe=class extends mL{constructor(e,n,r){let i=e.getScrollDimensions(),s=e.getCurrentScrollPosition();if(super({lazyRender:n.lazyRender,host:r,scrollbarState:new gL(n.verticalHasArrows?n.arrowSize:0,n.vertical===2?0:n.verticalScrollbarSize,0,i.height,i.scrollHeight,s.scrollTop),visibility:n.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:n.scrollByPage}),n.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((n.verticalScrollbarSize-n.verticalSliderSize)/2),n.verticalSliderSize,void 0)}_updateSlider(e,n){this.slider.setHeight(e),this.slider.setTop(n)}_renderDomNode(e,n){this.domNode.setWidth(n),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,n){return n}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,n){e.scrollTop=n}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},Ywe=500,VE=50,Xwe=class{constructor(e,n,r){this.timestamp=e,this.deltaX=n,this.deltaY=r,this.score=0}},F3=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let n=1,r=0,i=1,s=this._rear;do{let o=s===this._front?n:Math.pow(2,-i);if(n-=o,r+=this._memory[s].score*o,s===this._front)break;s=(this._capacity+s-1)%this._capacity,i++}while(!0);return r<=.5}acceptStandardWheelEvent(n){if(u4){let r=qo(n.browserEvent),i=awe(r);this.accept(Date.now(),n.deltaX*i,n.deltaY*i)}else this.accept(Date.now(),n.deltaX,n.deltaY)}accept(n,r,i){let s=null,o=new Xwe(n,r,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(s=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,s)}_computeScore(n,r){if(Math.abs(n.deltaX)>0&&Math.abs(n.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(n.deltaX)||!this._isAlmostInt(n.deltaY))&&(i+=.25),r){let s=Math.abs(n.deltaX),o=Math.abs(n.deltaY),a=Math.abs(r.deltaX),c=Math.abs(r.deltaY),d=Math.max(Math.min(s,a),1),h=Math.max(Math.min(o,c),1),g=Math.max(s,a),p=Math.max(o,c);g%d===0&&p%h===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(n){return Math.abs(Math.round(n)-n)<.01}};F3.INSTANCE=new F3;var Jwe=F3,Zwe=class extends p4{constructor(e,n,r){super(),this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new nt),this.onWillScroll=this._onWillScroll.event,this._options=e3e(n),this._scrollable=r,this._register(this._scrollable.onScroll(s=>{this._onWillScroll.fire(s),this._onDidScroll(s),this._onScroll.fire(s)}));let i={onMouseWheel:s=>this._onMouseWheel(s),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Gwe(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new Kwe(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=zp(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=zp(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=zp(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,s=>this._onMouseOver(s)),this.onmouseleave(this._listenOnDomNode,s=>this._onMouseLeave(s)),this._hideTimeout=this._register(new d4),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=xu(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Yo&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new LE(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=xu(this._mouseWheelToDispose),e)){let n=r=>{this._onMouseWheel(new LE(r))};this._mouseWheelToDispose.push(Rt(this._listenOnDomNode,Er.MOUSE_WHEEL,n,{passive:!1}))}}_onMouseWheel(e){var s;if((s=e.browserEvent)!=null&&s.defaultPrevented)return;let n=Jwe.INSTANCE;n.acceptStandardWheelEvent(e);let r=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let c=!Yo&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||c)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let d=this._scrollable.getFutureScrollPosition(),h={};if(o){let g=VE*o,p=d.scrollTop-(g<0?Math.floor(g):Math.ceil(g));this._verticalScrollbar.writeScrollPosition(h,p)}if(a){let g=VE*a,p=d.scrollLeft-(g<0?Math.floor(g):Math.ceil(g));this._horizontalScrollbar.writeScrollPosition(h,p)}h=this._scrollable.validateScrollPosition(h),(d.scrollLeft!==h.scrollLeft||d.scrollTop!==h.scrollTop)&&(this._options.mouseWheelSmoothScroll&&n.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(h):this._scrollable.setScrollPositionNow(h),r=!0)}let i=r;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),n=e.scrollTop>0,r=e.scrollLeft>0,i=r?" left":"",s=n?" top":"",o=r||n?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${s}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${s}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Ywe)}},Qwe=class extends Zwe{constructor(e,n,r){super(e,n,r)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function e3e(e){let n={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return n.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:n.horizontalScrollbarSize,n.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:n.verticalScrollbarSize,Yo&&(n.className+=" mac"),n}var H3=class extends Xt{constructor(e,n,r,i,s,o,a,c){super(),this._bufferService=r,this._optionsService=a,this._renderService=c,this._onRequestScrollLines=this._register(new nt),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let d=this._register(new Fwe({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:h=>h4(i.window,h)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{d.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new Qwe(n,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},d)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(s.onProtocolChange(h=>{this._scrollableElement.updateOptions({handleMouseWheel:!(h&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Gr.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(qn(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),n.appendChild(this._styleElement),this._register(qn(()=>this._styleElement.remove())),this._register(Gr.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
|
|
777
|
+
`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(h=>this._handleScroll(h)))}scrollLines(e){let n=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:n.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,n){n&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!n,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let n=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),r=n-this._bufferService.buffer.ydisp;r!==0&&(this._latestYDisp=n,this._onRequestScrollLines.fire(r)),this._isHandlingScroll=!1}};H3=Zn([ct(2,wi),ct(3,nl),ct(4,Xz),ct(5,Ed),ct(6,Si),ct(7,rl)],H3);var U3=class extends Xt{constructor(e,n,r,i,s){super(),this._screenElement=e,this._bufferService=n,this._coreBrowserService=r,this._decorationService=i,this._renderService=s,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(qn(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var i;let n=this._coreBrowserService.mainDocument.createElement("div");n.classList.add("xterm-decoration"),n.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let r=e.options.x??0;return r&&r>this._bufferService.cols&&(n.style.display="none"),this._refreshXPosition(e,n),n}_refreshStyle(e){let n=e.marker.line-this._bufferService.buffers.active.ydisp;if(n<0||n>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let r=this._decorationElements.get(e);r||(r=this._createElement(e),e.element=r,this._decorationElements.set(e,r),this._container.appendChild(r),e.onDispose(()=>{this._decorationElements.delete(e),r.remove()})),r.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(r.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,r.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,r.style.top=`${n*this._renderService.dimensions.css.cell.height}px`,r.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(r)}}_refreshXPosition(e,n=e.element){if(!n)return;let r=e.options.x??0;(e.options.anchor||"left")==="right"?n.style.right=r?`${r*this._renderService.dimensions.css.cell.width}px`:"":n.style.left=r?`${r*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var n;(n=this._decorationElements.get(e))==null||n.remove(),this._decorationElements.delete(e),e.dispose()}};U3=Zn([ct(1,wi),ct(2,nl),ct(3,Vg),ct(4,rl)],U3);var t3e=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let n of this._zones)if(n.color===e.options.overviewRulerOptions.color&&n.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(n,e.marker.line))return;if(this._lineAdjacentToZone(n,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(n,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,n){return n>=e.startBufferLine&&n<=e.endBufferLine}_lineAdjacentToZone(e,n,r){return n>=e.startBufferLine-this._linePadding[r||"full"]&&n<=e.endBufferLine+this._linePadding[r||"full"]}_addLineToZone(e,n){e.startBufferLine=Math.min(e.startBufferLine,n),e.endBufferLine=Math.max(e.endBufferLine,n)}},Do={full:0,left:0,center:0,right:0},Wl={full:0,left:0,center:0,right:0},ep={full:0,left:0,center:0,right:0},sv=class extends Xt{constructor(e,n,r,i,s,o,a,c){var h;super(),this._viewportElement=e,this._screenElement=n,this._bufferService=r,this._decorationService=i,this._renderService=s,this._optionsService=o,this._themeService=a,this._coreBrowserService=c,this._colorZoneStore=new t3e,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(h=this._viewportElement.parentElement)==null||h.insertBefore(this._canvas,this._viewportElement),this._register(qn(()=>{var g;return(g=this._canvas)==null?void 0:g.remove()}));let d=this._canvas.getContext("2d");if(d)this._ctx=d;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),n=Math.ceil((this._canvas.width-1)/3);Wl.full=this._canvas.width,Wl.left=e,Wl.center=n,Wl.right=e,this._refreshDrawHeightConstants(),ep.full=1,ep.left=1,ep.center=1+Wl.left,ep.right=1+Wl.left+Wl.center}_refreshDrawHeightConstants(){Do.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,n=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);Do.left=n,Do.center=n,Do.right=n}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Do.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Do.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Do.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*Do.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let n of this._decorationService.decorations)this._colorZoneStore.addDecoration(n);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let n of e)n.position!=="full"&&this._renderColorZone(n);for(let n of e)n.position==="full"&&this._renderColorZone(n);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(ep[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-Do[e.position||"full"]/2),Wl[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+Do[e.position||"full"]))}_queueRefresh(e,n){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=n||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};sv=Zn([ct(2,wi),ct(3,Vg),ct(4,rl),ct(5,Si),ct(6,Ed),ct(7,nl)],sv);var He;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
|
|
778
|
+
`,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(He||(He={}));var py;(e=>(e.PAD="",e.HOP="",e.BPH="",e.NBH="",e.IND="",e.NEL="
",e.SSA="",e.ESA="",e.HTS="",e.HTJ="",e.VTS="",e.PLD="",e.PLU="",e.RI="",e.SS2="",e.SS3="",e.DCS="",e.PU1="",e.PU2="",e.STS="",e.CCH="",e.MW="",e.SPA="",e.EPA="",e.SOS="",e.SGCI="",e.SCI="",e.CSI="",e.ST="",e.OSC="",e.PM="",e.APC=""))(py||(py={}));var yL;(e=>e.ST=`${He.ESC}\\`)(yL||(yL={}));var V3=class{constructor(e,n,r,i,s,o){this._textarea=e,this._compositionView=n,this._bufferService=r,this._optionsService=i,this._coreService=s,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let n={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let r;n.start+=this._dataAlreadySent.length,this._isComposing?r=this._textarea.value.substring(n.start,this._compositionPosition.start):r=this._textarea.value.substring(n.start),r.length>0&&this._coreService.triggerDataEvent(r,!0)}},0)}else{this._isSendingComposition=!1;let n=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(n,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let n=this._textarea.value,r=n.replace(e,"");this._dataAlreadySent=r,n.length>e.length?this._coreService.triggerDataEvent(r,!0):n.length<e.length?this._coreService.triggerDataEvent(`${He.DEL}`,!0):n.length===e.length&&n!==e&&this._coreService.triggerDataEvent(n,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let n=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),r=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=s+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=r+"px",this._compositionView.style.lineHeight=r+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=s+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};V3=Zn([ct(2,wi),ct(3,Si),ct(4,Mu),ct(5,rl)],V3);var Or=0,Nr=0,Tr=0,Jn=0,WE={css:"#00000000",rgba:0},gr;(e=>{function n(s,o,a,c){return c!==void 0?`#${Jc(s)}${Jc(o)}${Jc(a)}${Jc(c)}`:`#${Jc(s)}${Jc(o)}${Jc(a)}`}e.toCss=n;function r(s,o,a,c=255){return(s<<24|o<<16|a<<8|c)>>>0}e.toRgba=r;function i(s,o,a,c){return{css:e.toCss(s,o,a,c),rgba:e.toRgba(s,o,a,c)}}e.toColor=i})(gr||(gr={}));var $n;(e=>{function n(d,h){if(Jn=(h.rgba&255)/255,Jn===1)return{css:h.css,rgba:h.rgba};let g=h.rgba>>24&255,p=h.rgba>>16&255,_=h.rgba>>8&255,b=d.rgba>>24&255,x=d.rgba>>16&255,C=d.rgba>>8&255;Or=b+Math.round((g-b)*Jn),Nr=x+Math.round((p-x)*Jn),Tr=C+Math.round((_-C)*Jn);let j=gr.toCss(Or,Nr,Tr),S=gr.toRgba(Or,Nr,Tr);return{css:j,rgba:S}}e.blend=n;function r(d){return(d.rgba&255)===255}e.isOpaque=r;function i(d,h,g){let p=my.ensureContrastRatio(d.rgba,h.rgba,g);if(p)return gr.toColor(p>>24&255,p>>16&255,p>>8&255)}e.ensureContrastRatio=i;function s(d){let h=(d.rgba|255)>>>0;return[Or,Nr,Tr]=my.toChannels(h),{css:gr.toCss(Or,Nr,Tr),rgba:h}}e.opaque=s;function o(d,h){return Jn=Math.round(h*255),[Or,Nr,Tr]=my.toChannels(d.rgba),{css:gr.toCss(Or,Nr,Tr,Jn),rgba:gr.toRgba(Or,Nr,Tr,Jn)}}e.opacity=o;function a(d,h){return Jn=d.rgba&255,o(d,Jn*h/255)}e.multiplyOpacity=a;function c(d){return[d.rgba>>24&255,d.rgba>>16&255,d.rgba>>8&255]}e.toColorRGB=c})($n||($n={}));var Gn;(e=>{let n,r;try{let s=document.createElement("canvas");s.width=1,s.height=1;let o=s.getContext("2d",{willReadFrequently:!0});o&&(n=o,n.globalCompositeOperation="copy",r=n.createLinearGradient(0,0,1,1))}catch{}function i(s){if(s.match(/#[\da-f]{3,8}/i))switch(s.length){case 4:return Or=parseInt(s.slice(1,2).repeat(2),16),Nr=parseInt(s.slice(2,3).repeat(2),16),Tr=parseInt(s.slice(3,4).repeat(2),16),gr.toColor(Or,Nr,Tr);case 5:return Or=parseInt(s.slice(1,2).repeat(2),16),Nr=parseInt(s.slice(2,3).repeat(2),16),Tr=parseInt(s.slice(3,4).repeat(2),16),Jn=parseInt(s.slice(4,5).repeat(2),16),gr.toColor(Or,Nr,Tr,Jn);case 7:return{css:s,rgba:(parseInt(s.slice(1),16)<<8|255)>>>0};case 9:return{css:s,rgba:parseInt(s.slice(1),16)>>>0}}let o=s.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Or=parseInt(o[1]),Nr=parseInt(o[2]),Tr=parseInt(o[3]),Jn=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),gr.toColor(Or,Nr,Tr,Jn);if(!n||!r)throw new Error("css.toColor: Unsupported css format");if(n.fillStyle=r,n.fillStyle=s,typeof n.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(n.fillRect(0,0,1,1),[Or,Nr,Tr,Jn]=n.getImageData(0,0,1,1).data,Jn!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:gr.toRgba(Or,Nr,Tr,Jn),css:s}}e.toColor=i})(Gn||(Gn={}));var yi;(e=>{function n(i){return r(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=n;function r(i,s,o){let a=i/255,c=s/255,d=o/255,h=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),g=c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4),p=d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4);return h*.2126+g*.7152+p*.0722}e.relativeLuminance2=r})(yi||(yi={}));var my;(e=>{function n(a,c){if(Jn=(c&255)/255,Jn===1)return c;let d=c>>24&255,h=c>>16&255,g=c>>8&255,p=a>>24&255,_=a>>16&255,b=a>>8&255;return Or=p+Math.round((d-p)*Jn),Nr=_+Math.round((h-_)*Jn),Tr=b+Math.round((g-b)*Jn),gr.toRgba(Or,Nr,Tr)}e.blend=n;function r(a,c,d){let h=yi.relativeLuminance(a>>8),g=yi.relativeLuminance(c>>8);if($a(h,g)<d){if(g<h){let b=i(a,c,d),x=$a(h,yi.relativeLuminance(b>>8));if(x<d){let C=s(a,c,d),j=$a(h,yi.relativeLuminance(C>>8));return x>j?b:C}return b}let p=s(a,c,d),_=$a(h,yi.relativeLuminance(p>>8));if(_<d){let b=i(a,c,d),x=$a(h,yi.relativeLuminance(b>>8));return _>x?p:b}return p}}e.ensureContrastRatio=r;function i(a,c,d){let h=a>>24&255,g=a>>16&255,p=a>>8&255,_=c>>24&255,b=c>>16&255,x=c>>8&255,C=$a(yi.relativeLuminance2(_,b,x),yi.relativeLuminance2(h,g,p));for(;C<d&&(_>0||b>0||x>0);)_-=Math.max(0,Math.ceil(_*.1)),b-=Math.max(0,Math.ceil(b*.1)),x-=Math.max(0,Math.ceil(x*.1)),C=$a(yi.relativeLuminance2(_,b,x),yi.relativeLuminance2(h,g,p));return(_<<24|b<<16|x<<8|255)>>>0}e.reduceLuminance=i;function s(a,c,d){let h=a>>24&255,g=a>>16&255,p=a>>8&255,_=c>>24&255,b=c>>16&255,x=c>>8&255,C=$a(yi.relativeLuminance2(_,b,x),yi.relativeLuminance2(h,g,p));for(;C<d&&(_<255||b<255||x<255);)_=Math.min(255,_+Math.ceil((255-_)*.1)),b=Math.min(255,b+Math.ceil((255-b)*.1)),x=Math.min(255,x+Math.ceil((255-x)*.1)),C=$a(yi.relativeLuminance2(_,b,x),yi.relativeLuminance2(h,g,p));return(_<<24|b<<16|x<<8|255)>>>0}e.increaseLuminance=s;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(my||(my={}));function Jc(e){let n=e.toString(16);return n.length<2?"0"+n:n}function $a(e,n){return e<n?(n+.05)/(e+.05):(e+.05)/(n+.05)}var n3e=class extends Ug{constructor(e,n,r){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=n,this._width=r}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},ov=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new Bs}register(e){let n={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(n),n.id}deregister(e){for(let n=0;n<this._characterJoiners.length;n++)if(this._characterJoiners[n].id===e)return this._characterJoiners.splice(n,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let n=this._bufferService.buffer.lines.get(e);if(!n||n.length===0)return[];let r=[],i=n.translateToString(!0),s=0,o=0,a=0,c=n.getFg(0),d=n.getBg(0);for(let h=0;h<n.getTrimmedLength();h++)if(n.loadCell(h,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==c||this._workCell.bg!==d){if(h-s>1){let g=this._getJoinedRanges(i,a,o,n,s);for(let p=0;p<g.length;p++)r.push(g[p])}s=h,a=o,c=this._workCell.fg,d=this._workCell.bg}o+=this._workCell.getChars().length||nc.length}if(this._bufferService.cols-s>1){let h=this._getJoinedRanges(i,a,o,n,s);for(let g=0;g<h.length;g++)r.push(h[g])}return r}_getJoinedRanges(e,n,r,i,s){let o=e.substring(n,r),a=[];try{a=this._characterJoiners[0].handler(o)}catch(c){console.error(c)}for(let c=1;c<this._characterJoiners.length;c++)try{let d=this._characterJoiners[c].handler(o);for(let h=0;h<d.length;h++)ov._mergeRanges(a,d[h])}catch(d){console.error(d)}return this._stringRangesToCellRanges(a,i,s),a}_stringRangesToCellRanges(e,n,r){let i=0,s=!1,o=0,a=e[i];if(a){for(let c=r;c<this._bufferService.cols;c++){let d=n.getWidth(c),h=n.getString(c).length||nc.length;if(d!==0){if(!s&&a[0]<=o&&(a[0]=c,s=!0),a[1]<=o){if(a[1]=c,a=e[++i],!a)break;a[0]<=o?(a[0]=c,s=!0):s=!1}o+=h}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,n){let r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(r){if(n[1]<=s[0])return e[i-1][1]=n[1],e;if(n[1]<=s[1])return e[i-1][1]=Math.max(n[1],s[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(n[1]<=s[0])return e.splice(i,0,n),e;if(n[1]<=s[1])return s[0]=Math.min(n[0],s[0]),e;n[0]<s[1]&&(s[0]=Math.min(n[0],s[0]),r=!0);continue}}return r?e[e.length-1][1]=n[1]:e.push(n),e}};ov=Zn([ct(0,wi)],ov);function r3e(e){return 57508<=e&&e<=57558}function i3e(e){return 9472<=e&&e<=9631}function s3e(e){return r3e(e)||i3e(e)}function o3e(){return{css:{canvas:H1(),cell:H1()},device:{canvas:H1(),cell:H1(),char:{width:0,height:0,left:0,top:0}}}}function H1(){return{width:0,height:0}}var W3=class{constructor(e,n,r,i,s,o,a){this._document=e,this._characterJoinerService=n,this._optionsService=r,this._coreBrowserService=i,this._coreService=s,this._decorationService=o,this._themeService=a,this._workCell=new Bs,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,n,r){this._selectionStart=e,this._selectionEnd=n,this._columnSelectMode=r}createRow(e,n,r,i,s,o,a,c,d,h,g){let p=[],_=this._characterJoinerService.getJoinedCharacters(n),b=this._themeService.colors,x=e.getNoBgTrimmedLength();r&&x<o+1&&(x=o+1);let C,j=0,S="",E=0,O=0,N=0,T=0,P=!1,D=0,H=!1,J=0,I=0,B=[],F=h!==-1&&g!==-1;for(let W=0;W<x;W++){e.loadCell(W,this._workCell);let z=this._workCell.getWidth();if(z===0)continue;let V=!1,A=W>=I,U=W,K=this._workCell;if(_.length>0&&W===_[0][0]&&A){let me=_.shift(),Ye=this._isCellInSelection(me[0],n);for(E=me[0]+1;E<me[1];E++)A&&(A=Ye===this._isCellInSelection(E,n));A&&(A=!r||o<me[0]||o>=me[1]),A?(V=!0,K=new n3e(this._workCell,e.translateToString(!0,me[0],me[1]),me[1]-me[0]),U=me[1]-1,z=K.getWidth()):I=me[1]}let Y=this._isCellInSelection(W,n),$=r&&W===o,R=F&&W>=h&&W<=g,Z=!1;this._decorationService.forEachDecorationAtCell(W,n,void 0,me=>{Z=!0});let L=K.getChars()||nc;if(L===" "&&(K.isUnderline()||K.isOverline())&&(L=" "),J=z*c-d.get(L,K.isBold(),K.isItalic()),!C)C=this._document.createElement("span");else if(j&&(Y&&H||!Y&&!H&&K.bg===O)&&(Y&&H&&b.selectionForeground||K.fg===N)&&K.extended.ext===T&&R===P&&J===D&&!$&&!V&&!Z&&A){K.isInvisible()?S+=nc:S+=L,j++;continue}else j&&(C.textContent=S),C=this._document.createElement("span"),j=0,S="";if(O=K.bg,N=K.fg,T=K.extended.ext,P=R,D=J,H=Y,V&&o>=W&&o<=U&&(o=W),!this._coreService.isCursorHidden&&$&&this._coreService.isCursorInitialized){if(B.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&B.push("xterm-cursor-blink"),B.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(s)switch(s){case"outline":B.push("xterm-cursor-outline");break;case"block":B.push("xterm-cursor-block");break;case"bar":B.push("xterm-cursor-bar");break;case"underline":B.push("xterm-cursor-underline");break}}if(K.isBold()&&B.push("xterm-bold"),K.isItalic()&&B.push("xterm-italic"),K.isDim()&&B.push("xterm-dim"),K.isInvisible()?S=nc:S=K.getChars()||nc,K.isUnderline()&&(B.push(`xterm-underline-${K.extended.underlineStyle}`),S===" "&&(S=" "),!K.isUnderlineColorDefault()))if(K.isUnderlineColorRGB())C.style.textDecorationColor=`rgb(${Ug.toColorRGB(K.getUnderlineColor()).join(",")})`;else{let me=K.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&K.isBold()&&me<8&&(me+=8),C.style.textDecorationColor=b.ansi[me].css}K.isOverline()&&(B.push("xterm-overline"),S===" "&&(S=" ")),K.isStrikethrough()&&B.push("xterm-strikethrough"),R&&(C.style.textDecoration="underline");let Q=K.getFgColor(),X=K.getFgColorMode(),ie=K.getBgColor(),se=K.getBgColorMode(),ce=!!K.isInverse();if(ce){let me=Q;Q=ie,ie=me;let Ye=X;X=se,se=Ye}let be,ze,fe=!1;this._decorationService.forEachDecorationAtCell(W,n,void 0,me=>{me.options.layer!=="top"&&fe||(me.backgroundColorRGB&&(se=50331648,ie=me.backgroundColorRGB.rgba>>8&16777215,be=me.backgroundColorRGB),me.foregroundColorRGB&&(X=50331648,Q=me.foregroundColorRGB.rgba>>8&16777215,ze=me.foregroundColorRGB),fe=me.options.layer==="top")}),!fe&&Y&&(be=this._coreBrowserService.isFocused?b.selectionBackgroundOpaque:b.selectionInactiveBackgroundOpaque,ie=be.rgba>>8&16777215,se=50331648,fe=!0,b.selectionForeground&&(X=50331648,Q=b.selectionForeground.rgba>>8&16777215,ze=b.selectionForeground)),fe&&B.push("xterm-decoration-top");let Ce;switch(se){case 16777216:case 33554432:Ce=b.ansi[ie],B.push(`xterm-bg-${ie}`);break;case 50331648:Ce=gr.toColor(ie>>16,ie>>8&255,ie&255),this._addStyle(C,`background-color:#${qE((ie>>>0).toString(16),"0",6)}`);break;case 0:default:ce?(Ce=b.foreground,B.push("xterm-bg-257")):Ce=b.background}switch(be||K.isDim()&&(be=$n.multiplyOpacity(Ce,.5)),X){case 16777216:case 33554432:K.isBold()&&Q<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Q+=8),this._applyMinimumContrast(C,Ce,b.ansi[Q],K,be,void 0)||B.push(`xterm-fg-${Q}`);break;case 50331648:let me=gr.toColor(Q>>16&255,Q>>8&255,Q&255);this._applyMinimumContrast(C,Ce,me,K,be,ze)||this._addStyle(C,`color:#${qE(Q.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(C,Ce,b.foreground,K,be,ze)||ce&&B.push("xterm-fg-257")}B.length&&(C.className=B.join(" "),B.length=0),!$&&!V&&!Z&&A?j++:C.textContent=S,J!==this.defaultSpacing&&(C.style.letterSpacing=`${J}px`),p.push(C),W=U}return C&&j&&(C.textContent=S),p}_applyMinimumContrast(e,n,r,i,s,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||s3e(i.getCode()))return!1;let a=this._getContrastCache(i),c;if(!s&&!o&&(c=a.getColor(n.rgba,r.rgba)),c===void 0){let d=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);c=$n.ensureContrastRatio(s||n,o||r,d),a.setColor((s||n).rgba,(o||r).rgba,c??null)}return c?(this._addStyle(e,`color:${c.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,n){e.setAttribute("style",`${e.getAttribute("style")||""}${n};`)}_isCellInSelection(e,n){let r=this._selectionStart,i=this._selectionEnd;return!r||!i?!1:this._columnSelectMode?r[0]<=i[0]?e>=r[0]&&n>=r[1]&&e<i[0]&&n<=i[1]:e<r[0]&&n>=r[1]&&e>=i[0]&&n<=i[1]:n>r[1]&&n<i[1]||r[1]===i[1]&&n===r[1]&&e>=r[0]&&e<i[0]||r[1]<i[1]&&n===i[1]&&e<i[0]||r[1]<i[1]&&n===r[1]&&e>=r[0]}};W3=Zn([ct(1,Qz),ct(2,Si),ct(3,nl),ct(4,Mu),ct(5,Vg),ct(6,Ed)],W3);function qE(e,n,r){for(;e.length<r;)e=n+e;return e}var a3e=class{constructor(e,n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let r=e.createElement("span");r.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let s=e.createElement("span");s.classList.add("xterm-char-measure-element"),s.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[r,i,s,o],this._container.appendChild(r),this._container.appendChild(i),this._container.appendChild(s),this._container.appendChild(o),n.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,n,r,i){e===this._font&&n===this._fontSize&&r===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=n,this._weight=r,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${r}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${r}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,n,r){let i=0;if(!n&&!r&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(e,0);return a>0&&(this._flat[i]=a),a}let s=e;n&&(s+="B"),r&&(s+="I");let o=this._holey.get(s);if(o===void 0){let a=0;n&&(a|=1),r&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(s,o)}return o}_measure(e,n){let r=this._measureElements[n];return r.textContent=e.repeat(32),r.offsetWidth/32}},l3e=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,n,r,i=!1){if(this.selectionStart=n,this.selectionEnd=r,!n||!r||n[0]===r[0]&&n[1]===r[1]){this.clear();return}let s=e.buffers.active.ydisp,o=n[1]-s,a=r[1]-s,c=Math.max(o,0),d=Math.min(a,e.rows-1);if(c>=e.rows||d<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=c,this.viewportCappedEndRow=d,this.startCol=n[0],this.endCol=r[0]}isCellSelected(e,n,r){return this.hasSelection?(r-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?n>=this.startCol&&r>=this.viewportCappedStartRow&&n<this.endCol&&r<=this.viewportCappedEndRow:n<this.startCol&&r>=this.viewportCappedStartRow&&n>=this.endCol&&r<=this.viewportCappedEndRow:r>this.viewportStartRow&&r<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&r===this.viewportStartRow&&n>=this.startCol&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportEndRow&&n<this.endCol||this.viewportStartRow<this.viewportEndRow&&r===this.viewportStartRow&&n>=this.startCol):!1}};function c3e(){return new l3e}var G2="xterm-dom-renderer-owner-",Ns="xterm-rows",U1="xterm-fg-",KE="xterm-bg-",tp="xterm-focus",V1="xterm-selection",u3e=1,q3=class extends Xt{constructor(e,n,r,i,s,o,a,c,d,h,g,p,_,b){super(),this._terminal=e,this._document=n,this._element=r,this._screenElement=i,this._viewportElement=s,this._helperContainer=o,this._linkifier2=a,this._charSizeService=d,this._optionsService=h,this._bufferService=g,this._coreService=p,this._coreBrowserService=_,this._themeService=b,this._terminalClass=u3e++,this._rowElements=[],this._selectionRenderModel=c3e(),this.onRequestRedraw=this._register(new nt).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Ns),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(V1),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=o3e(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(x=>this._injectCss(x))),this._injectCss(this._themeService.colors),this._rowFactory=c.createInstance(W3,document),this._element.classList.add(G2+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(x=>this._handleLinkHover(x))),this._register(this._linkifier2.onHideLinkUnderline(x=>this._handleLinkLeave(x))),this._register(qn(()=>{this._element.classList.remove(G2+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new a3e(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let r of this._rowElements)r.style.width=`${this.dimensions.css.canvas.width}px`,r.style.height=`${this.dimensions.css.cell.height}px`,r.style.lineHeight=`${this.dimensions.css.cell.height}px`,r.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let n=`${this._terminalSelector} .${Ns} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=n,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let n=`${this._terminalSelector} .${Ns} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;n+=`${this._terminalSelector} .${Ns} .xterm-dim { color: ${$n.multiplyOpacity(e.foreground,.5).css};}`,n+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let r=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,s=`blink_block_${this._terminalClass}`;n+=`@keyframes ${r} { 50% { border-bottom-style: hidden; }}`,n+=`@keyframes ${i} { 50% { box-shadow: none; }}`,n+=`@keyframes ${s} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,n+=`${this._terminalSelector} .${Ns}.${tp} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ns}.${tp} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ns}.${tp} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ns} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,n+=`${this._terminalSelector} .${V1} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${V1} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${V1} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())n+=`${this._terminalSelector} .${U1}${o} { color: ${a.css}; }${this._terminalSelector} .${U1}${o}.xterm-dim { color: ${$n.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${KE}${o} { background-color: ${a.css}; }`;n+=`${this._terminalSelector} .${U1}257 { color: ${$n.opaque(e.background).css}; }${this._terminalSelector} .${U1}257.xterm-dim { color: ${$n.multiplyOpacity($n.opaque(e.background),.5).css}; }${this._terminalSelector} .${KE}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=n}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,n){for(let r=this._rowElements.length;r<=n;r++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>n;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,n){this._refreshRowElements(e,n),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(tp),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(tp),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,n,r){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,n,r),this.renderRows(0,this._bufferService.rows-1),!e||!n||(this._selectionRenderModel.update(this._terminal,e,n,r),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,s=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,c=this._document.createDocumentFragment();if(r){let d=e[0]>n[0];c.appendChild(this._createSelectionElement(o,d?n[0]:e[0],d?e[0]:n[0],a-o+1))}else{let d=i===o?e[0]:0,h=o===s?n[0]:this._bufferService.cols;c.appendChild(this._createSelectionElement(o,d,h));let g=a-o-1;if(c.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,g)),o!==a){let p=s===a?n[0]:this._bufferService.cols;c.appendChild(this._createSelectionElement(a,0,p))}}this._selectionContainer.appendChild(c)}_createSelectionElement(e,n,r,i=1){let s=this._document.createElement("div"),o=n*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(r-n);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),s.style.height=`${i*this.dimensions.css.cell.height}px`,s.style.top=`${e*this.dimensions.css.cell.height}px`,s.style.left=`${o}px`,s.style.width=`${a}px`,s}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,n){let r=this._bufferService.buffer,i=r.ybase+r.y,s=Math.min(r.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,c=this._optionsService.rawOptions.cursorInactiveStyle;for(let d=e;d<=n;d++){let h=d+r.ydisp,g=this._rowElements[d],p=r.lines.get(h);if(!g||!p)break;g.replaceChildren(...this._rowFactory.createRow(p,h,h===i,a,c,s,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${G2}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,n,r,i,s,o){r<0&&(e=0),i<0&&(n=0);let a=this._bufferService.rows-1;r=Math.max(Math.min(r,a),0),i=Math.max(Math.min(i,a),0),s=Math.min(s,this._bufferService.cols);let c=this._bufferService.buffer,d=c.ybase+c.y,h=Math.min(c.x,s-1),g=this._optionsService.rawOptions.cursorBlink,p=this._optionsService.rawOptions.cursorStyle,_=this._optionsService.rawOptions.cursorInactiveStyle;for(let b=r;b<=i;++b){let x=b+c.ydisp,C=this._rowElements[b],j=c.lines.get(x);if(!C||!j)break;C.replaceChildren(...this._rowFactory.createRow(j,x,x===d,p,_,h,g,this.dimensions.css.cell.width,this._widthCache,o?b===r?e:0:-1,o?(b===i?n:s)-1:-1))}}};q3=Zn([ct(7,a4),ct(8,i_),ct(9,Si),ct(10,wi),ct(11,Mu),ct(12,nl),ct(13,Ed)],q3);var K3=class extends Xt{constructor(e,n,r){super(),this._optionsService=r,this.width=0,this.height=0,this._onCharSizeChange=this._register(new nt),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new d3e(this._optionsService))}catch{this._measureStrategy=this._register(new f3e(e,n,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};K3=Zn([ct(2,Si)],K3);var vL=class extends Xt{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,n){e!==void 0&&e>0&&n!==void 0&&n>0&&(this._result.width=e,this._result.height=n)}},f3e=class extends vL{constructor(e,n,r){super(),this._document=e,this._parentElement=n,this._optionsService=r,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},d3e=class extends vL{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let n=this._ctx.measureText("W");if(!("width"in n&&"fontBoundingBoxAscent"in n&&"fontBoundingBoxDescent"in n))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},h3e=class extends Xt{constructor(e,n,r){super(),this._textarea=e,this._window=n,this.mainDocument=r,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new p3e(this._window)),this._onDprChange=this._register(new nt),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new nt),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(Gr.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(Rt(this._textarea,"focus",()=>this._isFocused=!0)),this._register(Rt(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},p3e=class extends Xt{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ld),this._onDprChange=this._register(new nt),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(qn(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=Rt(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},m3e=class extends Xt{constructor(){super(),this.linkProviders=[],this._register(qn(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let n=this.linkProviders.indexOf(e);n!==-1&&this.linkProviders.splice(n,1)}}}};function m4(e,n,r){let i=r.getBoundingClientRect(),s=e.getComputedStyle(r),o=parseInt(s.getPropertyValue("padding-left")),a=parseInt(s.getPropertyValue("padding-top"));return[n.clientX-i.left-o,n.clientY-i.top-a]}function g3e(e,n,r,i,s,o,a,c,d){if(!o)return;let h=m4(e,n,r);if(h)return h[0]=Math.ceil((h[0]+(d?a/2:0))/a),h[1]=Math.ceil(h[1]/c),h[0]=Math.min(Math.max(h[0],1),i+(d?1:0)),h[1]=Math.min(Math.max(h[1],1),s),h}var G3=class{constructor(e,n){this._renderService=e,this._charSizeService=n}getCoords(e,n,r,i,s){return g3e(window,e,n,r,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,s)}getMouseReportCoords(e,n){let r=m4(window,e,n);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};G3=Zn([ct(0,rl),ct(1,i_)],G3);var y3e=class{constructor(e,n){this._renderCallback=e,this._coreBrowserService=n,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,n,r){this._rowCount=r,e=e!==void 0?e:0,n=n!==void 0?n:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,n):n,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),n=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,n),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},_L={};E2e(_L,{getSafariVersion:()=>_3e,isChromeOS:()=>SL,isFirefox:()=>bL,isIpad:()=>b3e,isIphone:()=>x3e,isLegacyEdge:()=>v3e,isLinux:()=>g4,isMac:()=>av,isNode:()=>s_,isSafari:()=>xL,isWindows:()=>wL});var s_=typeof process<"u"&&"title"in process,Wg=s_?"node":navigator.userAgent,qg=s_?"node":navigator.platform,bL=Wg.includes("Firefox"),v3e=Wg.includes("Edge"),xL=/^((?!chrome|android).)*safari/i.test(Wg);function _3e(){if(!xL)return 0;let e=Wg.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var av=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(qg),b3e=qg==="iPad",x3e=qg==="iPhone",wL=["Windows","Win16","Win32","WinCE"].includes(qg),g4=qg.indexOf("Linux")>=0,SL=/\bCrOS\b/.test(Wg),CL=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),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(e){this._idleCallback=void 0;let n=0,r=0,i=e.timeRemaining(),s=0;for(;this._i<this._tasks.length;){if(n=performance.now(),this._tasks[this._i]()||this._i++,n=Math.max(1,performance.now()-n),r=Math.max(n,r),s=e.timeRemaining(),r*1.5>s){i-n<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-n))}ms`),this._start();return}i=s}this.clear()}},w3e=class extends CL{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let n=performance.now()+e;return{timeRemaining:()=>Math.max(0,n-performance.now())}}},S3e=class extends CL{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},lv=!s_&&"requestIdleCallback"in window?S3e:w3e,C3e=class{constructor(){this._queue=new lv}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Y3=class extends Xt{constructor(e,n,r,i,s,o,a,c,d){super(),this._rowCount=e,this._optionsService=r,this._charSizeService=i,this._coreService=s,this._coreBrowserService=c,this._renderer=this._register(new ld),this._pausedResizeTask=new C3e,this._observerDisposable=this._register(new ld),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new nt),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new nt),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new nt),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new nt),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new y3e((h,g)=>this._renderRows(h,g),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new j3e(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(qn(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var h;return(h=this._renderer.value)==null?void 0:h.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(d.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,n),this._register(this._coreBrowserService.onWindowChange(h=>this._registerIntersectionObserver(h,n)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,n){if("IntersectionObserver"in e){let r=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});r.observe(n),this._observerDisposable.value=qn(()=>r.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,n,r=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,n);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),n=Math.max(n,i.end)),r||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,n,this._rowCount)}_renderRows(e,n){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,n);return}e=Math.min(e,this._rowCount-1),n=Math.min(n,this._rowCount-1),this._renderer.value.renderRows(e,n),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:n}),this._onRender.fire({start:e,end:n}),this._isNextRenderRedrawOnly=!0}}resize(e,n){this._rowCount=n,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(n=>this.refreshRows(n.start,n.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,n;this._renderer.value&&((n=(e=this._renderer.value).clearTextureAtlas)==null||n.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,n){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var r;return(r=this._renderer.value)==null?void 0:r.handleResize(e,n)}):this._renderer.value.handleResize(e,n),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,n,r){var i;this._selectionState.start=e,this._selectionState.end=n,this._selectionState.columnSelectMode=r,(i=this._renderer.value)==null||i.handleSelectionChanged(e,n,r)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Y3=Zn([ct(2,Si),ct(3,i_),ct(4,Mu),ct(5,Vg),ct(6,wi),ct(7,nl),ct(8,Ed)],Y3);var j3e=class{constructor(e,n,r){this._coreBrowserService=e,this._coreService=n,this._onTimeout=r,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,n){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,n)):(this._start=e,this._end=n,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function k3e(e,n,r,i){let s=r.buffer.x,o=r.buffer.y;if(!r.buffer.hasScrollback)return N3e(s,o,e,n,r,i)+o_(o,n,r,i)+T3e(s,o,e,n,r,i);let a;if(o===n)return a=s>e?"D":"C",pg(Math.abs(s-e),hg(a,i));a=o>n?"D":"C";let c=Math.abs(o-n),d=O3e(o>n?e:s,r)+(c-1)*r.cols+1+E3e(o>n?s:e);return pg(d,hg(a,i))}function E3e(e,n){return e-1}function O3e(e,n){return n.cols-e}function N3e(e,n,r,i,s,o){return o_(n,i,s,o).length===0?"":pg(kL(e,n,e,n-wu(n,s),!1,s).length,hg("D",o))}function o_(e,n,r,i){let s=e-wu(e,r),o=n-wu(n,r),a=Math.abs(s-o)-P3e(e,n,r);return pg(a,hg(jL(e,n),i))}function T3e(e,n,r,i,s,o){let a;o_(n,i,s,o).length>0?a=i-wu(i,s):a=n;let c=i,d=A3e(e,n,r,i,s,o);return pg(kL(e,a,r,c,d==="C",s).length,hg(d,o))}function P3e(e,n,r){var a;let i=0,s=e-wu(e,r),o=n-wu(n,r);for(let c=0;c<Math.abs(s-o);c++){let d=jL(e,n)==="A"?-1:1;(a=r.buffer.lines.get(s+d*c))!=null&&a.isWrapped&&i++}return i}function wu(e,n){let r=0,i=n.buffer.lines.get(e),s=i==null?void 0:i.isWrapped;for(;s&&e>=0&&e<n.rows;)r++,i=n.buffer.lines.get(--e),s=i==null?void 0:i.isWrapped;return r}function A3e(e,n,r,i,s,o){let a;return o_(r,i,s,o).length>0?a=i-wu(i,s):a=n,e<r&&a<=i||e>=r&&a<i?"C":"D"}function jL(e,n){return e>n?"A":"B"}function kL(e,n,r,i,s,o){let a=e,c=n,d="";for(;(a!==r||c!==i)&&c>=0&&c<o.buffer.lines.length;)a+=s?1:-1,s&&a>o.cols-1?(d+=o.buffer.translateBufferLineToString(c,!1,e,a),a=0,e=0,c++):!s&&a<0&&(d+=o.buffer.translateBufferLineToString(c,!1,0,e+1),a=o.cols-1,e=a,c--);return d+o.buffer.translateBufferLineToString(c,!1,e,a)}function hg(e,n){let r=n?"O":"[";return He.ESC+r+e}function pg(e,n){e=Math.floor(e);let r="";for(let i=0;i<e;i++)r+=n;return r}var M3e=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,n=this.selectionEnd;return!e||!n?!1:e[1]>n[1]||e[1]===n[1]&&e[0]>n[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function GE(e,n){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return n*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Y2=50,R3e=15,D3e=50,z3e=500,L3e=" ",$3e=new RegExp(L3e,"g"),X3=class extends Xt{constructor(e,n,r,i,s,o,a,c,d){super(),this._element=e,this._screenElement=n,this._linkifier=r,this._bufferService=i,this._coreService=s,this._mouseService=o,this._optionsService=a,this._renderService=c,this._coreBrowserService=d,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Bs,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new nt),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new nt),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new nt),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new nt),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=h=>this._handleMouseMove(h),this._mouseUpListener=h=>this._handleMouseUp(h),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(h=>this._handleTrim(h)),this._register(this._bufferService.buffers.onBufferActivate(h=>this._handleBufferActivate(h))),this.enable(),this._model=new M3e(this._bufferService),this._activeSelectionMode=0,this._register(qn(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(h=>{h.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;return!e||!n?!1:e[0]!==n[0]||e[1]!==n[1]}get selectionText(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd;if(!e||!n)return"";let r=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===n[0])return"";let s=e[0]<n[0]?e[0]:n[0],o=e[0]<n[0]?n[0]:e[0];for(let a=e[1];a<=n[1];a++){let c=r.translateBufferLineToString(a,!0,s,o);i.push(c)}}else{let s=e[1]===n[1]?n[0]:void 0;i.push(r.translateBufferLineToString(e[1],!0,e[0],s));for(let o=e[1]+1;o<=n[1]-1;o++){let a=r.lines.get(o),c=r.translateBufferLineToString(o,!0);a!=null&&a.isWrapped?i[i.length-1]+=c:i.push(c)}if(e[1]!==n[1]){let o=r.lines.get(n[1]),a=r.translateBufferLineToString(n[1],!0,0,n[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(s=>s.replace($3e," ")).join(wL?`\r
|
|
779
779
|
`:`
|
|
780
|
-
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),g4&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let n=this._getMouseBufferCoords(e),r=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!r||!i||!n?!1:this._areCoordsInSelection(n,r,i)}isCellInSelection(e,n){let r=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!r||!i?!1:this._areCoordsInSelection([e,n],r,i)}_areCoordsInSelection(e,n,r){return e[1]>n[1]&&e[1]<r[1]||n[1]===r[1]&&e[1]===n[1]&&e[0]>=n[0]&&e[0]<r[0]||n[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||n[1]<r[1]&&e[1]===n[1]&&e[0]>=n[0]}_selectWordAtCursor(e,n){var s,o;let r=(o=(s=this._linkifier.currentLink)==null?void 0:s.link)==null?void 0:o.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=GE(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,n),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,n){this._model.clearSelection(),e=Math.max(e,0),n=Math.min(n,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,n],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let n=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(n)return n[0]--,n[1]--,n[1]+=this._bufferService.buffer.ydisp,n}_getMouseEventScrollAmount(e){let n=m4(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return n>=0&&n<=r?0:(n>r&&(n-=r),n=Math.min(Math.max(n,-Y2),Y2),n/=Y2,n/Math.abs(n)+Math.round(n*(M3e-1)))}shouldForceSelection(e){return av?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),R3e)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let n=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);n&&n.length!==this._model.selectionStart[0]&&n.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let n=this._getMouseBufferCoords(e);n&&(this._activeSelectionMode=2,this._selectLineAt(n[1]))}shouldColumnSelect(e){return e.altKey&&!(av&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let n=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let i=r.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!n||n[0]!==this._model.selectionEnd[0]||n[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let n=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&n<D3e&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let i=j3e(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd,r=!!e&&!!n&&(e[0]!==n[0]||e[1]!==n[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,n,r);return}!e||!n||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||n[0]!==this._oldSelectionEnd[0]||n[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,n,r)}_fireOnSelectionChange(e,n,r){this._oldSelectionStart=e,this._oldSelectionEnd=n,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(n=>this._handleTrim(n))}_convertViewportColToCharacterIndex(e,n){let r=n;for(let i=0;n>=i;i++){let s=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:s>1&&n!==i&&(r+=s-1)}return r}setSelection(e,n,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,n],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,n,r=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let s=this._bufferService.buffer,o=s.lines.get(e[1]);if(!o)return;let a=s.translateBufferLineToString(e[1],!1),c=this._convertViewportColToCharacterIndex(o,e[0]),d=c,h=e[0]-c,g=0,p=0,_=0,b=0;if(a.charAt(c)===" "){for(;c>0&&a.charAt(c-1)===" ";)c--;for(;d<a.length&&a.charAt(d+1)===" ";)d++}else{let j=e[0],S=e[0];o.getWidth(j)===0&&(g++,j--),o.getWidth(S)===2&&(p++,S++);let E=o.getString(S).length;for(E>1&&(b+=E-1,d+=E-1);j>0&&c>0&&!this._isCharWordSeparator(o.loadCell(j-1,this._workCell));){o.loadCell(j-1,this._workCell);let O=this._workCell.getChars().length;this._workCell.getWidth()===0?(g++,j--):O>1&&(_+=O-1,c-=O-1),c--,j--}for(;S<o.length&&d+1<a.length&&!this._isCharWordSeparator(o.loadCell(S+1,this._workCell));){o.loadCell(S+1,this._workCell);let O=this._workCell.getChars().length;this._workCell.getWidth()===2?(p++,S++):O>1&&(b+=O-1,d+=O-1),d++,S++}}d++;let x=c+h-g+_,C=Math.min(this._bufferService.cols,d-c+g+p-_-b);if(!(!n&&a.slice(c,d).trim()==="")){if(r&&x===0&&o.getCodePoint(0)!==32){let j=s.lines.get(e[1]-1);if(j&&o.isWrapped&&j.getCodePoint(this._bufferService.cols-1)!==32){let S=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(S){let E=this._bufferService.cols-S.start;x-=E,C+=E}}}if(i&&x+C===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let j=s.lines.get(e[1]+1);if(j!=null&&j.isWrapped&&j.getCodePoint(0)!==32){let S=this._getWordAt([0,e[1]+1],!1,!1,!0);S&&(C+=S.length)}}return{start:x,length:C}}}_selectWordAt(e,n){let r=this._getWordAt(e,n);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let n=this._getWordAt(e,!0);if(n){let r=e[1];for(;n.start<0;)n.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;n.start+n.length>this._bufferService.cols;)n.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?n.start:n.start+n.length,r]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let n=this._bufferService.buffer.getWrappedRangeForLine(e),r={start:{x:0,y:n.first},end:{x:this._bufferService.cols-1,y:n.last}};this._model.selectionStart=[0,n.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=GE(r,this._bufferService.cols)}};X3=Zn([ct(3,wi),ct(4,Mu),ct(5,l4),ct(6,Si),ct(7,rl),ct(8,nl)],X3);var YE=class{constructor(){this._data={}}set(e,n,r){this._data[e]||(this._data[e]={}),this._data[e][n]=r}get(e,n){return this._data[e]?this._data[e][n]:void 0}clear(){this._data={}}},XE=class{constructor(){this._color=new YE,this._css=new YE}setCss(e,n,r){this._css.set(e,n,r)}getCss(e,n){return this._css.get(e,n)}setColor(e,n,r){this._color.set(e,n,r)}getColor(e,n){return this._color.get(e,n)}clear(){this._color.clear(),this._css.clear()}},wr=Object.freeze((()=>{let e=[Gn.toColor("#2e3436"),Gn.toColor("#cc0000"),Gn.toColor("#4e9a06"),Gn.toColor("#c4a000"),Gn.toColor("#3465a4"),Gn.toColor("#75507b"),Gn.toColor("#06989a"),Gn.toColor("#d3d7cf"),Gn.toColor("#555753"),Gn.toColor("#ef2929"),Gn.toColor("#8ae234"),Gn.toColor("#fce94f"),Gn.toColor("#729fcf"),Gn.toColor("#ad7fa8"),Gn.toColor("#34e2e2"),Gn.toColor("#eeeeec")],n=[0,95,135,175,215,255];for(let r=0;r<216;r++){let i=n[r/36%6|0],s=n[r/6%6|0],o=n[r%6];e.push({css:gr.toCss(i,s,o),rgba:gr.toRgba(i,s,o)})}for(let r=0;r<24;r++){let i=8+r*10;e.push({css:gr.toCss(i,i,i),rgba:gr.toRgba(i,i,i)})}return e})()),Zc=Gn.toColor("#ffffff"),bp=Gn.toColor("#000000"),JE=Gn.toColor("#ffffff"),ZE=bp,np={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},$3e=Zc,J3=class extends Xt{constructor(e){super(),this._optionsService=e,this._contrastCache=new XE,this._halfContrastCache=new XE,this._onChangeColors=this._register(new nt),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Zc,background:bp,cursor:JE,cursorAccent:ZE,selectionForeground:void 0,selectionBackgroundTransparent:np,selectionBackgroundOpaque:$n.blend(bp,np),selectionInactiveBackgroundTransparent:np,selectionInactiveBackgroundOpaque:$n.blend(bp,np),scrollbarSliderBackground:$n.opacity(Zc,.2),scrollbarSliderHoverBackground:$n.opacity(Zc,.4),scrollbarSliderActiveBackground:$n.opacity(Zc,.5),overviewRulerBorder:Zc,ansi:wr.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let n=this._colors;if(n.foreground=kn(e.foreground,Zc),n.background=kn(e.background,bp),n.cursor=$n.blend(n.background,kn(e.cursor,JE)),n.cursorAccent=$n.blend(n.background,kn(e.cursorAccent,ZE)),n.selectionBackgroundTransparent=kn(e.selectionBackground,np),n.selectionBackgroundOpaque=$n.blend(n.background,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundTransparent=kn(e.selectionInactiveBackground,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundOpaque=$n.blend(n.background,n.selectionInactiveBackgroundTransparent),n.selectionForeground=e.selectionForeground?kn(e.selectionForeground,WE):void 0,n.selectionForeground===WE&&(n.selectionForeground=void 0),$n.isOpaque(n.selectionBackgroundTransparent)&&(n.selectionBackgroundTransparent=$n.opacity(n.selectionBackgroundTransparent,.3)),$n.isOpaque(n.selectionInactiveBackgroundTransparent)&&(n.selectionInactiveBackgroundTransparent=$n.opacity(n.selectionInactiveBackgroundTransparent,.3)),n.scrollbarSliderBackground=kn(e.scrollbarSliderBackground,$n.opacity(n.foreground,.2)),n.scrollbarSliderHoverBackground=kn(e.scrollbarSliderHoverBackground,$n.opacity(n.foreground,.4)),n.scrollbarSliderActiveBackground=kn(e.scrollbarSliderActiveBackground,$n.opacity(n.foreground,.5)),n.overviewRulerBorder=kn(e.overviewRulerBorder,$3e),n.ansi=wr.slice(),n.ansi[0]=kn(e.black,wr[0]),n.ansi[1]=kn(e.red,wr[1]),n.ansi[2]=kn(e.green,wr[2]),n.ansi[3]=kn(e.yellow,wr[3]),n.ansi[4]=kn(e.blue,wr[4]),n.ansi[5]=kn(e.magenta,wr[5]),n.ansi[6]=kn(e.cyan,wr[6]),n.ansi[7]=kn(e.white,wr[7]),n.ansi[8]=kn(e.brightBlack,wr[8]),n.ansi[9]=kn(e.brightRed,wr[9]),n.ansi[10]=kn(e.brightGreen,wr[10]),n.ansi[11]=kn(e.brightYellow,wr[11]),n.ansi[12]=kn(e.brightBlue,wr[12]),n.ansi[13]=kn(e.brightMagenta,wr[13]),n.ansi[14]=kn(e.brightCyan,wr[14]),n.ansi[15]=kn(e.brightWhite,wr[15]),e.extendedAnsi){let r=Math.min(n.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<r;i++)n.ansi[i+16]=kn(e.extendedAnsi[i],wr[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let n=0;n<this._restoreColors.ansi.length;++n)this._colors.ansi[n]=this._restoreColors.ansi[n];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};J3=Zn([ct(0,Si)],J3);function kn(e,n){if(e!==void 0)try{return Gn.toColor(e)}catch{}return n}var I3e=class{constructor(...e){this._entries=new Map;for(let[n,r]of e)this.set(n,r)}set(e,n){let r=this._entries.get(e);return this._entries.set(e,n),r}forEach(e){for(let[n,r]of this._entries.entries())e(n,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},B3e=class{constructor(){this._services=new I3e,this._services.set(a4,this)}setService(e,n){this._services.set(e,n)}getService(e){return this._services.get(e)}createInstance(e,...n){let r=M2e(e).sort((o,a)=>o.index-a.index),i=[];for(let o of r){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let s=r.length>0?r[0].index:n.length;if(n.length!==s)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${s+1} conflicts with ${n.length} static arguments`);return new e(...n,...i)}},F3e={trace:0,debug:1,info:2,warn:3,error:4,off:5},H3e="xterm.js: ",Z3=class extends Xt{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=F3e[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let n=0;n<e.length;n++)typeof e[n]=="function"&&(e[n]=e[n]())}_log(e,n,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":H3e)+n,...r)}trace(e,...n){var r;this._logLevel<=0&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.trace.bind(this._optionsService.options.logger))??console.log,e,n)}debug(e,...n){var r;this._logLevel<=1&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.debug.bind(this._optionsService.options.logger))??console.log,e,n)}info(e,...n){var r;this._logLevel<=2&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.info.bind(this._optionsService.options.logger))??console.info,e,n)}warn(e,...n){var r;this._logLevel<=3&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.warn.bind(this._optionsService.options.logger))??console.warn,e,n)}error(e,...n){var r;this._logLevel<=4&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.error.bind(this._optionsService.options.logger))??console.error,e,n)}};Z3=Zn([ct(0,Si)],Z3);var QE=class extends Xt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new nt),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new nt),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new nt),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let n=new Array(e);for(let r=0;r<Math.min(e,this.length);r++)n[r]=this._array[this._getCyclicIndex(r)];this._array=n,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let n=this._length;n<e;n++)this._array[n]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,n){this._array[this._getCyclicIndex(e)]=n}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,n,...r){if(n){for(let i=e;i<this._length-n;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+n)];this._length-=n,this.onDeleteEmitter.fire({index:e,amount:n})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+r.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<r.length;i++)this._array[this._getCyclicIndex(e+i)]=r[i];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let i=this._length+r.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,n,r){if(!(n<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let s=n-1;s>=0;s--)this.set(e+s+r,this.get(e+s));let i=e+n+r-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<n;i++)this.set(e+i+r,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Yt=3,mr=Object.freeze(new Ug),W1=0,X2=2,xp=class EL{constructor(n,r,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(n*Yt);let s=r||Bs.fromCharData([0,qz,1,0]);for(let o=0;o<n;++o)this.setCell(o,s);this.length=n}get(n){let r=this._data[n*Yt+0],i=r&2097151;return[this._data[n*Yt+1],r&2097152?this._combined[n]:i?Jl(i):"",r>>22,r&2097152?this._combined[n].charCodeAt(this._combined[n].length-1):i]}set(n,r){this._data[n*Yt+1]=r[0],r[1].length>1?(this._combined[n]=r[1],this._data[n*Yt+0]=n|2097152|r[2]<<22):this._data[n*Yt+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(n){return this._data[n*Yt+0]>>22}hasWidth(n){return this._data[n*Yt+0]&12582912}getFg(n){return this._data[n*Yt+1]}getBg(n){return this._data[n*Yt+2]}hasContent(n){return this._data[n*Yt+0]&4194303}getCodePoint(n){let r=this._data[n*Yt+0];return r&2097152?this._combined[n].charCodeAt(this._combined[n].length-1):r&2097151}isCombined(n){return this._data[n*Yt+0]&2097152}getString(n){let r=this._data[n*Yt+0];return r&2097152?this._combined[n]:r&2097151?Jl(r&2097151):""}isProtected(n){return this._data[n*Yt+2]&536870912}loadCell(n,r){return W1=n*Yt,r.content=this._data[W1+0],r.fg=this._data[W1+1],r.bg=this._data[W1+2],r.content&2097152&&(r.combinedData=this._combined[n]),r.bg&268435456&&(r.extended=this._extendedAttrs[n]),r}setCell(n,r){r.content&2097152&&(this._combined[n]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[n]=r.extended),this._data[n*Yt+0]=r.content,this._data[n*Yt+1]=r.fg,this._data[n*Yt+2]=r.bg}setCellFromCodepoint(n,r,i,s){s.bg&268435456&&(this._extendedAttrs[n]=s.extended),this._data[n*Yt+0]=r|i<<22,this._data[n*Yt+1]=s.fg,this._data[n*Yt+2]=s.bg}addCodepointToCell(n,r,i){let s=this._data[n*Yt+0];s&2097152?this._combined[n]+=Jl(r):s&2097151?(this._combined[n]=Jl(s&2097151)+Jl(r),s&=-2097152,s|=2097152):s=r|1<<22,i&&(s&=-12582913,s|=i<<22),this._data[n*Yt+0]=s}insertCells(n,r,i){if(n%=this.length,n&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n-1,0,1,i),r<this.length-n){let s=new Bs;for(let o=this.length-n-r-1;o>=0;--o)this.setCell(n+r+o,this.loadCell(n+o,s));for(let o=0;o<r;++o)this.setCell(n+o,i)}else for(let s=n;s<this.length;++s)this.setCell(s,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(n,r,i){if(n%=this.length,r<this.length-n){let s=new Bs;for(let o=0;o<this.length-n-r;++o)this.setCell(n+o,this.loadCell(n+r+o,s));for(let o=this.length-r;o<this.length;++o)this.setCell(o,i)}else for(let s=n;s<this.length;++s)this.setCell(s,i);n&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n-1,0,1,i),this.getWidth(n)===0&&!this.hasContent(n)&&this.setCellFromCodepoint(n,0,1,i)}replaceCells(n,r,i,s=!1){if(s){for(n&&this.getWidth(n-1)===2&&!this.isProtected(n-1)&&this.setCellFromCodepoint(n-1,0,1,i),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,i);n<r&&n<this.length;)this.isProtected(n)||this.setCell(n,i),n++;return}for(n&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n-1,0,1,i),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,i);n<r&&n<this.length;)this.setCell(n++,i)}resize(n,r){if(n===this.length)return this._data.length*4*X2<this._data.buffer.byteLength;let i=n*Yt;if(n>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let s=new Uint32Array(i);s.set(this._data),this._data=s}for(let s=this.length;s<n;++s)this.setCell(s,r)}else{this._data=this._data.subarray(0,i);let s=Object.keys(this._combined);for(let a=0;a<s.length;a++){let c=parseInt(s[a],10);c>=n&&delete this._combined[c]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let c=parseInt(o[a],10);c>=n&&delete this._extendedAttrs[c]}}return this.length=n,i*4*X2<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*X2<this._data.buffer.byteLength){let n=new Uint32Array(this._data.length);return n.set(this._data),this._data=n,1}return 0}fill(n,r=!1){if(r){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,n);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,n)}copyFrom(n){this.length!==n.length?this._data=new Uint32Array(n._data):this._data.set(n._data),this.length=n.length,this._combined={};for(let r in n._combined)this._combined[r]=n._combined[r];this._extendedAttrs={};for(let r in n._extendedAttrs)this._extendedAttrs[r]=n._extendedAttrs[r];this.isWrapped=n.isWrapped}clone(){let n=new EL(0);n._data=new Uint32Array(this._data),n.length=this.length;for(let r in this._combined)n._combined[r]=this._combined[r];for(let r in this._extendedAttrs)n._extendedAttrs[r]=this._extendedAttrs[r];return n.isWrapped=this.isWrapped,n}getTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(this._data[n*Yt+0]&4194303)return n+(this._data[n*Yt+0]>>22);return 0}getNoBgTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(this._data[n*Yt+0]&4194303||this._data[n*Yt+2]&50331648)return n+(this._data[n*Yt+0]>>22);return 0}copyCellsFrom(n,r,i,s,o){let a=n._data;if(o)for(let d=s-1;d>=0;d--){for(let h=0;h<Yt;h++)this._data[(i+d)*Yt+h]=a[(r+d)*Yt+h];a[(r+d)*Yt+2]&268435456&&(this._extendedAttrs[i+d]=n._extendedAttrs[r+d])}else for(let d=0;d<s;d++){for(let h=0;h<Yt;h++)this._data[(i+d)*Yt+h]=a[(r+d)*Yt+h];a[(r+d)*Yt+2]&268435456&&(this._extendedAttrs[i+d]=n._extendedAttrs[r+d])}let c=Object.keys(n._combined);for(let d=0;d<c.length;d++){let h=parseInt(c[d],10);h>=r&&(this._combined[h-r+i]=n._combined[h])}}translateToString(n,r,i,s){r=r??0,i=i??this.length,n&&(i=Math.min(i,this.getTrimmedLength())),s&&(s.length=0);let o="";for(;r<i;){let a=this._data[r*Yt+0],c=a&2097151,d=a&2097152?this._combined[r]:c?Jl(c):nc;if(o+=d,s)for(let h=0;h<d.length;++h)s.push(r);r+=a>>22||1}return s&&s.push(r),o}};function U3e(e,n,r,i,s,o){let a=[];for(let c=0;c<e.length-1;c++){let d=c,h=e.get(++d);if(!h.isWrapped)continue;let g=[e.get(c)];for(;d<e.length&&h.isWrapped;)g.push(h),h=e.get(++d);if(!o&&i>=c&&i<d){c+=g.length-1;continue}let p=0,_=mg(g,p,n),b=1,x=0;for(;b<g.length;){let j=mg(g,b,n),S=j-x,E=r-_,O=Math.min(S,E);g[p].copyCellsFrom(g[b],x,_,O,!1),_+=O,_===r&&(p++,_=0),x+=O,x===j&&(b++,x=0),_===0&&p!==0&&g[p-1].getWidth(r-1)===2&&(g[p].copyCellsFrom(g[p-1],r-1,_++,1,!1),g[p-1].setCell(r-1,s))}g[p].replaceCells(_,r,s);let C=0;for(let j=g.length-1;j>0&&(j>p||g[j].getTrimmedLength()===0);j--)C++;C>0&&(a.push(c+g.length-C),a.push(C)),c+=g.length-1}return a}function V3e(e,n){let r=[],i=0,s=n[i],o=0;for(let a=0;a<e.length;a++)if(s===a){let c=n[++i];e.onDeleteEmitter.fire({index:a-o,amount:c}),a+=c-1,o+=c,s=n[++i]}else r.push(a);return{layout:r,countRemoved:o}}function W3e(e,n){let r=[];for(let i=0;i<n.length;i++)r.push(e.get(n[i]));for(let i=0;i<r.length;i++)e.set(i,r[i]);e.length=n.length}function q3e(e,n,r){let i=[],s=e.map((d,h)=>mg(e,h,n)).reduce((d,h)=>d+h),o=0,a=0,c=0;for(;c<s;){if(s-c<r){i.push(s-c);break}o+=r;let d=mg(e,a,n);o>d&&(o-=d,a++);let h=e[a].getWidth(o-1)===2;h&&o--;let g=h?r-1:r;i.push(g),c+=g}return i}function mg(e,n,r){if(n===e.length-1)return e[n].getTrimmedLength();let i=!e[n].hasContent(r-1)&&e[n].getWidth(r-1)===1,s=e[n+1].getWidth(0)===2;return i&&s?r-1:r}var OL=class NL{constructor(n){this.line=n,this.isDisposed=!1,this._disposables=[],this._id=NL._nextId++,this._onDispose=this.register(new nt),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),xu(this._disposables),this._disposables.length=0)}register(n){return this._disposables.push(n),n}};OL._nextId=1;var K3e=OL,Cr={},Qc=Cr.B;Cr[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Cr.A={"#":"£"};Cr.B=void 0;Cr[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Cr.C=Cr[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Cr.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Cr.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Cr.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Cr.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Cr.E=Cr[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Cr.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Cr.H=Cr[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Cr["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var eO=4294967295,tO=class{constructor(e,n,r){this._hasScrollback=e,this._optionsService=n,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=mr.clone(),this.savedCharset=Qc,this.markers=[],this._nullCell=Bs.fromCharData([0,qz,1,0]),this._whitespaceCell=Bs.fromCharData([0,nc,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new lv,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new QE(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new iv),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new iv),this._whitespaceCell}getBlankLine(e,n){return new xp(this._bufferService.cols,this.getNullCell(e),n)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let n=e+this._optionsService.rawOptions.scrollback;return n>eO?eO:n}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=mr);let n=this._rows;for(;n--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new QE(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,n){let r=this.getNullCell(mr),i=0,s=this._getCorrectBufferLength(n);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(e,r);let o=0;if(this._rows<n)for(let a=this._rows;a<n;a++)this.lines.length<n+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new xp(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new xp(e,r)));else for(let a=this._rows;a>n;a--)this.lines.length>n+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s<this.lines.maxLength){let a=this.lines.length-s;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=s}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,n-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=n-1,this._isReflowEnabled&&(this._reflow(e,n),this._cols>e))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,r);this._cols=e,this._rows=n,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let n=0;for(;this._memoryCleanupPosition<this.lines.length;)if(n+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),n>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,n){this._cols!==e&&(e>this._cols?this._reflowLarger(e,n):this._reflowSmaller(e,n))}_reflowLarger(e,n){let r=this._optionsService.rawOptions.reflowCursorLine,i=U3e(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(mr),r);if(i.length>0){let s=V3e(this.lines,i);W3e(this.lines,s.layout),this._reflowLargerAdjustViewport(e,n,s.countRemoved)}}_reflowLargerAdjustViewport(e,n,r){let i=this.getNullCell(mr),s=r;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<n&&this.lines.push(new xp(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,n){let r=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(mr),s=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let c=this.lines.get(a);if(!c||!c.isWrapped&&c.getTrimmedLength()<=e)continue;let d=[c];for(;c.isWrapped&&a>0;)c=this.lines.get(--a),d.unshift(c);if(!r){let O=this.ybase+this.y;if(O>=a&&O<a+d.length)continue}let h=d[d.length-1].getTrimmedLength(),g=q3e(d,this._cols,e),p=g.length-d.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+p):_=Math.max(0,this.lines.length-this.lines.maxLength+p);let b=[];for(let O=0;O<p;O++){let N=this.getBlankLine(mr,!0);b.push(N)}b.length>0&&(s.push({start:a+d.length+o,newLines:b}),o+=b.length),d.push(...b);let x=g.length-1,C=g[x];C===0&&(x--,C=g[x]);let j=d.length-p-1,S=h;for(;j>=0;){let O=Math.min(S,C);if(d[x]===void 0)break;if(d[x].copyCellsFrom(d[j],S-O,C-O,O,!0),C-=O,C===0&&(x--,C=g[x]),S-=O,S===0){j--;let N=Math.max(j,0);S=mg(d,N,this._cols)}}for(let O=0;O<d.length;O++)g[O]<e&&d[O].setCell(g[O],i);let E=p-_;for(;E-- >0;)this.ybase===0?this.y<n-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-n&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+p,this.ybase+n-1)}if(s.length>0){let a=[],c=[];for(let C=0;C<this.lines.length;C++)c.push(this.lines.get(C));let d=this.lines.length,h=d-1,g=0,p=s[g];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let _=0;for(let C=Math.min(this.lines.maxLength-1,d+o-1);C>=0;C--)if(p&&p.start>h+_){for(let j=p.newLines.length-1;j>=0;j--)this.lines.set(C--,p.newLines[j]);C++,a.push({index:h+1,amount:p.newLines.length}),_+=p.newLines.length,p=s[++g]}else this.lines.set(C,c[h--]);let b=0;for(let C=a.length-1;C>=0;C--)a[C].index+=b,this.lines.onInsertEmitter.fire(a[C]),b+=a[C].amount;let x=Math.max(0,d+o-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,n,r=0,i){let s=this.lines.get(e);return s?s.translateToString(n,r,i):""}getWrappedRangeForLine(e){let n=e,r=e;for(;n>0&&this.lines.get(n).isWrapped;)n--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:n,last:r}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let n=0;n<this.markers.length;n++)this.markers[n].line===e&&(this.markers[n].dispose(),this.markers.splice(n--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let n=new K3e(e);return this.markers.push(n),n.register(this.lines.onTrim(r=>{n.line-=r,n.line<0&&n.dispose()})),n.register(this.lines.onInsert(r=>{n.line>=r.index&&(n.line+=r.amount)})),n.register(this.lines.onDelete(r=>{n.line>=r.index&&n.line<r.index+r.amount&&n.dispose(),n.line>r.index&&(n.line-=r.amount)})),n.register(n.onDispose(()=>this._removeMarker(n))),n}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},G3e=class extends Xt{constructor(e,n){super(),this._optionsService=e,this._bufferService=n,this._onBufferActivate=this._register(new nt),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new tO(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new tO(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,n){this._normal.resize(e,n),this._alt.resize(e,n),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},TL=2,PL=1,Q3=class extends Xt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new nt),this.onResize=this._onResize.event,this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,TL),this.rows=Math.max(e.rawOptions.rows||0,PL),this.buffers=this._register(new G3e(e,this)),this._register(this.buffers.onBufferActivate(n=>{this._onScroll.fire(n.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,n){let r=this.cols!==e,i=this.rows!==n;this.cols=e,this.rows=n,this.buffers.resize(e,n),this._onResize.fire({cols:e,rows:n,colsChanged:r,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,n=!1){let r=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=r.getBlankLine(e,n),this._cachedBlankLine=i),i.isWrapped=n;let s=r.ybase+r.scrollTop,o=r.ybase+r.scrollBottom;if(r.scrollTop===0){let a=r.lines.isFull;o===r.lines.length-1?a?r.lines.recycle().copyFrom(i):r.lines.push(i.clone()):r.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let a=o-s+1;r.lines.shiftElements(s+1,a-1,-1),r.lines.set(o,i.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,n){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let i=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),i!==r.ydisp&&(n||this._onScroll.fire(r.ydisp))}};Q3=Zn([ct(0,Si)],Q3);var $f={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:av,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},Y3e=["normal","bold","100","200","300","400","500","600","700","800","900"],X3e=class extends Xt{constructor(e){super(),this._onOptionChange=this._register(new nt),this.onOptionChange=this._onOptionChange.event;let n={...$f};for(let r in e)if(r in n)try{let i=e[r];n[r]=this._sanitizeAndValidateOption(r,i)}catch(i){console.error(i)}this.rawOptions=n,this.options={...n},this._setupOptions(),this._register(qn(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,n){return this.onOptionChange(r=>{r===e&&n(this.rawOptions[e])})}onMultipleOptionChange(e,n){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&n()})}_setupOptions(){let e=r=>{if(!(r in $f))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},n=(r,i)=>{if(!(r in $f))throw new Error(`No option with key "${r}"`);i=this._sanitizeAndValidateOption(r,i),this.rawOptions[r]!==i&&(this.rawOptions[r]=i,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let i={get:e.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this.options,r,i)}}_sanitizeAndValidateOption(e,n){switch(e){case"cursorStyle":if(n||(n=$f[e]),!J3e(n))throw new Error(`"${n}" is not a valid value for ${e}`);break;case"wordSeparator":n||(n=$f[e]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=Y3e.includes(n)?n:$f[e];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${e} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(n*10)/10));break;case"scrollback":if(n=Math.min(n,4294967295),n<0)throw new Error(`${e} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${e} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{};break}return n}};function J3e(e){return e==="block"||e==="underline"||e==="bar"}function wp(e,n=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let i in e)r[i]=n<=1?e[i]:e[i]&&wp(e[i],n-1);return r}var nO=Object.freeze({insertMode:!1}),rO=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),e5=class extends Xt{constructor(e,n,r){super(),this._bufferService=e,this._logService=n,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new nt),this.onData=this._onData.event,this._onUserInput=this._register(new nt),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new nt),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new nt),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=wp(nO),this.decPrivateModes=wp(rO)}reset(){this.modes=wp(nO),this.decPrivateModes=wp(rO)}triggerDataEvent(e,n=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;n&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),n&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(n=>n.charCodeAt(0))),this._onBinary.fire(e))}};e5=Zn([ct(0,wi),ct(1,Jz),ct(2,Si)],e5);var iO={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function J2(e,n){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!n&&(r|=3)),r}var Z2=String.fromCharCode,sO={DEFAULT:e=>{let n=[J2(e,!1)+32,e.col+32,e.row+32];return n[0]>255||n[1]>255||n[2]>255?"":`\x1B[M${Z2(n[0])}${Z2(n[1])}${Z2(n[2])}`},SGR:e=>{let n=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${J2(e,!0)};${e.col};${e.row}${n}`},SGR_PIXELS:e=>{let n=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${J2(e,!0)};${e.x};${e.y}${n}`}},t5=class extends Xt{constructor(e,n,r){super(),this._bufferService=e,this._coreService=n,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new nt),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(iO))this.addProtocol(i,iO[i]);for(let i of Object.keys(sO))this.addEncoding(i,sO[i]);this.reset()}addProtocol(e,n){this._protocols[e]=n}addEncoding(e,n){this._encodings[e]=n}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,n,r){if(e.deltaY===0||e.shiftKey||n===void 0||r===void 0)return 0;let i=n/r,s=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=i+0,Math.abs(e.deltaY)<50&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(e,n){return n.altKey||n.ctrlKey||n.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let n=this._encodings[this._activeEncoding](e);return n&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(n):this._coreService.triggerDataEvent(n,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,n,r){if(r){if(e.x!==n.x||e.y!==n.y)return!1}else if(e.col!==n.col||e.row!==n.row)return!1;return!(e.button!==n.button||e.action!==n.action||e.ctrl!==n.ctrl||e.alt!==n.alt||e.shift!==n.shift)}};t5=Zn([ct(0,wi),ct(1,Mu),ct(2,Si)],t5);var Q2=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Z3e=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Sr;function Q3e(e,n){let r=0,i=n.length-1,s;if(e<n[0][0]||e>n[i][1])return!1;for(;i>=r;)if(s=r+i>>1,e>n[s][1])r=s+1;else if(e<n[s][0])i=s-1;else return!0;return!1}var e5e=class{constructor(){if(this.version="6",!Sr){Sr=new Uint8Array(65536),Sr.fill(1),Sr[0]=0,Sr.fill(0,1,32),Sr.fill(0,127,160),Sr.fill(2,4352,4448),Sr[9001]=2,Sr[9002]=2,Sr.fill(2,11904,42192),Sr[12351]=1,Sr.fill(2,44032,55204),Sr.fill(2,63744,64256),Sr.fill(2,65040,65050),Sr.fill(2,65072,65136),Sr.fill(2,65280,65377),Sr.fill(2,65504,65511);for(let e=0;e<Q2.length;++e)Sr.fill(0,Q2[e][0],Q2[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Sr[e]:Q3e(e,Z3e)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,n){let r=this.wcwidth(e),i=r===0&&n!==0;if(i){let s=iu.extractWidth(n);s===0?i=!1:s>r&&(r=s)}return iu.createPropertyValue(0,r,i)}},iu=class gy{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new nt,this.onChange=this._onChange.event;let n=new e5e;this.register(n),this._active=n.version,this._activeProvider=n}static extractShouldJoin(n){return(n&1)!==0}static extractWidth(n){return n>>1&3}static extractCharKind(n){return n>>3}static createPropertyValue(n,r,i=!1){return(n&16777215)<<3|(r&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(n){if(!this._providers[n])throw new Error(`unknown Unicode version "${n}"`);this._active=n,this._activeProvider=this._providers[n],this._onChange.fire(n)}register(n){this._providers[n.version]=n}wcwidth(n){return this._activeProvider.wcwidth(n)}getStringCellWidth(n){let r=0,i=0,s=n.length;for(let o=0;o<s;++o){let a=n.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return r+this.wcwidth(a);let h=n.charCodeAt(o);56320<=h&&h<=57343?a=(a-55296)*1024+h-56320+65536:r+=this.wcwidth(h)}let c=this.charProperties(a,i),d=gy.extractWidth(c);gy.extractShouldJoin(c)&&(d-=gy.extractWidth(i)),r+=d,i=c}return r}charProperties(n,r){return this._activeProvider.charProperties(n,r)}},t5e=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,n){this._charsets[e]=n,this.glevel===e&&(this.charset=n)}};function oO(e){var i;let n=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&n&&(r.isWrapped=n[3]!==0&&n[3]!==32)}var rp=2147483647,n5e=256,AL=class n5{constructor(n=32,r=32){if(this.maxLength=n,this.maxSubParamsLength=r,r>n5e)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(n),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(n),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(n){let r=new n5;if(!n.length)return r;for(let i=Array.isArray(n[0])?1:0;i<n.length;++i){let s=n[i];if(Array.isArray(s))for(let o=0;o<s.length;++o)r.addSubParam(s[o]);else r.addParam(s)}return r}clone(){let n=new n5(this.maxLength,this.maxSubParamsLength);return n.params.set(this.params),n.length=this.length,n._subParams.set(this._subParams),n._subParamsLength=this._subParamsLength,n._subParamsIdx.set(this._subParamsIdx),n._rejectDigits=this._rejectDigits,n._rejectSubDigits=this._rejectSubDigits,n._digitIsSub=this._digitIsSub,n}toArray(){let n=[];for(let r=0;r<this.length;++r){n.push(this.params[r]);let i=this._subParamsIdx[r]>>8,s=this._subParamsIdx[r]&255;s-i>0&&n.push(Array.prototype.slice.call(this._subParams,i,s))}return n}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(n){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(n<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=n>rp?rp:n}addSubParam(n){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(n<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=n>rp?rp:n,this._subParamsIdx[this.length-1]++}}hasSubParams(n){return(this._subParamsIdx[n]&255)-(this._subParamsIdx[n]>>8)>0}getSubParams(n){let r=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;return i-r>0?this._subParams.subarray(r,i):null}getSubParamsAll(){let n={};for(let r=0;r<this.length;++r){let i=this._subParamsIdx[r]>>8,s=this._subParamsIdx[r]&255;s-i>0&&(n[r]=this._subParams.slice(i,s))}return n}addDigit(n){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,s=i[r-1];i[r-1]=~s?Math.min(s*10+n,rp):n}},ip=[],r5e=class{constructor(){this._state=0,this._active=ip,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,n){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(n),{dispose:()=>{let i=r.indexOf(n);i!==-1&&r.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ip}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ip,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ip,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,n,r){if(!this._active.length)this._handlerFb(this._id,"PUT",r_(e,n,r));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,n,r)}start(){this.reset(),this._state=1}put(e,n,r){if(this._state!==3){if(this._state===1)for(;n<r;){let i=e[n++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&r-n>0&&this._put(e,n,r)}}end(e,n=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let r=!1,i=this._active.length-1,s=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,r=n,s=this._stack.fallThrough,this._stack.paused=!1),!s&&r===!1){for(;i>=0&&(r=this._active[i].end(e),r!==!0);i--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,r;i--}for(;i>=0;i--)if(r=this._active[i].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,r}this._active=ip,this._id=-1,this._state=0}}},ls=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,n,r){this._hitLimit||(this._data+=r_(e,n,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let n=!1;if(this._hitLimit)n=!1;else if(e&&(n=this._handler(this._data),n instanceof Promise))return n.then(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,n}},sp=[],i5e=class{constructor(){this._handlers=Object.create(null),this._active=sp,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=sp}registerHandler(e,n){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(n),{dispose:()=>{let i=r.indexOf(n);i!==-1&&r.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=sp,this._ident=0}hook(e,n){if(this.reset(),this._ident=e,this._active=this._handlers[e]||sp,!this._active.length)this._handlerFb(this._ident,"HOOK",n);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(n)}put(e,n,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",r_(e,n,r));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,n,r)}unhook(e,n=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,i=this._active.length-1,s=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,r=n,s=this._stack.fallThrough,this._stack.paused=!1),!s&&r===!1){for(;i>=0&&(r=this._active[i].unhook(e),r!==!0);i--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,r;i--}for(;i>=0;i--)if(r=this._active[i].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,r}this._active=sp,this._ident=0}},Sp=new AL;Sp.addParam(0);var aO=class{constructor(e){this._handler=e,this._data="",this._params=Sp,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Sp,this._data="",this._hitLimit=!1}put(e,n,r){this._hitLimit||(this._data+=r_(e,n,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let n=!1;if(this._hitLimit)n=!1;else if(e&&(n=this._handler(this._data,this._params),n instanceof Promise))return n.then(r=>(this._params=Sp,this._data="",this._hitLimit=!1,r));return this._params=Sp,this._data="",this._hitLimit=!1,n}},s5e=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,n){this.table.fill(e<<4|n)}add(e,n,r,i){this.table[n<<8|e]=r<<4|i}addMany(e,n,r,i){for(let s=0;s<e.length;s++)this.table[n<<8|e[s]]=r<<4|i}},Rs=160,o5e=(function(){let e=new s5e(4095),n=Array.apply(null,Array(256)).map((c,d)=>d),r=(c,d)=>n.slice(c,d),i=r(32,127),s=r(0,24);s.push(25),s.push.apply(s,r(28,32));let o=r(0,14),a;e.setDefault(1,0),e.addMany(i,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(r(128,144),a,3,0),e.addMany(r(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(s,0,3,0),e.addMany(s,1,3,1),e.add(127,1,0,1),e.addMany(s,8,0,8),e.addMany(s,3,3,3),e.add(127,3,0,3),e.addMany(s,4,3,4),e.add(127,4,0,4),e.addMany(s,6,3,6),e.addMany(s,5,3,5),e.add(127,5,0,5),e.addMany(s,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(s,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(s,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(s,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(s,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(s,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(s,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Rs,0,2,0),e.add(Rs,8,5,8),e.add(Rs,6,0,6),e.add(Rs,11,0,11),e.add(Rs,13,13,13),e})(),a5e=class extends Xt{constructor(e=o5e){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new AL,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(n,r,i)=>{},this._executeHandlerFb=n=>{},this._csiHandlerFb=(n,r)=>{},this._escHandlerFb=n=>{},this._errorHandlerFb=n=>n,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(qn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new r5e),this._dcsParser=this._register(new i5e),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,n=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let s=0;s<e.intermediates.length;++s){let o=e.intermediates.charCodeAt(s);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(n[0]>i||i>n[1])throw new Error(`final must be in range ${n[0]} .. ${n[1]}`);return r<<=8,r|=i,r}identToString(e){let n=[];for(;e;)n.push(String.fromCharCode(e&255)),e>>=8;return n.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,n){let r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let i=this._escHandlers[r];return i.push(n),{dispose:()=>{let s=i.indexOf(n);s!==-1&&i.splice(s,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,n){this._executeHandlers[e.charCodeAt(0)]=n}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,n){let r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let i=this._csiHandlers[r];return i.push(n),{dispose:()=>{let s=i.indexOf(n);s!==-1&&i.splice(s,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,n){return this._dcsParser.registerHandler(this._identifier(e),n)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,n){return this._oscParser.registerHandler(e,n)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,n,r,i,s){this._parseStack.state=e,this._parseStack.handlers=n,this._parseStack.handlerPos=r,this._parseStack.transition=i,this._parseStack.chunkPos=s}parse(e,n,r){let i=0,s=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let c=this._parseStack.handlers,d=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&d>-1){for(;d>=0&&(a=c[d](this._params),a!==!0);d--)if(a instanceof Promise)return this._parseStack.handlerPos=d,a}this._parseStack.handlers=[];break;case 4:if(r===!1&&d>-1){for(;d>=0&&(a=c[d](),a!==!0);d--)if(a instanceof Promise)return this._parseStack.handlerPos=d,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,r),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,r),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let c=o;c<n;++c){switch(i=e[c],s=this._transitions.table[this.currentState<<8|(i<160?i:Rs)],s>>4){case 2:for(let _=c+1;;++_){if(_>=n||(i=e[_])<32||i>126&&i<Rs){this._printHandler(e,c,_),c=_-1;break}if(++_>=n||(i=e[_])<32||i>126&&i<Rs){this._printHandler(e,c,_),c=_-1;break}if(++_>=n||(i=e[_])<32||i>126&&i<Rs){this._printHandler(e,c,_),c=_-1;break}if(++_>=n||(i=e[_])<32||i>126&&i<Rs){this._printHandler(e,c,_),c=_-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:c,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let d=this._csiHandlers[this._collect<<8|i],h=d?d.length-1:-1;for(;h>=0&&(a=d[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._preserveStack(3,d,h,s,c),a;h<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++c<n&&(i=e[c])>47&&i<60);c--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let g=this._escHandlers[this._collect<<8|i],p=g?g.length-1:-1;for(;p>=0&&(a=g[p](),a!==!0);p--)if(a instanceof Promise)return this._preserveStack(4,g,p,s,c),a;p<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let _=c+1;;++_)if(_>=n||(i=e[_])===24||i===26||i===27||i>127&&i<Rs){this._dcsParser.put(e,c,_),c=_-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,s,c),a;i===27&&(s|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=c+1;;_++)if(_>=n||(i=e[_])<32||i>127&&i<Rs){this._oscParser.put(e,c,_),c=_-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,s,c),a;i===27&&(s|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=s&15}}},l5e=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,c5e=/^[\da-f]+$/;function lO(e){if(!e)return;let n=e.toLowerCase();if(n.indexOf("rgb:")===0){n=n.slice(4);let r=l5e.exec(n);if(r){let i=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/i*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/i*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/i*255)]}}else if(n.indexOf("#")===0&&(n=n.slice(1),c5e.exec(n)&&[3,6,9,12].includes(n.length))){let r=n.length/3,i=[0,0,0];for(let s=0;s<3;++s){let o=parseInt(n.slice(r*s,r*s+r),16);i[s]=r===1?o<<4:r===2?o:r===3?o>>4:o>>8}return i}}function ew(e,n){let r=e.toString(16),i=r.length<2?"0"+r:r;switch(n){case 4:return r[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function u5e(e,n=16){let[r,i,s]=e;return`rgb:${ew(r,n)}/${ew(i,n)}/${ew(s,n)}`}var f5e={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ql=131072,cO=10;function uO(e,n){if(e>24)return n.setWinLines||!1;switch(e){case 1:return!!n.restoreWin;case 2:return!!n.minimizeWin;case 3:return!!n.setWinPosition;case 4:return!!n.setWinSizePixels;case 5:return!!n.raiseWin;case 6:return!!n.lowerWin;case 7:return!!n.refreshWin;case 8:return!!n.setWinSizeChars;case 9:return!!n.maximizeWin;case 10:return!!n.fullscreenWin;case 11:return!!n.getWinState;case 13:return!!n.getWinPosition;case 14:return!!n.getWinSizePixels;case 15:return!!n.getScreenSizePixels;case 16:return!!n.getCellSizePixels;case 18:return!!n.getWinSizeChars;case 19:return!!n.getScreenSizeChars;case 20:return!!n.getIconTitle;case 21:return!!n.getWinTitle;case 22:return!!n.pushTitle;case 23:return!!n.popTitle;case 24:return!!n.setWinLines}return!1}var fO=5e3,dO=0,d5e=class extends Xt{constructor(e,n,r,i,s,o,a,c,d=new a5e){super(),this._bufferService=e,this._charsetService=n,this._coreService=r,this._logService=i,this._optionsService=s,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=c,this._parser=d,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new P2e,this._utf8Decoder=new A2e,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=mr.clone(),this._eraseAttrDataInternal=mr.clone(),this._onRequestBell=this._register(new nt),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new nt),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new nt),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new nt),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new nt),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new nt),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new nt),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new nt),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new nt),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new nt),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new nt),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new nt),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new r5(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:g.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,g,p)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:g,data:p})}),this._parser.setDcsHandlerFallback((h,g,p)=>{g==="HOOK"&&(p=p.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:g,payload:p})}),this._parser.setPrintHandler((h,g,p)=>this.print(h,g,p)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(He.BEL,()=>this.bell()),this._parser.setExecuteHandler(He.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(He.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(He.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(He.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(He.BS,()=>this.backspace()),this._parser.setExecuteHandler(He.HT,()=>this.tab()),this._parser.setExecuteHandler(He.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(He.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(py.IND,()=>this.index()),this._parser.setExecuteHandler(py.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(py.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new ls(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new ls(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new ls(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new ls(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new ls(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new ls(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new ls(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new ls(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new ls(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new ls(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new ls(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new ls(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Cr)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new aO((h,g)=>this.requestStatusString(h,g)))}getAttrData(){return this._curAttrData}_preserveStack(e,n,r,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=n,this._parseStack.decodedLength=r,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((n,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),fO))]).catch(n=>{if(n!=="#SLOW_TIMEOUT")throw n;console.warn(`async parser handler taking longer than ${fO} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,n){let r,i=this._activeBuffer.x,s=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,n))return this._logSlowResolvingAsync(r),r;i=this._parseStack.cursorStartX,s=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ql&&(o=this._parseStack.position+ql)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<ql&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ql))),a||this._dirtyRowTracker.clearRange(),e.length>ql)for(let h=o;h<e.length;h+=ql){let g=h+ql<e.length?h+ql:e.length,p=typeof e=="string"?this._stringDecoder.decode(e.substring(h,g),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,g),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,p))return this._preserveStack(i,s,p,h),this._logSlowResolvingAsync(r),r}else if(!a){let h=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,h))return this._preserveStack(i,s,h,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==i||this._activeBuffer.y!==s)&&this._onCursorMove.fire();let c=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),d=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);d<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(d,this._bufferService.rows-1),end:Math.min(c,this._bufferService.rows-1)})}print(e,n,r){let i,s,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,c=this._bufferService.cols,d=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,g=this._curAttrData,p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-n>0&&p.getWidth(this._activeBuffer.x-1)===2&&p.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let _=this._parser.precedingJoinState;for(let b=n;b<r;++b){if(i=e[b],i<127&&o){let S=o[String.fromCharCode(i)];S&&(i=S.charCodeAt(0))}let x=this._unicodeService.charProperties(i,_);s=iu.extractWidth(x);let C=iu.extractShouldJoin(x),j=C?iu.extractWidth(_):0;if(_=x,a&&this._onA11yChar.fire(Jl(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+s-j>c){if(d){let S=p,E=this._activeBuffer.x-j;for(this._activeBuffer.x=j,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),j>0&&p instanceof xp&&p.copyCellsFrom(S,E,0,j,!1);E<c;)S.setCellFromCodepoint(E++,0,1,g)}else if(this._activeBuffer.x=c-1,s===2)continue}if(C&&this._activeBuffer.x){let S=p.getWidth(this._activeBuffer.x-1)?1:2;p.addCodepointToCell(this._activeBuffer.x-S,i,s);for(let E=s-j;--E>=0;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(h&&(p.insertCells(this._activeBuffer.x,s-j,this._activeBuffer.getNullCell(g)),p.getWidth(c-1)===2&&p.setCellFromCodepoint(c-1,0,1,g)),p.setCellFromCodepoint(this._activeBuffer.x++,i,s,g),s>0)for(;--s;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=_,this._activeBuffer.x<c&&r-n>0&&p.getWidth(this._activeBuffer.x)===0&&!p.hasContent(this._activeBuffer.x)&&p.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,n){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,r=>uO(r.params[0],this._optionsService.rawOptions.windowOptions)?n(r):!0):this._parser.registerCsiHandler(e,n)}registerDcsHandler(e,n){return this._parser.registerDcsHandler(e,new aO(n))}registerEscHandler(e,n){return this._parser.registerEscHandler(e,n)}registerOscHandler(e,n){return this._parser.registerOscHandler(e,new ls(n))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);n.hasWidth(this._activeBuffer.x)&&!n.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,n){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+n):(this._activeBuffer.x=e,this._activeBuffer.y=n),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,n){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+n)}cursorUp(e){let n=this._activeBuffer.y-this._activeBuffer.scrollTop;return n>=0?this._moveCursor(0,-Math.min(n,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let n=this._activeBuffer.scrollBottom-this._activeBuffer.y;return n>=0?this._moveCursor(0,Math.min(n,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let n=e.params[0];return n===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:n===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let n=e.params[0]||1;for(;n--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let n=e.params[0]||1;for(;n--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let n=e.params[0];return n===1&&(this._curAttrData.bg|=536870912),(n===2||n===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,n,r,i=!1,s=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(n,r,this._activeBuffer.getNullCell(this._eraseAttrData()),s),i&&(o.isWrapped=!1)}_resetBufferLine(e,n=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),n),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,n=!1){var i;this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,n);r<this._bufferService.rows;r++)this._resetBufferLine(r,n);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,n),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,n);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r))!=null&&i.getTrimmedLength()););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,n);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,n=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,n);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,n);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,n);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let n=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;n--;)this._activeBuffer.lines.splice(s-1,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let n=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;n--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return n&&(n.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return n&&(n.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let n=e.params[0]||1;for(;n--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let n=e.params[0]||1;for(;n--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(mr));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.deleteCells(0,n,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.insertCells(0,n,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.insertCells(this._activeBuffer.x,n,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.deleteCells(this._activeBuffer.x,n,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return n&&(n.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let n=this._parser.precedingJoinState;if(!n)return!0;let r=e.params[0]||1,i=iu.extractWidth(n),s=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(s),a=new Uint32Array(o.length*r),c=0;for(let h=0;h<o.length;){let g=o.codePointAt(h)||0;a[c++]=g,h+=g>65535?2:1}let d=c;for(let h=1;h<r;++h)a.copyWithin(d,0,c),d+=c;return this.print(a,0,d),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(He.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(He.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(He.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(He.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(He.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let n=0;n<e.length;n++)switch(e.params[n]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let n=0;n<e.length;n++)switch(e.params[n]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Qc),this._charsetService.setgCharset(1,Qc),this._charsetService.setgCharset(2,Qc),this._charsetService.setgCharset(3,Qc);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let n=0;n<e.length;n++)switch(e.params[n]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let n=0;n<e.length;n++)switch(e.params[n]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[n]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,n){(C=>(C[C.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",C[C.SET=1]="SET",C[C.RESET=2]="RESET",C[C.PERMANENTLY_SET=3]="PERMANENTLY_SET",C[C.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(r={}));let i=this._coreService.decPrivateModes,{activeProtocol:s,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:c,cols:d}=this._bufferService,{active:h,alt:g}=c,p=this._optionsService.rawOptions,_=(C,j)=>(a.triggerDataEvent(`${He.ESC}[${n?"":"?"}${C};${j}$y`),!0),b=C=>C?1:2,x=e.params[0];return n?x===2?_(x,4):x===4?_(x,b(a.modes.insertMode)):x===12?_(x,3):x===20?_(x,b(p.convertEol)):_(x,0):x===1?_(x,b(i.applicationCursorKeys)):x===3?_(x,p.windowOptions.setWinLines?d===80?2:d===132?1:0:0):x===6?_(x,b(i.origin)):x===7?_(x,b(i.wraparound)):x===8?_(x,3):x===9?_(x,b(s==="X10")):x===12?_(x,b(p.cursorBlink)):x===25?_(x,b(!a.isCursorHidden)):x===45?_(x,b(i.reverseWraparound)):x===66?_(x,b(i.applicationKeypad)):x===67?_(x,4):x===1e3?_(x,b(s==="VT200")):x===1002?_(x,b(s==="DRAG")):x===1003?_(x,b(s==="ANY")):x===1004?_(x,b(i.sendFocus)):x===1005?_(x,4):x===1006?_(x,b(o==="SGR")):x===1015?_(x,4):x===1016?_(x,b(o==="SGR_PIXELS")):x===1048?_(x,1):x===47||x===1047||x===1049?_(x,b(h===g)):x===2004?_(x,b(i.bracketedPasteMode)):x===2026?_(x,b(i.synchronizedOutput)):_(x,0)}_updateAttrColor(e,n,r,i,s){return n===2?(e|=50331648,e&=-16777216,e|=Ug.fromColorRGB([r,i,s])):n===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,n,r){let i=[0,0,-1,0,0,0],s=0,o=0;do{if(i[o+s]=e.params[n+o],e.hasSubParams(n+o)){let a=e.getSubParams(n+o),c=0;do i[1]===5&&(s=1),i[o+c+1+s]=a[c];while(++c<a.length&&c+o+1+s<i.length);break}if(i[1]===5&&o+s>=2||i[1]===2&&o+s>=5)break;i[1]&&(s=1)}while(++o+n<e.length&&o+s<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:r.fg=this._updateAttrColor(r.fg,i[1],i[3],i[4],i[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,i[1],i[3],i[4],i[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,n){n.extended=n.extended.clone(),(!~e||e>5)&&(e=1),n.extended.underlineStyle=e,n.fg|=268435456,e===0&&(n.fg&=-268435457),n.updateExtended()}_processSGR0(e){e.fg=mr.fg,e.bg=mr.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let n=e.length,r,i=this._curAttrData;for(let s=0;s<n;s++)r=e.params[s],r>=30&&r<=37?(i.fg&=-50331904,i.fg|=16777216|r-30):r>=40&&r<=47?(i.bg&=-50331904,i.bg|=16777216|r-40):r>=90&&r<=97?(i.fg&=-50331904,i.fg|=16777216|r-90|8):r>=100&&r<=107?(i.bg&=-50331904,i.bg|=16777216|r-100|8):r===0?this._processSGR0(i):r===1?i.fg|=134217728:r===3?i.bg|=67108864:r===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(s)?e.getSubParams(s)[0]:1,i)):r===5?i.fg|=536870912:r===7?i.fg|=67108864:r===8?i.fg|=1073741824:r===9?i.fg|=2147483648:r===2?i.bg|=134217728:r===21?this._processUnderline(2,i):r===22?(i.fg&=-134217729,i.bg&=-134217729):r===23?i.bg&=-67108865:r===24?(i.fg&=-268435457,this._processUnderline(0,i)):r===25?i.fg&=-536870913:r===27?i.fg&=-67108865:r===28?i.fg&=-1073741825:r===29?i.fg&=2147483647:r===39?(i.fg&=-67108864,i.fg|=mr.fg&16777215):r===49?(i.bg&=-67108864,i.bg|=mr.bg&16777215):r===38||r===48||r===58?s+=this._extractColor(e,s,i):r===53?i.bg|=1073741824:r===55?i.bg&=-1073741825:r===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):r===100?(i.fg&=-67108864,i.fg|=mr.fg&16777215,i.bg&=-67108864,i.bg|=mr.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${He.ESC}[0n`);break;case 6:let n=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${He.ESC}[${n};${r}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let n=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${He.ESC}[?${n};${r}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=mr.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let n=e.length===0?1:e.params[0];if(n===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(n){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let r=n%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let n=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>n&&(this._activeBuffer.scrollTop=n-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!uO(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let n=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:n!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${He.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(n===0||n===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>cO&&this._windowTitleStack.shift()),(n===0||n===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>cO&&this._iconNameStack.shift());break;case 23:(n===0||n===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(n===0||n===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let n=[],r=e.split(";");for(;r.length>1;){let i=r.shift(),s=r.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(hO(o))if(s==="?")n.push({type:0,index:o});else{let a=lO(s);a&&n.push({type:1,index:o,color:a})}}}return n.length&&this._onColor.fire(n),!0}setHyperlink(e){let n=e.indexOf(";");if(n===-1)return!0;let r=e.slice(0,n).trim(),i=e.slice(n+1);return i?this._createHyperlink(r,i):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,n){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),i,s=r.findIndex(o=>o.startsWith("id="));return s!==-1&&(i=r[s].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:n}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,n){let r=e.split(";");for(let i=0;i<r.length&&!(n>=this._specialColors.length);++i,++n)if(r[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[n]}]);else{let s=lO(r[i]);s&&this._onColor.fire([{type:1,index:this._specialColors[n],color:s}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let n=[],r=e.split(";");for(let i=0;i<r.length;++i)if(/^\d+$/.exec(r[i])){let s=parseInt(r[i]);hO(s)&&n.push({type:2,index:s})}return n.length&&this._onColor.fire(n),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Qc),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(f5e[e[0]],Cr[e[1]]||Qc),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=mr.clone(),this._eraseAttrDataInternal=mr.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Bs;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let n=0;n<this._bufferService.rows;++n){let r=this._activeBuffer.ybase+this._activeBuffer.y+n,i=this._activeBuffer.lines.get(r);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,n){let r=a=>(this._coreService.triggerDataEvent(`${He.ESC}${a}${He.ESC}\\`),!0),i=this._bufferService.buffer,s=this._optionsService.rawOptions;return r(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,n){this._dirtyRowTracker.markRangeDirty(e,n)}},r5=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,n){e>n&&(dO=e,e=n,n=dO),e<this.start&&(this.start=e),n>this.end&&(this.end=n)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};r5=Zn([ct(0,wi)],r5);function hO(e){return 0<=e&&e<256}var h5e=5e7,pO=12,p5e=50,m5e=class extends Xt{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new nt),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,n){if(n!==void 0&&this._syncCalls>n){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let r;for(;r=this._writeBuffer.shift();){this._action(r);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,n){if(this._pendingData>h5e)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(n),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(n)}_innerWrite(e=0,n=!0){let r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],s=this._action(i,n);if(s){let a=c=>performance.now()-r>=pO?setTimeout(()=>this._innerWrite(0,c)):this._innerWrite(r,c);s.catch(c=>(queueMicrotask(()=>{throw c}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-r>=pO)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>p5e&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},i5=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let n=this._bufferService.buffer;if(e.id===void 0){let c=n.addMarker(n.ybase+n.y),d={data:e,id:this._nextId++,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(d,c)),this._dataByLinkId.set(d.id,d),d.id}let r=e,i=this._getEntryIdKey(r),s=this._entriesWithId.get(i);if(s)return this.addLineToLink(s.id,n.ybase+n.y),s.id;let o=n.addMarker(n.ybase+n.y),a={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,n){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(i=>i.line!==n)){let i=this._bufferService.buffer.addMarker(n);r.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(r,i))}}getLinkData(e){var n;return(n=this._dataByLinkId.get(e))==null?void 0:n.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,n){let r=e.lines.indexOf(n);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};i5=Zn([ct(0,wi)],i5);var mO=!1,g5e=class extends Xt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ld),this._onBinary=this._register(new nt),this.onBinary=this._onBinary.event,this._onData=this._register(new nt),this.onData=this._onData.event,this._onLineFeed=this._register(new nt),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new nt),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new nt),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new nt),this._instantiationService=new B3e,this.optionsService=this._register(new X3e(e)),this._instantiationService.setService(Si,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Q3)),this._instantiationService.setService(wi,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Z3)),this._instantiationService.setService(Jz,this._logService),this.coreService=this._register(this._instantiationService.createInstance(e5)),this._instantiationService.setService(Mu,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(t5)),this._instantiationService.setService(Xz,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(iu)),this._instantiationService.setService(z2e,this.unicodeService),this._charsetService=this._instantiationService.createInstance(t5e),this._instantiationService.setService(D2e,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(i5),this._instantiationService.setService(Zz,this._oscLinkService),this._inputHandler=this._register(new d5e(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Gr.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Gr.forward(this._bufferService.onResize,this._onResize)),this._register(Gr.forward(this.coreService.onData,this._onData)),this._register(Gr.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new m5e((n,r)=>this._inputHandler.parse(n,r))),this._register(Gr.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new nt),this._onScroll.event(e=>{var n;(n=this._onScrollApi)==null||n.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let n in e)this.optionsService.options[n]=e[n]}write(e,n){this._writeBuffer.write(e,n)}writeSync(e,n){this._logService.logLevel<=3&&!mO&&(this._logService.warn("writeSync is unreliable and will be removed soon."),mO=!0),this._writeBuffer.writeSync(e,n)}input(e,n=!0){this.coreService.triggerDataEvent(e,n)}resize(e,n){isNaN(e)||isNaN(n)||(e=Math.max(e,TL),n=Math.max(n,PL),this._bufferService.resize(e,n))}scroll(e,n=!1){this._bufferService.scroll(e,n)}scrollLines(e,n){this._bufferService.scrollLines(e,n)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let n=e-this._bufferService.buffer.ydisp;n!==0&&this.scrollLines(n)}registerEscHandler(e,n){return this._inputHandler.registerEscHandler(e,n)}registerDcsHandler(e,n){return this._inputHandler.registerDcsHandler(e,n)}registerCsiHandler(e,n){return this._inputHandler.registerCsiHandler(e,n)}registerOscHandler(e,n){return this._inputHandler.registerOscHandler(e,n)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,n=this.optionsService.rawOptions.windowsPty;n&&n.buildNumber!==void 0&&n.buildNumber!==void 0?e=n.backend==="conpty"&&n.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(oO.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(oO(this._bufferService),!1))),this._windowsWrappingHeuristics.value=qn(()=>{for(let n of e)n.dispose()})}}},y5e={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function v5e(e,n,r,i){var a;let s={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?n?s.key=He.ESC+"OA":s.key=He.ESC+"[A":e.key==="UIKeyInputLeftArrow"?n?s.key=He.ESC+"OD":s.key=He.ESC+"[D":e.key==="UIKeyInputRightArrow"?n?s.key=He.ESC+"OC":s.key=He.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(n?s.key=He.ESC+"OB":s.key=He.ESC+"[B");break;case 8:s.key=e.ctrlKey?"\b":He.DEL,e.altKey&&(s.key=He.ESC+s.key);break;case 9:if(e.shiftKey){s.key=He.ESC+"[Z";break}s.key=He.HT,s.cancel=!0;break;case 13:s.key=e.altKey?He.ESC+He.CR:He.CR,s.cancel=!0;break;case 27:s.key=He.ESC,e.altKey&&(s.key=He.ESC+He.ESC),s.cancel=!0;break;case 37:if(e.metaKey)break;o?s.key=He.ESC+"[1;"+(o+1)+"D":n?s.key=He.ESC+"OD":s.key=He.ESC+"[D";break;case 39:if(e.metaKey)break;o?s.key=He.ESC+"[1;"+(o+1)+"C":n?s.key=He.ESC+"OC":s.key=He.ESC+"[C";break;case 38:if(e.metaKey)break;o?s.key=He.ESC+"[1;"+(o+1)+"A":n?s.key=He.ESC+"OA":s.key=He.ESC+"[A";break;case 40:if(e.metaKey)break;o?s.key=He.ESC+"[1;"+(o+1)+"B":n?s.key=He.ESC+"OB":s.key=He.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(s.key=He.ESC+"[2~");break;case 46:o?s.key=He.ESC+"[3;"+(o+1)+"~":s.key=He.ESC+"[3~";break;case 36:o?s.key=He.ESC+"[1;"+(o+1)+"H":n?s.key=He.ESC+"OH":s.key=He.ESC+"[H";break;case 35:o?s.key=He.ESC+"[1;"+(o+1)+"F":n?s.key=He.ESC+"OF":s.key=He.ESC+"[F";break;case 33:e.shiftKey?s.type=2:e.ctrlKey?s.key=He.ESC+"[5;"+(o+1)+"~":s.key=He.ESC+"[5~";break;case 34:e.shiftKey?s.type=3:e.ctrlKey?s.key=He.ESC+"[6;"+(o+1)+"~":s.key=He.ESC+"[6~";break;case 112:o?s.key=He.ESC+"[1;"+(o+1)+"P":s.key=He.ESC+"OP";break;case 113:o?s.key=He.ESC+"[1;"+(o+1)+"Q":s.key=He.ESC+"OQ";break;case 114:o?s.key=He.ESC+"[1;"+(o+1)+"R":s.key=He.ESC+"OR";break;case 115:o?s.key=He.ESC+"[1;"+(o+1)+"S":s.key=He.ESC+"OS";break;case 116:o?s.key=He.ESC+"[15;"+(o+1)+"~":s.key=He.ESC+"[15~";break;case 117:o?s.key=He.ESC+"[17;"+(o+1)+"~":s.key=He.ESC+"[17~";break;case 118:o?s.key=He.ESC+"[18;"+(o+1)+"~":s.key=He.ESC+"[18~";break;case 119:o?s.key=He.ESC+"[19;"+(o+1)+"~":s.key=He.ESC+"[19~";break;case 120:o?s.key=He.ESC+"[20;"+(o+1)+"~":s.key=He.ESC+"[20~";break;case 121:o?s.key=He.ESC+"[21;"+(o+1)+"~":s.key=He.ESC+"[21~";break;case 122:o?s.key=He.ESC+"[23;"+(o+1)+"~":s.key=He.ESC+"[23~";break;case 123:o?s.key=He.ESC+"[24;"+(o+1)+"~":s.key=He.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?s.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?s.key=He.NUL:e.keyCode>=51&&e.keyCode<=55?s.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?s.key=He.DEL:e.keyCode===219?s.key=He.ESC:e.keyCode===220?s.key=He.FS:e.keyCode===221&&(s.key=He.GS);else if((!r||i)&&e.altKey&&!e.metaKey){let c=(a=y5e[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(c)s.key=He.ESC+c;else if(e.keyCode>=65&&e.keyCode<=90){let d=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(d);e.shiftKey&&(h=h.toUpperCase()),s.key=He.ESC+h}else if(e.keyCode===32)s.key=He.ESC+(e.ctrlKey?He.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let d=e.code.slice(3,4);e.shiftKey||(d=d.toLowerCase()),s.key=He.ESC+d,s.cancel=!0}}else r&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(s.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?s.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(s.key=He.US),e.key==="@"&&(s.key=He.NUL));break}return s}var rr=0,_5e=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new lv,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new lv,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((s,o)=>this._getKey(s)-this._getKey(o)),n=0,r=0,i=new Array(this._array.length+this._insertedValues.length);for(let s=0;s<i.length;s++)r>=this._array.length||this._getKey(e[n])<=this._getKey(this._array[r])?(i[s]=e[n],n++):i[s]=this._array[r++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let n=this._getKey(e);if(n===void 0||(rr=this._search(n),rr===-1)||this._getKey(this._array[rr])!==n)return!1;do if(this._array[rr]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(rr),!0;while(++rr<this._array.length&&this._getKey(this._array[rr])===n);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((s,o)=>s-o),n=0,r=new Array(this._array.length-e.length),i=0;for(let s=0;s<this._array.length;s++)e[n]===s?n++:r[i++]=this._array[s];this._array=r,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(rr=this._search(e),!(rr<0||rr>=this._array.length)&&this._getKey(this._array[rr])===e))do yield this._array[rr];while(++rr<this._array.length&&this._getKey(this._array[rr])===e)}forEachByKey(e,n){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(rr=this._search(e),!(rr<0||rr>=this._array.length)&&this._getKey(this._array[rr])===e))do n(this._array[rr]);while(++rr<this._array.length&&this._getKey(this._array[rr])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let n=0,r=this._array.length-1;for(;r>=n;){let i=n+r>>1,s=this._getKey(this._array[i]);if(s>e)r=i-1;else if(s<e)n=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return n}},tw=0,gO=0,b5e=class extends Xt{constructor(){super(),this._decorations=new _5e(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new nt),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new nt),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(qn(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let n=new x5e(e);if(n){let r=n.marker.onDispose(()=>n.dispose()),i=n.onDispose(()=>{i.dispose(),n&&(this._decorations.delete(n)&&this._onDecorationRemoved.fire(n),r.dispose())});this._decorations.insert(n),this._onDecorationRegistered.fire(n)}return n}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,n,r){let i=0,s=0;for(let o of this._decorations.getKeyIterator(n))i=o.options.x??0,s=i+(o.options.width??1),e>=i&&e<s&&(!r||(o.options.layer??"bottom")===r)&&(yield o)}forEachDecorationAtCell(e,n,r,i){this._decorations.forEachByKey(n,s=>{tw=s.options.x??0,gO=tw+(s.options.width??1),e>=tw&&e<gO&&(!r||(s.options.layer??"bottom")===r)&&i(s)})}},x5e=class extends oc{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new nt),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new nt),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Gn.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Gn.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},w5e=1e3,S5e=class{constructor(e,n=w5e){this._renderCallback=e,this._debounceThresholdMS=n,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,n,r){this._rowCount=r,e=e!==void 0?e:0,n=n!==void 0?n:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,n):n;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let s=i-this._lastRefreshMs,o=this._debounceThresholdMS-s;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),n=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,n)}},yO=20,cv=class extends Xt{constructor(e,n,r,i){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let s=this._coreBrowserService.mainDocument;this._accessibilityContainer=s.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=s.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=s.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new S5e(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(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
780
|
+
`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),g4&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let n=this._getMouseBufferCoords(e),r=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!r||!i||!n?!1:this._areCoordsInSelection(n,r,i)}isCellInSelection(e,n){let r=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!r||!i?!1:this._areCoordsInSelection([e,n],r,i)}_areCoordsInSelection(e,n,r){return e[1]>n[1]&&e[1]<r[1]||n[1]===r[1]&&e[1]===n[1]&&e[0]>=n[0]&&e[0]<r[0]||n[1]<r[1]&&e[1]===r[1]&&e[0]<r[0]||n[1]<r[1]&&e[1]===n[1]&&e[0]>=n[0]}_selectWordAtCursor(e,n){var s,o;let r=(o=(s=this._linkifier.currentLink)==null?void 0:s.link)==null?void 0:o.range;if(r)return this._model.selectionStart=[r.start.x-1,r.start.y-1],this._model.selectionStartLength=GE(r,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,n),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,n){this._model.clearSelection(),e=Math.max(e,0),n=Math.min(n,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,n],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let n=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(n)return n[0]--,n[1]--,n[1]+=this._bufferService.buffer.ydisp,n}_getMouseEventScrollAmount(e){let n=m4(this._coreBrowserService.window,e,this._screenElement)[1],r=this._renderService.dimensions.css.canvas.height;return n>=0&&n<=r?0:(n>r&&(n-=r),n=Math.min(Math.max(n,-Y2),Y2),n/=Y2,n/Math.abs(n)+Math.round(n*(R3e-1)))}shouldForceSelection(e){return av?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),D3e)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let n=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);n&&n.length!==this._model.selectionStart[0]&&n.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let n=this._getMouseBufferCoords(e);n&&(this._activeSelectionMode=2,this._selectLineAt(n[1]))}shouldColumnSelect(e){return e.altKey&&!(av&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let n=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let r=this._bufferService.buffer;if(this._model.selectionEnd[1]<r.lines.length){let i=r.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!n||n[0]!==this._model.selectionEnd[0]||n[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let n=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&n<z3e&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let r=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(r&&r[0]!==void 0&&r[1]!==void 0){let i=k3e(r[0]-1,r[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,n=this._model.finalSelectionEnd,r=!!e&&!!n&&(e[0]!==n[0]||e[1]!==n[1]);if(!r){this._oldHasSelection&&this._fireOnSelectionChange(e,n,r);return}!e||!n||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||n[0]!==this._oldSelectionEnd[0]||n[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,n,r)}_fireOnSelectionChange(e,n,r){this._oldSelectionStart=e,this._oldSelectionEnd=n,this._oldHasSelection=r,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(n=>this._handleTrim(n))}_convertViewportColToCharacterIndex(e,n){let r=n;for(let i=0;n>=i;i++){let s=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?r--:s>1&&n!==i&&(r+=s-1)}return r}setSelection(e,n,r){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,n],this._model.selectionStartLength=r,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,n,r=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let s=this._bufferService.buffer,o=s.lines.get(e[1]);if(!o)return;let a=s.translateBufferLineToString(e[1],!1),c=this._convertViewportColToCharacterIndex(o,e[0]),d=c,h=e[0]-c,g=0,p=0,_=0,b=0;if(a.charAt(c)===" "){for(;c>0&&a.charAt(c-1)===" ";)c--;for(;d<a.length&&a.charAt(d+1)===" ";)d++}else{let j=e[0],S=e[0];o.getWidth(j)===0&&(g++,j--),o.getWidth(S)===2&&(p++,S++);let E=o.getString(S).length;for(E>1&&(b+=E-1,d+=E-1);j>0&&c>0&&!this._isCharWordSeparator(o.loadCell(j-1,this._workCell));){o.loadCell(j-1,this._workCell);let O=this._workCell.getChars().length;this._workCell.getWidth()===0?(g++,j--):O>1&&(_+=O-1,c-=O-1),c--,j--}for(;S<o.length&&d+1<a.length&&!this._isCharWordSeparator(o.loadCell(S+1,this._workCell));){o.loadCell(S+1,this._workCell);let O=this._workCell.getChars().length;this._workCell.getWidth()===2?(p++,S++):O>1&&(b+=O-1,d+=O-1),d++,S++}}d++;let x=c+h-g+_,C=Math.min(this._bufferService.cols,d-c+g+p-_-b);if(!(!n&&a.slice(c,d).trim()==="")){if(r&&x===0&&o.getCodePoint(0)!==32){let j=s.lines.get(e[1]-1);if(j&&o.isWrapped&&j.getCodePoint(this._bufferService.cols-1)!==32){let S=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(S){let E=this._bufferService.cols-S.start;x-=E,C+=E}}}if(i&&x+C===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let j=s.lines.get(e[1]+1);if(j!=null&&j.isWrapped&&j.getCodePoint(0)!==32){let S=this._getWordAt([0,e[1]+1],!1,!1,!0);S&&(C+=S.length)}}return{start:x,length:C}}}_selectWordAt(e,n){let r=this._getWordAt(e,n);if(r){for(;r.start<0;)r.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[r.start,e[1]],this._model.selectionStartLength=r.length}}_selectToWordAt(e){let n=this._getWordAt(e,!0);if(n){let r=e[1];for(;n.start<0;)n.start+=this._bufferService.cols,r--;if(!this._model.areSelectionValuesReversed())for(;n.start+n.length>this._bufferService.cols;)n.length-=this._bufferService.cols,r++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?n.start:n.start+n.length,r]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let n=this._bufferService.buffer.getWrappedRangeForLine(e),r={start:{x:0,y:n.first},end:{x:this._bufferService.cols-1,y:n.last}};this._model.selectionStart=[0,n.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=GE(r,this._bufferService.cols)}};X3=Zn([ct(3,wi),ct(4,Mu),ct(5,l4),ct(6,Si),ct(7,rl),ct(8,nl)],X3);var YE=class{constructor(){this._data={}}set(e,n,r){this._data[e]||(this._data[e]={}),this._data[e][n]=r}get(e,n){return this._data[e]?this._data[e][n]:void 0}clear(){this._data={}}},XE=class{constructor(){this._color=new YE,this._css=new YE}setCss(e,n,r){this._css.set(e,n,r)}getCss(e,n){return this._css.get(e,n)}setColor(e,n,r){this._color.set(e,n,r)}getColor(e,n){return this._color.get(e,n)}clear(){this._color.clear(),this._css.clear()}},wr=Object.freeze((()=>{let e=[Gn.toColor("#2e3436"),Gn.toColor("#cc0000"),Gn.toColor("#4e9a06"),Gn.toColor("#c4a000"),Gn.toColor("#3465a4"),Gn.toColor("#75507b"),Gn.toColor("#06989a"),Gn.toColor("#d3d7cf"),Gn.toColor("#555753"),Gn.toColor("#ef2929"),Gn.toColor("#8ae234"),Gn.toColor("#fce94f"),Gn.toColor("#729fcf"),Gn.toColor("#ad7fa8"),Gn.toColor("#34e2e2"),Gn.toColor("#eeeeec")],n=[0,95,135,175,215,255];for(let r=0;r<216;r++){let i=n[r/36%6|0],s=n[r/6%6|0],o=n[r%6];e.push({css:gr.toCss(i,s,o),rgba:gr.toRgba(i,s,o)})}for(let r=0;r<24;r++){let i=8+r*10;e.push({css:gr.toCss(i,i,i),rgba:gr.toRgba(i,i,i)})}return e})()),Zc=Gn.toColor("#ffffff"),bp=Gn.toColor("#000000"),JE=Gn.toColor("#ffffff"),ZE=bp,np={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},I3e=Zc,J3=class extends Xt{constructor(e){super(),this._optionsService=e,this._contrastCache=new XE,this._halfContrastCache=new XE,this._onChangeColors=this._register(new nt),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:Zc,background:bp,cursor:JE,cursorAccent:ZE,selectionForeground:void 0,selectionBackgroundTransparent:np,selectionBackgroundOpaque:$n.blend(bp,np),selectionInactiveBackgroundTransparent:np,selectionInactiveBackgroundOpaque:$n.blend(bp,np),scrollbarSliderBackground:$n.opacity(Zc,.2),scrollbarSliderHoverBackground:$n.opacity(Zc,.4),scrollbarSliderActiveBackground:$n.opacity(Zc,.5),overviewRulerBorder:Zc,ansi:wr.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let n=this._colors;if(n.foreground=kn(e.foreground,Zc),n.background=kn(e.background,bp),n.cursor=$n.blend(n.background,kn(e.cursor,JE)),n.cursorAccent=$n.blend(n.background,kn(e.cursorAccent,ZE)),n.selectionBackgroundTransparent=kn(e.selectionBackground,np),n.selectionBackgroundOpaque=$n.blend(n.background,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundTransparent=kn(e.selectionInactiveBackground,n.selectionBackgroundTransparent),n.selectionInactiveBackgroundOpaque=$n.blend(n.background,n.selectionInactiveBackgroundTransparent),n.selectionForeground=e.selectionForeground?kn(e.selectionForeground,WE):void 0,n.selectionForeground===WE&&(n.selectionForeground=void 0),$n.isOpaque(n.selectionBackgroundTransparent)&&(n.selectionBackgroundTransparent=$n.opacity(n.selectionBackgroundTransparent,.3)),$n.isOpaque(n.selectionInactiveBackgroundTransparent)&&(n.selectionInactiveBackgroundTransparent=$n.opacity(n.selectionInactiveBackgroundTransparent,.3)),n.scrollbarSliderBackground=kn(e.scrollbarSliderBackground,$n.opacity(n.foreground,.2)),n.scrollbarSliderHoverBackground=kn(e.scrollbarSliderHoverBackground,$n.opacity(n.foreground,.4)),n.scrollbarSliderActiveBackground=kn(e.scrollbarSliderActiveBackground,$n.opacity(n.foreground,.5)),n.overviewRulerBorder=kn(e.overviewRulerBorder,I3e),n.ansi=wr.slice(),n.ansi[0]=kn(e.black,wr[0]),n.ansi[1]=kn(e.red,wr[1]),n.ansi[2]=kn(e.green,wr[2]),n.ansi[3]=kn(e.yellow,wr[3]),n.ansi[4]=kn(e.blue,wr[4]),n.ansi[5]=kn(e.magenta,wr[5]),n.ansi[6]=kn(e.cyan,wr[6]),n.ansi[7]=kn(e.white,wr[7]),n.ansi[8]=kn(e.brightBlack,wr[8]),n.ansi[9]=kn(e.brightRed,wr[9]),n.ansi[10]=kn(e.brightGreen,wr[10]),n.ansi[11]=kn(e.brightYellow,wr[11]),n.ansi[12]=kn(e.brightBlue,wr[12]),n.ansi[13]=kn(e.brightMagenta,wr[13]),n.ansi[14]=kn(e.brightCyan,wr[14]),n.ansi[15]=kn(e.brightWhite,wr[15]),e.extendedAnsi){let r=Math.min(n.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<r;i++)n.ansi[i+16]=kn(e.extendedAnsi[i],wr[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let n=0;n<this._restoreColors.ansi.length;++n)this._colors.ansi[n]=this._restoreColors.ansi[n];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};J3=Zn([ct(0,Si)],J3);function kn(e,n){if(e!==void 0)try{return Gn.toColor(e)}catch{}return n}var B3e=class{constructor(...e){this._entries=new Map;for(let[n,r]of e)this.set(n,r)}set(e,n){let r=this._entries.get(e);return this._entries.set(e,n),r}forEach(e){for(let[n,r]of this._entries.entries())e(n,r)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},F3e=class{constructor(){this._services=new B3e,this._services.set(a4,this)}setService(e,n){this._services.set(e,n)}getService(e){return this._services.get(e)}createInstance(e,...n){let r=R2e(e).sort((o,a)=>o.index-a.index),i=[];for(let o of r){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let s=r.length>0?r[0].index:n.length;if(n.length!==s)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${s+1} conflicts with ${n.length} static arguments`);return new e(...n,...i)}},H3e={trace:0,debug:1,info:2,warn:3,error:4,off:5},U3e="xterm.js: ",Z3=class extends Xt{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=H3e[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let n=0;n<e.length;n++)typeof e[n]=="function"&&(e[n]=e[n]())}_log(e,n,r){this._evalLazyOptionalParams(r),e.call(console,(this._optionsService.options.logger?"":U3e)+n,...r)}trace(e,...n){var r;this._logLevel<=0&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.trace.bind(this._optionsService.options.logger))??console.log,e,n)}debug(e,...n){var r;this._logLevel<=1&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.debug.bind(this._optionsService.options.logger))??console.log,e,n)}info(e,...n){var r;this._logLevel<=2&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.info.bind(this._optionsService.options.logger))??console.info,e,n)}warn(e,...n){var r;this._logLevel<=3&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.warn.bind(this._optionsService.options.logger))??console.warn,e,n)}error(e,...n){var r;this._logLevel<=4&&this._log(((r=this._optionsService.options.logger)==null?void 0:r.error.bind(this._optionsService.options.logger))??console.error,e,n)}};Z3=Zn([ct(0,Si)],Z3);var QE=class extends Xt{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new nt),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new nt),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new nt),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let n=new Array(e);for(let r=0;r<Math.min(e,this.length);r++)n[r]=this._array[this._getCyclicIndex(r)];this._array=n,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let n=this._length;n<e;n++)this._array[n]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,n){this._array[this._getCyclicIndex(e)]=n}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,n,...r){if(n){for(let i=e;i<this._length-n;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+n)];this._length-=n,this.onDeleteEmitter.fire({index:e,amount:n})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+r.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<r.length;i++)this._array[this._getCyclicIndex(e+i)]=r[i];if(r.length&&this.onInsertEmitter.fire({index:e,amount:r.length}),this._length+r.length>this._maxLength){let i=this._length+r.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=r.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,n,r){if(!(n<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+r<0)throw new Error("Cannot shift elements in list beyond index 0");if(r>0){for(let s=n-1;s>=0;s--)this.set(e+s+r,this.get(e+s));let i=e+n+r-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<n;i++)this.set(e+i+r,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},Yt=3,mr=Object.freeze(new Ug),W1=0,X2=2,xp=class EL{constructor(n,r,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(n*Yt);let s=r||Bs.fromCharData([0,qz,1,0]);for(let o=0;o<n;++o)this.setCell(o,s);this.length=n}get(n){let r=this._data[n*Yt+0],i=r&2097151;return[this._data[n*Yt+1],r&2097152?this._combined[n]:i?Jl(i):"",r>>22,r&2097152?this._combined[n].charCodeAt(this._combined[n].length-1):i]}set(n,r){this._data[n*Yt+1]=r[0],r[1].length>1?(this._combined[n]=r[1],this._data[n*Yt+0]=n|2097152|r[2]<<22):this._data[n*Yt+0]=r[1].charCodeAt(0)|r[2]<<22}getWidth(n){return this._data[n*Yt+0]>>22}hasWidth(n){return this._data[n*Yt+0]&12582912}getFg(n){return this._data[n*Yt+1]}getBg(n){return this._data[n*Yt+2]}hasContent(n){return this._data[n*Yt+0]&4194303}getCodePoint(n){let r=this._data[n*Yt+0];return r&2097152?this._combined[n].charCodeAt(this._combined[n].length-1):r&2097151}isCombined(n){return this._data[n*Yt+0]&2097152}getString(n){let r=this._data[n*Yt+0];return r&2097152?this._combined[n]:r&2097151?Jl(r&2097151):""}isProtected(n){return this._data[n*Yt+2]&536870912}loadCell(n,r){return W1=n*Yt,r.content=this._data[W1+0],r.fg=this._data[W1+1],r.bg=this._data[W1+2],r.content&2097152&&(r.combinedData=this._combined[n]),r.bg&268435456&&(r.extended=this._extendedAttrs[n]),r}setCell(n,r){r.content&2097152&&(this._combined[n]=r.combinedData),r.bg&268435456&&(this._extendedAttrs[n]=r.extended),this._data[n*Yt+0]=r.content,this._data[n*Yt+1]=r.fg,this._data[n*Yt+2]=r.bg}setCellFromCodepoint(n,r,i,s){s.bg&268435456&&(this._extendedAttrs[n]=s.extended),this._data[n*Yt+0]=r|i<<22,this._data[n*Yt+1]=s.fg,this._data[n*Yt+2]=s.bg}addCodepointToCell(n,r,i){let s=this._data[n*Yt+0];s&2097152?this._combined[n]+=Jl(r):s&2097151?(this._combined[n]=Jl(s&2097151)+Jl(r),s&=-2097152,s|=2097152):s=r|1<<22,i&&(s&=-12582913,s|=i<<22),this._data[n*Yt+0]=s}insertCells(n,r,i){if(n%=this.length,n&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n-1,0,1,i),r<this.length-n){let s=new Bs;for(let o=this.length-n-r-1;o>=0;--o)this.setCell(n+r+o,this.loadCell(n+o,s));for(let o=0;o<r;++o)this.setCell(n+o,i)}else for(let s=n;s<this.length;++s)this.setCell(s,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(n,r,i){if(n%=this.length,r<this.length-n){let s=new Bs;for(let o=0;o<this.length-n-r;++o)this.setCell(n+o,this.loadCell(n+r+o,s));for(let o=this.length-r;o<this.length;++o)this.setCell(o,i)}else for(let s=n;s<this.length;++s)this.setCell(s,i);n&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n-1,0,1,i),this.getWidth(n)===0&&!this.hasContent(n)&&this.setCellFromCodepoint(n,0,1,i)}replaceCells(n,r,i,s=!1){if(s){for(n&&this.getWidth(n-1)===2&&!this.isProtected(n-1)&&this.setCellFromCodepoint(n-1,0,1,i),r<this.length&&this.getWidth(r-1)===2&&!this.isProtected(r)&&this.setCellFromCodepoint(r,0,1,i);n<r&&n<this.length;)this.isProtected(n)||this.setCell(n,i),n++;return}for(n&&this.getWidth(n-1)===2&&this.setCellFromCodepoint(n-1,0,1,i),r<this.length&&this.getWidth(r-1)===2&&this.setCellFromCodepoint(r,0,1,i);n<r&&n<this.length;)this.setCell(n++,i)}resize(n,r){if(n===this.length)return this._data.length*4*X2<this._data.buffer.byteLength;let i=n*Yt;if(n>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let s=new Uint32Array(i);s.set(this._data),this._data=s}for(let s=this.length;s<n;++s)this.setCell(s,r)}else{this._data=this._data.subarray(0,i);let s=Object.keys(this._combined);for(let a=0;a<s.length;a++){let c=parseInt(s[a],10);c>=n&&delete this._combined[c]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let c=parseInt(o[a],10);c>=n&&delete this._extendedAttrs[c]}}return this.length=n,i*4*X2<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*X2<this._data.buffer.byteLength){let n=new Uint32Array(this._data.length);return n.set(this._data),this._data=n,1}return 0}fill(n,r=!1){if(r){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,n);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,n)}copyFrom(n){this.length!==n.length?this._data=new Uint32Array(n._data):this._data.set(n._data),this.length=n.length,this._combined={};for(let r in n._combined)this._combined[r]=n._combined[r];this._extendedAttrs={};for(let r in n._extendedAttrs)this._extendedAttrs[r]=n._extendedAttrs[r];this.isWrapped=n.isWrapped}clone(){let n=new EL(0);n._data=new Uint32Array(this._data),n.length=this.length;for(let r in this._combined)n._combined[r]=this._combined[r];for(let r in this._extendedAttrs)n._extendedAttrs[r]=this._extendedAttrs[r];return n.isWrapped=this.isWrapped,n}getTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(this._data[n*Yt+0]&4194303)return n+(this._data[n*Yt+0]>>22);return 0}getNoBgTrimmedLength(){for(let n=this.length-1;n>=0;--n)if(this._data[n*Yt+0]&4194303||this._data[n*Yt+2]&50331648)return n+(this._data[n*Yt+0]>>22);return 0}copyCellsFrom(n,r,i,s,o){let a=n._data;if(o)for(let d=s-1;d>=0;d--){for(let h=0;h<Yt;h++)this._data[(i+d)*Yt+h]=a[(r+d)*Yt+h];a[(r+d)*Yt+2]&268435456&&(this._extendedAttrs[i+d]=n._extendedAttrs[r+d])}else for(let d=0;d<s;d++){for(let h=0;h<Yt;h++)this._data[(i+d)*Yt+h]=a[(r+d)*Yt+h];a[(r+d)*Yt+2]&268435456&&(this._extendedAttrs[i+d]=n._extendedAttrs[r+d])}let c=Object.keys(n._combined);for(let d=0;d<c.length;d++){let h=parseInt(c[d],10);h>=r&&(this._combined[h-r+i]=n._combined[h])}}translateToString(n,r,i,s){r=r??0,i=i??this.length,n&&(i=Math.min(i,this.getTrimmedLength())),s&&(s.length=0);let o="";for(;r<i;){let a=this._data[r*Yt+0],c=a&2097151,d=a&2097152?this._combined[r]:c?Jl(c):nc;if(o+=d,s)for(let h=0;h<d.length;++h)s.push(r);r+=a>>22||1}return s&&s.push(r),o}};function V3e(e,n,r,i,s,o){let a=[];for(let c=0;c<e.length-1;c++){let d=c,h=e.get(++d);if(!h.isWrapped)continue;let g=[e.get(c)];for(;d<e.length&&h.isWrapped;)g.push(h),h=e.get(++d);if(!o&&i>=c&&i<d){c+=g.length-1;continue}let p=0,_=mg(g,p,n),b=1,x=0;for(;b<g.length;){let j=mg(g,b,n),S=j-x,E=r-_,O=Math.min(S,E);g[p].copyCellsFrom(g[b],x,_,O,!1),_+=O,_===r&&(p++,_=0),x+=O,x===j&&(b++,x=0),_===0&&p!==0&&g[p-1].getWidth(r-1)===2&&(g[p].copyCellsFrom(g[p-1],r-1,_++,1,!1),g[p-1].setCell(r-1,s))}g[p].replaceCells(_,r,s);let C=0;for(let j=g.length-1;j>0&&(j>p||g[j].getTrimmedLength()===0);j--)C++;C>0&&(a.push(c+g.length-C),a.push(C)),c+=g.length-1}return a}function W3e(e,n){let r=[],i=0,s=n[i],o=0;for(let a=0;a<e.length;a++)if(s===a){let c=n[++i];e.onDeleteEmitter.fire({index:a-o,amount:c}),a+=c-1,o+=c,s=n[++i]}else r.push(a);return{layout:r,countRemoved:o}}function q3e(e,n){let r=[];for(let i=0;i<n.length;i++)r.push(e.get(n[i]));for(let i=0;i<r.length;i++)e.set(i,r[i]);e.length=n.length}function K3e(e,n,r){let i=[],s=e.map((d,h)=>mg(e,h,n)).reduce((d,h)=>d+h),o=0,a=0,c=0;for(;c<s;){if(s-c<r){i.push(s-c);break}o+=r;let d=mg(e,a,n);o>d&&(o-=d,a++);let h=e[a].getWidth(o-1)===2;h&&o--;let g=h?r-1:r;i.push(g),c+=g}return i}function mg(e,n,r){if(n===e.length-1)return e[n].getTrimmedLength();let i=!e[n].hasContent(r-1)&&e[n].getWidth(r-1)===1,s=e[n+1].getWidth(0)===2;return i&&s?r-1:r}var OL=class NL{constructor(n){this.line=n,this.isDisposed=!1,this._disposables=[],this._id=NL._nextId++,this._onDispose=this.register(new nt),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),xu(this._disposables),this._disposables.length=0)}register(n){return this._disposables.push(n),n}};OL._nextId=1;var G3e=OL,Cr={},Qc=Cr.B;Cr[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Cr.A={"#":"£"};Cr.B=void 0;Cr[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Cr.C=Cr[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Cr.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Cr.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Cr.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Cr.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Cr.E=Cr[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Cr.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Cr.H=Cr[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Cr["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var eO=4294967295,tO=class{constructor(e,n,r){this._hasScrollback=e,this._optionsService=n,this._bufferService=r,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=mr.clone(),this.savedCharset=Qc,this.markers=[],this._nullCell=Bs.fromCharData([0,qz,1,0]),this._whitespaceCell=Bs.fromCharData([0,nc,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new lv,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new QE(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new iv),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new iv),this._whitespaceCell}getBlankLine(e,n){return new xp(this._bufferService.cols,this.getNullCell(e),n)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let n=e+this._optionsService.rawOptions.scrollback;return n>eO?eO:n}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=mr);let n=this._rows;for(;n--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new QE(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,n){let r=this.getNullCell(mr),i=0,s=this._getCorrectBufferLength(n);if(s>this.lines.maxLength&&(this.lines.maxLength=s),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(e,r);let o=0;if(this._rows<n)for(let a=this._rows;a<n;a++)this.lines.length<n+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new xp(e,r)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new xp(e,r)));else for(let a=this._rows;a>n;a--)this.lines.length>n+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(s<this.lines.maxLength){let a=this.lines.length-s;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=s}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,n-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=n-1,this._isReflowEnabled&&(this._reflow(e,n),this._cols>e))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,r);this._cols=e,this._rows=n,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let n=0;for(;this._memoryCleanupPosition<this.lines.length;)if(n+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),n>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,n){this._cols!==e&&(e>this._cols?this._reflowLarger(e,n):this._reflowSmaller(e,n))}_reflowLarger(e,n){let r=this._optionsService.rawOptions.reflowCursorLine,i=V3e(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(mr),r);if(i.length>0){let s=W3e(this.lines,i);q3e(this.lines,s.layout),this._reflowLargerAdjustViewport(e,n,s.countRemoved)}}_reflowLargerAdjustViewport(e,n,r){let i=this.getNullCell(mr),s=r;for(;s-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<n&&this.lines.push(new xp(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-r,0)}_reflowSmaller(e,n){let r=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(mr),s=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let c=this.lines.get(a);if(!c||!c.isWrapped&&c.getTrimmedLength()<=e)continue;let d=[c];for(;c.isWrapped&&a>0;)c=this.lines.get(--a),d.unshift(c);if(!r){let O=this.ybase+this.y;if(O>=a&&O<a+d.length)continue}let h=d[d.length-1].getTrimmedLength(),g=K3e(d,this._cols,e),p=g.length-d.length,_;this.ybase===0&&this.y!==this.lines.length-1?_=Math.max(0,this.y-this.lines.maxLength+p):_=Math.max(0,this.lines.length-this.lines.maxLength+p);let b=[];for(let O=0;O<p;O++){let N=this.getBlankLine(mr,!0);b.push(N)}b.length>0&&(s.push({start:a+d.length+o,newLines:b}),o+=b.length),d.push(...b);let x=g.length-1,C=g[x];C===0&&(x--,C=g[x]);let j=d.length-p-1,S=h;for(;j>=0;){let O=Math.min(S,C);if(d[x]===void 0)break;if(d[x].copyCellsFrom(d[j],S-O,C-O,O,!0),C-=O,C===0&&(x--,C=g[x]),S-=O,S===0){j--;let N=Math.max(j,0);S=mg(d,N,this._cols)}}for(let O=0;O<d.length;O++)g[O]<e&&d[O].setCell(g[O],i);let E=p-_;for(;E-- >0;)this.ybase===0?this.y<n-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-n&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+p,this.ybase+n-1)}if(s.length>0){let a=[],c=[];for(let C=0;C<this.lines.length;C++)c.push(this.lines.get(C));let d=this.lines.length,h=d-1,g=0,p=s[g];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let _=0;for(let C=Math.min(this.lines.maxLength-1,d+o-1);C>=0;C--)if(p&&p.start>h+_){for(let j=p.newLines.length-1;j>=0;j--)this.lines.set(C--,p.newLines[j]);C++,a.push({index:h+1,amount:p.newLines.length}),_+=p.newLines.length,p=s[++g]}else this.lines.set(C,c[h--]);let b=0;for(let C=a.length-1;C>=0;C--)a[C].index+=b,this.lines.onInsertEmitter.fire(a[C]),b+=a[C].amount;let x=Math.max(0,d+o-this.lines.maxLength);x>0&&this.lines.onTrimEmitter.fire(x)}}translateBufferLineToString(e,n,r=0,i){let s=this.lines.get(e);return s?s.translateToString(n,r,i):""}getWrappedRangeForLine(e){let n=e,r=e;for(;n>0&&this.lines.get(n).isWrapped;)n--;for(;r+1<this.lines.length&&this.lines.get(r+1).isWrapped;)r++;return{first:n,last:r}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let n=0;n<this.markers.length;n++)this.markers[n].line===e&&(this.markers[n].dispose(),this.markers.splice(n--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let n=new G3e(e);return this.markers.push(n),n.register(this.lines.onTrim(r=>{n.line-=r,n.line<0&&n.dispose()})),n.register(this.lines.onInsert(r=>{n.line>=r.index&&(n.line+=r.amount)})),n.register(this.lines.onDelete(r=>{n.line>=r.index&&n.line<r.index+r.amount&&n.dispose(),n.line>r.index&&(n.line-=r.amount)})),n.register(n.onDispose(()=>this._removeMarker(n))),n}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Y3e=class extends Xt{constructor(e,n){super(),this._optionsService=e,this._bufferService=n,this._onBufferActivate=this._register(new nt),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new tO(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new tO(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,n){this._normal.resize(e,n),this._alt.resize(e,n),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},TL=2,PL=1,Q3=class extends Xt{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new nt),this.onResize=this._onResize.event,this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,TL),this.rows=Math.max(e.rawOptions.rows||0,PL),this.buffers=this._register(new Y3e(e,this)),this._register(this.buffers.onBufferActivate(n=>{this._onScroll.fire(n.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,n){let r=this.cols!==e,i=this.rows!==n;this.cols=e,this.rows=n,this.buffers.resize(e,n),this._onResize.fire({cols:e,rows:n,colsChanged:r,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,n=!1){let r=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=r.getBlankLine(e,n),this._cachedBlankLine=i),i.isWrapped=n;let s=r.ybase+r.scrollTop,o=r.ybase+r.scrollBottom;if(r.scrollTop===0){let a=r.lines.isFull;o===r.lines.length-1?a?r.lines.recycle().copyFrom(i):r.lines.push(i.clone()):r.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(r.ydisp=Math.max(r.ydisp-1,0)):(r.ybase++,this.isUserScrolling||r.ydisp++)}else{let a=o-s+1;r.lines.shiftElements(s+1,a-1,-1),r.lines.set(o,i.clone())}this.isUserScrolling||(r.ydisp=r.ybase),this._onScroll.fire(r.ydisp)}scrollLines(e,n){let r=this.buffer;if(e<0){if(r.ydisp===0)return;this.isUserScrolling=!0}else e+r.ydisp>=r.ybase&&(this.isUserScrolling=!1);let i=r.ydisp;r.ydisp=Math.max(Math.min(r.ydisp+e,r.ybase),0),i!==r.ydisp&&(n||this._onScroll.fire(r.ydisp))}};Q3=Zn([ct(0,Si)],Q3);var $f={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:av,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},X3e=["normal","bold","100","200","300","400","500","600","700","800","900"],J3e=class extends Xt{constructor(e){super(),this._onOptionChange=this._register(new nt),this.onOptionChange=this._onOptionChange.event;let n={...$f};for(let r in e)if(r in n)try{let i=e[r];n[r]=this._sanitizeAndValidateOption(r,i)}catch(i){console.error(i)}this.rawOptions=n,this.options={...n},this._setupOptions(),this._register(qn(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,n){return this.onOptionChange(r=>{r===e&&n(this.rawOptions[e])})}onMultipleOptionChange(e,n){return this.onOptionChange(r=>{e.indexOf(r)!==-1&&n()})}_setupOptions(){let e=r=>{if(!(r in $f))throw new Error(`No option with key "${r}"`);return this.rawOptions[r]},n=(r,i)=>{if(!(r in $f))throw new Error(`No option with key "${r}"`);i=this._sanitizeAndValidateOption(r,i),this.rawOptions[r]!==i&&(this.rawOptions[r]=i,this._onOptionChange.fire(r))};for(let r in this.rawOptions){let i={get:e.bind(this,r),set:n.bind(this,r)};Object.defineProperty(this.options,r,i)}}_sanitizeAndValidateOption(e,n){switch(e){case"cursorStyle":if(n||(n=$f[e]),!Z3e(n))throw new Error(`"${n}" is not a valid value for ${e}`);break;case"wordSeparator":n||(n=$f[e]);break;case"fontWeight":case"fontWeightBold":if(typeof n=="number"&&1<=n&&n<=1e3)break;n=X3e.includes(n)?n:$f[e];break;case"cursorWidth":n=Math.floor(n);case"lineHeight":case"tabStopWidth":if(n<1)throw new Error(`${e} cannot be less than 1, value: ${n}`);break;case"minimumContrastRatio":n=Math.max(1,Math.min(21,Math.round(n*10)/10));break;case"scrollback":if(n=Math.min(n,4294967295),n<0)throw new Error(`${e} cannot be less than 0, value: ${n}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(n<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${n}`);break;case"rows":case"cols":if(!n&&n!==0)throw new Error(`${e} must be numeric, value: ${n}`);break;case"windowsPty":n=n??{};break}return n}};function Z3e(e){return e==="block"||e==="underline"||e==="bar"}function wp(e,n=5){if(typeof e!="object")return e;let r=Array.isArray(e)?[]:{};for(let i in e)r[i]=n<=1?e[i]:e[i]&&wp(e[i],n-1);return r}var nO=Object.freeze({insertMode:!1}),rO=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),e5=class extends Xt{constructor(e,n,r){super(),this._bufferService=e,this._logService=n,this._optionsService=r,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new nt),this.onData=this._onData.event,this._onUserInput=this._register(new nt),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new nt),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new nt),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=wp(nO),this.decPrivateModes=wp(rO)}reset(){this.modes=wp(nO),this.decPrivateModes=wp(rO)}triggerDataEvent(e,n=!1){if(this._optionsService.rawOptions.disableStdin)return;let r=this._bufferService.buffer;n&&this._optionsService.rawOptions.scrollOnUserInput&&r.ybase!==r.ydisp&&this._onRequestScrollToBottom.fire(),n&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(n=>n.charCodeAt(0))),this._onBinary.fire(e))}};e5=Zn([ct(0,wi),ct(1,Jz),ct(2,Si)],e5);var iO={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function J2(e,n){let r=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(r|=64,r|=e.action):(r|=e.button&3,e.button&4&&(r|=64),e.button&8&&(r|=128),e.action===32?r|=32:e.action===0&&!n&&(r|=3)),r}var Z2=String.fromCharCode,sO={DEFAULT:e=>{let n=[J2(e,!1)+32,e.col+32,e.row+32];return n[0]>255||n[1]>255||n[2]>255?"":`\x1B[M${Z2(n[0])}${Z2(n[1])}${Z2(n[2])}`},SGR:e=>{let n=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${J2(e,!0)};${e.col};${e.row}${n}`},SGR_PIXELS:e=>{let n=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${J2(e,!0)};${e.x};${e.y}${n}`}},t5=class extends Xt{constructor(e,n,r){super(),this._bufferService=e,this._coreService=n,this._optionsService=r,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new nt),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(iO))this.addProtocol(i,iO[i]);for(let i of Object.keys(sO))this.addEncoding(i,sO[i]);this.reset()}addProtocol(e,n){this._protocols[e]=n}addEncoding(e,n){this._encodings[e]=n}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,n,r){if(e.deltaY===0||e.shiftKey||n===void 0||r===void 0)return 0;let i=n/r,s=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(s/=i+0,Math.abs(e.deltaY)<50&&(s*=.3),this._wheelPartialScroll+=s,s=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(s*=this._bufferService.rows),s}_applyScrollModifier(e,n){return n.altKey||n.ctrlKey||n.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let n=this._encodings[this._activeEncoding](e);return n&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(n):this._coreService.triggerDataEvent(n,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,n,r){if(r){if(e.x!==n.x||e.y!==n.y)return!1}else if(e.col!==n.col||e.row!==n.row)return!1;return!(e.button!==n.button||e.action!==n.action||e.ctrl!==n.ctrl||e.alt!==n.alt||e.shift!==n.shift)}};t5=Zn([ct(0,wi),ct(1,Mu),ct(2,Si)],t5);var Q2=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Q3e=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Sr;function e5e(e,n){let r=0,i=n.length-1,s;if(e<n[0][0]||e>n[i][1])return!1;for(;i>=r;)if(s=r+i>>1,e>n[s][1])r=s+1;else if(e<n[s][0])i=s-1;else return!0;return!1}var t5e=class{constructor(){if(this.version="6",!Sr){Sr=new Uint8Array(65536),Sr.fill(1),Sr[0]=0,Sr.fill(0,1,32),Sr.fill(0,127,160),Sr.fill(2,4352,4448),Sr[9001]=2,Sr[9002]=2,Sr.fill(2,11904,42192),Sr[12351]=1,Sr.fill(2,44032,55204),Sr.fill(2,63744,64256),Sr.fill(2,65040,65050),Sr.fill(2,65072,65136),Sr.fill(2,65280,65377),Sr.fill(2,65504,65511);for(let e=0;e<Q2.length;++e)Sr.fill(0,Q2[e][0],Q2[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Sr[e]:e5e(e,Q3e)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,n){let r=this.wcwidth(e),i=r===0&&n!==0;if(i){let s=iu.extractWidth(n);s===0?i=!1:s>r&&(r=s)}return iu.createPropertyValue(0,r,i)}},iu=class gy{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new nt,this.onChange=this._onChange.event;let n=new t5e;this.register(n),this._active=n.version,this._activeProvider=n}static extractShouldJoin(n){return(n&1)!==0}static extractWidth(n){return n>>1&3}static extractCharKind(n){return n>>3}static createPropertyValue(n,r,i=!1){return(n&16777215)<<3|(r&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(n){if(!this._providers[n])throw new Error(`unknown Unicode version "${n}"`);this._active=n,this._activeProvider=this._providers[n],this._onChange.fire(n)}register(n){this._providers[n.version]=n}wcwidth(n){return this._activeProvider.wcwidth(n)}getStringCellWidth(n){let r=0,i=0,s=n.length;for(let o=0;o<s;++o){let a=n.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return r+this.wcwidth(a);let h=n.charCodeAt(o);56320<=h&&h<=57343?a=(a-55296)*1024+h-56320+65536:r+=this.wcwidth(h)}let c=this.charProperties(a,i),d=gy.extractWidth(c);gy.extractShouldJoin(c)&&(d-=gy.extractWidth(i)),r+=d,i=c}return r}charProperties(n,r){return this._activeProvider.charProperties(n,r)}},n5e=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,n){this._charsets[e]=n,this.glevel===e&&(this.charset=n)}};function oO(e){var i;let n=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),r=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);r&&n&&(r.isWrapped=n[3]!==0&&n[3]!==32)}var rp=2147483647,r5e=256,AL=class n5{constructor(n=32,r=32){if(this.maxLength=n,this.maxSubParamsLength=r,r>r5e)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(n),this.length=0,this._subParams=new Int32Array(r),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(n),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(n){let r=new n5;if(!n.length)return r;for(let i=Array.isArray(n[0])?1:0;i<n.length;++i){let s=n[i];if(Array.isArray(s))for(let o=0;o<s.length;++o)r.addSubParam(s[o]);else r.addParam(s)}return r}clone(){let n=new n5(this.maxLength,this.maxSubParamsLength);return n.params.set(this.params),n.length=this.length,n._subParams.set(this._subParams),n._subParamsLength=this._subParamsLength,n._subParamsIdx.set(this._subParamsIdx),n._rejectDigits=this._rejectDigits,n._rejectSubDigits=this._rejectSubDigits,n._digitIsSub=this._digitIsSub,n}toArray(){let n=[];for(let r=0;r<this.length;++r){n.push(this.params[r]);let i=this._subParamsIdx[r]>>8,s=this._subParamsIdx[r]&255;s-i>0&&n.push(Array.prototype.slice.call(this._subParams,i,s))}return n}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(n){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(n<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=n>rp?rp:n}addSubParam(n){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(n<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=n>rp?rp:n,this._subParamsIdx[this.length-1]++}}hasSubParams(n){return(this._subParamsIdx[n]&255)-(this._subParamsIdx[n]>>8)>0}getSubParams(n){let r=this._subParamsIdx[n]>>8,i=this._subParamsIdx[n]&255;return i-r>0?this._subParams.subarray(r,i):null}getSubParamsAll(){let n={};for(let r=0;r<this.length;++r){let i=this._subParamsIdx[r]>>8,s=this._subParamsIdx[r]&255;s-i>0&&(n[r]=this._subParams.slice(i,s))}return n}addDigit(n){let r;if(this._rejectDigits||!(r=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,s=i[r-1];i[r-1]=~s?Math.min(s*10+n,rp):n}},ip=[],i5e=class{constructor(){this._state=0,this._active=ip,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,n){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(n),{dispose:()=>{let i=r.indexOf(n);i!==-1&&r.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ip}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ip,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ip,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,n,r){if(!this._active.length)this._handlerFb(this._id,"PUT",r_(e,n,r));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,n,r)}start(){this.reset(),this._state=1}put(e,n,r){if(this._state!==3){if(this._state===1)for(;n<r;){let i=e[n++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&r-n>0&&this._put(e,n,r)}}end(e,n=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let r=!1,i=this._active.length-1,s=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,r=n,s=this._stack.fallThrough,this._stack.paused=!1),!s&&r===!1){for(;i>=0&&(r=this._active[i].end(e),r!==!0);i--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,r;i--}for(;i>=0;i--)if(r=this._active[i].end(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,r}this._active=ip,this._id=-1,this._state=0}}},ls=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,n,r){this._hitLimit||(this._data+=r_(e,n,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let n=!1;if(this._hitLimit)n=!1;else if(e&&(n=this._handler(this._data),n instanceof Promise))return n.then(r=>(this._data="",this._hitLimit=!1,r));return this._data="",this._hitLimit=!1,n}},sp=[],s5e=class{constructor(){this._handlers=Object.create(null),this._active=sp,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=sp}registerHandler(e,n){this._handlers[e]===void 0&&(this._handlers[e]=[]);let r=this._handlers[e];return r.push(n),{dispose:()=>{let i=r.indexOf(n);i!==-1&&r.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=sp,this._ident=0}hook(e,n){if(this.reset(),this._ident=e,this._active=this._handlers[e]||sp,!this._active.length)this._handlerFb(this._ident,"HOOK",n);else for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(n)}put(e,n,r){if(!this._active.length)this._handlerFb(this._ident,"PUT",r_(e,n,r));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,n,r)}unhook(e,n=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let r=!1,i=this._active.length-1,s=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,r=n,s=this._stack.fallThrough,this._stack.paused=!1),!s&&r===!1){for(;i>=0&&(r=this._active[i].unhook(e),r!==!0);i--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,r;i--}for(;i>=0;i--)if(r=this._active[i].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,r}this._active=sp,this._ident=0}},Sp=new AL;Sp.addParam(0);var aO=class{constructor(e){this._handler=e,this._data="",this._params=Sp,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():Sp,this._data="",this._hitLimit=!1}put(e,n,r){this._hitLimit||(this._data+=r_(e,n,r),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let n=!1;if(this._hitLimit)n=!1;else if(e&&(n=this._handler(this._data,this._params),n instanceof Promise))return n.then(r=>(this._params=Sp,this._data="",this._hitLimit=!1,r));return this._params=Sp,this._data="",this._hitLimit=!1,n}},o5e=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,n){this.table.fill(e<<4|n)}add(e,n,r,i){this.table[n<<8|e]=r<<4|i}addMany(e,n,r,i){for(let s=0;s<e.length;s++)this.table[n<<8|e[s]]=r<<4|i}},Rs=160,a5e=(function(){let e=new o5e(4095),n=Array.apply(null,Array(256)).map((c,d)=>d),r=(c,d)=>n.slice(c,d),i=r(32,127),s=r(0,24);s.push(25),s.push.apply(s,r(28,32));let o=r(0,14),a;e.setDefault(1,0),e.addMany(i,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(r(128,144),a,3,0),e.addMany(r(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(s,0,3,0),e.addMany(s,1,3,1),e.add(127,1,0,1),e.addMany(s,8,0,8),e.addMany(s,3,3,3),e.add(127,3,0,3),e.addMany(s,4,3,4),e.add(127,4,0,4),e.addMany(s,6,3,6),e.addMany(s,5,3,5),e.add(127,5,0,5),e.addMany(s,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(r(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(s,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(r(64,127),3,7,0),e.addMany(r(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(r(48,60),4,8,4),e.addMany(r(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(r(32,64),6,0,6),e.add(127,6,0,6),e.addMany(r(64,127),6,0,0),e.addMany(r(32,48),3,9,5),e.addMany(r(32,48),5,9,5),e.addMany(r(48,64),5,0,6),e.addMany(r(64,127),5,7,0),e.addMany(r(32,48),4,9,5),e.addMany(r(32,48),1,9,2),e.addMany(r(32,48),2,9,2),e.addMany(r(48,127),2,10,0),e.addMany(r(48,80),1,10,0),e.addMany(r(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(r(96,127),1,10,0),e.add(80,1,11,9),e.addMany(s,9,0,9),e.add(127,9,0,9),e.addMany(r(28,32),9,0,9),e.addMany(r(32,48),9,9,12),e.addMany(r(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(s,11,0,11),e.addMany(r(32,128),11,0,11),e.addMany(r(28,32),11,0,11),e.addMany(s,10,0,10),e.add(127,10,0,10),e.addMany(r(28,32),10,0,10),e.addMany(r(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(r(32,48),10,9,12),e.addMany(s,12,0,12),e.add(127,12,0,12),e.addMany(r(28,32),12,0,12),e.addMany(r(32,48),12,9,12),e.addMany(r(48,64),12,0,11),e.addMany(r(64,127),12,12,13),e.addMany(r(64,127),10,12,13),e.addMany(r(64,127),9,12,13),e.addMany(s,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(Rs,0,2,0),e.add(Rs,8,5,8),e.add(Rs,6,0,6),e.add(Rs,11,0,11),e.add(Rs,13,13,13),e})(),l5e=class extends Xt{constructor(e=a5e){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new AL,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(n,r,i)=>{},this._executeHandlerFb=n=>{},this._csiHandlerFb=(n,r)=>{},this._escHandlerFb=n=>{},this._errorHandlerFb=n=>n,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(qn(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new i5e),this._dcsParser=this._register(new s5e),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,n=[64,126]){let r=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(r=e.prefix.charCodeAt(0),r&&60>r||r>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let s=0;s<e.intermediates.length;++s){let o=e.intermediates.charCodeAt(s);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");r<<=8,r|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(n[0]>i||i>n[1])throw new Error(`final must be in range ${n[0]} .. ${n[1]}`);return r<<=8,r|=i,r}identToString(e){let n=[];for(;e;)n.push(String.fromCharCode(e&255)),e>>=8;return n.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,n){let r=this._identifier(e,[48,126]);this._escHandlers[r]===void 0&&(this._escHandlers[r]=[]);let i=this._escHandlers[r];return i.push(n),{dispose:()=>{let s=i.indexOf(n);s!==-1&&i.splice(s,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,n){this._executeHandlers[e.charCodeAt(0)]=n}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,n){let r=this._identifier(e);this._csiHandlers[r]===void 0&&(this._csiHandlers[r]=[]);let i=this._csiHandlers[r];return i.push(n),{dispose:()=>{let s=i.indexOf(n);s!==-1&&i.splice(s,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,n){return this._dcsParser.registerHandler(this._identifier(e),n)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,n){return this._oscParser.registerHandler(e,n)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,n,r,i,s){this._parseStack.state=e,this._parseStack.handlers=n,this._parseStack.handlerPos=r,this._parseStack.transition=i,this._parseStack.chunkPos=s}parse(e,n,r){let i=0,s=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(r===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let c=this._parseStack.handlers,d=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(r===!1&&d>-1){for(;d>=0&&(a=c[d](this._params),a!==!0);d--)if(a instanceof Promise)return this._parseStack.handlerPos=d,a}this._parseStack.handlers=[];break;case 4:if(r===!1&&d>-1){for(;d>=0&&(a=c[d](),a!==!0);d--)if(a instanceof Promise)return this._parseStack.handlerPos=d,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,r),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,r),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let c=o;c<n;++c){switch(i=e[c],s=this._transitions.table[this.currentState<<8|(i<160?i:Rs)],s>>4){case 2:for(let _=c+1;;++_){if(_>=n||(i=e[_])<32||i>126&&i<Rs){this._printHandler(e,c,_),c=_-1;break}if(++_>=n||(i=e[_])<32||i>126&&i<Rs){this._printHandler(e,c,_),c=_-1;break}if(++_>=n||(i=e[_])<32||i>126&&i<Rs){this._printHandler(e,c,_),c=_-1;break}if(++_>=n||(i=e[_])<32||i>126&&i<Rs){this._printHandler(e,c,_),c=_-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:c,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let d=this._csiHandlers[this._collect<<8|i],h=d?d.length-1:-1;for(;h>=0&&(a=d[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._preserveStack(3,d,h,s,c),a;h<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++c<n&&(i=e[c])>47&&i<60);c--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let g=this._escHandlers[this._collect<<8|i],p=g?g.length-1:-1;for(;p>=0&&(a=g[p](),a!==!0);p--)if(a instanceof Promise)return this._preserveStack(4,g,p,s,c),a;p<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let _=c+1;;++_)if(_>=n||(i=e[_])===24||i===26||i===27||i>127&&i<Rs){this._dcsParser.put(e,c,_),c=_-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,s,c),a;i===27&&(s|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let _=c+1;;_++)if(_>=n||(i=e[_])<32||i>127&&i<Rs){this._oscParser.put(e,c,_),c=_-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,s,c),a;i===27&&(s|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=s&15}}},c5e=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,u5e=/^[\da-f]+$/;function lO(e){if(!e)return;let n=e.toLowerCase();if(n.indexOf("rgb:")===0){n=n.slice(4);let r=c5e.exec(n);if(r){let i=r[1]?15:r[4]?255:r[7]?4095:65535;return[Math.round(parseInt(r[1]||r[4]||r[7]||r[10],16)/i*255),Math.round(parseInt(r[2]||r[5]||r[8]||r[11],16)/i*255),Math.round(parseInt(r[3]||r[6]||r[9]||r[12],16)/i*255)]}}else if(n.indexOf("#")===0&&(n=n.slice(1),u5e.exec(n)&&[3,6,9,12].includes(n.length))){let r=n.length/3,i=[0,0,0];for(let s=0;s<3;++s){let o=parseInt(n.slice(r*s,r*s+r),16);i[s]=r===1?o<<4:r===2?o:r===3?o>>4:o>>8}return i}}function ew(e,n){let r=e.toString(16),i=r.length<2?"0"+r:r;switch(n){case 4:return r[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function f5e(e,n=16){let[r,i,s]=e;return`rgb:${ew(r,n)}/${ew(i,n)}/${ew(s,n)}`}var d5e={"(":0,")":1,"*":2,"+":3,"-":1,".":2},ql=131072,cO=10;function uO(e,n){if(e>24)return n.setWinLines||!1;switch(e){case 1:return!!n.restoreWin;case 2:return!!n.minimizeWin;case 3:return!!n.setWinPosition;case 4:return!!n.setWinSizePixels;case 5:return!!n.raiseWin;case 6:return!!n.lowerWin;case 7:return!!n.refreshWin;case 8:return!!n.setWinSizeChars;case 9:return!!n.maximizeWin;case 10:return!!n.fullscreenWin;case 11:return!!n.getWinState;case 13:return!!n.getWinPosition;case 14:return!!n.getWinSizePixels;case 15:return!!n.getScreenSizePixels;case 16:return!!n.getCellSizePixels;case 18:return!!n.getWinSizeChars;case 19:return!!n.getScreenSizeChars;case 20:return!!n.getIconTitle;case 21:return!!n.getWinTitle;case 22:return!!n.pushTitle;case 23:return!!n.popTitle;case 24:return!!n.setWinLines}return!1}var fO=5e3,dO=0,h5e=class extends Xt{constructor(e,n,r,i,s,o,a,c,d=new l5e){super(),this._bufferService=e,this._charsetService=n,this._coreService=r,this._logService=i,this._optionsService=s,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=c,this._parser=d,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new A2e,this._utf8Decoder=new M2e,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=mr.clone(),this._eraseAttrDataInternal=mr.clone(),this._onRequestBell=this._register(new nt),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new nt),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new nt),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new nt),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new nt),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new nt),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new nt),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new nt),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new nt),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new nt),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new nt),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new nt),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new nt),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new r5(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(h=>this._activeBuffer=h.activeBuffer)),this._parser.setCsiHandlerFallback((h,g)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(h),params:g.toArray()})}),this._parser.setEscHandlerFallback(h=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(h)})}),this._parser.setExecuteHandlerFallback(h=>{this._logService.debug("Unknown EXECUTE code: ",{code:h})}),this._parser.setOscHandlerFallback((h,g,p)=>{this._logService.debug("Unknown OSC code: ",{identifier:h,action:g,data:p})}),this._parser.setDcsHandlerFallback((h,g,p)=>{g==="HOOK"&&(p=p.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(h),action:g,payload:p})}),this._parser.setPrintHandler((h,g,p)=>this.print(h,g,p)),this._parser.registerCsiHandler({final:"@"},h=>this.insertChars(h)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},h=>this.scrollLeft(h)),this._parser.registerCsiHandler({final:"A"},h=>this.cursorUp(h)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},h=>this.scrollRight(h)),this._parser.registerCsiHandler({final:"B"},h=>this.cursorDown(h)),this._parser.registerCsiHandler({final:"C"},h=>this.cursorForward(h)),this._parser.registerCsiHandler({final:"D"},h=>this.cursorBackward(h)),this._parser.registerCsiHandler({final:"E"},h=>this.cursorNextLine(h)),this._parser.registerCsiHandler({final:"F"},h=>this.cursorPrecedingLine(h)),this._parser.registerCsiHandler({final:"G"},h=>this.cursorCharAbsolute(h)),this._parser.registerCsiHandler({final:"H"},h=>this.cursorPosition(h)),this._parser.registerCsiHandler({final:"I"},h=>this.cursorForwardTab(h)),this._parser.registerCsiHandler({final:"J"},h=>this.eraseInDisplay(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},h=>this.eraseInDisplay(h,!0)),this._parser.registerCsiHandler({final:"K"},h=>this.eraseInLine(h,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},h=>this.eraseInLine(h,!0)),this._parser.registerCsiHandler({final:"L"},h=>this.insertLines(h)),this._parser.registerCsiHandler({final:"M"},h=>this.deleteLines(h)),this._parser.registerCsiHandler({final:"P"},h=>this.deleteChars(h)),this._parser.registerCsiHandler({final:"S"},h=>this.scrollUp(h)),this._parser.registerCsiHandler({final:"T"},h=>this.scrollDown(h)),this._parser.registerCsiHandler({final:"X"},h=>this.eraseChars(h)),this._parser.registerCsiHandler({final:"Z"},h=>this.cursorBackwardTab(h)),this._parser.registerCsiHandler({final:"`"},h=>this.charPosAbsolute(h)),this._parser.registerCsiHandler({final:"a"},h=>this.hPositionRelative(h)),this._parser.registerCsiHandler({final:"b"},h=>this.repeatPrecedingCharacter(h)),this._parser.registerCsiHandler({final:"c"},h=>this.sendDeviceAttributesPrimary(h)),this._parser.registerCsiHandler({prefix:">",final:"c"},h=>this.sendDeviceAttributesSecondary(h)),this._parser.registerCsiHandler({final:"d"},h=>this.linePosAbsolute(h)),this._parser.registerCsiHandler({final:"e"},h=>this.vPositionRelative(h)),this._parser.registerCsiHandler({final:"f"},h=>this.hVPosition(h)),this._parser.registerCsiHandler({final:"g"},h=>this.tabClear(h)),this._parser.registerCsiHandler({final:"h"},h=>this.setMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"h"},h=>this.setModePrivate(h)),this._parser.registerCsiHandler({final:"l"},h=>this.resetMode(h)),this._parser.registerCsiHandler({prefix:"?",final:"l"},h=>this.resetModePrivate(h)),this._parser.registerCsiHandler({final:"m"},h=>this.charAttributes(h)),this._parser.registerCsiHandler({final:"n"},h=>this.deviceStatus(h)),this._parser.registerCsiHandler({prefix:"?",final:"n"},h=>this.deviceStatusPrivate(h)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},h=>this.softReset(h)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},h=>this.setCursorStyle(h)),this._parser.registerCsiHandler({final:"r"},h=>this.setScrollRegion(h)),this._parser.registerCsiHandler({final:"s"},h=>this.saveCursor(h)),this._parser.registerCsiHandler({final:"t"},h=>this.windowOptions(h)),this._parser.registerCsiHandler({final:"u"},h=>this.restoreCursor(h)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},h=>this.insertColumns(h)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},h=>this.deleteColumns(h)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},h=>this.selectProtected(h)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},h=>this.requestMode(h,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},h=>this.requestMode(h,!1)),this._parser.setExecuteHandler(He.BEL,()=>this.bell()),this._parser.setExecuteHandler(He.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(He.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(He.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(He.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(He.BS,()=>this.backspace()),this._parser.setExecuteHandler(He.HT,()=>this.tab()),this._parser.setExecuteHandler(He.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(He.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(py.IND,()=>this.index()),this._parser.setExecuteHandler(py.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(py.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new ls(h=>(this.setTitle(h),this.setIconName(h),!0))),this._parser.registerOscHandler(1,new ls(h=>this.setIconName(h))),this._parser.registerOscHandler(2,new ls(h=>this.setTitle(h))),this._parser.registerOscHandler(4,new ls(h=>this.setOrReportIndexedColor(h))),this._parser.registerOscHandler(8,new ls(h=>this.setHyperlink(h))),this._parser.registerOscHandler(10,new ls(h=>this.setOrReportFgColor(h))),this._parser.registerOscHandler(11,new ls(h=>this.setOrReportBgColor(h))),this._parser.registerOscHandler(12,new ls(h=>this.setOrReportCursorColor(h))),this._parser.registerOscHandler(104,new ls(h=>this.restoreIndexedColor(h))),this._parser.registerOscHandler(110,new ls(h=>this.restoreFgColor(h))),this._parser.registerOscHandler(111,new ls(h=>this.restoreBgColor(h))),this._parser.registerOscHandler(112,new ls(h=>this.restoreCursorColor(h))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let h in Cr)this._parser.registerEscHandler({intermediates:"(",final:h},()=>this.selectCharset("("+h)),this._parser.registerEscHandler({intermediates:")",final:h},()=>this.selectCharset(")"+h)),this._parser.registerEscHandler({intermediates:"*",final:h},()=>this.selectCharset("*"+h)),this._parser.registerEscHandler({intermediates:"+",final:h},()=>this.selectCharset("+"+h)),this._parser.registerEscHandler({intermediates:"-",final:h},()=>this.selectCharset("-"+h)),this._parser.registerEscHandler({intermediates:".",final:h},()=>this.selectCharset("."+h)),this._parser.registerEscHandler({intermediates:"/",final:h},()=>this.selectCharset("/"+h));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(h=>(this._logService.error("Parsing error: ",h),h)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new aO((h,g)=>this.requestStatusString(h,g)))}getAttrData(){return this._curAttrData}_preserveStack(e,n,r,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=n,this._parseStack.decodedLength=r,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((n,r)=>setTimeout(()=>r("#SLOW_TIMEOUT"),fO))]).catch(n=>{if(n!=="#SLOW_TIMEOUT")throw n;console.warn(`async parser handler taking longer than ${fO} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,n){let r,i=this._activeBuffer.x,s=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(r=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,n))return this._logSlowResolvingAsync(r),r;i=this._parseStack.cursorStartX,s=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>ql&&(o=this._parseStack.position+ql)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,h=>String.fromCharCode(h)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(h=>h.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<ql&&(this._parseBuffer=new Uint32Array(Math.min(e.length,ql))),a||this._dirtyRowTracker.clearRange(),e.length>ql)for(let h=o;h<e.length;h+=ql){let g=h+ql<e.length?h+ql:e.length,p=typeof e=="string"?this._stringDecoder.decode(e.substring(h,g),this._parseBuffer):this._utf8Decoder.decode(e.subarray(h,g),this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,p))return this._preserveStack(i,s,p,h),this._logSlowResolvingAsync(r),r}else if(!a){let h=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(r=this._parser.parse(this._parseBuffer,h))return this._preserveStack(i,s,h,0),this._logSlowResolvingAsync(r),r}(this._activeBuffer.x!==i||this._activeBuffer.y!==s)&&this._onCursorMove.fire();let c=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),d=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);d<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(d,this._bufferService.rows-1),end:Math.min(c,this._bufferService.rows-1)})}print(e,n,r){let i,s,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,c=this._bufferService.cols,d=this._coreService.decPrivateModes.wraparound,h=this._coreService.modes.insertMode,g=this._curAttrData,p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&r-n>0&&p.getWidth(this._activeBuffer.x-1)===2&&p.setCellFromCodepoint(this._activeBuffer.x-1,0,1,g);let _=this._parser.precedingJoinState;for(let b=n;b<r;++b){if(i=e[b],i<127&&o){let S=o[String.fromCharCode(i)];S&&(i=S.charCodeAt(0))}let x=this._unicodeService.charProperties(i,_);s=iu.extractWidth(x);let C=iu.extractShouldJoin(x),j=C?iu.extractWidth(_):0;if(_=x,a&&this._onA11yChar.fire(Jl(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+s-j>c){if(d){let S=p,E=this._activeBuffer.x-j;for(this._activeBuffer.x=j,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),j>0&&p instanceof xp&&p.copyCellsFrom(S,E,0,j,!1);E<c;)S.setCellFromCodepoint(E++,0,1,g)}else if(this._activeBuffer.x=c-1,s===2)continue}if(C&&this._activeBuffer.x){let S=p.getWidth(this._activeBuffer.x-1)?1:2;p.addCodepointToCell(this._activeBuffer.x-S,i,s);for(let E=s-j;--E>=0;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,g);continue}if(h&&(p.insertCells(this._activeBuffer.x,s-j,this._activeBuffer.getNullCell(g)),p.getWidth(c-1)===2&&p.setCellFromCodepoint(c-1,0,1,g)),p.setCellFromCodepoint(this._activeBuffer.x++,i,s,g),s>0)for(;--s;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,g)}this._parser.precedingJoinState=_,this._activeBuffer.x<c&&r-n>0&&p.getWidth(this._activeBuffer.x)===0&&!p.hasContent(this._activeBuffer.x)&&p.setCellFromCodepoint(this._activeBuffer.x,0,1,g),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,n){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,r=>uO(r.params[0],this._optionsService.rawOptions.windowOptions)?n(r):!0):this._parser.registerCsiHandler(e,n)}registerDcsHandler(e,n){return this._parser.registerDcsHandler(e,new aO(n))}registerEscHandler(e,n){return this._parser.registerEscHandler(e,n)}registerOscHandler(e,n){return this._parser.registerOscHandler(e,new ls(n))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);n.hasWidth(this._activeBuffer.x)&&!n.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,n){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+n):(this._activeBuffer.x=e,this._activeBuffer.y=n),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,n){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+n)}cursorUp(e){let n=this._activeBuffer.y-this._activeBuffer.scrollTop;return n>=0?this._moveCursor(0,-Math.min(n,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let n=this._activeBuffer.scrollBottom-this._activeBuffer.y;return n>=0?this._moveCursor(0,Math.min(n,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let n=e.params[0];return n===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:n===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let n=e.params[0]||1;for(;n--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let n=e.params[0]||1;for(;n--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let n=e.params[0];return n===1&&(this._curAttrData.bg|=536870912),(n===2||n===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,n,r,i=!1,s=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(n,r,this._activeBuffer.getNullCell(this._eraseAttrData()),s),i&&(o.isWrapped=!1)}_resetBufferLine(e,n=!1){let r=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);r&&(r.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),n),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),r.isWrapped=!1)}eraseInDisplay(e,n=!1){var i;this._restrictCursor(this._bufferService.cols);let r;switch(e.params[0]){case 0:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,n);r<this._bufferService.rows;r++)this._resetBufferLine(r,n);this._dirtyRowTracker.markDirty(r);break;case 1:for(r=this._activeBuffer.y,this._dirtyRowTracker.markDirty(r),this._eraseInBufferLine(r,0,this._activeBuffer.x+1,!0,n),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(r+1).isWrapped=!1);r--;)this._resetBufferLine(r,n);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(r=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,r-1);r--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r))!=null&&i.getTrimmedLength()););for(;r>=0;r--)this._bufferService.scroll(this._eraseAttrData())}else{for(r=this._bufferService.rows,this._dirtyRowTracker.markDirty(r-1);r--;)this._resetBufferLine(r,n);this._dirtyRowTracker.markDirty(0)}break;case 3:let s=this._activeBuffer.lines.length-this._bufferService.rows;s>0&&(this._activeBuffer.lines.trimStart(s),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-s,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-s,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,n=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,n);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,n);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,n);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let n=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,s=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;n--;)this._activeBuffer.lines.splice(s-1,1),this._activeBuffer.lines.splice(r,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let n=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let r=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;n--;)this._activeBuffer.lines.splice(r,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return n&&(n.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return n&&(n.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let n=e.params[0]||1;for(;n--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let n=e.params[0]||1;for(;n--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(mr));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.deleteCells(0,n,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.insertCells(0,n,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.insertCells(this._activeBuffer.x,n,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let n=e.params[0]||1;for(let r=this._activeBuffer.scrollTop;r<=this._activeBuffer.scrollBottom;++r){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+r);i.deleteCells(this._activeBuffer.x,n,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return n&&(n.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let n=this._parser.precedingJoinState;if(!n)return!0;let r=e.params[0]||1,i=iu.extractWidth(n),s=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(s),a=new Uint32Array(o.length*r),c=0;for(let h=0;h<o.length;){let g=o.codePointAt(h)||0;a[c++]=g,h+=g>65535?2:1}let d=c;for(let h=1;h<r;++h)a.copyWithin(d,0,c),d+=c;return this.print(a,0,d),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(He.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(He.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(He.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(He.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(He.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let n=0;n<e.length;n++)switch(e.params[n]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let n=0;n<e.length;n++)switch(e.params[n]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,Qc),this._charsetService.setgCharset(1,Qc),this._charsetService.setgCharset(2,Qc),this._charsetService.setgCharset(3,Qc);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let n=0;n<e.length;n++)switch(e.params[n]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let n=0;n<e.length;n++)switch(e.params[n]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[n]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,n){(C=>(C[C.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",C[C.SET=1]="SET",C[C.RESET=2]="RESET",C[C.PERMANENTLY_SET=3]="PERMANENTLY_SET",C[C.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(r={}));let i=this._coreService.decPrivateModes,{activeProtocol:s,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:c,cols:d}=this._bufferService,{active:h,alt:g}=c,p=this._optionsService.rawOptions,_=(C,j)=>(a.triggerDataEvent(`${He.ESC}[${n?"":"?"}${C};${j}$y`),!0),b=C=>C?1:2,x=e.params[0];return n?x===2?_(x,4):x===4?_(x,b(a.modes.insertMode)):x===12?_(x,3):x===20?_(x,b(p.convertEol)):_(x,0):x===1?_(x,b(i.applicationCursorKeys)):x===3?_(x,p.windowOptions.setWinLines?d===80?2:d===132?1:0:0):x===6?_(x,b(i.origin)):x===7?_(x,b(i.wraparound)):x===8?_(x,3):x===9?_(x,b(s==="X10")):x===12?_(x,b(p.cursorBlink)):x===25?_(x,b(!a.isCursorHidden)):x===45?_(x,b(i.reverseWraparound)):x===66?_(x,b(i.applicationKeypad)):x===67?_(x,4):x===1e3?_(x,b(s==="VT200")):x===1002?_(x,b(s==="DRAG")):x===1003?_(x,b(s==="ANY")):x===1004?_(x,b(i.sendFocus)):x===1005?_(x,4):x===1006?_(x,b(o==="SGR")):x===1015?_(x,4):x===1016?_(x,b(o==="SGR_PIXELS")):x===1048?_(x,1):x===47||x===1047||x===1049?_(x,b(h===g)):x===2004?_(x,b(i.bracketedPasteMode)):x===2026?_(x,b(i.synchronizedOutput)):_(x,0)}_updateAttrColor(e,n,r,i,s){return n===2?(e|=50331648,e&=-16777216,e|=Ug.fromColorRGB([r,i,s])):n===5&&(e&=-50331904,e|=33554432|r&255),e}_extractColor(e,n,r){let i=[0,0,-1,0,0,0],s=0,o=0;do{if(i[o+s]=e.params[n+o],e.hasSubParams(n+o)){let a=e.getSubParams(n+o),c=0;do i[1]===5&&(s=1),i[o+c+1+s]=a[c];while(++c<a.length&&c+o+1+s<i.length);break}if(i[1]===5&&o+s>=2||i[1]===2&&o+s>=5)break;i[1]&&(s=1)}while(++o+n<e.length&&o+s<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:r.fg=this._updateAttrColor(r.fg,i[1],i[3],i[4],i[5]);break;case 48:r.bg=this._updateAttrColor(r.bg,i[1],i[3],i[4],i[5]);break;case 58:r.extended=r.extended.clone(),r.extended.underlineColor=this._updateAttrColor(r.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,n){n.extended=n.extended.clone(),(!~e||e>5)&&(e=1),n.extended.underlineStyle=e,n.fg|=268435456,e===0&&(n.fg&=-268435457),n.updateExtended()}_processSGR0(e){e.fg=mr.fg,e.bg=mr.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let n=e.length,r,i=this._curAttrData;for(let s=0;s<n;s++)r=e.params[s],r>=30&&r<=37?(i.fg&=-50331904,i.fg|=16777216|r-30):r>=40&&r<=47?(i.bg&=-50331904,i.bg|=16777216|r-40):r>=90&&r<=97?(i.fg&=-50331904,i.fg|=16777216|r-90|8):r>=100&&r<=107?(i.bg&=-50331904,i.bg|=16777216|r-100|8):r===0?this._processSGR0(i):r===1?i.fg|=134217728:r===3?i.bg|=67108864:r===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(s)?e.getSubParams(s)[0]:1,i)):r===5?i.fg|=536870912:r===7?i.fg|=67108864:r===8?i.fg|=1073741824:r===9?i.fg|=2147483648:r===2?i.bg|=134217728:r===21?this._processUnderline(2,i):r===22?(i.fg&=-134217729,i.bg&=-134217729):r===23?i.bg&=-67108865:r===24?(i.fg&=-268435457,this._processUnderline(0,i)):r===25?i.fg&=-536870913:r===27?i.fg&=-67108865:r===28?i.fg&=-1073741825:r===29?i.fg&=2147483647:r===39?(i.fg&=-67108864,i.fg|=mr.fg&16777215):r===49?(i.bg&=-67108864,i.bg|=mr.bg&16777215):r===38||r===48||r===58?s+=this._extractColor(e,s,i):r===53?i.bg|=1073741824:r===55?i.bg&=-1073741825:r===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):r===100?(i.fg&=-67108864,i.fg|=mr.fg&16777215,i.bg&=-67108864,i.bg|=mr.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",r);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${He.ESC}[0n`);break;case 6:let n=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${He.ESC}[${n};${r}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let n=this._activeBuffer.y+1,r=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${He.ESC}[?${n};${r}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=mr.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let n=e.length===0?1:e.params[0];if(n===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(n){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let r=n%2===1;this._coreService.decPrivateModes.cursorBlink=r}return!0}setScrollRegion(e){let n=e.params[0]||1,r;return(e.length<2||(r=e.params[1])>this._bufferService.rows||r===0)&&(r=this._bufferService.rows),r>n&&(this._activeBuffer.scrollTop=n-1,this._activeBuffer.scrollBottom=r-1,this._setCursor(0,0)),!0}windowOptions(e){if(!uO(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let n=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:n!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${He.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(n===0||n===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>cO&&this._windowTitleStack.shift()),(n===0||n===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>cO&&this._iconNameStack.shift());break;case 23:(n===0||n===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(n===0||n===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let n=[],r=e.split(";");for(;r.length>1;){let i=r.shift(),s=r.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(hO(o))if(s==="?")n.push({type:0,index:o});else{let a=lO(s);a&&n.push({type:1,index:o,color:a})}}}return n.length&&this._onColor.fire(n),!0}setHyperlink(e){let n=e.indexOf(";");if(n===-1)return!0;let r=e.slice(0,n).trim(),i=e.slice(n+1);return i?this._createHyperlink(r,i):r.trim()?!1:this._finishHyperlink()}_createHyperlink(e,n){this._getCurrentLinkId()&&this._finishHyperlink();let r=e.split(":"),i,s=r.findIndex(o=>o.startsWith("id="));return s!==-1&&(i=r[s].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:n}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,n){let r=e.split(";");for(let i=0;i<r.length&&!(n>=this._specialColors.length);++i,++n)if(r[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[n]}]);else{let s=lO(r[i]);s&&this._onColor.fire([{type:1,index:this._specialColors[n],color:s}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let n=[],r=e.split(";");for(let i=0;i<r.length;++i)if(/^\d+$/.exec(r[i])){let s=parseInt(r[i]);hO(s)&&n.push({type:2,index:s})}return n.length&&this._onColor.fire(n),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,Qc),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(d5e[e[0]],Cr[e[1]]||Qc),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=mr.clone(),this._eraseAttrDataInternal=mr.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Bs;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let n=0;n<this._bufferService.rows;++n){let r=this._activeBuffer.ybase+this._activeBuffer.y+n,i=this._activeBuffer.lines.get(r);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,n){let r=a=>(this._coreService.triggerDataEvent(`${He.ESC}${a}${He.ESC}\\`),!0),i=this._bufferService.buffer,s=this._optionsService.rawOptions;return r(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[s.cursorStyle]-(s.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,n){this._dirtyRowTracker.markRangeDirty(e,n)}},r5=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,n){e>n&&(dO=e,e=n,n=dO),e<this.start&&(this.start=e),n>this.end&&(this.end=n)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};r5=Zn([ct(0,wi)],r5);function hO(e){return 0<=e&&e<256}var p5e=5e7,pO=12,m5e=50,g5e=class extends Xt{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new nt),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,n){if(n!==void 0&&this._syncCalls>n){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let r;for(;r=this._writeBuffer.shift();){this._action(r);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,n){if(this._pendingData>p5e)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(n),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(n)}_innerWrite(e=0,n=!0){let r=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],s=this._action(i,n);if(s){let a=c=>performance.now()-r>=pO?setTimeout(()=>this._innerWrite(0,c)):this._innerWrite(r,c);s.catch(c=>(queueMicrotask(()=>{throw c}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-r>=pO)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>m5e&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},i5=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let n=this._bufferService.buffer;if(e.id===void 0){let c=n.addMarker(n.ybase+n.y),d={data:e,id:this._nextId++,lines:[c]};return c.onDispose(()=>this._removeMarkerFromLink(d,c)),this._dataByLinkId.set(d.id,d),d.id}let r=e,i=this._getEntryIdKey(r),s=this._entriesWithId.get(i);if(s)return this.addLineToLink(s.id,n.ybase+n.y),s.id;let o=n.addMarker(n.ybase+n.y),a={id:this._nextId++,key:this._getEntryIdKey(r),data:r,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,n){let r=this._dataByLinkId.get(e);if(r&&r.lines.every(i=>i.line!==n)){let i=this._bufferService.buffer.addMarker(n);r.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(r,i))}}getLinkData(e){var n;return(n=this._dataByLinkId.get(e))==null?void 0:n.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,n){let r=e.lines.indexOf(n);r!==-1&&(e.lines.splice(r,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};i5=Zn([ct(0,wi)],i5);var mO=!1,y5e=class extends Xt{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ld),this._onBinary=this._register(new nt),this.onBinary=this._onBinary.event,this._onData=this._register(new nt),this.onData=this._onData.event,this._onLineFeed=this._register(new nt),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new nt),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new nt),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new nt),this._instantiationService=new F3e,this.optionsService=this._register(new J3e(e)),this._instantiationService.setService(Si,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Q3)),this._instantiationService.setService(wi,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Z3)),this._instantiationService.setService(Jz,this._logService),this.coreService=this._register(this._instantiationService.createInstance(e5)),this._instantiationService.setService(Mu,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(t5)),this._instantiationService.setService(Xz,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(iu)),this._instantiationService.setService(L2e,this.unicodeService),this._charsetService=this._instantiationService.createInstance(n5e),this._instantiationService.setService(z2e,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(i5),this._instantiationService.setService(Zz,this._oscLinkService),this._inputHandler=this._register(new h5e(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Gr.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Gr.forward(this._bufferService.onResize,this._onResize)),this._register(Gr.forward(this.coreService.onData,this._onData)),this._register(Gr.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new g5e((n,r)=>this._inputHandler.parse(n,r))),this._register(Gr.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new nt),this._onScroll.event(e=>{var n;(n=this._onScrollApi)==null||n.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let n in e)this.optionsService.options[n]=e[n]}write(e,n){this._writeBuffer.write(e,n)}writeSync(e,n){this._logService.logLevel<=3&&!mO&&(this._logService.warn("writeSync is unreliable and will be removed soon."),mO=!0),this._writeBuffer.writeSync(e,n)}input(e,n=!0){this.coreService.triggerDataEvent(e,n)}resize(e,n){isNaN(e)||isNaN(n)||(e=Math.max(e,TL),n=Math.max(n,PL),this._bufferService.resize(e,n))}scroll(e,n=!1){this._bufferService.scroll(e,n)}scrollLines(e,n){this._bufferService.scrollLines(e,n)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let n=e-this._bufferService.buffer.ydisp;n!==0&&this.scrollLines(n)}registerEscHandler(e,n){return this._inputHandler.registerEscHandler(e,n)}registerDcsHandler(e,n){return this._inputHandler.registerDcsHandler(e,n)}registerCsiHandler(e,n){return this._inputHandler.registerCsiHandler(e,n)}registerOscHandler(e,n){return this._inputHandler.registerOscHandler(e,n)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,n=this.optionsService.rawOptions.windowsPty;n&&n.buildNumber!==void 0&&n.buildNumber!==void 0?e=n.backend==="conpty"&&n.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(oO.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(oO(this._bufferService),!1))),this._windowsWrappingHeuristics.value=qn(()=>{for(let n of e)n.dispose()})}}},v5e={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function _5e(e,n,r,i){var a;let s={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?n?s.key=He.ESC+"OA":s.key=He.ESC+"[A":e.key==="UIKeyInputLeftArrow"?n?s.key=He.ESC+"OD":s.key=He.ESC+"[D":e.key==="UIKeyInputRightArrow"?n?s.key=He.ESC+"OC":s.key=He.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(n?s.key=He.ESC+"OB":s.key=He.ESC+"[B");break;case 8:s.key=e.ctrlKey?"\b":He.DEL,e.altKey&&(s.key=He.ESC+s.key);break;case 9:if(e.shiftKey){s.key=He.ESC+"[Z";break}s.key=He.HT,s.cancel=!0;break;case 13:s.key=e.altKey?He.ESC+He.CR:He.CR,s.cancel=!0;break;case 27:s.key=He.ESC,e.altKey&&(s.key=He.ESC+He.ESC),s.cancel=!0;break;case 37:if(e.metaKey)break;o?s.key=He.ESC+"[1;"+(o+1)+"D":n?s.key=He.ESC+"OD":s.key=He.ESC+"[D";break;case 39:if(e.metaKey)break;o?s.key=He.ESC+"[1;"+(o+1)+"C":n?s.key=He.ESC+"OC":s.key=He.ESC+"[C";break;case 38:if(e.metaKey)break;o?s.key=He.ESC+"[1;"+(o+1)+"A":n?s.key=He.ESC+"OA":s.key=He.ESC+"[A";break;case 40:if(e.metaKey)break;o?s.key=He.ESC+"[1;"+(o+1)+"B":n?s.key=He.ESC+"OB":s.key=He.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(s.key=He.ESC+"[2~");break;case 46:o?s.key=He.ESC+"[3;"+(o+1)+"~":s.key=He.ESC+"[3~";break;case 36:o?s.key=He.ESC+"[1;"+(o+1)+"H":n?s.key=He.ESC+"OH":s.key=He.ESC+"[H";break;case 35:o?s.key=He.ESC+"[1;"+(o+1)+"F":n?s.key=He.ESC+"OF":s.key=He.ESC+"[F";break;case 33:e.shiftKey?s.type=2:e.ctrlKey?s.key=He.ESC+"[5;"+(o+1)+"~":s.key=He.ESC+"[5~";break;case 34:e.shiftKey?s.type=3:e.ctrlKey?s.key=He.ESC+"[6;"+(o+1)+"~":s.key=He.ESC+"[6~";break;case 112:o?s.key=He.ESC+"[1;"+(o+1)+"P":s.key=He.ESC+"OP";break;case 113:o?s.key=He.ESC+"[1;"+(o+1)+"Q":s.key=He.ESC+"OQ";break;case 114:o?s.key=He.ESC+"[1;"+(o+1)+"R":s.key=He.ESC+"OR";break;case 115:o?s.key=He.ESC+"[1;"+(o+1)+"S":s.key=He.ESC+"OS";break;case 116:o?s.key=He.ESC+"[15;"+(o+1)+"~":s.key=He.ESC+"[15~";break;case 117:o?s.key=He.ESC+"[17;"+(o+1)+"~":s.key=He.ESC+"[17~";break;case 118:o?s.key=He.ESC+"[18;"+(o+1)+"~":s.key=He.ESC+"[18~";break;case 119:o?s.key=He.ESC+"[19;"+(o+1)+"~":s.key=He.ESC+"[19~";break;case 120:o?s.key=He.ESC+"[20;"+(o+1)+"~":s.key=He.ESC+"[20~";break;case 121:o?s.key=He.ESC+"[21;"+(o+1)+"~":s.key=He.ESC+"[21~";break;case 122:o?s.key=He.ESC+"[23;"+(o+1)+"~":s.key=He.ESC+"[23~";break;case 123:o?s.key=He.ESC+"[24;"+(o+1)+"~":s.key=He.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?s.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?s.key=He.NUL:e.keyCode>=51&&e.keyCode<=55?s.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?s.key=He.DEL:e.keyCode===219?s.key=He.ESC:e.keyCode===220?s.key=He.FS:e.keyCode===221&&(s.key=He.GS);else if((!r||i)&&e.altKey&&!e.metaKey){let c=(a=v5e[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(c)s.key=He.ESC+c;else if(e.keyCode>=65&&e.keyCode<=90){let d=e.ctrlKey?e.keyCode-64:e.keyCode+32,h=String.fromCharCode(d);e.shiftKey&&(h=h.toUpperCase()),s.key=He.ESC+h}else if(e.keyCode===32)s.key=He.ESC+(e.ctrlKey?He.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let d=e.code.slice(3,4);e.shiftKey||(d=d.toLowerCase()),s.key=He.ESC+d,s.cancel=!0}}else r&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(s.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?s.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(s.key=He.US),e.key==="@"&&(s.key=He.NUL));break}return s}var rr=0,b5e=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new lv,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new lv,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((s,o)=>this._getKey(s)-this._getKey(o)),n=0,r=0,i=new Array(this._array.length+this._insertedValues.length);for(let s=0;s<i.length;s++)r>=this._array.length||this._getKey(e[n])<=this._getKey(this._array[r])?(i[s]=e[n],n++):i[s]=this._array[r++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let n=this._getKey(e);if(n===void 0||(rr=this._search(n),rr===-1)||this._getKey(this._array[rr])!==n)return!1;do if(this._array[rr]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(rr),!0;while(++rr<this._array.length&&this._getKey(this._array[rr])===n);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((s,o)=>s-o),n=0,r=new Array(this._array.length-e.length),i=0;for(let s=0;s<this._array.length;s++)e[n]===s?n++:r[i++]=this._array[s];this._array=r,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(rr=this._search(e),!(rr<0||rr>=this._array.length)&&this._getKey(this._array[rr])===e))do yield this._array[rr];while(++rr<this._array.length&&this._getKey(this._array[rr])===e)}forEachByKey(e,n){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(rr=this._search(e),!(rr<0||rr>=this._array.length)&&this._getKey(this._array[rr])===e))do n(this._array[rr]);while(++rr<this._array.length&&this._getKey(this._array[rr])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let n=0,r=this._array.length-1;for(;r>=n;){let i=n+r>>1,s=this._getKey(this._array[i]);if(s>e)r=i-1;else if(s<e)n=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return n}},tw=0,gO=0,x5e=class extends Xt{constructor(){super(),this._decorations=new b5e(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new nt),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new nt),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(qn(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let n=new w5e(e);if(n){let r=n.marker.onDispose(()=>n.dispose()),i=n.onDispose(()=>{i.dispose(),n&&(this._decorations.delete(n)&&this._onDecorationRemoved.fire(n),r.dispose())});this._decorations.insert(n),this._onDecorationRegistered.fire(n)}return n}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,n,r){let i=0,s=0;for(let o of this._decorations.getKeyIterator(n))i=o.options.x??0,s=i+(o.options.width??1),e>=i&&e<s&&(!r||(o.options.layer??"bottom")===r)&&(yield o)}forEachDecorationAtCell(e,n,r,i){this._decorations.forEachByKey(n,s=>{tw=s.options.x??0,gO=tw+(s.options.width??1),e>=tw&&e<gO&&(!r||(s.options.layer??"bottom")===r)&&i(s)})}},w5e=class extends oc{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new nt),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new nt),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Gn.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Gn.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},S5e=1e3,C5e=class{constructor(e,n=S5e){this._renderCallback=e,this._debounceThresholdMS=n,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,n,r){this._rowCount=r,e=e!==void 0?e:0,n=n!==void 0?n:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,n):n;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let s=i-this._lastRefreshMs,o=this._debounceThresholdMS-s;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),n=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,n)}},yO=20,cv=class extends Xt{constructor(e,n,r,i){super(),this._terminal=e,this._coreBrowserService=r,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let s=this._coreBrowserService.mainDocument;this._accessibilityContainer=s.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=s.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=s.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new C5e(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(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
|
|
781
781
|
`))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(Rt(s,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(qn(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let n=0;n<e;n++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<yO+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
|
|
782
|
-
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===yO+1&&(this._liveRegion.textContent+=C3.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,n){this._liveRegionDebouncer.refresh(e,n,this._terminal.rows)}_renderRows(e,n){let r=this._terminal.buffer,i=r.lines.length.toString();for(let s=e;s<=n;s++){let o=r.lines.get(r.ydisp+s),a=[],c=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",d=(r.ydisp+s+1).toString(),h=this._rowElements[s];h&&(c.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=c,this._rowColumns.set(h,a)),h.setAttribute("aria-posinset",d),h.setAttribute("aria-setsize",i),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,n){let r=e.target,i=this._rowElements[n===0?1:this._rowElements.length-2],s=r.getAttribute("aria-posinset"),o=n===0?"1":`${this._terminal.buffer.lines.length}`;if(s===o||e.relatedTarget!==i)return;let a,c;if(n===0?(a=r,c=this._rowElements.pop(),this._rowContainer.removeChild(c)):(a=this._rowElements.shift(),c=r,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),c.removeEventListener("focus",this._bottomBoundaryFocusListener),n===0){let d=this._createAccessibilityTreeNode();this._rowElements.unshift(d),this._rowContainer.insertAdjacentElement("afterbegin",d)}else{let d=this._createAccessibilityTreeNode();this._rowElements.push(d),this._rowContainer.appendChild(d)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(n===0?-1:1),this._rowElements[n===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var c;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let n={node:e.anchorNode,offset:e.anchorOffset},r={node:e.focusNode,offset:e.focusOffset};if((n.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||n.node===r.node&&n.offset>r.offset)&&([n,r]=[r,n]),n.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(n={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(n.node))return;let i=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:i,offset:((c=i.textContent)==null?void 0:c.length)??0}),!this._rowContainer.contains(r.node))return;let s=({node:d,offset:h})=>{let g=d instanceof Text?d.parentNode:d,p=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(p))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(g);if(!_)return console.warn("columns is null. Race condition?"),null;let b=h<_.length?_[h]:_.slice(-1)[0]+1;return b>=this._terminal.cols&&(++p,b=0),{row:p,column:b}},o=s(n),a=s(r);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let n=this._rowContainer.children.length;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var s,o;e.style.transform="";let n=e.getBoundingClientRect().width,r=(o=(s=this._rowColumns.get(e))==null?void 0:s.slice(-1))==null?void 0:o[0];if(!r)return;let i=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/n})`}};cv=Zn([ct(1,a4),ct(2,nl),ct(3,rl)],cv);var s5=class extends Xt{constructor(e,n,r,i,s){super(),this._element=e,this._mouseService=n,this._renderService=r,this._bufferService=i,this._linkProviderService=s,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new nt),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new nt),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(qn(()=>{var o;xu(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Rt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Rt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Rt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Rt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let n=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!n)return;this._isMouseOut=!1;let r=e.composedPath();for(let i=0;i<r.length;i++){let s=r[i];if(s.classList.contains("xterm"))break;if(s.classList.contains("xterm-hover"))return}(!this._lastBufferCell||n.x!==this._lastBufferCell.x||n.y!==this._lastBufferCell.y)&&(this._handleHover(n),this._lastBufferCell=n)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,n){var i,s;(!this._activeProviderReplies||!n)&&((i=this._activeProviderReplies)==null||i.forEach(o=>{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())n?(s=this._activeProviderReplies)!=null&&s.get(o)&&(r=this._checkLinkProviderResult(o,e,r)):a.provideLinks(e.y,c=>{var h,g;if(this._isMouseOut)return;let d=c==null?void 0:c.map(p=>({link:p}));(h=this._activeProviderReplies)==null||h.set(o,d),r=this._checkLinkProviderResult(o,e,r),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,n){let r=new Set;for(let i=0;i<n.size;i++){let s=n.get(i);if(s)for(let o=0;o<s.length;o++){let a=s[o],c=a.link.range.start.y<e?0:a.link.range.start.x,d=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let h=c;h<=d;h++){if(r.has(h)){s.splice(o--,1);break}r.add(h)}}}}_checkLinkProviderResult(e,n,r){var o;if(!this._activeProviderReplies)return r;let i=this._activeProviderReplies.get(e),s=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(s=!0);if(!s&&i){let a=i.find(c=>this._linkAtPosition(c.link,n));a&&(r=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let a=0;a<this._activeProviderReplies.size;a++){let c=(o=this._activeProviderReplies.get(a))==null?void 0:o.find(d=>this._linkAtPosition(d.link,n));if(c){r=!0,this._handleNewLink(c);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let n=this._positionFromMouseEvent(e,this._element,this._mouseService);n&&this._mouseDownLink&&C5e(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,n)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,n){!this._currentLink||!this._lastMouseEvent||(!e||!n||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=n)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,xu(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._linkAtPosition(e.link,n)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var r,i;return(i=(r=this._currentLink)==null?void 0:r.state)==null?void 0:i.decorations.pointerCursor},set:r=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>{var r,i;return(i=(r=this._currentLink)==null?void 0:r.state)==null?void 0:i.decorations.underline},set:r=>{var i,s,o;(i=this._currentLink)!=null&&i.state&&((o=(s=this._currentLink)==null?void 0:s.state)==null?void 0:o.decorations.underline)!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let i=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(i,s),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,n,r){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(n,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),n.hover&&n.hover(r,n.text)}_fireUnderlineEvent(e,n){let r=e.range,i=this._bufferService.buffer.ydisp,s=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-i-1,r.end.x,r.end.y-i-1,void 0);(n?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(s)}_linkLeave(e,n,r){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(n,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),n.leave&&n.leave(r,n.text)}_linkAtPosition(e,n){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,s=n.y*this._bufferService.cols+n.x;return r<=s&&s<=i}_positionFromMouseEvent(e,n,r){let i=r.getCoords(e,n,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,n,r,i,s){return{x1:e,y1:n,x2:r,y2:i,cols:this._bufferService.cols,fg:s}}};s5=Zn([ct(1,l4),ct(2,rl),ct(3,wi),ct(4,eL)],s5);function C5e(e,n){return e.text===n.text&&e.range.start.x===n.range.start.x&&e.range.start.y===n.range.start.y&&e.range.end.x===n.range.end.x&&e.range.end.y===n.range.end.y}var j5e=class extends g5e{constructor(e={}){super(e),this._linkifier=this._register(new ld),this.browser=_L,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ld),this._onCursorMove=this._register(new nt),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new nt),this.onKey=this._onKey.event,this._onRender=this._register(new nt),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new nt),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new nt),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new nt),this.onBell=this._onBell.event,this._onFocus=this._register(new nt),this._onBlur=this._register(new nt),this._onA11yCharEmitter=this._register(new nt),this._onA11yTabEmitter=this._register(new nt),this._onWillOpen=this._register(new nt),this._setup(),this._decorationService=this._instantiationService.createInstance(b5e),this._instantiationService.setService(Vg,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(p3e),this._instantiationService.setService(eL,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(k3)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(n=>this.refresh((n==null?void 0:n.start)??0,(n==null?void 0:n.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(n=>this._reportWindowsOptions(n))),this._register(this._inputHandler.onColor(n=>this._handleColorEvent(n))),this._register(Gr.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Gr.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Gr.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Gr.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(n=>this._afterResize(n.cols,n.rows))),this._register(qn(()=>{var n,r;this._customKeyEventHandler=void 0,(r=(n=this.element)==null?void 0:n.parentNode)==null||r.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let n of e){let r,i="";switch(n.index){case 256:r="foreground",i="10";break;case 257:r="background",i="11";break;case 258:r="cursor",i="12";break;default:r="ansi",i="4;"+n.index}switch(n.type){case 0:let s=$n.toColorRGB(r==="ansi"?this._themeService.colors.ansi[n.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${He.ESC}]${i};${u5e(s)}${yL.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(o=>o.ansi[n.index]=gr.toColor(...n.color));else{let o=r;this._themeService.modifyColors(a=>a[o]=gr.toColor(...n.color))}break;case 2:this._themeService.restoreColor(n.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(cv,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(He.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(He.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,n=this.buffer.lines.get(e);if(!n)return;let r=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,s=n.getWidth(r),o=this._renderService.dimensions.css.cell.width*s,a=this.buffer.y*this._renderService.dimensions.css.cell.height,c=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=c+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Rt(this.element,"copy",n=>{this.hasSelection()&&N2e(n,this._selectionService)}));let e=n=>T2e(n,this.textarea,this.coreService,this.optionsService);this._register(Rt(this.textarea,"paste",e)),this._register(Rt(this.element,"paste",e)),bL?this._register(Rt(this.element,"mousedown",n=>{n.button===2&&EE(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Rt(this.element,"contextmenu",n=>{EE(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),g4&&this._register(Rt(this.element,"auxclick",n=>{n.button===1&&Wz(n,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Rt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Rt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Rt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Rt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Rt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Rt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Rt(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var s;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((s=this.element)==null?void 0:s.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let n=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),n.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Rt(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),n.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",S3.get()),SL||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(d3e,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(nl,this._coreBrowserService),this._register(Rt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Rt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(K3,this._document,this._helperContainer),this._instantiationService.setService(i_,this._charSizeService),this._themeService=this._instantiationService.createInstance(J3),this._instantiationService.setService(Ed,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ov),this._instantiationService.setService(Qz,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Y3,this.rows,this.screenElement)),this._instantiationService.setService(rl,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(V3,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(G3),this._instantiationService.setService(l4,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(s5,this.screenElement));this.element.appendChild(n);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(H3,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(X3,this.element,this.screenElement,i)),this._instantiationService.setService($2e,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Gr.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(U3,this.screenElement)),this._register(Rt(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(cv,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sv,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sv,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(q3,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,n=this.element;function r(o){var h,g,p,_,b;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let c,d;switch(o.overrideType||o.type){case"mousemove":d=32,o.buttons===void 0?(c=3,o.button!==void 0&&(c=o.button<3?o.button:3)):c=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":d=0,c=o.button<3?o.button:3;break;case"mousedown":d=1,c=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let x=o.deltaY;if(x===0||e.coreMouseService.consumeWheelEvent(o,(_=(p=(g=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:g.device)==null?void 0:p.cell)==null?void 0:_.height,(b=e._coreBrowserService)==null?void 0:b.dpr)===0)return!1;d=x<0?0:1,c=4;break;default:return!1}return d===void 0||c===void 0||c>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:c,action:d,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},s={mouseup:o=>(r(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(r(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&r(o)},mousemove:o=>{o.buttons||r(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?i.mousemove||(n.addEventListener("mousemove",s.mousemove),i.mousemove=s.mousemove):(n.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(n.addEventListener("wheel",s.wheel,{passive:!1}),i.wheel=s.wheel):(n.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=s.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=s.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Rt(n,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return r(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(Rt(n,"wheel",o=>{var a,c,d,h,g;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(h=(d=(c=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:c.device)==null?void 0:d.cell)==null?void 0:h.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return this.cancel(o,!0);let p=He.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(p,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,n){var r;(r=this._renderService)==null||r.refreshRows(e,n)}updateCursorStyle(e){var n;(n=this._selectionService)!=null&&n.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,n){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,n),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let n=e-this._bufferService.buffer.ydisp;n!==0&&this.scrollLines(n)}paste(e){Vz(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let n=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),n}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,n,r){this._selectionService.setSelection(e,n,r)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,n){var r;(r=this._selectionService)==null||r.selectLines(e,n)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let n=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!n&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!n&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let r=v5e(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let i=this.rows-1;return this.scrollLines(r.type===2?-i:i),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((r.key===He.ETX||r.key===He.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,n){let r=e.isMac&&!this.options.macOptionIsMeta&&n.altKey&&!n.ctrlKey&&!n.metaKey||e.isWindows&&n.altKey&&n.ctrlKey&&!n.metaKey||e.isWindows&&n.getModifierState("AltGraph");return n.type==="keypress"?r:r&&(!n.keyCode||n.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(k5e(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let n;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)n=e.charCode;else if(e.which===null||e.which===void 0)n=e.keyCode;else if(e.which!==0&&e.charCode!==0)n=e.which;else return!1;return!n||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(n=String.fromCharCode(n),this._onKey.fire({key:n,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let n=e.data;return this.coreService.triggerDataEvent(n,!0),this.cancel(e),!0}return!1}resize(e,n){if(e===this.cols&&n===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,n)}_afterResize(e,n){var r;(r=this._charSizeService)==null||r.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(mr));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var n;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(n=this._selectionService)==null||n.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(He.ESC+"[I"):this.coreService.triggerDataEvent(He.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let n=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${He.ESC}[4;${r};${n}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),s=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${He.ESC}[6;${s};${i}t`);break}}cancel(e,n){if(!(!this.options.cancelEvents&&!n))return e.preventDefault(),e.stopPropagation(),!1}};function k5e(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var E5e=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,n){let r={instance:n,dispose:n.dispose,isDisposed:!1};this._addons.push(r),n.dispose=()=>this._wrappedAddonDispose(r),n.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let n=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){n=r;break}if(n===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(n,1)}},O5e=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,n){if(!(e<0||e>=this._line.length))return n?(this._line.loadCell(e,n),n):this._line.loadCell(e,new Bs)}translateToString(e,n,r){return this._line.translateToString(e,n,r)}},vO=class{constructor(e,n){this._buffer=e,this.type=n}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let n=this._buffer.lines.get(e);if(n)return new O5e(n)}getNullCell(){return new Bs}},N5e=class extends Xt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new nt),this.onBufferChange=this._onBufferChange.event,this._normal=new vO(this._core.buffers.normal,"normal"),this._alternate=new vO(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},T5e=class{constructor(e){this._core=e}registerCsiHandler(e,n){return this._core.registerCsiHandler(e,r=>n(r.toArray()))}addCsiHandler(e,n){return this.registerCsiHandler(e,n)}registerDcsHandler(e,n){return this._core.registerDcsHandler(e,(r,i)=>n(r,i.toArray()))}addDcsHandler(e,n){return this.registerDcsHandler(e,n)}registerEscHandler(e,n){return this._core.registerEscHandler(e,n)}addEscHandler(e,n){return this.registerEscHandler(e,n)}registerOscHandler(e,n){return this._core.registerOscHandler(e,n)}addOscHandler(e,n){return this.registerOscHandler(e,n)}},P5e=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},A5e=["cols","rows"],zo=0,M5e=class extends Xt{constructor(e){super(),this._core=this._register(new j5e(e)),this._addonManager=this._register(new E5e),this._publicOptions={...this._core.options};let n=i=>this._core.options[i],r=(i,s)=>{this._checkReadonlyOptions(i),this._core.options[i]=s};for(let i in this._core.options){let s={get:n.bind(this,i),set:r.bind(this,i)};Object.defineProperty(this._publicOptions,i,s)}}_checkReadonlyOptions(e){if(A5e.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new T5e(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new P5e(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new N5e(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,n="none";switch(this._core.coreMouseService.activeProtocol){case"X10":n="x10";break;case"VT200":n="vt200";break;case"DRAG":n="drag";break;case"ANY":n="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:n,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let n in e)this._publicOptions[n]=e[n]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,n=!0){this._core.input(e,n)}resize(e,n){this._verifyIntegers(e,n),this._core.resize(e,n)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,n,r){this._verifyIntegers(e,n,r),this._core.select(e,n,r)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,n){this._verifyIntegers(e,n),this._core.selectLines(e,n)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,n){this._core.write(e,n)}writeln(e,n){this._core.write(e),this._core.write(`\r
|
|
782
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===yO+1&&(this._liveRegion.textContent+=C3.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,n){this._liveRegionDebouncer.refresh(e,n,this._terminal.rows)}_renderRows(e,n){let r=this._terminal.buffer,i=r.lines.length.toString();for(let s=e;s<=n;s++){let o=r.lines.get(r.ydisp+s),a=[],c=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",d=(r.ydisp+s+1).toString(),h=this._rowElements[s];h&&(c.length===0?(h.textContent=" ",this._rowColumns.set(h,[0,1])):(h.textContent=c,this._rowColumns.set(h,a)),h.setAttribute("aria-posinset",d),h.setAttribute("aria-setsize",i),this._alignRowWidth(h))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,n){let r=e.target,i=this._rowElements[n===0?1:this._rowElements.length-2],s=r.getAttribute("aria-posinset"),o=n===0?"1":`${this._terminal.buffer.lines.length}`;if(s===o||e.relatedTarget!==i)return;let a,c;if(n===0?(a=r,c=this._rowElements.pop(),this._rowContainer.removeChild(c)):(a=this._rowElements.shift(),c=r,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),c.removeEventListener("focus",this._bottomBoundaryFocusListener),n===0){let d=this._createAccessibilityTreeNode();this._rowElements.unshift(d),this._rowContainer.insertAdjacentElement("afterbegin",d)}else{let d=this._createAccessibilityTreeNode();this._rowElements.push(d),this._rowContainer.appendChild(d)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(n===0?-1:1),this._rowElements[n===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var c;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let n={node:e.anchorNode,offset:e.anchorOffset},r={node:e.focusNode,offset:e.focusOffset};if((n.node.compareDocumentPosition(r.node)&Node.DOCUMENT_POSITION_PRECEDING||n.node===r.node&&n.offset>r.offset)&&([n,r]=[r,n]),n.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(n={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(n.node))return;let i=this._rowElements.slice(-1)[0];if(r.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(r={node:i,offset:((c=i.textContent)==null?void 0:c.length)??0}),!this._rowContainer.contains(r.node))return;let s=({node:d,offset:h})=>{let g=d instanceof Text?d.parentNode:d,p=parseInt(g==null?void 0:g.getAttribute("aria-posinset"),10)-1;if(isNaN(p))return console.warn("row is invalid. Race condition?"),null;let _=this._rowColumns.get(g);if(!_)return console.warn("columns is null. Race condition?"),null;let b=h<_.length?_[h]:_.slice(-1)[0]+1;return b>=this._terminal.cols&&(++p,b=0),{row:p,column:b}},o=s(n),a=s(r);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let n=this._rowContainer.children.length;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var s,o;e.style.transform="";let n=e.getBoundingClientRect().width,r=(o=(s=this._rowColumns.get(e))==null?void 0:s.slice(-1))==null?void 0:o[0];if(!r)return;let i=r*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/n})`}};cv=Zn([ct(1,a4),ct(2,nl),ct(3,rl)],cv);var s5=class extends Xt{constructor(e,n,r,i,s){super(),this._element=e,this._mouseService=n,this._renderService=r,this._bufferService=i,this._linkProviderService=s,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new nt),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new nt),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(qn(()=>{var o;xu(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(Rt(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(Rt(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(Rt(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(Rt(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let n=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!n)return;this._isMouseOut=!1;let r=e.composedPath();for(let i=0;i<r.length;i++){let s=r[i];if(s.classList.contains("xterm"))break;if(s.classList.contains("xterm-hover"))return}(!this._lastBufferCell||n.x!==this._lastBufferCell.x||n.y!==this._lastBufferCell.y)&&(this._handleHover(n),this._lastBufferCell=n)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,n){var i,s;(!this._activeProviderReplies||!n)&&((i=this._activeProviderReplies)==null||i.forEach(o=>{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let r=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())n?(s=this._activeProviderReplies)!=null&&s.get(o)&&(r=this._checkLinkProviderResult(o,e,r)):a.provideLinks(e.y,c=>{var h,g;if(this._isMouseOut)return;let d=c==null?void 0:c.map(p=>({link:p}));(h=this._activeProviderReplies)==null||h.set(o,d),r=this._checkLinkProviderResult(o,e,r),((g=this._activeProviderReplies)==null?void 0:g.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,n){let r=new Set;for(let i=0;i<n.size;i++){let s=n.get(i);if(s)for(let o=0;o<s.length;o++){let a=s[o],c=a.link.range.start.y<e?0:a.link.range.start.x,d=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let h=c;h<=d;h++){if(r.has(h)){s.splice(o--,1);break}r.add(h)}}}}_checkLinkProviderResult(e,n,r){var o;if(!this._activeProviderReplies)return r;let i=this._activeProviderReplies.get(e),s=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(s=!0);if(!s&&i){let a=i.find(c=>this._linkAtPosition(c.link,n));a&&(r=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!r)for(let a=0;a<this._activeProviderReplies.size;a++){let c=(o=this._activeProviderReplies.get(a))==null?void 0:o.find(d=>this._linkAtPosition(d.link,n));if(c){r=!0,this._handleNewLink(c);break}}return r}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let n=this._positionFromMouseEvent(e,this._element,this._mouseService);n&&this._mouseDownLink&&j5e(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,n)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,n){!this._currentLink||!this._lastMouseEvent||(!e||!n||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=n)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,xu(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._linkAtPosition(e.link,n)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var r,i;return(i=(r=this._currentLink)==null?void 0:r.state)==null?void 0:i.decorations.pointerCursor},set:r=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==r&&(this._currentLink.state.decorations.pointerCursor=r,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",r))}},underline:{get:()=>{var r,i;return(i=(r=this._currentLink)==null?void 0:r.state)==null?void 0:i.decorations.underline},set:r=>{var i,s,o;(i=this._currentLink)!=null&&i.state&&((o=(s=this._currentLink)==null?void 0:s.state)==null?void 0:o.decorations.underline)!==r&&(this._currentLink.state.decorations.underline=r,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,r))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(r=>{if(!this._currentLink)return;let i=r.start===0?0:r.start+1+this._bufferService.buffer.ydisp,s=this._bufferService.buffer.ydisp+1+r.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=s&&(this._clearCurrentLink(i,s),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,n,r){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(n,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),n.hover&&n.hover(r,n.text)}_fireUnderlineEvent(e,n){let r=e.range,i=this._bufferService.buffer.ydisp,s=this._createLinkUnderlineEvent(r.start.x-1,r.start.y-i-1,r.end.x,r.end.y-i-1,void 0);(n?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(s)}_linkLeave(e,n,r){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(n,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),n.leave&&n.leave(r,n.text)}_linkAtPosition(e,n){let r=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,s=n.y*this._bufferService.cols+n.x;return r<=s&&s<=i}_positionFromMouseEvent(e,n,r){let i=r.getCoords(e,n,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,n,r,i,s){return{x1:e,y1:n,x2:r,y2:i,cols:this._bufferService.cols,fg:s}}};s5=Zn([ct(1,l4),ct(2,rl),ct(3,wi),ct(4,eL)],s5);function j5e(e,n){return e.text===n.text&&e.range.start.x===n.range.start.x&&e.range.start.y===n.range.start.y&&e.range.end.x===n.range.end.x&&e.range.end.y===n.range.end.y}var k5e=class extends y5e{constructor(e={}){super(e),this._linkifier=this._register(new ld),this.browser=_L,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ld),this._onCursorMove=this._register(new nt),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new nt),this.onKey=this._onKey.event,this._onRender=this._register(new nt),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new nt),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new nt),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new nt),this.onBell=this._onBell.event,this._onFocus=this._register(new nt),this._onBlur=this._register(new nt),this._onA11yCharEmitter=this._register(new nt),this._onA11yTabEmitter=this._register(new nt),this._onWillOpen=this._register(new nt),this._setup(),this._decorationService=this._instantiationService.createInstance(x5e),this._instantiationService.setService(Vg,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(m3e),this._instantiationService.setService(eL,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(k3)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(n=>this.refresh((n==null?void 0:n.start)??0,(n==null?void 0:n.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(n=>this._reportWindowsOptions(n))),this._register(this._inputHandler.onColor(n=>this._handleColorEvent(n))),this._register(Gr.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Gr.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Gr.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Gr.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(n=>this._afterResize(n.cols,n.rows))),this._register(qn(()=>{var n,r;this._customKeyEventHandler=void 0,(r=(n=this.element)==null?void 0:n.parentNode)==null||r.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let n of e){let r,i="";switch(n.index){case 256:r="foreground",i="10";break;case 257:r="background",i="11";break;case 258:r="cursor",i="12";break;default:r="ansi",i="4;"+n.index}switch(n.type){case 0:let s=$n.toColorRGB(r==="ansi"?this._themeService.colors.ansi[n.index]:this._themeService.colors[r]);this.coreService.triggerDataEvent(`${He.ESC}]${i};${f5e(s)}${yL.ST}`);break;case 1:if(r==="ansi")this._themeService.modifyColors(o=>o.ansi[n.index]=gr.toColor(...n.color));else{let o=r;this._themeService.modifyColors(a=>a[o]=gr.toColor(...n.color))}break;case 2:this._themeService.restoreColor(n.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(cv,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(He.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(He.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,n=this.buffer.lines.get(e);if(!n)return;let r=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,s=n.getWidth(r),o=this._renderService.dimensions.css.cell.width*s,a=this.buffer.y*this._renderService.dimensions.css.cell.height,c=r*this._renderService.dimensions.css.cell.width;this.textarea.style.left=c+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(Rt(this.element,"copy",n=>{this.hasSelection()&&T2e(n,this._selectionService)}));let e=n=>P2e(n,this.textarea,this.coreService,this.optionsService);this._register(Rt(this.textarea,"paste",e)),this._register(Rt(this.element,"paste",e)),bL?this._register(Rt(this.element,"mousedown",n=>{n.button===2&&EE(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(Rt(this.element,"contextmenu",n=>{EE(n,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),g4&&this._register(Rt(this.element,"auxclick",n=>{n.button===1&&Wz(n,this.textarea,this.screenElement)}))}_bindKeys(){this._register(Rt(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(Rt(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(Rt(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(Rt(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(Rt(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(Rt(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(Rt(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var s;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((s=this.element)==null?void 0:s.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let n=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),n.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(Rt(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),n.appendChild(this.screenElement);let r=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",S3.get()),SL||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>r.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(h3e,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(nl,this._coreBrowserService),this._register(Rt(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(Rt(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(K3,this._document,this._helperContainer),this._instantiationService.setService(i_,this._charSizeService),this._themeService=this._instantiationService.createInstance(J3),this._instantiationService.setService(Ed,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(ov),this._instantiationService.setService(Qz,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Y3,this.rows,this.screenElement)),this._instantiationService.setService(rl,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(V3,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(G3),this._instantiationService.setService(l4,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(s5,this.screenElement));this.element.appendChild(n);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(H3,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(X3,this.element,this.screenElement,i)),this._instantiationService.setService(I2e,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register(Gr.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(U3,this.screenElement)),this._register(Rt(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(cv,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sv,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(sv,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(q3,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,n=this.element;function r(o){var h,g,p,_,b;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let c,d;switch(o.overrideType||o.type){case"mousemove":d=32,o.buttons===void 0?(c=3,o.button!==void 0&&(c=o.button<3?o.button:3)):c=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":d=0,c=o.button<3?o.button:3;break;case"mousedown":d=1,c=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let x=o.deltaY;if(x===0||e.coreMouseService.consumeWheelEvent(o,(_=(p=(g=(h=e._renderService)==null?void 0:h.dimensions)==null?void 0:g.device)==null?void 0:p.cell)==null?void 0:_.height,(b=e._coreBrowserService)==null?void 0:b.dpr)===0)return!1;d=x<0?0:1,c=4;break;default:return!1}return d===void 0||c===void 0||c>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:c,action:d,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},s={mouseup:o=>(r(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(r(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&r(o)},mousemove:o=>{o.buttons||r(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?i.mousemove||(n.addEventListener("mousemove",s.mousemove),i.mousemove=s.mousemove):(n.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(n.addEventListener("wheel",s.wheel,{passive:!1}),i.wheel=s.wheel):(n.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=s.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=s.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(Rt(n,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return r(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(Rt(n,"wheel",o=>{var a,c,d,h,g;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(h=(d=(c=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:c.device)==null?void 0:d.cell)==null?void 0:h.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return this.cancel(o,!0);let p=He.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(p,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,n){var r;(r=this._renderService)==null||r.refreshRows(e,n)}updateCursorStyle(e){var n;(n=this._selectionService)!=null&&n.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,n){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,n),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let n=e-this._bufferService.buffer.ydisp;n!==0&&this.scrollLines(n)}paste(e){Vz(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let n=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),n}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,n,r){this._selectionService.setSelection(e,n,r)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,n){var r;(r=this._selectionService)==null||r.selectLines(e,n)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let n=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!n&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!n&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let r=_5e(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),r.type===3||r.type===2){let i=this.rows-1;return this.scrollLines(r.type===2?-i:i),this.cancel(e,!0)}if(r.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(r.cancel&&this.cancel(e,!0),!r.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((r.key===He.ETX||r.key===He.CR)&&(this.textarea.value=""),this._onKey.fire({key:r.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(r.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,n){let r=e.isMac&&!this.options.macOptionIsMeta&&n.altKey&&!n.ctrlKey&&!n.metaKey||e.isWindows&&n.altKey&&n.ctrlKey&&!n.metaKey||e.isWindows&&n.getModifierState("AltGraph");return n.type==="keypress"?r:r&&(!n.keyCode||n.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(E5e(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let n;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)n=e.charCode;else if(e.which===null||e.which===void 0)n=e.keyCode;else if(e.which!==0&&e.charCode!==0)n=e.which;else return!1;return!n||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(n=String.fromCharCode(n),this._onKey.fire({key:n,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let n=e.data;return this.coreService.triggerDataEvent(n,!0),this.cancel(e),!0}return!1}resize(e,n){if(e===this.cols&&n===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,n)}_afterResize(e,n){var r;(r=this._charSizeService)==null||r.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(mr));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var n;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(n=this._selectionService)==null||n.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(He.ESC+"[I"):this.coreService.triggerDataEvent(He.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let n=this._renderService.dimensions.css.canvas.width.toFixed(0),r=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${He.ESC}[4;${r};${n}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),s=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${He.ESC}[6;${s};${i}t`);break}}cancel(e,n){if(!(!this.options.cancelEvents&&!n))return e.preventDefault(),e.stopPropagation(),!1}};function E5e(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var O5e=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,n){let r={instance:n,dispose:n.dispose,isDisposed:!1};this._addons.push(r),n.dispose=()=>this._wrappedAddonDispose(r),n.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let n=-1;for(let r=0;r<this._addons.length;r++)if(this._addons[r]===e){n=r;break}if(n===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(n,1)}},N5e=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,n){if(!(e<0||e>=this._line.length))return n?(this._line.loadCell(e,n),n):this._line.loadCell(e,new Bs)}translateToString(e,n,r){return this._line.translateToString(e,n,r)}},vO=class{constructor(e,n){this._buffer=e,this.type=n}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let n=this._buffer.lines.get(e);if(n)return new N5e(n)}getNullCell(){return new Bs}},T5e=class extends Xt{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new nt),this.onBufferChange=this._onBufferChange.event,this._normal=new vO(this._core.buffers.normal,"normal"),this._alternate=new vO(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},P5e=class{constructor(e){this._core=e}registerCsiHandler(e,n){return this._core.registerCsiHandler(e,r=>n(r.toArray()))}addCsiHandler(e,n){return this.registerCsiHandler(e,n)}registerDcsHandler(e,n){return this._core.registerDcsHandler(e,(r,i)=>n(r,i.toArray()))}addDcsHandler(e,n){return this.registerDcsHandler(e,n)}registerEscHandler(e,n){return this._core.registerEscHandler(e,n)}addEscHandler(e,n){return this.registerEscHandler(e,n)}registerOscHandler(e,n){return this._core.registerOscHandler(e,n)}addOscHandler(e,n){return this.registerOscHandler(e,n)}},A5e=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},M5e=["cols","rows"],zo=0,R5e=class extends Xt{constructor(e){super(),this._core=this._register(new k5e(e)),this._addonManager=this._register(new O5e),this._publicOptions={...this._core.options};let n=i=>this._core.options[i],r=(i,s)=>{this._checkReadonlyOptions(i),this._core.options[i]=s};for(let i in this._core.options){let s={get:n.bind(this,i),set:r.bind(this,i)};Object.defineProperty(this._publicOptions,i,s)}}_checkReadonlyOptions(e){if(M5e.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new P5e(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new A5e(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new T5e(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,n="none";switch(this._core.coreMouseService.activeProtocol){case"X10":n="x10";break;case"VT200":n="vt200";break;case"DRAG":n="drag";break;case"ANY":n="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:n,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let n in e)this._publicOptions[n]=e[n]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,n=!0){this._core.input(e,n)}resize(e,n){this._verifyIntegers(e,n),this._core.resize(e,n)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,n,r){this._verifyIntegers(e,n,r),this._core.select(e,n,r)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,n){this._verifyIntegers(e,n),this._core.selectLines(e,n)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,n){this._core.write(e,n)}writeln(e,n){this._core.write(e),this._core.write(`\r
|
|
783
783
|
`,n)}paste(e){this._core.paste(e)}refresh(e,n){this._verifyIntegers(e,n),this._core.refresh(e,n)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return S3.get()},set promptLabel(e){S3.set(e)},get tooMuchOutput(){return C3.get()},set tooMuchOutput(e){C3.set(e)}}}_verifyIntegers(...e){for(zo of e)if(zo===1/0||isNaN(zo)||zo%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(zo of e)if(zo&&(zo===1/0||isNaN(zo)||zo%1!==0||zo<0))throw new Error("This API only accepts positive integers")}};/**
|
|
784
784
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
785
785
|
* @license MIT
|
|
@@ -791,7 +791,7 @@ WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){t
|
|
|
791
791
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
792
792
|
* http://bellard.org/jslinux/
|
|
793
793
|
* Copyright (c) 2011 Fabrice Bellard
|
|
794
|
-
*/var
|
|
794
|
+
*/var D5e=2,z5e=1,L5e=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let n=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(n._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var p;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let n=this._terminal.options.scrollback===0?0:((p=this._terminal.options.overviewRuler)==null?void 0:p.width)||14,r=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(r.getPropertyValue("height")),s=Math.max(0,parseInt(r.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},c=a.top+a.bottom,d=a.right+a.left,h=i-c,g=s-d-n;return{cols:Math.max(D5e,Math.floor(g/e.css.cell.width)),rows:Math.max(z5e,Math.floor(h/e.css.cell.height))}}};/**
|
|
795
795
|
* Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
|
|
796
796
|
* @license MIT
|
|
797
797
|
*
|
|
@@ -802,16 +802,16 @@ WARNING: This link could potentially be dangerous`)){let r=window.open();if(r){t
|
|
|
802
802
|
* Fabrice Bellard's javascript vt100 for jslinux:
|
|
803
803
|
* http://bellard.org/jslinux/
|
|
804
804
|
* Copyright (c) 2011 Fabrice Bellard
|
|
805
|
-
*/var L5e=class{constructor(e,n,r,i={}){this._terminal=e,this._regex=n,this._handler=r,this._options=i}provideLinks(e,n){let r=I5e.computeLink(e,this._regex,this._terminal,this._handler);n(this._addCallbacks(r))}_addCallbacks(e){return e.map(n=>(n.leave=this._options.leave,n.hover=(r,i)=>{if(this._options.hover){let{range:s}=n;this._options.hover(r,i,s)}},n))}};function $5e(e){try{let n=new URL(e),r=n.password&&n.username?`${n.protocol}//${n.username}:${n.password}@${n.host}`:n.username?`${n.protocol}//${n.username}@${n.host}`:`${n.protocol}//${n.host}`;return e.toLocaleLowerCase().startsWith(r.toLocaleLowerCase())}catch{return!1}}var I5e=class yy{static computeLink(n,r,i,s){let o=new RegExp(r.source,(r.flags||"")+"g"),[a,c]=yy._getWindowedLineStrings(n-1,i),d=a.join(""),h,g=[];for(;h=o.exec(d);){let p=h[0];if(!$5e(p))continue;let[_,b]=yy._mapStrIdx(i,c,0,h.index),[x,C]=yy._mapStrIdx(i,_,b,p.length);if(_===-1||b===-1||x===-1||C===-1)continue;let j={start:{x:b+1,y:_+1},end:{x:C,y:x+1}};g.push({range:j,text:p,activate:s})}return g}static _getWindowedLineStrings(n,r){let i,s=n,o=n,a=0,c="",d=[];if(i=r.buffer.active.getLine(n)){let h=i.translateToString(!0);if(i.isWrapped&&h[0]!==" "){for(a=0;(i=r.buffer.active.getLine(--s))&&a<2048&&(c=i.translateToString(!0),a+=c.length,d.push(c),!(!i.isWrapped||c.indexOf(" ")!==-1)););d.reverse()}for(d.push(h),a=0;(i=r.buffer.active.getLine(++o))&&i.isWrapped&&a<2048&&(c=i.translateToString(!0),a+=c.length,d.push(c),c.indexOf(" ")===-1););}return[d,s]}static _mapStrIdx(n,r,i,s){let o=n.buffer.active,a=o.getNullCell(),c=i;for(;s;){let d=o.getLine(r);if(!d)return[-1,-1];for(let h=c;h<d.length;++h){d.getCell(h,a);let g=a.getChars();if(a.getWidth()&&(s-=g.length||1,h===d.length-1&&g==="")){let p=o.getLine(r+1);p&&p.isWrapped&&(p.getCell(0,a),a.getWidth()===2&&(s+=1))}if(s<0)return[r,h]}r++,c=0}return[r,c]}},B5e=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function F5e(e,n){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}var H5e=class{constructor(e=F5e,n={}){this._handler=e,this._options=n}activate(e){this._terminal=e;let n=this._options,r=n.urlRegex||B5e;this._linkProvider=this._terminal.registerLinkProvider(new L5e(this._terminal,r,this._handler,n))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const vy=Wn(),U5e=Pg();function _y(e){return e?{Authorization:`Bearer ${e}`}:{}}function V5e(e){const[n,r]=y.useState([]),[i,s]=y.useState(null),o=y.useCallback(async()=>{try{const h=await(await fetch(`${vy}/api/terminals`,{headers:_y(e)})).json();return r(h.terminals),h.terminals}catch{return[]}},[e]),a=y.useCallback(async(d,h)=>{const p=await(await fetch(`${vy}/api/terminals`,{method:"POST",headers:{"Content-Type":"application/json",..._y(e)},body:JSON.stringify({sessionId:d,workspaceRoot:h})})).json();return r(_=>[..._,p]),s(p.id),p},[e]),c=y.useCallback(async d=>{await fetch(`${vy}/api/terminals/${d}`,{method:"DELETE",headers:_y(e)}),r(h=>h.filter(g=>g.id!==d)),s(h=>h===d?null:h)},[e]);return y.useEffect(()=>{o()},[o]),{terminals:n,activeTerminalId:i,setActiveTerminalId:s,createTerminal:a,killTerminal:c,refresh:o}}function W5e({terminalId:e,className:n,token:r}){const i=y.useRef(null),s=y.useRef(null),o=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{if(!i.current)return;const c=new M5e({cursorBlink:!0,fontSize:13,fontFamily:"'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace",theme:{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",selectionBackground:"#27272a"},allowProposedApi:!0}),d=new z5e,h=new H5e;c.loadAddon(d),c.loadAddon(h),c.open(i.current),requestAnimationFrame(()=>{d.fit(),c.focus()}),s.current=c,o.current=d;let g=null,p=null,_=!1;function b(){if(_)return;const C=r?`?token=${encodeURIComponent(r)}`:"";g=new WebSocket(`${U5e}${C}`),a.current=g,g.onopen=()=>{g.send(JSON.stringify({type:"terminal.subscribe",terminalId:e}))},g.onmessage=j=>{var S;try{const E=JSON.parse(j.data);((S=E.payload)==null?void 0:S.type)==="terminal.output"&&E.payload.terminalId===e&&c.write(E.payload.data??"")}catch{}},g.onclose=()=>{_||(p=setTimeout(b,1e3))},g.onerror=()=>{}}b(),c.onData(C=>{g&&g.readyState===WebSocket.OPEN&&g.send(JSON.stringify({type:"terminal.input",terminalId:e,data:C}))}),c.onResize(({cols:C,rows:j})=>{g&&g.readyState===WebSocket.OPEN&&g.send(JSON.stringify({type:"terminal.resize",terminalId:e,cols:C,rows:j})),fetch(`${vy}/api/terminals/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json",..._y(r)},body:JSON.stringify({cols:C,rows:j})})});const x=new ResizeObserver(()=>{requestAnimationFrame(()=>d.fit())});return x.observe(i.current),()=>{_=!0,p&&clearTimeout(p),x.disconnect(),g&&g.close(),c.dispose(),s.current=null,o.current=null,a.current=null}},[e,r]),f.jsx("div",{className:`w-full overflow-hidden ${n??""}`,onClick:()=>{var c;return(c=s.current)==null?void 0:c.focus()},children:f.jsx("div",{ref:i,className:"h-full w-full"})})}function q5e({terminals:e,activeTerminalId:n,onSelect:r,onCreate:i,onKill:s}){return f.jsxs("div",{className:"flex items-center gap-1 px-2 h-8 border-b bg-muted/50 shrink-0 overflow-x-auto",children:[e.map(o=>f.jsxs("div",{role:"tab",tabIndex:0,onClick:()=>r(o.id),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&r(o.id)},className:`group flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-sm transition-colors cursor-pointer ${n===o.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-background/50"}`,children:[f.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o.state==="running"?"bg-green-500":"bg-zinc-500"}`}),f.jsx("span",{className:"truncate max-w-[100px]",children:o.id.replace(/^term-/,"").slice(0,8)}),f.jsx("button",{onClick:a=>{a.stopPropagation(),s(o.id)},className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive ml-0.5",children:"×"})]},o.id)),f.jsx("button",{onClick:i,className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:"+"})]})}const nw=Wn();function K5e({platform:e}){switch(e){case"windows":case"macos":case"linux":return f.jsx(gs,{className:"h-3.5 w-3.5"});case"android":case"ios":return f.jsx(p5,{className:"h-3.5 w-3.5"});default:return f.jsx(kr,{className:"h-3.5 w-3.5"})}}function _O({open:e,onOpenChange:n,onSelect:r,gatewayOnly:i,initialPath:s,initialNodeId:o}){const[a,c]=y.useState(null),[d,h]=y.useState(null),[g,p]=y.useState([]),[_,b]=y.useState([]),[x,C]=y.useState(!1),[j,S]=y.useState(null),[E,O]=y.useState(""),[N,T]=y.useState(!1),[P,D]=y.useState([]),[H,J]=y.useState("gateway"),I=y.useCallback(Y=>{c(Y.path),h(Y.parent),p(Y.entries),O(Y.path)},[]),B=y.useCallback(async(Y,$)=>{const R=`${nw}/api/filesystem/browse?path=${encodeURIComponent(Y)}&nodeId=${encodeURIComponent($)}`,Z=await fetch(R);if(!Z.ok){const L=await Z.json().catch(()=>({message:"Failed to browse"}));throw new Error(L.message??"Failed to browse")}return await Z.json()},[]),F=y.useCallback(async(Y,$)=>{try{C(!0),S(null),c(null),h(null),p([]);const R=`${nw}/api/filesystem/roots?nodeId=${encodeURIComponent(Y)}`,Z=await fetch(R);if(!Z.ok)throw new Error("Failed to load roots");const L=await Z.json();if(b(L.roots),$)try{const X=await B($,Y);I(X);return}catch{}const Q=L.roots.find(X=>X.name==="Home")??L.roots[0];if(Q){const X=await B(Q.path,Y);I(X)}}catch(R){S(R instanceof Error?R.message:"Failed to load")}finally{C(!1)}},[I,B]),W=y.useCallback(async(Y,$)=>{try{const R=await fetch(`${nw}/api/filesystem/nodes`);if(!R.ok)throw new Error("Failed to load nodes");const Z=await R.json();D(Z.nodes);const L=qr();let Q="gateway";if(Y&&Z.nodes.some(X=>X.id===Y)&&(Q=Y),Q==="gateway"&&(L==="electron"||L==="capacitor")){const X=o4(),ie=Z.nodes.find(se=>se.id===X);ie&&(Q=ie.id)}J(Q),await F(Q,Y===Q?$:null)}catch(R){S(R instanceof Error?R.message:"Failed to load nodes")}},[F]);y.useEffect(()=>{if(e){if(i){J("gateway"),F("gateway",s);return}W(o,s)}},[e,i,o,s,W,F]);const z=y.useCallback(async(Y,$)=>{const R=$??H;try{C(!0),S(null);const Z=await B(Y,R);I(Z)}catch(Z){S(Z instanceof Error?Z.message:"Failed to browse")}finally{C(!1)}},[I,B,H]),V=y.useCallback(Y=>{J(Y),F(Y)},[F]),A=y.useCallback(()=>{a&&(r(a,H),n(!1))},[a,H,r,n]),U=y.useCallback(()=>{E.trim()&&(z(E.trim()),T(!1))},[E,z]),K=g.filter(Y=>Y.type==="dir");return f.jsx(Cu,{open:e,onOpenChange:n,children:f.jsxs(fc,{className:"max-w-md sm:max-w-lg p-0 gap-0 overflow-hidden",children:[f.jsx(Ga,{className:"px-4 pt-4 pb-2",children:f.jsxs(Ya,{className:"flex items-center gap-2 text-base",children:[f.jsx(fu,{className:"h-4 w-4"}),"Open Workspace"]})}),!i&&P.length>1&&f.jsx("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b bg-muted/20 overflow-x-auto",children:P.map(Y=>f.jsxs("button",{onClick:()=>V(Y.id),className:We("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs whitespace-nowrap transition-colors",H===Y.id?"bg-primary text-primary-foreground":"hover:bg-accent hover:text-accent-foreground text-muted-foreground"),children:[f.jsx(K5e,{platform:Y.platform}),f.jsx("span",{children:Y.name})]},Y.id))}),f.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b text-xs text-muted-foreground bg-muted/30",children:[_.filter(Y=>Y.name!=="Home").map(Y=>f.jsxs("button",{onClick:()=>void z(Y.path),className:"px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground flex items-center gap-1",title:Y.path,children:[f.jsx(JI,{className:"h-3 w-3"}),f.jsx("span",{children:Y.name})]},Y.path)),f.jsx("button",{onClick:()=>{const Y=_.find($=>$.name==="Home");Y&&z(Y.path)},className:"px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground flex items-center gap-1",title:"Home directory",children:f.jsx(BO,{className:"h-3 w-3"})}),f.jsx("div",{className:"h-3 w-px bg-border mx-1"}),d&&f.jsx("button",{onClick:()=>void z(d),className:"px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground flex items-center gap-1",title:"Go up",children:f.jsx(MO,{className:"h-3 w-3"})}),f.jsx("button",{onClick:()=>T(Y=>!Y),className:"ml-auto px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground text-[10px]",children:N?"Browse":"Enter path"})]}),N&&f.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b bg-muted/20",children:[f.jsx("input",{type:"text",value:E,onChange:Y=>O(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&U()},className:"flex-1 h-7 px-2 text-xs border rounded bg-background focus:outline-none focus:ring-1 focus:ring-ring",placeholder:"Enter absolute path...",autoFocus:!0}),f.jsx($e,{size:"sm",variant:"secondary",className:"h-7 text-xs",onClick:U,children:"Go"})]}),f.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-muted-foreground truncate border-b",children:a??"..."}),f.jsx("div",{className:"overflow-y-auto min-h-[120px] max-h-[50vh]",children:f.jsxs("div",{className:"p-2",children:[x&&f.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[f.jsx(kt,{className:"h-4 w-4 animate-spin mr-2"}),"Loading..."]}),j&&f.jsx("div",{className:"text-destructive text-xs py-4 text-center",children:j}),!x&&!j&&K.length===0&&f.jsx("div",{className:"text-muted-foreground text-xs py-4 text-center",children:"No subdirectories"}),!x&&!j&&K.map(Y=>f.jsxs("button",{onClick:()=>void z(Y.path),className:We("w-full flex items-center gap-2 px-2 py-1.5 rounded text-xs text-left","hover:bg-accent hover:text-accent-foreground transition-colors"),children:[f.jsx(YI,{className:"h-3.5 w-3.5 text-yellow-500 shrink-0"}),f.jsx("span",{className:"truncate",children:Y.name}),f.jsx(xo,{className:"h-3 w-3 ml-auto text-muted-foreground shrink-0"})]},Y.path))]})}),f.jsxs(_g,{className:"px-4 py-3 border-t",children:[f.jsx($e,{variant:"ghost",size:"sm",onClick:()=>n(!1),children:"Cancel"}),f.jsxs($e,{size:"sm",onClick:A,disabled:!a,children:[f.jsx(fu,{className:"h-3.5 w-3.5 mr-1.5"}),"Open this folder"]})]})]})})}function bO(e){return{id:e.id??`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,source:e.source,title:e.title,detail:e.detail,createdAt:e.createdAt??new Date().toISOString()}}const eu=Wn(),rw={theme:"system",api_keys:{},stt_provider:"simulated",chat_provider:"jait",workspace_picker_path:null,workspace_picker_node_id:null,updated_at:new Date(0).toISOString()};async function iw(e){try{const n=await fetch(`${eu}/auth/settings`,{headers:{Authorization:`Bearer ${e}`}});return n.ok?await n.json():null}catch{return null}}function G5e(){const[e,n]=y.useState({user:null,token:null,settings:null,isLoading:!0}),r=y.useCallback(async p=>{try{const _=await fetch(`${eu}/auth/me`,{headers:{Authorization:`Bearer ${p}`}});if(!_.ok){Fx(),n({user:null,token:null,settings:null,isLoading:!1});return}const b=await _.json(),x=await iw(p);n({user:b,token:p,settings:x??rw,isLoading:!1})}catch{Fx(),n({user:null,token:null,settings:null,isLoading:!1})}},[]);y.useEffect(()=>{const p=ou();if(p){r(p);return}n(_=>({..._,isLoading:!1}))},[r]);const i=y.useCallback(async p=>{_ie(p.access_token);const _=await iw(p.access_token);n({user:p.user,token:p.access_token,settings:_??rw,isLoading:!1})},[]),s=y.useCallback(async(p,_)=>{const b=await fetch(`${eu}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:p,password:_})});if(!b.ok){const C=await b.json().catch(()=>({detail:"Login failed"}));throw new Error(C.detail??"Login failed")}const x=await b.json();return await i(x),x},[i]),o=y.useCallback(async(p,_)=>{const b=await fetch(`${eu}/auth/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:p,password:_})});if(!b.ok){const C=await b.json().catch(()=>({detail:"Registration failed"}));throw new Error(C.detail??"Registration failed")}const x=await b.json();return await i(x),x},[i]),a=y.useCallback(()=>{Fx(),n({user:null,token:null,settings:null,isLoading:!1})},[]),c=y.useCallback(async()=>{if(!e.token)return null;const p=await iw(e.token);return p?(n(_=>({..._,settings:p})),p):null},[e.token]),d=y.useCallback(async p=>{if(!e.token)throw new Error("Not authenticated");const _=await fetch(`${eu}/auth/settings`,{method:"PATCH",headers:{Authorization:`Bearer ${e.token}`,"Content-Type":"application/json"},body:JSON.stringify(p)});if(!_.ok){const x=await _.json().catch(()=>({detail:"Failed to update settings"}));throw new Error(x.detail??"Failed to update settings")}const b=await _.json();return n(x=>({...x,settings:b})),b},[e.token]),h=y.useCallback(async()=>{if(!e.token)throw new Error("Not authenticated");const p=await fetch(`${eu}/auth/settings/archive`,{method:"DELETE",headers:{Authorization:`Bearer ${e.token}`}});if(!p.ok){const _=await p.json().catch(()=>({detail:"Failed to clear archive"}));throw new Error(_.detail??"Failed to clear archive")}return await p.json()},[e.token]),g=y.useCallback(async p=>{if(e.token)try{await fetch(`${eu}/auth/session/bind`,{method:"POST",headers:{Authorization:`Bearer ${e.token}`,"Content-Type":"application/json"},body:JSON.stringify({session_id:p})})}catch{}},[e.token]);return{user:e.user,token:e.token,settings:e.settings??rw,isLoading:e.isLoading,isAuthenticated:!!e.user,login:s,register:o,logout:a,bindSession:g,refreshSettings:c,updateSettings:d,clearSessionArchive:h}}const oo=Wn(),Y5e=120;function sw(e){return e?{Authorization:`Bearer ${e}`}:{}}function X5e(e,n,r){const i=e.findIndex(c=>c.id===n),s=e.findIndex(c=>c.id===r);if(i<0||s<0||i===s)return e;const o=[...e],[a]=o.splice(i,1);return o.splice(s,0,a),o}function J5e(e,n,r){const[i,s]=y.useState({messages:[],isLoading:!1,isLoadingHistory:!1,promptCount:0,remainingPrompts:null,error:null,hitMaxRounds:!1}),[o,a]=y.useState(null),[c,d]=y.useState([]),[h,g]=y.useState([]),[p,_]=y.useState([]),[b,x]=y.useState(null),[C,j]=y.useState(null),S=y.useRef(!1),E=y.useRef(null),O=y.useRef(null),N=y.useRef(null),T=y.useRef(0),P=y.useRef(!1),[D,H]=y.useState(0),J=y.useCallback(()=>{e&&(O.current=null,H(Ce=>Ce+1))},[e]);y.useEffect(()=>{if(e===O.current)return;if(T.current+=1,O.current=e,E.current=null,N.current&&(N.current.abort(),N.current=null),!e){s({messages:[],isLoading:!1,isLoadingHistory:!1,promptCount:0,remainingPrompts:null,hitMaxRounds:!1,error:null}),d([]),g([]),_([]),x(null);return}let Ce=!1;s(Ye=>({...Ye,messages:[],isLoading:!1,isLoadingHistory:!0,error:null})),x(null);const me=new AbortController;return N.current=me,(async()=>{var Ye,tt,Ue;try{const mt=await fetch(`${oo}/api/sessions/${e}/stream?limit=${Y5e}`,{signal:me.signal,headers:sw(n)});if(mt.status===401){r==null||r(),s(Pe=>({...Pe,isLoadingHistory:!1}));return}if(!mt.ok||Ce)return;const Dt=(Ye=mt.body)==null?void 0:Ye.getReader();if(!Dt)return;const Et=new TextDecoder;let St="",Ct=null;const qe=(Pe,Fe)=>{const re=Pe?[...Pe]:[],he=re[re.length-1];return(he==null?void 0:he.type)==="text"?re[re.length-1]={type:"text",content:he.content+Fe}:re.push({type:"text",content:Fe}),re},Ne=(Pe,Fe)=>{const re=Pe?[...Pe]:[],he=re[re.length-1];return(he==null?void 0:he.type)==="toolGroup"?he.callIds.includes(Fe)||(re[re.length-1]={type:"toolGroup",callIds:[...he.callIds,Fe]}):re.push({type:"toolGroup",callIds:[Fe]}),re};for(;;){const{done:Pe,value:Fe}=await Dt.read();if(Pe)break;if(Ce){Dt.cancel();break}St+=Et.decode(Fe,{stream:!0});const re=St.split(`
|
|
805
|
+
*/var $5e=class{constructor(e,n,r,i={}){this._terminal=e,this._regex=n,this._handler=r,this._options=i}provideLinks(e,n){let r=B5e.computeLink(e,this._regex,this._terminal,this._handler);n(this._addCallbacks(r))}_addCallbacks(e){return e.map(n=>(n.leave=this._options.leave,n.hover=(r,i)=>{if(this._options.hover){let{range:s}=n;this._options.hover(r,i,s)}},n))}};function I5e(e){try{let n=new URL(e),r=n.password&&n.username?`${n.protocol}//${n.username}:${n.password}@${n.host}`:n.username?`${n.protocol}//${n.username}@${n.host}`:`${n.protocol}//${n.host}`;return e.toLocaleLowerCase().startsWith(r.toLocaleLowerCase())}catch{return!1}}var B5e=class yy{static computeLink(n,r,i,s){let o=new RegExp(r.source,(r.flags||"")+"g"),[a,c]=yy._getWindowedLineStrings(n-1,i),d=a.join(""),h,g=[];for(;h=o.exec(d);){let p=h[0];if(!I5e(p))continue;let[_,b]=yy._mapStrIdx(i,c,0,h.index),[x,C]=yy._mapStrIdx(i,_,b,p.length);if(_===-1||b===-1||x===-1||C===-1)continue;let j={start:{x:b+1,y:_+1},end:{x:C,y:x+1}};g.push({range:j,text:p,activate:s})}return g}static _getWindowedLineStrings(n,r){let i,s=n,o=n,a=0,c="",d=[];if(i=r.buffer.active.getLine(n)){let h=i.translateToString(!0);if(i.isWrapped&&h[0]!==" "){for(a=0;(i=r.buffer.active.getLine(--s))&&a<2048&&(c=i.translateToString(!0),a+=c.length,d.push(c),!(!i.isWrapped||c.indexOf(" ")!==-1)););d.reverse()}for(d.push(h),a=0;(i=r.buffer.active.getLine(++o))&&i.isWrapped&&a<2048&&(c=i.translateToString(!0),a+=c.length,d.push(c),c.indexOf(" ")===-1););}return[d,s]}static _mapStrIdx(n,r,i,s){let o=n.buffer.active,a=o.getNullCell(),c=i;for(;s;){let d=o.getLine(r);if(!d)return[-1,-1];for(let h=c;h<d.length;++h){d.getCell(h,a);let g=a.getChars();if(a.getWidth()&&(s-=g.length||1,h===d.length-1&&g==="")){let p=o.getLine(r+1);p&&p.isWrapped&&(p.getCell(0,a),a.getWidth()===2&&(s+=1))}if(s<0)return[r,h]}r++,c=0}return[r,c]}},F5e=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function H5e(e,n){let r=window.open();if(r){try{r.opener=null}catch{}r.location.href=n}else console.warn("Opening link blocked as opener could not be cleared")}var U5e=class{constructor(e=H5e,n={}){this._handler=e,this._options=n}activate(e){this._terminal=e;let n=this._options,r=n.urlRegex||F5e;this._linkProvider=this._terminal.registerLinkProvider(new $5e(this._terminal,r,this._handler,n))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const vy=Wn(),V5e=Pg();function _y(e){return e?{Authorization:`Bearer ${e}`}:{}}function W5e(e){const[n,r]=y.useState([]),[i,s]=y.useState(null),o=y.useCallback(async()=>{try{const h=await(await fetch(`${vy}/api/terminals`,{headers:_y(e)})).json();return r(h.terminals),h.terminals}catch{return[]}},[e]),a=y.useCallback(async(d,h)=>{const p=await(await fetch(`${vy}/api/terminals`,{method:"POST",headers:{"Content-Type":"application/json",..._y(e)},body:JSON.stringify({sessionId:d,workspaceRoot:h})})).json();return r(_=>[..._,p]),s(p.id),p},[e]),c=y.useCallback(async d=>{await fetch(`${vy}/api/terminals/${d}`,{method:"DELETE",headers:_y(e)}),r(h=>h.filter(g=>g.id!==d)),s(h=>h===d?null:h)},[e]);return y.useEffect(()=>{o()},[o]),{terminals:n,activeTerminalId:i,setActiveTerminalId:s,createTerminal:a,killTerminal:c,refresh:o}}function q5e({terminalId:e,className:n,token:r}){const i=y.useRef(null),s=y.useRef(null),o=y.useRef(null),a=y.useRef(null);return y.useEffect(()=>{if(!i.current)return;const c=new R5e({cursorBlink:!0,fontSize:13,fontFamily:"'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace",theme:{background:"#0a0a0a",foreground:"#e4e4e7",cursor:"#e4e4e7",selectionBackground:"#27272a"},allowProposedApi:!0}),d=new L5e,h=new U5e;c.loadAddon(d),c.loadAddon(h),c.open(i.current),requestAnimationFrame(()=>{d.fit(),c.focus()}),s.current=c,o.current=d;let g=null,p=null,_=!1;function b(){if(_)return;const C=r?`?token=${encodeURIComponent(r)}`:"";g=new WebSocket(`${V5e}${C}`),a.current=g,g.onopen=()=>{g.send(JSON.stringify({type:"terminal.subscribe",terminalId:e}))},g.onmessage=j=>{var S;try{const E=JSON.parse(j.data);((S=E.payload)==null?void 0:S.type)==="terminal.output"&&E.payload.terminalId===e&&c.write(E.payload.data??"")}catch{}},g.onclose=()=>{_||(p=setTimeout(b,1e3))},g.onerror=()=>{}}b(),c.onData(C=>{g&&g.readyState===WebSocket.OPEN&&g.send(JSON.stringify({type:"terminal.input",terminalId:e,data:C}))}),c.onResize(({cols:C,rows:j})=>{g&&g.readyState===WebSocket.OPEN&&g.send(JSON.stringify({type:"terminal.resize",terminalId:e,cols:C,rows:j})),fetch(`${vy}/api/terminals/${e}/resize`,{method:"POST",headers:{"Content-Type":"application/json",..._y(r)},body:JSON.stringify({cols:C,rows:j})})});const x=new ResizeObserver(()=>{requestAnimationFrame(()=>d.fit())});return x.observe(i.current),()=>{_=!0,p&&clearTimeout(p),x.disconnect(),g&&g.close(),c.dispose(),s.current=null,o.current=null,a.current=null}},[e,r]),f.jsx("div",{className:`w-full overflow-hidden ${n??""}`,onClick:()=>{var c;return(c=s.current)==null?void 0:c.focus()},children:f.jsx("div",{ref:i,className:"h-full w-full"})})}function K5e({terminals:e,activeTerminalId:n,onSelect:r,onCreate:i,onKill:s}){return f.jsxs("div",{className:"flex items-center gap-1 px-2 h-8 border-b bg-muted/50 shrink-0 overflow-x-auto",children:[e.map(o=>f.jsxs("div",{role:"tab",tabIndex:0,onClick:()=>r(o.id),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&r(o.id)},className:`group flex items-center gap-1.5 px-2.5 py-1 text-xs rounded-sm transition-colors cursor-pointer ${n===o.id?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground hover:bg-background/50"}`,children:[f.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${o.state==="running"?"bg-green-500":"bg-zinc-500"}`}),f.jsx("span",{className:"truncate max-w-[100px]",children:o.id.replace(/^term-/,"").slice(0,8)}),f.jsx("button",{onClick:a=>{a.stopPropagation(),s(o.id)},className:"opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-destructive ml-0.5",children:"×"})]},o.id)),f.jsx("button",{onClick:i,className:"px-2 py-1 text-xs text-muted-foreground hover:text-foreground transition-colors",children:"+"})]})}const nw=Wn();function G5e({platform:e}){switch(e){case"windows":case"macos":case"linux":return f.jsx(gs,{className:"h-3.5 w-3.5"});case"android":case"ios":return f.jsx(p5,{className:"h-3.5 w-3.5"});default:return f.jsx(kr,{className:"h-3.5 w-3.5"})}}function _O({open:e,onOpenChange:n,onSelect:r,gatewayOnly:i,initialPath:s,initialNodeId:o}){const[a,c]=y.useState(null),[d,h]=y.useState(null),[g,p]=y.useState([]),[_,b]=y.useState([]),[x,C]=y.useState(!1),[j,S]=y.useState(null),[E,O]=y.useState(""),[N,T]=y.useState(!1),[P,D]=y.useState([]),[H,J]=y.useState("gateway"),I=y.useCallback(Y=>{c(Y.path),h(Y.parent),p(Y.entries),O(Y.path)},[]),B=y.useCallback(async(Y,$)=>{const R=`${nw}/api/filesystem/browse?path=${encodeURIComponent(Y)}&nodeId=${encodeURIComponent($)}`,Z=await fetch(R);if(!Z.ok){const L=await Z.json().catch(()=>({message:"Failed to browse"}));throw new Error(L.message??"Failed to browse")}return await Z.json()},[]),F=y.useCallback(async(Y,$)=>{try{C(!0),S(null),c(null),h(null),p([]);const R=`${nw}/api/filesystem/roots?nodeId=${encodeURIComponent(Y)}`,Z=await fetch(R);if(!Z.ok)throw new Error("Failed to load roots");const L=await Z.json();if(b(L.roots),$)try{const X=await B($,Y);I(X);return}catch{}const Q=L.roots.find(X=>X.name==="Home")??L.roots[0];if(Q){const X=await B(Q.path,Y);I(X)}}catch(R){S(R instanceof Error?R.message:"Failed to load")}finally{C(!1)}},[I,B]),W=y.useCallback(async(Y,$)=>{try{const R=await fetch(`${nw}/api/filesystem/nodes`);if(!R.ok)throw new Error("Failed to load nodes");const Z=await R.json();D(Z.nodes);const L=qr();let Q="gateway";if(Y&&Z.nodes.some(X=>X.id===Y)&&(Q=Y),Q==="gateway"&&(L==="electron"||L==="capacitor")){const X=o4(),ie=Z.nodes.find(se=>se.id===X);ie&&(Q=ie.id)}J(Q),await F(Q,Y===Q?$:null)}catch(R){S(R instanceof Error?R.message:"Failed to load nodes")}},[F]);y.useEffect(()=>{if(e){if(i){J("gateway"),F("gateway",s);return}W(o,s)}},[e,i,o,s,W,F]);const z=y.useCallback(async(Y,$)=>{const R=$??H;try{C(!0),S(null);const Z=await B(Y,R);I(Z)}catch(Z){S(Z instanceof Error?Z.message:"Failed to browse")}finally{C(!1)}},[I,B,H]),V=y.useCallback(Y=>{J(Y),F(Y)},[F]),A=y.useCallback(()=>{a&&(r(a,H),n(!1))},[a,H,r,n]),U=y.useCallback(()=>{E.trim()&&(z(E.trim()),T(!1))},[E,z]),K=g.filter(Y=>Y.type==="dir");return f.jsx(Cu,{open:e,onOpenChange:n,children:f.jsxs(fc,{className:"max-w-md sm:max-w-lg p-0 gap-0 overflow-hidden",children:[f.jsx(Ga,{className:"px-4 pt-4 pb-2",children:f.jsxs(Ya,{className:"flex items-center gap-2 text-base",children:[f.jsx(fu,{className:"h-4 w-4"}),"Open Workspace"]})}),!i&&P.length>1&&f.jsx("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b bg-muted/20 overflow-x-auto",children:P.map(Y=>f.jsxs("button",{onClick:()=>V(Y.id),className:We("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs whitespace-nowrap transition-colors",H===Y.id?"bg-primary text-primary-foreground":"hover:bg-accent hover:text-accent-foreground text-muted-foreground"),children:[f.jsx(G5e,{platform:Y.platform}),f.jsx("span",{children:Y.name})]},Y.id))}),f.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b text-xs text-muted-foreground bg-muted/30",children:[_.filter(Y=>Y.name!=="Home").map(Y=>f.jsxs("button",{onClick:()=>void z(Y.path),className:"px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground flex items-center gap-1",title:Y.path,children:[f.jsx(JI,{className:"h-3 w-3"}),f.jsx("span",{children:Y.name})]},Y.path)),f.jsx("button",{onClick:()=>{const Y=_.find($=>$.name==="Home");Y&&z(Y.path)},className:"px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground flex items-center gap-1",title:"Home directory",children:f.jsx(BO,{className:"h-3 w-3"})}),f.jsx("div",{className:"h-3 w-px bg-border mx-1"}),d&&f.jsx("button",{onClick:()=>void z(d),className:"px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground flex items-center gap-1",title:"Go up",children:f.jsx(MO,{className:"h-3 w-3"})}),f.jsx("button",{onClick:()=>T(Y=>!Y),className:"ml-auto px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground text-[10px]",children:N?"Browse":"Enter path"})]}),N&&f.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b bg-muted/20",children:[f.jsx("input",{type:"text",value:E,onChange:Y=>O(Y.target.value),onKeyDown:Y=>{Y.key==="Enter"&&U()},className:"flex-1 h-7 px-2 text-xs border rounded bg-background focus:outline-none focus:ring-1 focus:ring-ring",placeholder:"Enter absolute path...",autoFocus:!0}),f.jsx($e,{size:"sm",variant:"secondary",className:"h-7 text-xs",onClick:U,children:"Go"})]}),f.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-muted-foreground truncate border-b",children:a??"..."}),f.jsx("div",{className:"overflow-y-auto min-h-[120px] max-h-[50vh]",children:f.jsxs("div",{className:"p-2",children:[x&&f.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[f.jsx(kt,{className:"h-4 w-4 animate-spin mr-2"}),"Loading..."]}),j&&f.jsx("div",{className:"text-destructive text-xs py-4 text-center",children:j}),!x&&!j&&K.length===0&&f.jsx("div",{className:"text-muted-foreground text-xs py-4 text-center",children:"No subdirectories"}),!x&&!j&&K.map(Y=>f.jsxs("button",{onClick:()=>void z(Y.path),className:We("w-full flex items-center gap-2 px-2 py-1.5 rounded text-xs text-left","hover:bg-accent hover:text-accent-foreground transition-colors"),children:[f.jsx(YI,{className:"h-3.5 w-3.5 text-yellow-500 shrink-0"}),f.jsx("span",{className:"truncate",children:Y.name}),f.jsx(xo,{className:"h-3 w-3 ml-auto text-muted-foreground shrink-0"})]},Y.path))]})}),f.jsxs(_g,{className:"px-4 py-3 border-t",children:[f.jsx($e,{variant:"ghost",size:"sm",onClick:()=>n(!1),children:"Cancel"}),f.jsxs($e,{size:"sm",onClick:A,disabled:!a,children:[f.jsx(fu,{className:"h-3.5 w-3.5 mr-1.5"}),"Open this folder"]})]})]})})}function bO(e){return{id:e.id??`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,source:e.source,title:e.title,detail:e.detail,createdAt:e.createdAt??new Date().toISOString()}}const eu=Wn(),rw={theme:"system",api_keys:{},stt_provider:"simulated",chat_provider:"jait",workspace_picker_path:null,workspace_picker_node_id:null,updated_at:new Date(0).toISOString()};async function iw(e){try{const n=await fetch(`${eu}/auth/settings`,{headers:{Authorization:`Bearer ${e}`}});return n.ok?await n.json():null}catch{return null}}function Y5e(){const[e,n]=y.useState({user:null,token:null,settings:null,isLoading:!0}),r=y.useCallback(async p=>{try{const _=await fetch(`${eu}/auth/me`,{headers:{Authorization:`Bearer ${p}`}});if(!_.ok){Fx(),n({user:null,token:null,settings:null,isLoading:!1});return}const b=await _.json(),x=await iw(p);n({user:b,token:p,settings:x??rw,isLoading:!1})}catch{Fx(),n({user:null,token:null,settings:null,isLoading:!1})}},[]);y.useEffect(()=>{const p=ou();if(p){r(p);return}n(_=>({..._,isLoading:!1}))},[r]);const i=y.useCallback(async p=>{_ie(p.access_token);const _=await iw(p.access_token);n({user:p.user,token:p.access_token,settings:_??rw,isLoading:!1})},[]),s=y.useCallback(async(p,_)=>{const b=await fetch(`${eu}/auth/login`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:p,password:_})});if(!b.ok){const C=await b.json().catch(()=>({detail:"Login failed"}));throw new Error(C.detail??"Login failed")}const x=await b.json();return await i(x),x},[i]),o=y.useCallback(async(p,_)=>{const b=await fetch(`${eu}/auth/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:p,password:_})});if(!b.ok){const C=await b.json().catch(()=>({detail:"Registration failed"}));throw new Error(C.detail??"Registration failed")}const x=await b.json();return await i(x),x},[i]),a=y.useCallback(()=>{Fx(),n({user:null,token:null,settings:null,isLoading:!1})},[]),c=y.useCallback(async()=>{if(!e.token)return null;const p=await iw(e.token);return p?(n(_=>({..._,settings:p})),p):null},[e.token]),d=y.useCallback(async p=>{if(!e.token)throw new Error("Not authenticated");const _=await fetch(`${eu}/auth/settings`,{method:"PATCH",headers:{Authorization:`Bearer ${e.token}`,"Content-Type":"application/json"},body:JSON.stringify(p)});if(!_.ok){const x=await _.json().catch(()=>({detail:"Failed to update settings"}));throw new Error(x.detail??"Failed to update settings")}const b=await _.json();return n(x=>({...x,settings:b})),b},[e.token]),h=y.useCallback(async()=>{if(!e.token)throw new Error("Not authenticated");const p=await fetch(`${eu}/auth/settings/archive`,{method:"DELETE",headers:{Authorization:`Bearer ${e.token}`}});if(!p.ok){const _=await p.json().catch(()=>({detail:"Failed to clear archive"}));throw new Error(_.detail??"Failed to clear archive")}return await p.json()},[e.token]),g=y.useCallback(async p=>{if(e.token)try{await fetch(`${eu}/auth/session/bind`,{method:"POST",headers:{Authorization:`Bearer ${e.token}`,"Content-Type":"application/json"},body:JSON.stringify({session_id:p})})}catch{}},[e.token]);return{user:e.user,token:e.token,settings:e.settings??rw,isLoading:e.isLoading,isAuthenticated:!!e.user,login:s,register:o,logout:a,bindSession:g,refreshSettings:c,updateSettings:d,clearSessionArchive:h}}const oo=Wn(),X5e=120;function sw(e){return e?{Authorization:`Bearer ${e}`}:{}}function J5e(e,n,r){const i=e.findIndex(c=>c.id===n),s=e.findIndex(c=>c.id===r);if(i<0||s<0||i===s)return e;const o=[...e],[a]=o.splice(i,1);return o.splice(s,0,a),o}function Z5e(e,n,r){const[i,s]=y.useState({messages:[],isLoading:!1,isLoadingHistory:!1,promptCount:0,remainingPrompts:null,error:null,hitMaxRounds:!1}),[o,a]=y.useState(null),[c,d]=y.useState([]),[h,g]=y.useState([]),[p,_]=y.useState([]),[b,x]=y.useState(null),[C,j]=y.useState(null),S=y.useRef(!1),E=y.useRef(null),O=y.useRef(null),N=y.useRef(null),T=y.useRef(0),P=y.useRef(!1),[D,H]=y.useState(0),J=y.useCallback(()=>{e&&(O.current=null,H(Ce=>Ce+1))},[e]);y.useEffect(()=>{if(e===O.current)return;if(T.current+=1,O.current=e,E.current=null,N.current&&(N.current.abort(),N.current=null),!e){s({messages:[],isLoading:!1,isLoadingHistory:!1,promptCount:0,remainingPrompts:null,hitMaxRounds:!1,error:null}),d([]),g([]),_([]),x(null);return}let Ce=!1;s(Ye=>({...Ye,messages:[],isLoading:!1,isLoadingHistory:!0,error:null})),x(null);const me=new AbortController;return N.current=me,(async()=>{var Ye,tt,Ue;try{const mt=await fetch(`${oo}/api/sessions/${e}/stream?limit=${X5e}`,{signal:me.signal,headers:sw(n)});if(mt.status===401){r==null||r(),s(Pe=>({...Pe,isLoadingHistory:!1}));return}if(!mt.ok||Ce)return;const Dt=(Ye=mt.body)==null?void 0:Ye.getReader();if(!Dt)return;const Et=new TextDecoder;let St="",Ct=null;const qe=(Pe,Fe)=>{const re=Pe?[...Pe]:[],he=re[re.length-1];return(he==null?void 0:he.type)==="text"?re[re.length-1]={type:"text",content:he.content+Fe}:re.push({type:"text",content:Fe}),re},Ne=(Pe,Fe)=>{const re=Pe?[...Pe]:[],he=re[re.length-1];return(he==null?void 0:he.type)==="toolGroup"?he.callIds.includes(Fe)||(re[re.length-1]={type:"toolGroup",callIds:[...he.callIds,Fe]}):re.push({type:"toolGroup",callIds:[Fe]}),re};for(;;){const{done:Pe,value:Fe}=await Dt.read();if(Pe)break;if(Ce){Dt.cancel();break}St+=Et.decode(Fe,{stream:!0});const re=St.split(`
|
|
806
806
|
`);St=re.pop()||"";for(const he of re)if(he.startsWith("data: "))try{const _e=JSON.parse(he.slice(6));if(Wx(String(_e.type??"unknown"),he.slice(6)),_e.type==="snapshot"){const ke=_e.messages,Oe=_e.streaming,Ie=ke.map(Ke=>{const ht={id:Ke.id,role:Ke.role,content:Ke.content};return Ke.segments&&Ke.segments.length>0&&(ht.segments=Ke.segments),Ke.toolCalls&&Ke.toolCalls.length>0&&(ht.toolCalls=Ke.toolCalls.map(de=>{let gt=de.status??(de.ok?"success":"error");return(gt==="running"||gt==="pending")&&!Oe&&(gt="error"),{callId:de.callId,tool:de.tool,args:de.args??{},status:gt,result:gt==="running"?void 0:{ok:!!de.ok,message:de.message??"Cancelled",data:de.data??(de.output!=null?{output:de.output}:void 0)},streamingOutput:de.streamingOutput,startedAt:de.startedAt??0,completedAt:de.completedAt??0}})),ht}),Ae=Ie[Ie.length-1];(Ae==null?void 0:Ae.role)==="assistant"&&(Ct=Ae.id),s(Ke=>({...Ke,messages:Ie,isLoadingHistory:!1,isLoading:Oe}))}else if(_e.type==="token"&&Ct){const ke=_e.content;s(Oe=>({...Oe,messages:Oe.messages.map(Ie=>Ie.id===Ct?{...Ie,content:Ie.content+ke,segments:qe(Ie.segments,ke)}:Ie)}))}else if(_e.type==="tool_call_delta"&&Ct){const ke=_e.call_id,Oe=_e.name_delta||"",Ie=_e.args_delta||"";s(Ae=>{var gt;const Ke=Ae.messages.find(Le=>Le.id===Ct);if((gt=Ke==null?void 0:Ke.toolCalls)==null?void 0:gt.find(Le=>Le.callId===ke))return{...Ae,messages:Ae.messages.map(Le=>{var Je;return Le.id===Ct?{...Le,toolCalls:(Je=Le.toolCalls)==null?void 0:Je.map(rt=>rt.callId===ke?{...rt,tool:rt.tool+Oe,streamingArgs:(rt.streamingArgs??"")+Ie}:rt)}:Le})};const de={callId:ke,tool:Oe,args:{},status:"pending",streamingArgs:Ie,startedAt:Date.now()};return{...Ae,messages:Ae.messages.map(Le=>Le.id===Ct?{...Le,toolCalls:[...Le.toolCalls??[],de],segments:Ne(Le.segments,ke)}:Le)}})}else if(_e.type==="tool_start"&&Ct){const ke=_e.call_id;s(Oe=>{var ht;const Ie=Oe.messages.find(de=>de.id===Ct);if((ht=Ie==null?void 0:Ie.toolCalls)==null?void 0:ht.find(de=>de.callId===ke))return{...Oe,messages:Oe.messages.map(de=>{var gt;return de.id===Ct?{...de,toolCalls:(gt=de.toolCalls)==null?void 0:gt.map(Le=>Le.callId===ke?{...Le,tool:_e.tool,args:_e.args??{},status:"running",streamingArgs:void 0}:Le)}:de})};const Ke={callId:ke,tool:_e.tool,args:_e.args??{},status:"running",startedAt:Date.now()};return{...Oe,messages:Oe.messages.map(de=>de.id===Ct?{...de,toolCalls:[...de.toolCalls??[],Ke],segments:Ne(de.segments,ke)}:de)}})}else if(_e.type==="tool_output"&&Ct)s(ke=>({...ke,messages:ke.messages.map(Oe=>{var Ie;return Oe.id!==Ct?Oe:{...Oe,toolCalls:(Ie=Oe.toolCalls)==null?void 0:Ie.map(Ae=>Ae.callId===_e.call_id?{...Ae,streamingOutput:(Ae.streamingOutput??"")+_e.content}:Ae)}})}));else if(_e.type==="tool_result"&&Ct){if(s(ke=>({...ke,messages:ke.messages.map(Oe=>{var Ie;return Oe.id!==Ct?Oe:{...Oe,toolCalls:(Ie=Oe.toolCalls)==null?void 0:Ie.map(Ae=>Ae.callId===_e.call_id?{...Ae,status:_e.ok?"success":"error",result:{ok:_e.ok,message:_e.message,data:_e.data},completedAt:Date.now()}:Ae)}})})),_e.ok){const ke=i.messages.find(Ie=>Ie.id===Ct),Oe=(tt=ke==null?void 0:ke.toolCalls)==null?void 0:tt.find(Ie=>Ie.callId===_e.call_id);if(Oe){const Ie=Oe.tool.replace("_",".");if(Ie==="file.write"||Ie==="file.patch"||Ie==="edit"){const Ae=String(((Ue=Oe.args)==null?void 0:Ue.path)??"");if(Ae){const Ke=Ae.split("/").pop()??Ae;g(ht=>ht.some(de=>de.path===Ae)?ht:[...ht,{path:Ae,name:Ke,state:"undecided"}])}}}}}else if(_e.type==="todo_list"){const ke=_e.items;d(ke)}else if(_e.type==="context_usage")x(_e);else if(_e.type==="session_info")j({provider:_e.provider,workspacePath:_e.workspacePath,isRemote:_e.isRemote,remoteNode:_e.remoteNode});else if(_e.type==="file_changed"){const ke=_e.path,Oe=_e.name;g(Ie=>Ie.find(Ke=>Ke.path===ke)?Ie:[...Ie,{path:ke,name:Oe,state:"undecided"}])}else _e.type==="done"?s(ke=>({...ke,isLoading:!1,promptCount:_e.prompt_count??ke.promptCount,remainingPrompts:_e.remaining_prompts??ke.remainingPrompts,messages:ke.messages.map(Oe=>{var Ie;return(Ie=Oe.toolCalls)!=null&&Ie.some(Ae=>Ae.status==="running")?{...Oe,toolCalls:Oe.toolCalls.map(Ae=>Ae.status==="running"?{...Ae,status:"error",result:{ok:!1,message:"Cancelled"},completedAt:Date.now()}:Ae)}:Oe})})):_e.type==="error"&&s(ke=>({...ke,isLoading:!1,error:_e.message}))}catch(_e){if(!(_e instanceof SyntaxError))throw _e}}}catch(mt){if(mt instanceof Error&&mt.name==="AbortError")return;Ce||s(Dt=>({...Dt,isLoadingHistory:!1}))}})(),()=>{Ce=!0,me.abort(),O.current=null}},[n,r,e,D]);const I=y.useCallback(()=>{!e||i.isLoading||J()},[J,e,i.isLoading]),B=y.useCallback(async(Ce,me={})=>{var he,_e,ke;const{token:Ye,sessionId:tt,onLoginRequired:Ue}=me,mt=Ye??n,Dt=Ue??r,Et=tt??e,St=`assistant-${Date.now()}`,Ct={id:`user-${Date.now()}`,role:"user",content:Ce,...me.displayContent?{displayContent:me.displayContent}:{},...(he=me.referencedFiles)!=null&&he.length?{referencedFiles:me.referencedFiles}:{}};s(Oe=>({...Oe,messages:[...Oe.messages,Ct,{id:St,role:"assistant",content:""}],isLoading:!0,error:null,hitMaxRounds:!1})),d([]),g([]);const qe=new AbortController;E.current=qe;const Ne=++T.current,Pe=()=>O.current!==Et||T.current!==Ne;let Fe=null,re=null;try{const Oe={"Content-Type":"application/json"};mt&&(Oe.Authorization=`Bearer ${mt}`);const Ie={content:Ce,sessionId:Et,...me.mode&&me.mode!=="agent"?{mode:me.mode}:{},...me.provider&&me.provider!=="jait"?{provider:me.provider}:{},...me.model?{model:me.model}:{}};Wx("request",JSON.stringify(Ie));const Ae=await fetch(`${oo}/api/chat`,{method:"POST",headers:Oe,body:JSON.stringify(Ie),signal:qe.signal});if(Ae.status===401){const ft=await Ae.json();if(ft.detail==="login_required"||ft.detail==="limit_reached")return s(at=>({...at,isLoading:!1,error:ft.detail,messages:at.messages.filter(rn=>me.queued?rn.id!==St&&rn.id!==Ct.id:!(rn.id===St&&!rn.content&&!rn.thinking&&(!rn.toolCalls||rn.toolCalls.length===0)))})),ft.detail==="login_required"&&(Dt==null||Dt()),!1}if(!Ae.ok)throw new Error(`HTTP ${Ae.status}`);const Ke=(_e=Ae.body)==null?void 0:_e.getReader();if(!Ke)throw new Error("No response body");const ht=new TextDecoder;let de="",gt="",Le=null,Je;const rt=[],zt=[];let jt="";const nn=ft=>{const at=zt[zt.length-1];(at==null?void 0:at.type)==="text"?at.content+=ft:zt.push({type:"text",content:ft})},At=ft=>{const at=zt[zt.length-1];(at==null?void 0:at.type)==="toolGroup"?at.callIds.includes(ft)||at.callIds.push(ft):zt.push({type:"toolGroup",callIds:[ft]})},it=()=>{if(re!==null&&(window.cancelAnimationFrame(re),re=null),Pe()||!Fe)return;const ft=Fe;Fe=null,s(at=>({...at,messages:at.messages.map(rn=>rn.id===St?{...rn,...ft}:rn)}))},Tt=ft=>{Pe()||(Fe={...Fe??{},...ft},re===null&&(re=window.requestAnimationFrame(()=>{re=null,it()})))};for(;;){const{done:ft,value:at}=await Ke.read();if(ft)break;jt+=ht.decode(at,{stream:!0});const rn=jt.split(`
|
|
807
807
|
`);jt=rn.pop()||"";for(const Ft of rn)if(Ft.startsWith("data: "))try{const st=JSON.parse(Ft.slice(6));if(Wx(String(st.type??"unknown"),Ft.slice(6)),st.type==="thinking")Le||(Le=Date.now()),gt+=st.content,Tt({thinking:gt});else if(st.type==="token")Le&&!Je&&(Je=Math.round((Date.now()-Le)/1e3)),de+=st.content,nn(st.content),Tt({content:de,thinkingDuration:Je,segments:[...zt]});else if(st.type==="tool_call_delta"){const Bt=st.call_id,Lt=st.name_delta||"",Kt=st.args_delta||"",An=rt.findIndex(In=>In.callId===Bt);An!==-1?rt[An]={...rt[An],tool:rt[An].tool+Lt,streamingArgs:(rt[An].streamingArgs??"")+Kt}:(rt.push({callId:Bt,tool:Lt,args:{},status:"pending",streamingArgs:Kt,startedAt:Date.now()}),At(Bt)),Tt({toolCalls:[...rt],segments:[...zt]})}else if(st.type==="tool_start"){const Bt=st.call_id,Lt=rt.findIndex(Kt=>Kt.callId===Bt);Lt!==-1?rt[Lt]={...rt[Lt],tool:st.tool,args:st.args??{},status:"running",streamingArgs:void 0}:(rt.push({callId:Bt,tool:st.tool,args:st.args??{},status:"running",startedAt:Date.now()}),At(Bt)),Tt({toolCalls:[...rt],segments:[...zt]})}else if(st.type==="tool_output"){const Bt=rt.findIndex(Lt=>Lt.callId===st.call_id);Bt!==-1&&(rt[Bt]={...rt[Bt],streamingOutput:(rt[Bt].streamingOutput??"")+st.content},Tt({toolCalls:[...rt]}))}else if(st.type==="tool_result"){const Bt=rt.findIndex(Lt=>Lt.callId===st.call_id);if(Bt!==-1&&(rt[Bt]={...rt[Bt],status:st.ok?"success":"error",result:{ok:st.ok,message:st.message,data:st.data},completedAt:Date.now()},Tt({toolCalls:[...rt]}),st.ok)){const Lt=rt[Bt],Kt=Lt.tool.replace("_",".");if(Kt==="file.write"||Kt==="file.patch"||Kt==="edit"){const An=String(((ke=Lt.args)==null?void 0:ke.path)??"");if(An){const In=An.split("/").pop()??An;g(Gi=>Gi.some(jo=>jo.path===An)?Gi:[...Gi,{path:An,name:In,state:"undecided"}])}}}}else if(st.type==="plan_complete"){const Bt={plan_id:st.plan_id,summary:st.summary,actions:st.actions??[]};a(Bt)}else if(st.type==="mode_notice"){const Bt=`
|
|
808
808
|
|
|
809
|
-
*${st.message}*`;de+=Bt,nn(Bt),Tt({content:de,segments:[...zt]})}else if(st.type==="todo_list"){const Bt=st.items;d(Bt)}else if(st.type==="context_usage")x(st);else if(st.type==="session_info")j({provider:st.provider,workspacePath:st.workspacePath,isRemote:st.isRemote,remoteNode:st.remoteNode});else if(st.type==="file_changed"){const Bt=st.path,Lt=st.name;g(Kt=>Kt.find(In=>In.path===Bt)?Kt:[...Kt,{path:Bt,name:Lt,state:"undecided"}])}else if(st.type==="done"){if(it(),Le&&!Je&&(Je=Math.round((Date.now()-Le)/1e3)),!Pe()){const Bt=de.length===0&>.length===0&&rt.length===0;s(Lt=>({...Lt,promptCount:st.prompt_count,remainingPrompts:st.remaining_prompts,isLoading:!1,hitMaxRounds:!!st.hit_max_rounds,messages:Bt?Lt.messages.filter(Kt=>Kt.id!==St):Lt.messages.map(Kt=>Kt.id===St?{...Kt,content:de,thinking:gt||void 0,thinkingDuration:Je,toolCalls:rt.length>0?rt:void 0,segments:zt.length>0?zt:void 0}:Kt)}))}return!0}else if(st.type==="error")throw new Error(st.message)}catch(st){if(!(st instanceof SyntaxError))throw st}}it()}catch(Oe){return re!==null&&(window.cancelAnimationFrame(re),re=null),Fe=null,Oe instanceof Error&&Oe.name==="AbortError"?(Pe()||s(Ie=>({...Ie,isLoading:!1,messages:Ie.messages.filter(Ae=>me.queued?Ae.id!==St&&Ae.id!==Ct.id:!(Ae.id===St&&!Ae.content&&!Ae.thinking&&(!Ae.toolCalls||Ae.toolCalls.length===0))).map(Ae=>{var Ke;return(Ke=Ae.toolCalls)!=null&&Ke.some(ht=>ht.status==="running")?{...Ae,toolCalls:Ae.toolCalls.map(ht=>ht.status==="running"?{...ht,status:"error",result:{ok:!1,message:"Cancelled"},completedAt:Date.now()}:ht)}:Ae})})),!1):(Pe()||s(Ie=>({...Ie,isLoading:!1,error:Oe instanceof Error?Oe.message:"An error occurred",messages:Ie.messages.filter(Ae=>me.queued?Ae.id!==St&&Ae.id!==Ct.id:!(Ae.id===St&&!Ae.content&&!Ae.thinking&&(!Ae.toolCalls||Ae.toolCalls.length===0)))})),!1)}return!0},[n,r,e]),F=y.useCallback(Ce=>{const me={id:`q-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,...Ce,queuedAt:Date.now()};_(Ye=>[...Ye,me])},[]),W=y.useCallback(Ce=>{_(me=>me.filter(Ye=>Ye.id!==Ce))},[]),z=y.useCallback((Ce,me)=>{const Ye=me.trim();Ye&&_(tt=>tt.map(Ue=>Ue.id===Ce?{...Ue,content:Ye,displayContent:Ye,referencedFiles:void 0}:Ue))},[]),V=y.useCallback((Ce,me)=>{_(Ye=>
|
|
810
|
-
`);Et=qe.pop()||"";for(const Ne of qe)if(Ne.startsWith("data: "))try{const Pe=JSON.parse(Ne.slice(6));Pe.type==="plan_action_start"?a(Fe=>Fe?{...Fe,actions:Fe.actions.map(re=>re.id===Pe.action_id?{...re,status:"approved"}:re)}:null):Pe.type==="plan_action_result"?a(Fe=>Fe?{...Fe,actions:Fe.actions.map(re=>re.id===Pe.action_id?{...re,status:Pe.ok?"executed":"failed",result:{ok:Pe.ok,message:Pe.message,data:Pe.data}}:re)}:null):Pe.type==="plan_execution_complete"&&setTimeout(()=>a(null),2e3)}catch{}}}catch(Ue){s(mt=>({...mt,error:Ue instanceof Error?Ue.message:"Plan execution failed"}))}},[n,o]),ze=y.useCallback(async()=>{const Ce=O.current;if(!Ce||!o)return;const me={"Content-Type":"application/json"};n&&(me.Authorization=`Bearer ${n}`);try{await fetch(`${oo}/api/sessions/${Ce}/plan/reject`,{method:"POST",headers:me}),a(null)}catch{a(null)}},[n,o]),fe=y.useCallback((Ce,me)=>{g(Ye=>Ye.some(tt=>tt.path===Ce)?Ye:[...Ye,{path:Ce,name:me,state:"undecided"}])},[]);return{messages:i.messages,isLoading:i.isLoading,isLoadingHistory:i.isLoadingHistory,remainingPrompts:i.remainingPrompts,error:i.error,hitMaxRounds:i.hitMaxRounds,pendingPlan:o,todoList:c,changedFiles:h,messageQueue:p,contextUsage:b,sessionInfo:C,sendMessage:B,restartFromMessage:ce,cancelRequest:X,clearMessages:ie,continueChat:se,executePlan:be,rejectPlan:ze,enqueueMessage:F,dequeueMessage:W,updateQueueItem:z,reorderQueueItem:V,setMessageQueueState:A,acceptFile:R,rejectFile:Z,acceptAllFiles:L,rejectAllFiles:Q,setTodoList:d,addChangedFile:fe,setChangedFiles:g,setOnChangedFilesSync:Y,refreshMessages:I}}function Z5e(){const[e,n]=y.useState(null),[r,i]=y.useState(null),[s,o]=y.useState(null),[a,c]=y.useState(!0);return y.useEffect(()=>{let d=!1;return fetch(`${Wn()}/health`).then(h=>h.json()).then(h=>{d||(n(h.provider??null),i(h.model??null),o(h.ollamaUrl??null))}).catch(()=>{}).finally(()=>{d||c(!1)}),()=>{d=!0}},[]),{provider:e,model:r,ollamaUrl:s,loading:a}}const q1=Wn(),K1=10;function G1(e){return e?{Authorization:`Bearer ${e}`}:{}}function Q5e(e,n){const[r,i]=y.useState([]),[s,o]=y.useState(null),[a,c]=y.useState(K1),[d,h]=y.useState(!1),[g,p]=y.useState(!0),_=y.useCallback(async()=>{if(!e){i(E=>E.length===0?E:[]),o(null),h(!1),p(!1);return}p(!0);try{const[E,O]=await Promise.all([fetch(`${q1}/api/sessions?status=active&limit=${a}`,{headers:G1(e)}),fetch(`${q1}/api/sessions/last-active`,{headers:G1(e)})]);if((E.status===401||O.status===401)&&(n==null||n()),E.ok){const N=await E.json();i(N.sessions),h(!!N.hasMore)}if(O.ok){const N=await O.json();N.session&&o(T=>T??N.session.id)}}catch(E){console.error("Failed to fetch sessions:",E)}finally{p(!1)}},[n,e,a]),b=y.useCallback(async E=>{if(!e)return n==null||n(),null;try{const O=await fetch(`${q1}/api/sessions`,{method:"POST",headers:{...G1(e),"Content-Type":"application/json"},body:JSON.stringify({name:E||`Session ${new Date().toLocaleString()}`})});if(O.status===401)return n==null||n(),null;if(O.ok){const N=await O.json();return i(T=>[N,...T].slice(0,a)),o(N.id),N}}catch(O){console.error("Failed to create session:",O)}return null},[n,e]),x=y.useCallback(E=>{o(E)},[]),C=y.useCallback(async E=>{if(!e){n==null||n();return}try{if((await fetch(`${q1}/api/sessions/${E}/archive`,{method:"POST",headers:G1(e)})).status===401){n==null||n();return}await _(),s===E&&o(null)}catch(O){console.error("Failed to archive session:",O)}},[s,_,n,e]),j=y.useCallback(()=>{c(E=>E+K1)},[]),S=y.useCallback(()=>{c(K1)},[]);return y.useEffect(()=>{_()},[_]),{sessions:r,activeSessionId:s,loading:g,hasMoreSessions:d,fetchSessions:_,createSession:b,switchSession:x,archiveSession:C,showMoreSessions:j,showFewerSessions:S,sessionListLimit:K1}}const eSe=Pg();function tSe(e){let n=0;for(let r=0;r<e.length;r++)n=Math.imul(31,n)+e.charCodeAt(r)|0;return n}function nSe(){const e=qr(),n=navigator.userAgent;return e==="electron"?`Desktop (${navigator.platform})`:e==="capacitor"?"Mobile":n.includes("Chrome")?`Chrome (${navigator.platform})`:n.includes("Firefox")?`Firefox (${navigator.platform})`:n.includes("Safari")?`Safari (${navigator.platform})`:`Browser (${navigator.platform})`}function rSe(){var n;const e=qr();if(e==="capacitor")return"android";if(e==="electron"){const r=((n=navigator.platform)==null?void 0:n.toLowerCase())??"";return r.includes("win")?"windows":r.includes("mac")?"macos":"linux"}return"web"}function iSe(){const e=qr();return e==="electron"||e==="capacitor"}function sSe(e){const{listeners:n,sessionId:r,token:i,onStateSync:s,onFullState:o,onMessageComplete:a,onThreadEvent:c,onFsChanges:d,onConnectionStateChange:h}=e,g=y.useRef(n);g.current=n;const p=y.useRef(s);p.current=s;const _=y.useRef(o);_.current=o;const b=y.useRef(a);b.current=a;const x=y.useRef(c);x.current=c;const C=y.useRef(d);C.current=d;const j=y.useRef(h);j.current=h;const S=y.useRef(null),E=y.useRef(null),O=y.useRef(!0),N=y.useRef(!1),T=y.useRef(i);T.current=i;const P=y.useRef(r);P.current=r;const D=y.useRef([]),H=y.useCallback($=>{for(;D.current.length>0&&$.readyState===WebSocket.OPEN;){const R=D.current.shift();$.send(R)}},[]),J=y.useCallback(($,R)=>{!R||$.readyState!==WebSocket.OPEN||($.send(JSON.stringify({type:"subscribe",sessionId:R})),E.current=R)},[]),I=y.useCallback(async $=>{var Z;if((Z=window.jaitDesktop)!=null&&Z.notify){window.jaitDesktop.notify({title:$.title,body:$.body});return}if(window.Capacitor)try{const L="@capacitor/local-notifications",{LocalNotifications:Q}=await import(L);if((await Q.requestPermissions()).display==="granted"){await Q.schedule({notifications:[{id:Math.abs(tSe($.id)),title:$.title,body:$.body,schedule:{at:new Date}}]});return}}catch{}"Notification"in window&&(Notification.permission==="granted"?new Notification($.title,{body:$.body,tag:$.id}):Notification.permission!=="denied"&&await Notification.requestPermission()==="granted"&&new Notification($.title,{body:$.body,tag:$.id})),($.level==="error"?Pr.error:$.level==="warning"?Pr.warning:$.level==="success"?Pr.success:Pr.info)($.title,{description:$.body})},[]),B=y.useCallback($=>{var R,Z,L;try{const Q=JSON.parse($.data);if(Q.type==="ui.command"){const X=Q.payload,ie=g.current[X.command];ie&&ie(X.data)}else if(Q.type==="ui.state-sync"){const X=Q.payload;X!=null&&X.key&&p.current&&p.current(X.key,X.value??null)}else if(Q.type==="ui.full-state"){const X=Q.payload;X&&_.current&&_.current(X)}else if(Q.type==="message.complete")(R=b.current)==null||R.call(b);else if(Q.type==="fs.changes"){const X=Q.payload;(Z=C.current)==null||Z.call(C,X)}else Q.type==="fs.browse-request"?z(Q.payload):Q.type==="fs.roots-request"?V(Q.payload):Q.type==="fs.op-request"?A(Q.payload):Q.type==="provider.op-request"?U(Q.payload):Q.type==="tool.op-request"?K(Q.payload):Q.type==="notification"?I(Q.payload):(Q.type.startsWith("thread.")||Q.type.startsWith("repo.")||Q.type.startsWith("plan.")||Q.type.startsWith("fs.node-"))&&((L=x.current)==null||L.call(x,Q.type,Q.payload))}catch{}},[]),F=y.useCallback(async $=>{const R="@capacitor/filesystem",{Filesystem:Z,Directory:L}=await import(R);let Q,X=$;$==="~"||$==="/storage"||$==="/"?(Q=L.ExternalStorage,X=""):$.startsWith("/storage/emulated/0")&&(Q=L.ExternalStorage,X=$.replace("/storage/emulated/0","").replace(/^\//,""));const ie=await Z.readdir({path:X||"",...Q?{directory:Q}:{}}),se=Q===L.ExternalStorage?"/storage/emulated/0"+(X?"/"+X:""):$,ce=[];for(const fe of ie.files)fe.name.startsWith(".")||ce.push({name:fe.name,path:se+"/"+fe.name,type:fe.type==="directory"?"dir":"file"});ce.sort((fe,Ce)=>fe.type!==Ce.type?fe.type==="dir"?-1:1:fe.name.localeCompare(Ce.name));const be=se.replace(/\/+$/,"").split("/"),ze=be.length>3?be.slice(0,-1).join("/"):null;return{path:se,parent:ze,entries:ce}},[]),W=y.useCallback(async()=>[{name:"Internal Storage",path:"/storage/emulated/0",type:"dir"},{name:"Documents",path:"/storage/emulated/0/Documents",type:"dir"},{name:"Downloads",path:"/storage/emulated/0/Download",type:"dir"},{name:"Home",path:"/storage/emulated/0",type:"dir"}],[]),z=y.useCallback(async $=>{var Q;const R=S.current;if(!R||R.readyState!==WebSocket.OPEN)return;const{requestId:Z,path:L}=$;try{let X;const ie=qr();if(ie==="electron"&&((Q=window.jaitDesktop)!=null&&Q.browsePath))X=await window.jaitDesktop.browsePath(L);else if(ie==="capacitor")X=await F(L);else throw new Error("Local filesystem browsing not supported on this platform");R.send(JSON.stringify({type:"fs.browse-response",payload:{requestId:Z,path:X.path,parent:X.parent,entries:X.entries}}))}catch(X){R.send(JSON.stringify({type:"fs.browse-response",payload:{requestId:Z,error:X instanceof Error?X.message:"Browse failed"}}))}},[F]),V=y.useCallback(async $=>{var L;const R=S.current;if(!R||R.readyState!==WebSocket.OPEN)return;const{requestId:Z}=$;try{let Q;const X=qr();if(X==="electron"&&((L=window.jaitDesktop)!=null&&L.getRoots))Q=(await window.jaitDesktop.getRoots()).roots;else if(X==="capacitor")Q=await W();else throw new Error("Local filesystem browsing not supported on this platform");R.send(JSON.stringify({type:"fs.roots-response",payload:{requestId:Z,roots:Q}}))}catch(Q){R.send(JSON.stringify({type:"fs.roots-response",payload:{requestId:Z,error:Q instanceof Error?Q.message:"Roots request failed"}}))}},[W]),A=y.useCallback(async $=>{var X;const R=S.current;if(!R||R.readyState!==WebSocket.OPEN)return;const{requestId:Z,op:L,...Q}=$;try{const ie=qr();if(ie==="electron"&&((X=window.jaitDesktop)!=null&&X.fsOp)){const se=await window.jaitDesktop.fsOp(L,Q);R.send(JSON.stringify({type:"fs.op-response",payload:{requestId:Z,result:se}}))}else throw ie==="capacitor"?new Error("Full filesystem operations not yet supported on mobile"):new Error("Filesystem operations not supported on this platform")}catch(ie){R.send(JSON.stringify({type:"fs.op-response",payload:{requestId:Z,error:ie instanceof Error?ie.message:"Filesystem operation failed"}}))}},[]),U=y.useCallback(async $=>{var X;const R=S.current;if(!R||R.readyState!==WebSocket.OPEN)return;const{requestId:Z,op:L,...Q}=$;try{if(qr()==="electron"&&((X=window.jaitDesktop)!=null&&X.providerOp)){const se=await window.jaitDesktop.providerOp(L,Q);R.send(JSON.stringify({type:"provider.op-response",payload:{requestId:Z,result:se}}))}else throw new Error("Provider operations not supported on this platform")}catch(ie){R.send(JSON.stringify({type:"provider.op-response",payload:{requestId:Z,error:ie instanceof Error?ie.message:"Provider operation failed"}}))}},[]),K=y.useCallback(async $=>{var se;const R=S.current;if(!R||R.readyState!==WebSocket.OPEN)return;const{requestId:Z,tool:L,args:Q,sessionId:X,workspaceRoot:ie}=$;try{if(qr()==="electron"&&((se=window.jaitDesktop)!=null&&se.toolOp)){const be=await window.jaitDesktop.toolOp(L,Q,{sessionId:X,workspaceRoot:ie});R.send(JSON.stringify({type:"tool.op-response",payload:{requestId:Z,result:be}}))}else throw new Error("Tool execution not supported on this platform")}catch(ce){R.send(JSON.stringify({type:"tool.op-response",payload:{requestId:Z,error:ce instanceof Error?ce.message:"Tool execution failed"}}))}},[]);return y.useEffect(()=>{var L;O.current=!0;let $=null;const R=()=>{if(!O.current)return;const Q=new WebSocket(`${eSe}?token=${T.current??"dev"}`);S.current=Q,Q.onopen=()=>{var se;const X=N.current;N.current=!0,(se=j.current)==null||se.call(j,{connected:!0,reconnected:X});const ie=P.current;ie&&J(Q,ie),H(Q),iSe()&&_2e().then(async ce=>{var fe;let be=[];if(qr()==="electron"&&((fe=window.jaitDesktop)!=null&&fe.detectProviders))try{be=await window.jaitDesktop.detectProviders()}catch{}const ze=JSON.stringify({type:"fs.register-node",payload:{id:ce,name:nSe(),platform:rSe(),providers:be}});Q.readyState===WebSocket.OPEN&&Q.send(ze)})},Q.onmessage=B,Q.onclose=()=>{var X;S.current=null,E.current=null,(X=j.current)==null||X.call(j,{connected:!1,reconnected:!1}),O.current&&($=setTimeout(R,1e3))},Q.onerror=()=>{}};R();const Z=(Q,X)=>{if((X==null?void 0:X.type)==="provider.event-from-child"){const ie=S.current;ie&&ie.readyState===WebSocket.OPEN&&ie.send(JSON.stringify({type:"provider.event",payload:{sessionId:X.sessionId,event:X.notification}}))}};return qr()==="electron"&&((L=window.jaitDesktop)!=null&&L.onGatewayEvent)&&window.jaitDesktop.onGatewayEvent(Z),()=>{var X;O.current=!1,$&&clearTimeout($),qr()==="electron"&&((X=window.jaitDesktop)!=null&&X.removeGatewayEventListener)&&window.jaitDesktop.removeGatewayEventListener();const Q=S.current;Q&&(Q.onclose=null,Q.close(),S.current=null)}},[i]),y.useEffect(()=>{const $=S.current;$&&$.readyState===WebSocket.OPEN&&r!==E.current&&J($,r??null),P.current=r??null},[r,J]),{sendUIState:y.useCallback(($,R,Z)=>{const L=JSON.stringify({type:"ui.state",payload:{sessionId:Z??"",key:$,value:R}}),Q=S.current;Q&&Q.readyState===WebSocket.OPEN?Q.send(L):D.current.push(L)},[])}}const xO=Wn();function wO(e){const n={"Content-Type":"application/json"};return e&&(n.Authorization=`Bearer ${e}`),n}function ao(e,n,r){const[i,s]=y.useState(null),[o,a]=y.useState(!1),c=y.useRef(null),d=y.useRef(null);y.useEffect(()=>{if(!e||!r){s(null);return}let g=!1;return a(!0),fetch(`${xO}/api/sessions/${e}/state?keys=${encodeURIComponent(n)}`,{headers:wO(r)}).then(p=>p.ok?p.json():null).then(p=>{if(g)return;const _=(p==null?void 0:p[n])??null;s(_),d.current=_}).catch(()=>{g||s(null)}).finally(()=>{g||a(!1)}),()=>{g=!0}},[e,n,r]);const h=y.useCallback(g=>{s(g),d.current=g,!(!e||!r)&&(c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{fetch(`${xO}/api/sessions/${e}/state`,{method:"PATCH",headers:wO(r),body:JSON.stringify({[n]:d.current})}).catch(()=>{})},300))},[e,n,r]);return y.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),[i,h,o]}function uv(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function oSe(e){const r=uv(e).split("/").filter(Boolean);return r[r.length-1]??e}function aSe(e){var r;const n=e.match(/^\[([^\]]+)\]/);return((r=n==null?void 0:n[1])==null?void 0:r.trim())||null}function ML(e){if(!e)return null;const r=uv(e).split("/").filter(Boolean),i=r.lastIndexOf("worktrees");return i===-1?null:r[i+1]??null}function a_(e){return aSe(e.title)??ML(e.workingDirectory)??(e.workingDirectory?oSe(e.workingDirectory):null)}function o5(e,n){var c,d;const r=n.name.trim().toLowerCase(),i=(c=a_(e))==null?void 0:c.toLowerCase(),s=e.workingDirectory?uv(e.workingDirectory):null,o=uv(n.localPath);if(s&&(s===o||s.startsWith(`${o}/`)))return!0;const a=(d=ML(e.workingDirectory))==null?void 0:d.toLowerCase();return a&&a===r?!0:i===r}function lSe(e,n){const r=[],i=new Set;for(const s of e){if(n.some(c=>o5(s,c)))continue;const o=a_(s),a=o==null?void 0:o.trim().toLowerCase();!o||!a||i.has(a)||(r.push({id:`shared:${a}`,name:o,defaultBranch:"main",localPath:s.workingDirectory??o,source:"shared"}),i.add(a))}return r}function cSe(e){return e==="jait"||e==="codex"||e==="claude-code"?e:null}function uSe(e){const n=new Set;for(const r of e){const i=cSe(r);i&&n.add(i)}return[...n]}function fSe(e,n){const{localDeviceId:r,localProviders:i,remoteProviders:s,providersLoaded:o}=n;if(!e.deviceId)return{hostType:"gateway",locationLabel:"Gateway",online:!0,loading:!1,availableProviders:i.filter(h=>h.available).map(h=>h.id)};const a=s.find(h=>h.nodeId===e.deviceId),c=e.deviceId===r?"This device":(a==null?void 0:a.nodeName)??"Desktop app",d=!!a;return{hostType:"device",locationLabel:c,online:d,loading:!d&&!o,availableProviders:uSe((a==null?void 0:a.providers)??[])}}function SO(e,n){return e.githubUrl?`Couldn't reach ${n.locationLabel}.`:n.hostType==="device"&&!n.online?`${n.locationLabel==="This device"?"This desktop app":n.locationLabel} is offline and no GitHub URL is configured for gateway fallback. Reconnect it or pick a connected repo/device.`:"No GitHub URL is configured for this repo, so the gateway cannot clone it as a fallback."}const ow=10;function dSe(e){const r=e.replace(/\\/g,"/").split("/").filter(Boolean);return r[r.length-1]??e}function hSe(){return`jait/${Math.random().toString(16).slice(2,10)}`}function RL(e){return[...e].sort((n,r)=>new Date(n.createdAt).getTime()-new Date(r.createdAt).getTime())}function pSe(e,n){if(n.length===0)return e;const r=new Map(e.map(i=>[i.id,i]));for(const i of n)r.set(i.id,i);return RL([...r.values()])}function op(e,n){return{id:e.id,name:e.name,defaultBranch:e.defaultBranch,localPath:e.localPath,deviceId:e.deviceId,githubUrl:e.githubUrl,source:!e.deviceId||e.deviceId===n?"local":"shared"}}function mSe(e=!0){const n=y.useMemo(()=>o4(),[]),[r,i]=y.useState([]),[s,o]=y.useState(null),[a,c]=y.useState(!1),[d,h]=y.useState([]),[g,p]=y.useState(ow),[_,b]=y.useState(!1),[x,C]=y.useState(null),[j,S]=y.useState([]),[E,O]=y.useState({}),[N,T]=y.useState(!0),[P,D]=y.useState([]),[H,J]=y.useState([]),[I,B]=y.useState(!1),[F,W]=y.useState(!1),[z,V]=y.useState(!1),[A,U]=y.useState(null),K=y.useRef(null),Y=y.useRef(new Map),$=y.useMemo(()=>lSe(d,r),[d,r]),R=y.useMemo(()=>[...r,...$],[r,$]),Z=y.useMemo(()=>R.find(Ne=>Ne.id===s)??null,[R,s]),L=y.useMemo(()=>d.find(Ne=>Ne.id===x)??null,[d,x]),Q=y.useCallback(Ne=>R.find(Pe=>o5(Ne,Pe))??null,[R]),X=y.useMemo(()=>L!=null&&Z!=null&&(L.status==="completed"||!!L.prUrl),[L,Z]);y.useEffect(()=>{var Ne;e&&(!s&&R.length>0&&o(R[0].id),s&&R.every(Pe=>Pe.id!==s)&&o(((Ne=R[0])==null?void 0:Ne.id)??null))},[R,s,e]),y.useEffect(()=>{if(!e||!L)return;const Ne=Q(L);Ne&&Ne.id!==s&&o(Ne.id)},[e,Q,s,L]);const ie=y.useCallback(async()=>{if(ou()){B(!0);try{const[Ne,Pe,Fe]=await Promise.all([en.listThreadsPage({limit:g}),en.listProviders(),en.listRepos()]);h(Ne.threads),b(Ne.hasMore),D(Pe.providers),J(Pe.remoteProviders),W(!0),i(Fe.map(re=>op(re,n))),U(null)}catch(Ne){U(Ne instanceof Error?Ne.message:"Failed to fetch data")}finally{B(!1)}}},[n,g]),se=y.useCallback(async()=>{if(ou())try{const[Ne,Pe]=await Promise.all([en.listProviders(),en.listRepos()]);D(Ne.providers),J(Ne.remoteProviders),i(Pe.map(Fe=>op(Fe,n)))}catch{}},[n]),ce=y.useCallback(Ne=>fSe(Ne,{localDeviceId:n,localProviders:P,remoteProviders:H,providersLoaded:F}),[n,P,H,F]);y.useEffect(()=>{e&&ie()},[ie,e]);const be=y.useRef(x);be.current=x;const ze=y.useCallback((Ne,Pe)=>{switch(Ne){case"thread.created":{const Fe=Pe.thread;Fe&&h(re=>re.some(he=>he.id===Fe.id)?re:[Fe,...re]);break}case"thread.updated":{const Fe=Pe.thread;Fe&&h(re=>re.map(he=>he.id===Fe.id?Fe:he));break}case"thread.deleted":{const Fe=Pe.threadId;Fe&&(Y.current.delete(Fe),h(re=>re.filter(he=>he.id!==Fe)),be.current===Fe&&C(null));break}case"thread.status":{const Fe=Pe.threadId,re=Pe.status,he=Pe.thread;Fe&&re&&h(_e=>he?_e.some(Oe=>Oe.id===Fe)?_e.map(Oe=>Oe.id===Fe?he:Oe):[he,..._e]:_e.map(ke=>ke.id===Fe?{...ke,status:re,error:re==="running"||re==="completed"?Pe.error??null:Pe.error??ke.error}:ke));break}case"thread.activity":{const Fe=Pe.threadId,re=Pe.activity;if(Fe&&re){const he=pSe(Y.current.get(Fe)??[],[re]);Y.current.set(Fe,he),Fe===be.current&&S(he)}break}case"repo.created":{const Fe=Pe.repo;Fe&&i(re=>re.some(he=>he.id===Fe.id)?re:[op(Fe,n),...re]);break}case"repo.updated":{const Fe=Pe.repo;Fe&&i(re=>re.map(he=>he.id===Fe.id?op(Fe,n):he));break}case"repo.deleted":{const Fe=Pe.repoId;Fe&&(i(re=>re.filter(he=>he.id!==Fe)),o(re=>re===Fe?null:re));break}case"fs.node-registered":case"fs.node-disconnected":{se();break}}},[]);y.useEffect(()=>{if(!e||!x){S([]),V(!1);return}const Ne=Y.current.get(x);if(Ne){S(Ne),V(!1);return}S([]),V(!0);let Pe=!1;return(async()=>{if(ou())try{const re=await en.getActivities(x);if(!Pe){const he=RL(re);Y.current.set(x,he),S(he)}}catch{}finally{Pe||V(!1)}})(),()=>{Pe=!0}},[x,e]),y.useEffect(()=>{var Ne;e&&((Ne=K.current)==null||Ne.scrollIntoView({behavior:"smooth"}))},[j,e]);const fe=y.useMemo(()=>Z?d.filter(Ne=>o5(Ne,Z)).sort((Ne,Pe)=>new Date(Pe.updatedAt).getTime()-new Date(Ne.updatedAt).getTime()):[],[d,Z]),Ce=y.useRef(0),me=10;y.useEffect(()=>{if(!e||!Z){O({});return}const Ne=++Ce.current,Pe=Z.localPath,Fe=fe.filter(_e=>typeof _e.branch=="string"&&_e.branch.length>0).slice(0,me),re=async()=>{var Ae;if(Fe.length===0){Ne===Ce.current&&O({});return}const _e=Fe.filter(Ke=>Ke.prState!=="merged"&&Ke.prState!=="closed"),ke=[];for(const Ke of _e){if(Ne!==Ce.current)return;try{const ht=Ke.workingDirectory??Pe,de=await Hi.status(ht,Ke.branch??void 0),gt=((Ae=de.pr)==null?void 0:Ae.state)??null;if(de.ghAvailable&&de.pr&&(Ke.prUrl!==de.pr.url||Ke.prState!==de.pr.state||Ke.prNumber!==de.pr.number))try{await en.updateThread(Ke.id,{prUrl:de.pr.url,prNumber:de.pr.number,prTitle:de.pr.title??null,prState:de.pr.state})}catch{}ke.push({threadId:Ke.id,prState:gt,ghAvailable:de.ghAvailable})}catch{}}if(Ne!==Ce.current)return;const Oe={};let Ie=!1;for(const Ke of ke)Oe[Ke.threadId]=Ke.prState,Ke.ghAvailable&&(Ie=!0);for(const Ke of Fe)!(Ke.id in Oe)&&(Ke.prState==="merged"||Ke.prState==="closed")&&(Oe[Ke.id]=Ke.prState);T(Ie),O(Oe)};re();const he=setInterval(()=>{Ce.current===Ne&&re()},6e4);return()=>clearInterval(he)},[e,fe,Z]);const Ye=y.useCallback(async(Ne,Pe)=>{const Fe=Pe&&Pe!=="gateway"?Pe:void 0,re=r.find(ke=>ke.localPath===Ne);if(re){o(re.id);const ke={},Oe=Fe??"";if((re.deviceId??"")!==Oe&&(ke.deviceId=Oe),!re.githubUrl)try{const Ie=await Hi.status(Ne);Ie.remoteUrl&&(ke.githubUrl=Ie.remoteUrl)}catch{}if(Object.keys(ke).length>0)try{await en.updateRepo(re.id,ke)}catch{}return}let he="main",_e;try{const ke=await Hi.status(Ne);ke.branch&&(he=ke.branch),ke.remoteUrl&&(_e=ke.remoteUrl)}catch{}try{const ke=await en.createRepo({name:dSe(Ne),defaultBranch:he,localPath:Ne,deviceId:Fe,githubUrl:_e}),Oe=op(ke,n);i(Ie=>Ie.some(Ae=>Ae.id===Oe.id)?Ie:[Oe,...Ie]),o(Oe.id),U(null)}catch(ke){U(ke instanceof Error?ke.message:"Failed to create repository")}},[r]),tt=y.useCallback(async Ne=>{try{await en.deleteRepo(Ne)}catch{}i(Pe=>Pe.filter(Fe=>Fe.id!==Ne)),s===Ne&&o(null)},[s]),Ue=y.useCallback(async(Ne,Pe,Fe="jait",re,he={})=>{if(!Pe.trim())return;const _e=Ne?d.find(Oe=>Oe.id===Ne)??null:L,ke=_e?Q(_e):Z;if(_e&&(_e.status==="running"||_e.providerSessionId))await en.sendTurn(_e.id,{message:Pe,...he}),ie();else if(_e&&(_e.status==="completed"||_e.status==="error"||_e.status==="interrupted"))try{const Oe=await en.startThread(_e.id,{message:Pe,...he});h(Ie=>Ie.map(Ae=>Ae.id===Oe.id?Oe:Ae)),ie()}catch(Oe){if(Oe.code==="NODE_OFFLINE"&&ke){const Ae=ke.githubUrl;if(Ae&&confirm("The desktop app is not connected. Clone the repo to the gateway and run the thread there?")){const Ke=await en.startThread(_e.id,{message:Pe,cloneToGateway:!0,repoUrl:Ae,...he});h(ht=>ht.map(de=>de.id===Ke.id?Ke:de)),ie()}else Ae||U(SO(ke,ce(ke)))}else throw Oe}else{if(!ke)return;Ne||C(null);const Oe=ke;(async()=>{var Ie,Ae;try{const Ke=hSe();let ht;try{ht=(await Hi.createWorktree(Oe.localPath,Oe.defaultBranch,Ke)).path}catch{try{await Hi.createBranch(Oe.localPath,Ke,Oe.defaultBranch)}catch{}}const de=await en.createThread({title:`[${Oe.name}] Generating title…`,providerId:Fe,...re?{model:re}:{},workingDirectory:ht??Oe.localPath,branch:Ke});try{await en.startThread(de.id,{message:Pe,titleTask:((Ie=he.displayContent)==null?void 0:Ie.trim())||Pe,titlePrefix:`[${Oe.name}] `,...he})}catch(gt){if(gt.code==="NODE_OFFLINE"){const Je=Oe.githubUrl;Je&&confirm("The desktop app is not connected. Clone the repo to the gateway and run the thread there?")?await en.startThread(de.id,{message:Pe,titleTask:((Ae=he.displayContent)==null?void 0:Ae.trim())||Pe,titlePrefix:`[${Oe.name}] `,cloneToGateway:!0,repoUrl:Je,...he}):Je||U(SO(Oe,ce(Oe)));return}throw gt}}catch(Ke){U(Ke instanceof Error?Ke.message:"Failed to create thread")}})()}},[ce,Q,ie,Z,L,d]),mt=y.useCallback(async(Ne,Pe="jait",Fe,re)=>{await Ue((L==null?void 0:L.id)??null,Ne,Pe,Fe,re)},[L==null?void 0:L.id,Ue]),Dt=y.useCallback(async(Ne,Pe,Fe="jait",re,he)=>{await Ue(Ne,Pe,Fe,re,he)},[Ue]),Et=y.useCallback(async Ne=>{try{await en.stopThread(Ne),ie()}catch(Pe){U(Pe instanceof Error?Pe.message:"Failed to stop thread")}},[ie]),St=y.useCallback(async Ne=>{try{await en.deleteThread(Ne),h(Pe=>Pe.filter(Fe=>Fe.id!==Ne)),x===Ne&&C(null)}catch(Pe){U(Pe instanceof Error?Pe.message:"Failed to delete thread")}},[x]),Ct=y.useCallback(()=>{p(Ne=>Ne+ow)},[]),qe=y.useCallback(()=>{p(ow)},[]);return{repositories:R,selectedRepoId:s,setSelectedRepoId:o,selectedRepo:Z,folderPickerOpen:a,setFolderPickerOpen:c,handleFolderSelected:Ye,removeRepository:tt,threads:d,hasMoreThreads:_,threadListLimit:g,showMoreThreads:Ct,showFewerThreads:qe,repoThreads:fe,selectedThreadId:x,setSelectedThreadId:C,selectedThread:L,getRepositoryForThread:Q,threadPrStates:E,ghAvailable:N,activities:j,loadingActivities:z,activityEndRef:K,providers:P,remoteProviders:H,loading:I,error:A,setError:U,creating:!1,showGitActions:X,getRuntimeInfoForRepository:ce,refresh:ie,handleSend:mt,handleSendToThread:Dt,handleStop:Et,handleDelete:St,handleThreadEvent:ze}}const DL=16,gSe=280,ySe=200;function fv(e,n,r){return Math.min(Math.max(e,n),r)}function Y1({size:e,viewport:n,margin:r=DL}){const i=Math.max(220,n.width-r*2),s=Math.max(160,n.height-r*2),o=Math.min(gSe,i),a=Math.min(ySe,s);return{w:fv(e.w,o,i),h:fv(e.h,a,s)}}function Cp({position:e,size:n,viewport:r}){return{x:fv(e.x,0,Math.max(0,r.width-n.w)),y:fv(e.y,0,Math.max(0,r.height-n.h))}}function vSe({size:e,viewport:n,margin:r=DL}){return Cp({position:{x:n.width-e.w-r,y:n.height-e.h-r},size:e,viewport:n})}const gi=Wn(),zL=28,a5=.05;function aw(){return Array.from({length:zL},()=>a5)}function LL(e){return e.trim()}function CO(e,n){const r=e.trim(),i=LL(n);return i?r?`${r} ${i}`:i:r}function _Se(e,n,r){const i=e.findIndex(c=>c.id===n),s=e.findIndex(c=>c.id===r);if(i<0||s<0||i===s)return e;const o=[...e],[a]=o.splice(i,1);return o.splice(s,0,a),o}const bSe=["What can you help me with?","Explain quantum computing","Write a Python script","What time is it?"];function lw(e){const n={};try{const i=localStorage.getItem("cliModelsByProvider");if(i){const s=JSON.parse(i);for(const o of["codex","claude-code"]){const a=s[o];typeof a=="string"&&a.trim()&&(n[o]=a)}}}catch{}const r=localStorage.getItem("cliModel");return r&&e!=="jait"&&!n[e]&&(n[e]=r),n}function jO(e){const n=window.matchMedia("(prefers-color-scheme: dark)").matches,r=e==="dark"||e==="system"&&n;document.documentElement.classList.toggle("dark",r)}const xSe="Generating title…";function y4(e){return e.replace(/^\[.*?\]\s*/,"").trim()===xSe}function $L({className:e=""}){return f.jsx("span",{className:`inline-block rounded bg-muted animate-pulse ${e}`,children:f.jsx("span",{className:"invisible",children:"Generating title"})})}function v4({status:e}){const n={running:{icon:kt,color:"text-blue-500 animate-spin"},paused:{icon:E8,color:"text-yellow-500"},interrupted:{icon:E8,color:"text-yellow-500"},done:{icon:Fs,color:"text-green-500"},completed:{icon:Fs,color:"text-green-500"},error:{icon:uu,color:"text-red-500"}},{icon:r,color:i}=n[e]??{icon:qa,color:"text-muted-foreground"};return f.jsx(r,{className:`h-3 w-3 shrink-0 ${i}`})}function IL({prState:e}){if(!e)return null;const n=e==="open"?"PR created":e==="merged"?"PR merged":"PR closed",r=e==="open"?"bg-blue-500/10 text-blue-700 border-blue-500/20 dark:text-blue-300 dark:bg-blue-500/20 dark:border-blue-400/30":e==="merged"?"bg-purple-500/10 text-purple-700 border-purple-500/20 dark:text-purple-300 dark:bg-purple-500/20 dark:border-purple-400/30":"bg-red-500/10 text-red-700 border-red-500/20 dark:text-red-300 dark:bg-red-500/20 dark:border-red-400/30";return f.jsx(ln,{variant:"outline",className:`h-4 shrink-0 whitespace-nowrap px-1 py-0 text-[9px] ${r}`,children:n})}const wSe={codex:"Codex","claude-code":"Claude"};function dv({runtime:e,className:n=""}){const r=e.availableProviders.filter(i=>i==="codex"||i==="claude-code");return f.jsxs("div",{className:`flex flex-wrap items-center gap-1 text-[10px] text-muted-foreground ${n}`.trim(),children:[f.jsx("span",{children:e.locationLabel}),e.loading?f.jsx(kt,{className:"h-3 w-3 animate-spin text-muted-foreground"}):!e.online&&f.jsx(ln,{variant:"outline",className:"h-4 border-amber-500/30 bg-amber-500/10 px-1 py-0 text-[9px] text-amber-700 dark:text-amber-300",children:"Offline"}),r.map(i=>f.jsx(ln,{variant:"outline",className:"h-4 px-1 py-0 text-[9px]",children:wSe[i]},i))]})}function SSe({repositories:e,selectedRepo:n,disabled:r=!1,getRuntimeInfo:i,onSelect:s,onAddRepository:o}){return f.jsxs(Eu,{children:[f.jsx(Ou,{asChild:!0,children:f.jsxs($e,{variant:"outline",size:"sm",className:"h-8 gap-1.5 rounded-lg px-2 text-xs",disabled:r,children:[f.jsx(fu,{className:"h-3.5 w-3.5 shrink-0"}),f.jsx("span",{className:"max-w-[140px] truncate",children:n?n.name:"Select repository"}),f.jsx(bo,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]})}),f.jsxs(dc,{align:"start",side:"top",className:"w-64",children:[f.jsx(Ov,{children:"Repository"}),e.map(a=>{const c=i(a);return f.jsx(Xo,{onSelect:()=>s(a.id),children:f.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[f.jsx(fu,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx("span",{className:"truncate",children:a.name}),f.jsx("span",{className:"text-[10px] text-muted-foreground",children:a.defaultBranch}),a.source==="shared"&&f.jsx(ln,{variant:"outline",className:"h-4 px-1 py-0 text-[9px]",children:"Shared"})]}),f.jsx(dv,{runtime:c,className:"mt-1"})]})]})},a.id)}),e.length===0&&f.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No repositories yet."}),f.jsx(Vo,{}),f.jsxs(Xo,{onSelect:o,children:[f.jsx(rc,{className:"mr-2 h-3.5 w-3.5"}),"Add repository"]})]})]})}function CSe({repositories:e,selectedRepoId:n,isMobile:r=!1,getRuntimeInfo:i,onSelect:s,onAddRepository:o,onRemoveRepository:a,onOpenStrategy:c,onOpenPlan:d}){return f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[f.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Repositories"}),f.jsxs($e,{variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[11px]",onClick:o,children:[f.jsx(rc,{className:"h-3 w-3"}),"Add"]})]}),f.jsx("div",{className:r?"flex-1 overflow-y-auto p-1.5 space-y-0.5":"flex-1 overflow-y-auto p-2 space-y-1",children:e.length===0?f.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground",children:["No repositories yet.",f.jsx("br",{}),f.jsx("button",{type:"button",onClick:o,className:"mt-1 inline-block underline underline-offset-2 hover:text-foreground",children:"Add one"})]}):e.map(h=>{const g=i(h);return f.jsxs("div",{role:"button",tabIndex:0,className:`flex w-full items-start gap-2 px-2 py-1.5 text-left transition-colors ${r?"cursor-pointer rounded-md text-sm":"rounded-lg text-xs"} ${n===h.id?r?"bg-secondary text-secondary-foreground":"bg-primary/10 text-primary":r?"hover:bg-muted/50":"hover:bg-muted"}`,onClick:()=>s(h.id),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),s(h.id))},children:[f.jsx(fu,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:r?"truncate text-xs font-medium":"truncate font-medium",children:h.name}),f.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1",children:[f.jsx("span",{className:"text-[10px] text-muted-foreground",children:h.defaultBranch}),h.source==="shared"&&f.jsx(ln,{variant:"outline",className:"h-4 shrink-0 px-1 py-0 text-[9px]",children:"Shared"})]}),f.jsx(dv,{runtime:g,className:"mt-1"})]}),f.jsxs("div",{className:"mt-0.5 flex shrink-0 flex-col gap-0.5",children:[f.jsx("button",{type:"button",title:"Strategy",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-primary",onClick:p=>{p.stopPropagation(),c(h)},children:f.jsx(WO,{className:"h-3 w-3"})}),f.jsx("button",{type:"button",title:"Plans",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-primary",onClick:p=>{p.stopPropagation(),d(h)},children:f.jsx(FO,{className:"h-3 w-3"})}),h.source==="local"&&f.jsx("button",{type:"button",title:"Remove",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-destructive",onClick:p=>{p.stopPropagation(),a(h.id)},children:f.jsx(Zf,{className:"h-3 w-3"})})]})]},h.id)})})]})}function jSe({thread:e,repo:n,repoName:r,prState:i,ghAvailable:s,onOpen:o,onStop:a,onDelete:c}){const d=n!=null&&(e.status==="completed"||!!e.prUrl);return f.jsxs("div",{role:"button",tabIndex:0,className:"group relative grid w-full grid-cols-[minmax(0,1fr)_auto] items-center gap-5 border-b px-3 py-3.5 text-sm transition-colors hover:bg-muted/40",onClick:o,onKeyDown:h=>{h.target===h.currentTarget&&(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),o())},children:[f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5",children:[f.jsx(v4,{status:e.status}),f.jsx("div",{className:"flex-1 truncate font-medium",children:y4(e.title)?f.jsx($L,{className:"h-3.5 w-28"}):f.jsx("span",{children:e.title.replace(/^\[.*?\]\s*/,"")})})]}),f.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 pl-[calc(0.75rem+6px)] text-xs text-muted-foreground sm:flex-nowrap sm:gap-x-1 sm:gap-y-0",children:[f.jsx("span",{className:"min-w-0 basis-full truncate sm:basis-auto",children:r}),e.branch&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"hidden sm:inline",children:"·"}),f.jsx("span",{className:"max-w-full truncate font-mono",children:e.branch})]}),e.providerId&&e.providerId!=="jait"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"hidden sm:inline",children:"·"}),f.jsx("span",{className:"shrink-0 whitespace-nowrap",children:e.providerId})]}),e.executionNodeName&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"hidden sm:inline",children:"·"}),f.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 truncate text-blue-500 dark:text-blue-400",children:[f.jsx(gs,{className:"inline h-3 w-3 mr-0.5 -mt-px"}),e.executionNodeName]})]}),i&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"hidden sm:inline",children:"·"}),f.jsx(IL,{prState:i})]})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[d&&n&&f.jsx("div",{className:"shrink-0",onClick:h=>h.stopPropagation(),onMouseDown:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),children:f.jsx(LS,{threadId:e.id,cwd:e.workingDirectory??n.localPath,branch:e.branch,baseBranch:n.defaultBranch,threadTitle:e.title,threadStatus:e.status,prUrl:e.prUrl,prState:i,ghAvailable:s,showStatusBadge:!1})}),e.status==="running"&&f.jsx($e,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg",onClick:h=>{h.stopPropagation(),a()},children:f.jsx($p,{className:"h-3 w-3"})}),f.jsx($e,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg opacity-100 transition-opacity",onClick:h=>{h.stopPropagation(),c()},children:f.jsx(Zf,{className:"h-3.5 w-3.5"})})]})]})}function kSe({threads:e,getRepositoryForThread:n,threadPrStates:r,ghAvailable:i,onOpenThread:s,onStopThread:o}){const[a,c]=y.useState(!1);return e.length===0?null:f.jsxs(Eu,{open:a,onOpenChange:c,children:[f.jsx(Ou,{asChild:!0,children:f.jsxs($e,{variant:"outline",size:"sm",className:"h-8 gap-1.5 rounded-lg px-2 text-xs",title:`${e.length} active ${e.length===1?"thread":"threads"}`,children:[f.jsx(kt,{className:"h-3.5 w-3.5 animate-spin text-blue-500"}),f.jsx("span",{className:"hidden sm:inline",children:"Active"}),f.jsx(ln,{variant:"secondary",className:"h-4 rounded-md px-1 text-[10px]",children:e.length})]})}),f.jsxs(dc,{align:"end",className:"w-[min(34rem,calc(100vw-1rem))] p-0",children:[f.jsx("div",{className:"flex items-center justify-between border-b px-3 py-2",children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(kt,{className:"h-3.5 w-3.5 animate-spin text-blue-500"}),f.jsxs("span",{className:"text-sm font-medium",children:[e.length," active ",e.length===1?"thread":"threads"]})]})}),f.jsx("div",{className:"max-h-[min(28rem,70vh)] overflow-y-auto",children:e.map(d=>{const h=n(d),g=(h==null?void 0:h.name)??a_(d)??"Unknown repo";return f.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-3 border-b px-3 py-3 last:border-b-0",children:[f.jsxs("button",{type:"button",className:"min-w-0 text-left transition-colors hover:text-foreground",onClick:()=>{c(!1),s(d.id)},children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[f.jsx(v4,{status:d.status}),f.jsx("span",{className:"truncate text-sm font-medium",children:y4(d.title)?"Generating title...":d.title.replace(/^\[.*?\]\s*/,"")})]}),f.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[f.jsx("span",{className:"truncate",children:g}),d.branch&&f.jsx(ln,{variant:"outline",className:"h-4 px-1 py-0 font-mono text-[9px]",children:d.branch}),d.providerId&&d.providerId!=="jait"&&f.jsx(ln,{variant:"outline",className:"h-4 px-1 py-0 text-[9px]",children:d.providerId}),d.executionNodeName&&f.jsxs(ln,{variant:"outline",className:"h-4 px-1 py-0 text-[9px] text-blue-500 dark:text-blue-400 border-blue-200 dark:border-blue-800",children:[f.jsx(gs,{className:"inline h-2.5 w-2.5 mr-0.5"}),d.executionNodeName]}),f.jsx(IL,{prState:d.id in r?r[d.id]:d.prState})]})]}),f.jsxs("div",{className:"flex items-center gap-1 self-start",children:[h&&f.jsx("div",{onClick:p=>p.stopPropagation(),onMouseDown:p=>p.stopPropagation(),children:f.jsx(LS,{threadId:d.id,cwd:d.workingDirectory??h.localPath,branch:d.branch,baseBranch:h.defaultBranch,threadTitle:d.title,threadStatus:d.status,prUrl:d.prUrl,prState:d.id in r?r[d.id]:d.prState,ghAvailable:i,showStatusBadge:!1})}),f.jsx($e,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg",onClick:p=>{p.stopPropagation(),Promise.resolve(o(d.id))},title:"Stop thread",children:f.jsx($p,{className:"h-3 w-3"})})]})]},d.id)})})]})]})}function ESe(){var yl,of,Po,Ss,ro,Cs,af;const[e,n]=y.useState(""),[r,i]=y.useState(!1),[s,o]=y.useState(null),[a,c]=y.useState("chat"),[d,h]=y.useState("system"),[g,p]=y.useState(()=>localStorage.getItem("showSessionsSidebar")==="true"),[_,b]=y.useState(!1),[x,C]=y.useState(!1),[j,S]=y.useState(null),[E,O]=y.useState(null),[N,T]=y.useState(!1),[P,D]=y.useState(!1),[H,J]=y.useState(!0),[I,B]=y.useState(!0),[F,W]=y.useState(!1),z=y.useRef(null),[V,A]=y.useState(()=>localStorage.getItem("showDebugPanel")==="true"),[U,K]=y.useState(280),[Y,$]=y.useState({x:-1,y:-1}),[R,Z]=y.useState({w:420,h:320}),L=y.useRef(null),Q=y.useRef(null),X=y.useRef(null),ie=y.useRef(null),[se,ce]=y.useState(!1),[be,ze]=y.useState("agent"),[fe,Ce]=y.useState("jait"),[me,Ye]=y.useState(()=>lw("jait")),tt=fe==="jait"?null:me[fe]??null,[Ue,mt]=y.useState("developer"),[Dt,Et]=y.useState("idle"),[St,Ct]=y.useState("idle"),qe=y.useRef(Ue),[Ne,Pe]=y.useState(""),[Fe,re]=y.useState(""),[he,_e]=y.useState(""),[ke,Oe]=y.useState(""),[Ie,Ae]=y.useState(""),[Ke,ht]=y.useState("login"),[de,gt]=y.useState(()=>ic()??""),Le=!!window.jaitDesktop||!!window.Capacitor,Je=!!window.jaitDesktop,rt=!!window.Capacitor,zt=Je?"electron":rt?"capacitor":"web",[jt,nn]=y.useState(null),[At,it]=y.useState(!1),[Tt,ft]=y.useState(!1),at=y.useRef(null),rn=y.useRef(!1),Ft=y.useRef(async()=>{}),[st,Bt]=y.useState(null),[Lt,Kt]=y.useState(!1),[An,In]=y.useState(()=>Le&&!R7()?"url":"auth"),[Gi,jo]=y.useState(!1),[Ci,En]=y.useState(null),[Bn,Us]=y.useState([]),[sa,zr]=y.useState(null),[il,oa]=y.useState([]),[ji,aa]=y.useState(!1),_s=y.useRef(!1),Lr=y.useRef(null),ki=y.useRef(null),sn=bS(),[On,la]=y.useState(0),Vs=!sn&&N,yr=sn&&N,cn=y.useCallback(()=>({width:window.innerWidth,height:window.innerHeight}),[]),gc=y.useCallback((q=R)=>vSe({size:q,viewport:cn()}),[R,cn]),yc=y.useCallback(q=>{var Pt;if(q.pointerType!=="touch"&&q.button!==0)return;q.preventDefault();const ee=cn(),ae=Y1({size:R,viewport:ee}),ve=Y.x<0||Y.y<0?gc(ae):Cp({position:Y,size:ae,viewport:ee});(ae.w!==R.w||ae.h!==R.h)&&Z(ae),(ve.x!==Y.x||ve.y!==Y.y)&&$(ve),L.current={pointerId:q.pointerId,startX:q.clientX,startY:q.clientY,posX:ve.x,posY:ve.y};const Re=Mt=>{!L.current||L.current.pointerId!==Mt.pointerId||$(Cp({position:{x:L.current.posX+Mt.clientX-L.current.startX,y:L.current.posY+Mt.clientY-L.current.startY},size:ae,viewport:cn()}))},Ve=()=>{document.removeEventListener("pointermove",Re),document.removeEventListener("pointerup",dt),document.removeEventListener("pointercancel",dt),document.body.style.cursor="",document.body.style.userSelect="",X.current=null},dt=Mt=>{!L.current||L.current.pointerId!==Mt.pointerId||(L.current=null,Ve())};q.pointerType!=="touch"&&(document.body.style.cursor="move"),document.body.style.userSelect="none",(Pt=X.current)==null||Pt.call(X),X.current=Ve,document.addEventListener("pointermove",Re),document.addEventListener("pointerup",dt),document.addEventListener("pointercancel",dt)},[Y,R,gc,cn]),Ru=y.useCallback(q=>{var dt;if(q.pointerType!=="touch"&&q.button!==0)return;q.preventDefault(),q.stopPropagation();const ee=cn(),ae=Y1({size:R,viewport:ee});(ae.w!==R.w||ae.h!==R.h)&&Z(ae),Q.current={pointerId:q.pointerId,startX:q.clientX,startY:q.clientY,w:ae.w,h:ae.h};const ve=Pt=>{if(!Q.current||Q.current.pointerId!==Pt.pointerId)return;const Mt=Y1({size:{w:Q.current.w+Pt.clientX-Q.current.startX,h:Q.current.h+Pt.clientY-Q.current.startY},viewport:cn()});Z(Mt),$(hn=>hn.x<0||hn.y<0?hn:Cp({position:hn,size:Mt,viewport:cn()}))},Re=()=>{document.removeEventListener("pointermove",ve),document.removeEventListener("pointerup",Ve),document.removeEventListener("pointercancel",Ve),document.body.style.cursor="",document.body.style.userSelect="",ie.current=null},Ve=Pt=>{!Q.current||Q.current.pointerId!==Pt.pointerId||(Q.current=null,Re())};q.pointerType!=="touch"&&(document.body.style.cursor="nwse-resize"),document.body.style.userSelect="none",(dt=ie.current)==null||dt.call(ie),ie.current=Re,document.addEventListener("pointermove",ve),document.addEventListener("pointerup",Ve),document.addEventListener("pointercancel",Ve)},[R,cn]);y.useEffect(()=>{var q,ee;P||(L.current=null,Q.current=null,(q=X.current)==null||q.call(X),(ee=ie.current)==null||ee.call(ie),document.body.style.cursor="",document.body.style.userSelect="")},[P]),y.useEffect(()=>()=>{var q,ee;(q=X.current)==null||q.call(X),(ee=ie.current)==null||ee.call(ie),document.body.style.cursor="",document.body.style.userSelect=""},[]),y.useEffect(()=>{if(!P)return;const q=()=>{const ee=cn();let ae;Z(ve=>{const Re=Y1({size:ve,viewport:ee});return ae=Re,Re.w===ve.w&&Re.h===ve.h?ve:Re}),$(ve=>{if(ve.x<0&&ve.y<0)return ve;const Re=Cp({position:ve,size:ae,viewport:ee});return Re.x===ve.x&&Re.y===ve.y?ve:Re})};return q(),window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[P,cn]);const{user:Yi,token:ut,settings:Mn,isLoading:$r,isAuthenticated:Qn,login:te,register:pe,logout:Ee,bindSession:Se,updateSettings:Me,clearSessionArchive:bt}=G5e(),lt=y.useCallback(async()=>{if(ut){it(!0);try{const q=await fetch(`${gi}/api/update/check`,{headers:{Authorization:`Bearer ${ut}`}});q.ok&&nn(await q.json())}catch{}it(!1)}},[ut]),yt=y.useCallback(async()=>{if(!(!ut||!(jt!=null&&jt.hasUpdate))){ft(!0);try{const q=await fetch(`${gi}/api/update/apply`,{method:"POST",headers:{Authorization:`Bearer ${ut}`,"Content-Type":"application/json"},body:JSON.stringify({version:jt.latestVersion})});if(q.ok)at.current=jt.latestVersion,rn.current=!1,Pr.success(`Updated to v${jt.latestVersion}. Gateway is restarting...`);else{const ee=await q.json().catch(()=>({}));Pr.error(ee.error??"Update failed")}}catch{Pr.error("Update request failed")}ft(!1)}},[ut,jt]),dn=y.useCallback(({connected:q,reconnected:ee})=>{if(!q){at.current&&(rn.current=!0);return}if(Ft.current(),ee&&at.current&&rn.current){const ae=at.current;at.current=null,rn.current=!1,Pr.success(`Gateway restarted on v${ae}.`),lt()}},[lt]);y.useEffect(()=>{ut&<()},[ut,lt]);const Gt=y.useCallback(()=>i(!0),[]),{sessions:wn,activeSessionId:Ge,createSession:Ir,switchSession:Ws,archiveSession:l_,fetchSessions:Kg,hasMoreSessions:Gg,showMoreSessions:Nd,showFewerSessions:c_,sessionListLimit:u_}=Q5e(ut,Gt),{messages:qs,isLoading:vr,isLoadingHistory:Du,remainingPrompts:ca,error:Ei,hitMaxRounds:sl,pendingPlan:Td,todoList:zu,changedFiles:Xi,messageQueue:Oi,contextUsage:Ks,sessionInfo:vc,sendMessage:ko,restartFromMessage:Gs,cancelRequest:Lu,clearMessages:_c,continueChat:Yg,executePlan:$u,rejectPlan:Iu,enqueueMessage:ol,dequeueMessage:Xr,updateQueueItem:ua,reorderQueueItem:Bu,setMessageQueueState:Ni,acceptFile:Pd,rejectFile:Ad,acceptAllFiles:Md,rejectAllFiles:bc,setTodoList:Ys,addChangedFile:xc,setChangedFiles:wc,setOnChangedFilesSync:Rd,refreshMessages:f_}=J5e(Ge,ut,Gt),[al,fa]=y.useState({}),Dd=y.useRef(new Set),{terminals:Sc,activeTerminalId:da,setActiveTerminalId:ll,createTerminal:Cc,killTerminal:Xg,refresh:Jg}=V5e(ut),{provider:d_,model:Fu}=Z5e(),Hu=C2e({token:ut}),we=mSe();Ft.current=we.refresh;const Uu=y.useMemo(()=>che(we.activities),[we.activities]),cl=y.useMemo(()=>[...we.threads].sort((q,ee)=>new Date(ee.updatedAt).getTime()-new Date(q.updatedAt).getTime()),[we.threads]),Vu=y.useMemo(()=>we.selectedRepo?we.getRuntimeInfoForRepository(we.selectedRepo):null,[we.getRuntimeInfoForRepository,we.selectedRepo]),bs=y.useMemo(()=>we.selectedThread?we.getRepositoryForThread(we.selectedThread):null,[we.getRepositoryForThread,we.selectedThread]),zd=y.useMemo(()=>bs?we.getRuntimeInfoForRepository(bs):null,[we.getRuntimeInfoForRepository,bs]),Zg=y.useMemo(()=>cl.filter(q=>q.status==="running"),[cl]),h_=sn&&Ue==="manager"&&!!we.selectedThread,Qg=y.useMemo(()=>we.selectedThread?al[we.selectedThread.id]??[]:[],[we.selectedThread,al]),p_=we.selectedRepo!=null,e0=we.creating||!p_,m_=we.selectedRepo?"Describe what you want to do...":"Select a repository to start a thread...",[_t,Ji]=y.useState(null);y.useEffect(()=>{var ae,ve,Re;const q=window.jaitDesktop;if(!q)return;(ae=q.getInfo)==null||ae.call(q).then(Ve=>Bt(Ve.platform)),(ve=q.windowIsMaximized)==null||ve.call(q).then(Ve=>Kt(Ve));const ee=(Re=q.onMaximizedChange)==null?void 0:Re.call(q,(Ve,dt)=>Kt(dt));return()=>{ee==null||ee()}},[]);const _r=y.useRef(!1);y.useEffect(()=>{_r.current=!1},[Ge]);const[ha,Zi]=ao(Ge,"workspace.panel",ut),[jc,Xs]=ao(Ge,"screen-share.panel",ut),[kc,pa]=ao(Ge,"terminal.panel",ut),[Js,t0,n0]=ao(Ge,"workspace.layout",ut),[Ld,$d,Id]=ao(Ge,"chat.mode",ut),[xs,ul,r0]=ao(Ge,"chat.cliModels",ut),[fl,Bd,Fd]=ao(Ge,"chat.view",ut),[Wu,qu]=ao(Ge,"workspace.tabs",ut),[Ku,Hd]=ao(Ge,"queued_messages",ut),[Ud,dl]=y.useState(null);y.useEffect(()=>{dl(null)},[Ge]);const[Gu]=ao(Ge,"todo_list",ut),[Yu]=ao(Ge,"changed_files",ut);y.useEffect(()=>{_r.current||ha&&(_t||ha.open&&ha.remotePath&&Ji({surfaceId:ha.surfaceId??"",workspaceRoot:ha.remotePath,nodeId:ha.nodeId}))},[ha]),y.useEffect(()=>{_r.current||jc!=null&&jc.open&&D(!0)},[jc]),y.useEffect(()=>{_r.current||kc!=null&&kc.open&&b(!0)},[kc]),y.useEffect(()=>{_r.current||Js&&(J(Js.tree!==!1),B(Js.editor!==!1))},[Js]),y.useEffect(()=>{_r.current||Ld&&ze(Ld)},[Ld]),y.useEffect(()=>{if(_r.current)return;if(xs&&Object.keys(xs).length>0){Ye(ee=>{const ae=Object.keys(xs);return ae.length===Object.keys(ee).length&&ae.every(ve=>ee[ve]===xs[ve])?ee:xs});return}const q=lw(fe);Object.keys(q).length>0&&Ye(q)},[xs,fe]),y.useEffect(()=>{_r.current||fl&&mt(fl)},[fl]),y.useEffect(()=>{_r.current||dl(Wu??null)},[Wu]);const i0=y.useRef(null);y.useEffect(()=>{if(_r.current)return;const q=JSON.stringify(Ku??[]);q!==i0.current&&(i0.current=q,Ni(Ku??[]))},[Ku,Ni]),y.useEffect(()=>{_r.current||Gu&&Gu.length>0&&Ys(Gu)},[Gu,Ys]),y.useEffect(()=>{if(!_r.current&&Yu&&Yu.length>0)for(const q of Yu)xc(q.path,q.name)},[Yu,xc]);const g_=y.useCallback((q,ee)=>{switch(q){case"workspace.panel":{if(!ee)T(!1),Ji(null);else{const ae=ee;ae.open?(T(!0),ae.remotePath&&Ji({surfaceId:ae.surfaceId??"",workspaceRoot:ae.remotePath,nodeId:ae.nodeId})):T(!1)}break}case"screen-share.panel":D(ee?ee.open!==!1:!1);break;case"terminal.panel":b(ee?ee.open!==!1:!1);break;case"workspace.layout":{const ae=ee;ae?(J(ae.tree!==!1),B(ae.editor!==!1)):(J(!0),B(!0));break}case"chat.mode":(ee==="ask"||ee==="agent"||ee==="plan")&&ze(ee);break;case"chat.cliModels":ee&&typeof ee=="object"&&!Array.isArray(ee)?Ye(ee):ee===null&&Ye({});break;case"chat.view":(ee==="developer"||ee==="manager")&&mt(ee);break;case"todo_list":Array.isArray(ee)&&Ys(ee);break;case"file_changed":{const ae=ee;ae!=null&&ae.path&&xc(ae.path,ae.name??ae.path.split("/").pop()??ae.path);break}case"changed_files":{Array.isArray(ee)?wc(ee):ee===null&&wc([]);break}case"workspace.tabs":{dl(ee&&typeof ee=="object"?ee:null);break}case"queued_messages":{Array.isArray(ee)?Ni(ee):ee===null&&Ni([]);break}}},[Ys,xc,wc,Ni]),ai=y.useCallback(q=>{_r.current=!0;const ee=q["workspace.panel"];ee&&ee.open?(T(!0),ee.remotePath&&Ji({surfaceId:ee.surfaceId??"",workspaceRoot:ee.remotePath,nodeId:ee.nodeId})):(T(!1),Ji(null));const ae=q["screen-share.panel"];ae&&ae.open!==!1?D(!0):D(!1);const ve=q["terminal.panel"];ve&&ve.open!==!1?b(!0):b(!1);const Re=q["workspace.layout"];Re?(J(Re.tree!==!1),B(Re.editor!==!1)):(J(!0),B(!0));const Ve=q["chat.mode"];(Ve==="ask"||Ve==="agent"||Ve==="plan")&&ze(Ve);const dt=q["chat.cliModels"];if(dt&&typeof dt=="object"&&!Array.isArray(dt))Ye(dt);else{const Qr=lw(fe);Ye(Qr)}const Pt=q["chat.view"];(Pt==="developer"||Pt==="manager")&&mt(Pt);const Mt=q.todo_list;Array.isArray(Mt)&&Mt.length>0&&Ys(Mt);const hn=q.changed_files;Array.isArray(hn)&&wc(hn);const $t=q["workspace.tabs"];dl($t&&typeof $t=="object"?$t:null);const br=q.queued_messages;Array.isArray(br)?Ni(br):Ni([])},[Ys,wc,Ni]),{sendUIState:un}=sSe({sessionId:Ge,token:ut,onStateSync:g_,onFullState:ai,onMessageComplete:f_,onThreadEvent:we.handleThreadEvent,onConnectionStateChange:dn,onFsChanges:y.useCallback(q=>{la(ee=>ee+1)},[]),listeners:{"workspace.open":y.useCallback(q=>{T(!0),Ji({surfaceId:q.surfaceId,workspaceRoot:q.workspaceRoot,nodeId:q.nodeId});const ee={open:!0,remotePath:q.workspaceRoot,surfaceId:q.surfaceId,nodeId:q.nodeId};Zi(ee)},[Zi]),"workspace.close":y.useCallback(()=>{T(!1),Ji(null),Zi(null)},[Zi]),"terminal.focus":y.useCallback(q=>{c("chat"),b(!0),pa({open:!0}),q.terminalId&&ll(q.terminalId),q.reason==="interactive-input-required"&&Pr(q.message??"Terminal wartet auf deine Eingabe (z. B. sudo Passwort).",{description:"Klicke ins Terminal und gib die erforderliche Eingabe ein.",duration:1e4})},[pa,ll]),"screen-share.open":y.useCallback(()=>{D(!0),Xs({open:!0})},[Xs]),"screen-share.close":y.useCallback(()=>{D(!1),Xs(null)},[Xs])}}),Vd=y.useCallback(q=>{dl(q),qu(q),un("workspace.tabs",q,Ge)},[qu,un,Ge]);y.useEffect(()=>{if(Ge&&ut&&n0)return;const q={tree:H,editor:I};t0(q),un("workspace.layout",q,Ge)},[H,I,t0,un,Ge,n0,ut]),y.useEffect(()=>{Ge&&ut&&Id||($d(be),un("chat.mode",be,Ge))},[be,$d,un,Ge,Id,ut]),y.useEffect(()=>{Ge&&ut&&Fd||(Bd(Ue),un("chat.view",Ue,Ge))},[Ue,Bd,un,Ge,Fd,ut]);const Wd=y.useRef(null);y.useEffect(()=>{const q=Oi.length>0?Oi:null,ee=JSON.stringify(q);ee!==Wd.current&&(Wd.current=ee,Hd(q),un("queued_messages",q,Ge))},[Oi,Hd,un,Ge]),y.useEffect(()=>(Rd(q=>{un("changed_files",q,Ge)}),()=>Rd(null)),[un,Ge,Rd]),y.useEffect(()=>{localStorage.setItem("showSessionsSidebar",g?"true":"false")},[g]),y.useEffect(()=>{localStorage.setItem("showDebugPanel",V?"true":"false")},[V]);const Ec=y.useCallback(q=>{Ce(q)},[]),Oc=y.useCallback(q=>{fe!=="jait"&&Ye(ee=>({...ee,[fe]:q}))},[fe]),Xu=y.useRef(null);y.useEffect(()=>{if(Ge&&ut&&r0)return;const q={};for(const ve of["codex","claude-code"]){const Re=me[ve];typeof Re=="string"&&Re.trim()&&(q[ve]=Re)}const ee=Object.keys(q).length>0?q:null,ae=JSON.stringify(ee);ae!==Xu.current&&(Xu.current=ae,ul(ee),un("chat.cliModels",ee,Ge),localStorage.removeItem("cliModelsByProvider"),localStorage.removeItem("cliModel"))},[me,Ge,r0,un,ul,ut]);const s0=y.useRef(!1);y.useEffect(()=>{if(!s0.current){s0.current=!0;return}ut&&Me({chat_provider:fe})},[fe]),y.useEffect(()=>{qe.current!=="manager"&&Ue==="manager"?(Et("center"),requestAnimationFrame(()=>{document.body.offsetHeight,requestAnimationFrame(()=>Et("top"))})):(qe.current==="manager"&&Ue==="developer"&&Ct("animating"),Et("idle")),qe.current=Ue},[Ue]),y.useEffect(()=>{Ue==="manager"&&V&&A(!1)},[Ue,V]);const hl=y.useCallback(()=>{D(!0),Xs({open:!0}),un("screen-share.panel",{open:!0},Ge)},[Xs,un,Ge]),Ju=y.useCallback(()=>{D(!1),Xs(null),un("screen-share.panel",null,Ge)},[Xs,un,Ge]),Eo=y.useCallback(()=>{b(!0),pa({open:!0}),un("terminal.panel",{open:!0},Ge)},[pa,un,Ge]),ma=y.useCallback(()=>{b(!1),pa(null),un("terminal.panel",null,Ge)},[pa,un,Ge]),Zu=y.useCallback(()=>{T(!1),Ji(null),Zi(null),un("workspace.panel",null,Ge)},[Zi,un,Ge]),Oo=y.useCallback(()=>{J(q=>!q)},[]),ga=y.useCallback(()=>{B(q=>!q)},[]),Nc=y.useCallback(()=>{J(!0)},[]),Zs=y.useCallback(()=>{B(!0)},[]),Qi=y.useCallback(async(q,ee,ae)=>{const ve=ae??Ge,Re=await fetch(`${gi}/api/workspace/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:q,sessionId:ve,nodeId:ee||"gateway"})});if(!Re.ok){const Ve=await Re.json().catch(()=>({message:"Unknown error"}));throw new Error(Ve.message??"Failed to open workspace")}ut&&Me({workspace_picker_path:q,workspace_picker_node_id:ee||"gateway"}).catch(()=>{})},[Ge,ut,Me]),o0=y.useCallback(async()=>{if(N){if(Xi.length>0){W(!0);return}Zu();return}if(Ue==="manager"&&we.selectedThread){const q=we.selectedThread.workingDirectory??(bs==null?void 0:bs.localPath);if(q){if((_t==null?void 0:_t.workspaceRoot)===q){T(!0);const ae={open:!0,remotePath:_t.workspaceRoot,surfaceId:_t.surfaceId};Zi(ae),un("workspace.panel",ae,Ge);return}let ee=Ge;if(!ee){const ae=await Ir();ee=(ae==null?void 0:ae.id)??null}if(!ee)return;await Qi(q,(bs==null?void 0:bs.deviceId)??void 0,ee);return}}if(_t){T(!0);const q={open:!0,remotePath:_t.workspaceRoot,surfaceId:_t.surfaceId};Zi(q),un("workspace.panel",q,Ge);return}aa(!0)},[N,_t,Zu,Zi,un,Ge,Qi,Xi.length,Ue,we.selectedThread,bs,Ir]);y.useEffect(()=>{_t&&(N||T(!0))},[_t]),y.useEffect(()=>{if(!(_t!=null&&_t.surfaceId)||!_t.workspaceRoot||!Ge)return;let q=!1;return(async()=>{try{if((await fetch(`${gi}/api/workspace/list?path=${encodeURIComponent(_t.workspaceRoot)}&surfaceId=${encodeURIComponent(_t.surfaceId)}`)).ok||q)return;const ae=await fetch(`${gi}/api/workspace/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:_t.workspaceRoot,sessionId:Ge})});if(!ae.ok||q)return;const ve=await ae.json();if(q)return;Ji({surfaceId:ve.surfaceId,workspaceRoot:ve.workspaceRoot});const Re={open:!0,remotePath:ve.workspaceRoot,surfaceId:ve.surfaceId};Zi(Re),un("workspace.panel",Re,Ge)}catch{}})(),()=>{q=!0}},[_t==null?void 0:_t.surfaceId,Ge]),y.useEffect(()=>{Xi.length!==0&&(N||T(!0))},[Xi.length]);const qd=y.useMemo(()=>Xi.filter(q=>q.state==="undecided").map(q=>q.path),[Xi]);y.useEffect(()=>{h(Mn.theme)},[Mn.theme]),y.useEffect(()=>{$r||Mn.chat_provider&&Mn.chat_provider!==fe&&Ce(Mn.chat_provider)},[Mn.chat_provider,$r]),y.useEffect(()=>{var ae,ve;if(jO(d),Je&&st==="win32"){const Re=d==="dark"||d==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches;(ve=(ae=window.jaitDesktop)==null?void 0:ae.setTitleBarOverlay)==null||ve.call(ae,{color:Re?"#202020":"#e8ecf1",symbolColor:Re?"#f2f2f2":"#0a0a0a",height:39})}const q=window.matchMedia("(prefers-color-scheme: dark)"),ee=()=>{var Re,Ve;if(d==="system"&&jO("system"),Je&&st==="win32"){const dt=q.matches;(Ve=(Re=window.jaitDesktop)==null?void 0:Re.setTitleBarOverlay)==null||Ve.call(Re,{color:dt?"#202020":"#e8ecf1",symbolColor:dt?"#f2f2f2":"#0a0a0a",height:39})}};return q.addEventListener("change",ee),()=>q.removeEventListener("change",ee)},[d,st]),y.useEffect(()=>{if(!$r&&!Qn){const q=requestAnimationFrame(()=>i(!0));return Le&&R7()&&fetch(`${Wn()}/health`,{signal:AbortSignal.timeout(4e3)}).then(ee=>{if(!ee.ok)throw new Error("unhealthy")}).catch(()=>{In("url"),En("Gateway is unreachable. Check the URL or try a different one."),gt(ic()??"")}),()=>cancelAnimationFrame(q)}},[$r,Qn]),y.useEffect(()=>{Qn&&Ge&&Se(Ge)},[Qn,Ge,Se]),y.useEffect(()=>{if(Ei==="login_required"){const q=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(q)}},[Ei]),y.useEffect(()=>{(async()=>{if(!Ge){ce(!1);return}try{const ae=await(await fetch(`${gi}/api/consent/pending/${Ge}/approve-all`)).json();ce(ae.approveAllEnabled===!0)}catch{ce(!1)}})()},[Ge]);const a0=y.useCallback(async q=>{const ee=d;h(q);try{await Me({theme:q})}catch{h(ee)}},[d,Me]),y_=y.useCallback(q=>{q.preventDefault(),_s.current=!0;const ee=q.clientY,ae=U,ve=window.innerHeight*.5,Re=dt=>{if(!_s.current)return;const Pt=ee-dt.clientY;K(Math.min(ve,Math.max(280,ae+Pt)))},Ve=()=>{_s.current=!1,document.removeEventListener("mousemove",Re),document.removeEventListener("mouseup",Ve),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",Re),document.addEventListener("mouseup",Ve)},[U]),Qu=y.useCallback(async(q=null)=>{const ee=await Jg();if(q&&ee.some(Re=>Re.id===q))return ll(q),q;if(da&&ee.some(ve=>ve.id===da))return da;if(ee.length>0){const ve=ee[ee.length-1].id;return ll(ve),ve}return(await Cc(Ge??"default")).id},[Jg,ll,da,Cc,Ge]),v_=y.useCallback(async q=>{c("chat"),Eo(),await Qu(q)},[Qu,Eo]),l0=y.useCallback(async()=>{if(_){ma();return}c("chat"),Eo(),await Qu()},[_,Qu,Eo,ma]),c0=y.useCallback(async q=>{var ae;const ee=Sc.length===1&&((ae=Sc[0])==null?void 0:ae.id)===q;await Xg(q),ee&&ma()},[Sc,Xg,ma]),ws=y.useCallback(q=>{q.length!==0&&(Us(ee=>{const ae=[...ee];for(const ve of q){const Re=ae.findIndex(Ve=>Ve.path===ve.path);Re>=0?ae[Re]=ve:ae.push(ve)}return ae}),zr(ee=>{var ae;return ee??((ae=q[0])==null?void 0:ae.id)??null}))},[]),li=y.useCallback(async q=>{var ee,ae,ve;try{const Re={};ut&&(Re.Authorization=`Bearer ${ut}`);const Ve=_t!=null&&_t.surfaceId?`&surfaceId=${encodeURIComponent(_t.surfaceId)}`:"",dt=await fetch(`${gi}/api/workspace/backup?path=${encodeURIComponent(q)}${Ve}`,{headers:Re});if(dt.ok){const pi=await dt.json(),ts=q.split(/[\/\\]/).pop()??q;await((ee=Lr.current)==null?void 0:ee.openReviewDiff({path:pi.path,originalContent:pi.originalContent??"",modifiedContent:pi.currentContent,language:dp(ts)})),N||T(!0),Zs();return}if(await((ae=Lr.current)==null?void 0:ae.openFileByPath(q))){N||T(!0);return}const Mt=await((ve=Lr.current)==null?void 0:ve.readFileByPath(q));if(Mt){ws([Mt]),zr(Mt.id),N||T(!0);return}const hn=await fetch(`${gi}/api/workspace/read?path=${encodeURIComponent(q)}${Ve}`,{headers:Re});if(!hn.ok)return;const $t=await hn.json(),br=q.split("/").pop()??q,Qr={id:`changed-${q}`,name:br,path:$t.path,content:$t.content,language:dp(br)};ws([Qr]),zr(Qr.id),N||T(!0)}catch{}},[ut,_t==null?void 0:_t.surfaceId,N,ws,Zs]),Tc=y.useCallback(async q=>{var ee;try{let ae=(_t==null?void 0:_t.workspaceRoot)??null;if(jne(q,ae)||(ae=kne(q)),ae&&(!_t||_t.workspaceRoot!==ae)&&await Qi(ae,_t==null?void 0:_t.nodeId,Ge),await((ee=Lr.current)==null?void 0:ee.openFileByPath(q))){N||T(!0),Zs();return}const Re=Bn.find(Ve=>Ve.path===q);if(Re)ws([Re]),zr(Re.id);else{const Ve={};ut&&(Ve.Authorization=`Bearer ${ut}`);const dt=await fetch(`${gi}/api/workspace/read?path=${encodeURIComponent(q)}`,{headers:Ve});if(!dt.ok)throw new Error(`Failed to open file: ${dt.status}`);const Pt=await dt.json(),Mt=q.split(/[\\/]/).pop()??q,hn={id:Pt.path,name:Mt,path:Pt.path,content:Pt.content,language:dp(Mt)};ws([hn]),zr(hn.id)}N||T(!0),Zs()}catch(ae){Pr(ae instanceof Error?ae.message:"Failed to open linked file")}},[Ge,_t,ws,Qi,N,Zs,ut,Bn]),ci=y.useCallback(async(q,ee)=>{try{const ae={"Content-Type":"application/json"};ut&&(ae.Authorization=`Bearer ${ut}`),await fetch(`${gi}/api/workspace/apply-diff`,{method:"POST",headers:ae,body:JSON.stringify({path:q,content:ee})})}catch{}Pd(q)},[ut,Pd]),ya=y.useCallback(async q=>{const ee=Array.from(q),ae=await Promise.all(ee.filter(ve=>ve.size<1024*1024).map(async ve=>{const Re=await ve.text(),Ve=ve.webkitRelativePath||ve.name;return{id:`${Ve}-${ve.lastModified}`,name:ve.name,path:Ve,content:Re,language:dp(Ve)}}));ws(ae)},[ws]),Pc=y.useCallback(async(q,ee,ae)=>{var ve;return((ve=Lr.current)==null?void 0:ve.searchFiles(q,ee,ae))??[]},[]),Qs=y.useCallback(async(q,ee)=>{var dt;const ae=q.trim();if(!ae&&(!ee||ee.length===0))return null;const ve=[],Re=new Set;if(ee!=null&&ee.length){const Pt=new Set;for(const Mt of ee){if(Pt.has(Mt.path))continue;Pt.add(Mt.path),Re.add(Mt.path);const hn=Bn.find(br=>br.path===Mt.path);if(hn){ve.push({path:hn.path,content:hn.content});continue}const $t=await((dt=Lr.current)==null?void 0:dt.readFileByPath(Mt.path));$t&&ve.push({path:$t.path,content:$t.content})}}return{promptWithReferences:ve.length>0?`${ae}${ae?`
|
|
809
|
+
*${st.message}*`;de+=Bt,nn(Bt),Tt({content:de,segments:[...zt]})}else if(st.type==="todo_list"){const Bt=st.items;d(Bt)}else if(st.type==="context_usage")x(st);else if(st.type==="session_info")j({provider:st.provider,workspacePath:st.workspacePath,isRemote:st.isRemote,remoteNode:st.remoteNode});else if(st.type==="file_changed"){const Bt=st.path,Lt=st.name;g(Kt=>Kt.find(In=>In.path===Bt)?Kt:[...Kt,{path:Bt,name:Lt,state:"undecided"}])}else if(st.type==="done"){if(it(),Le&&!Je&&(Je=Math.round((Date.now()-Le)/1e3)),!Pe()){const Bt=de.length===0&>.length===0&&rt.length===0;s(Lt=>({...Lt,promptCount:st.prompt_count,remainingPrompts:st.remaining_prompts,isLoading:!1,hitMaxRounds:!!st.hit_max_rounds,messages:Bt?Lt.messages.filter(Kt=>Kt.id!==St):Lt.messages.map(Kt=>Kt.id===St?{...Kt,content:de,thinking:gt||void 0,thinkingDuration:Je,toolCalls:rt.length>0?rt:void 0,segments:zt.length>0?zt:void 0}:Kt)}))}return!0}else if(st.type==="error")throw new Error(st.message)}catch(st){if(!(st instanceof SyntaxError))throw st}}it()}catch(Oe){return re!==null&&(window.cancelAnimationFrame(re),re=null),Fe=null,Oe instanceof Error&&Oe.name==="AbortError"?(Pe()||s(Ie=>({...Ie,isLoading:!1,messages:Ie.messages.filter(Ae=>me.queued?Ae.id!==St&&Ae.id!==Ct.id:!(Ae.id===St&&!Ae.content&&!Ae.thinking&&(!Ae.toolCalls||Ae.toolCalls.length===0))).map(Ae=>{var Ke;return(Ke=Ae.toolCalls)!=null&&Ke.some(ht=>ht.status==="running")?{...Ae,toolCalls:Ae.toolCalls.map(ht=>ht.status==="running"?{...ht,status:"error",result:{ok:!1,message:"Cancelled"},completedAt:Date.now()}:ht)}:Ae})})),!1):(Pe()||s(Ie=>({...Ie,isLoading:!1,error:Oe instanceof Error?Oe.message:"An error occurred",messages:Ie.messages.filter(Ae=>me.queued?Ae.id!==St&&Ae.id!==Ct.id:!(Ae.id===St&&!Ae.content&&!Ae.thinking&&(!Ae.toolCalls||Ae.toolCalls.length===0)))})),!1)}return!0},[n,r,e]),F=y.useCallback(Ce=>{const me={id:`q-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,...Ce,queuedAt:Date.now()};_(Ye=>[...Ye,me])},[]),W=y.useCallback(Ce=>{_(me=>me.filter(Ye=>Ye.id!==Ce))},[]),z=y.useCallback((Ce,me)=>{const Ye=me.trim();Ye&&_(tt=>tt.map(Ue=>Ue.id===Ce?{...Ue,content:Ye,displayContent:Ye,referencedFiles:void 0}:Ue))},[]),V=y.useCallback((Ce,me)=>{_(Ye=>J5e(Ye,Ce,me))},[]),A=y.useCallback(Ce=>{_(Ce)},[]),U=y.useCallback(async(Ce={})=>{var Ye;if(S.current||i.isLoading||i.isLoadingHistory||p.length===0||typeof document<"u"&&document.hidden)return;const me=p[0];if(me){S.current=!0,_(tt=>{var Ue;return tt.length===0?tt:((Ue=tt[0])==null?void 0:Ue.id)===me.id?tt.slice(1):tt.filter(mt=>mt.id!==me.id)});try{await B(me.content,{...Ce,queued:!0,...me.mode?{mode:me.mode}:{},...me.provider?{provider:me.provider}:{},...me.model!==void 0?{model:me.model}:{},...me.displayContent?{displayContent:me.displayContent}:{},...(Ye=me.referencedFiles)!=null&&Ye.length?{referencedFiles:me.referencedFiles}:{}})||_(Ue=>Ue.some(mt=>mt.id===me.id)?Ue:[me,...Ue])}finally{S.current=!1}}},[p,B,i.isLoading,i.isLoadingHistory]);y.useEffect(()=>{if(!i.isLoading&&!i.isLoadingHistory&&p.length>0&&!S.current&&!document.hidden){const Ce=O.current;U({token:n,sessionId:Ce,onLoginRequired:r})}},[i.isLoading,i.isLoadingHistory,p,U,n,r]),y.useEffect(()=>{const Ce=()=>{if(!document.hidden&&(J(),!i.isLoading&&!i.isLoadingHistory&&p.length>0&&!S.current)){const me=O.current;U({token:n,sessionId:me,onLoginRequired:r})}};return document.addEventListener("visibilitychange",Ce),()=>document.removeEventListener("visibilitychange",Ce)},[i.isLoading,i.isLoadingHistory,p,U,n,r,J]),y.useEffect(()=>{if(typeof window>"u")return;const Ce=()=>{if(!(typeof document<"u"&&document.hidden)&&(J(),!i.isLoading&&!i.isLoadingHistory&&p.length>0&&!S.current)){const me=O.current;U({token:n,sessionId:me,onLoginRequired:r})}};return window.addEventListener("focus",Ce),window.addEventListener("pageshow",Ce),window.addEventListener("online",Ce),()=>{window.removeEventListener("focus",Ce),window.removeEventListener("pageshow",Ce),window.removeEventListener("online",Ce)}},[i.isLoading,i.isLoadingHistory,p,U,n,r,J]);const K=y.useRef(null),Y=y.useCallback(Ce=>{K.current=Ce},[]),$=y.useCallback(Ce=>{g(me=>{var tt;const Ye=Ce(me);return(tt=K.current)==null||tt.call(K,Ye),Ye})},[]),R=y.useCallback(async Ce=>{$(me=>me.map(Ye=>Ye.path===Ce?{...Ye,state:"accepted"}:Ye));try{const me={"Content-Type":"application/json"};n&&(me.Authorization=`Bearer ${n}`),await fetch(`${oo}/api/workspace/apply-diff`,{method:"POST",headers:me,body:JSON.stringify({path:Ce,content:null})})}catch{}},[n,$]),Z=y.useCallback(async Ce=>{try{const me={"Content-Type":"application/json"};n&&(me.Authorization=`Bearer ${n}`),await fetch(`${oo}/api/workspace/undo`,{method:"POST",headers:me,body:JSON.stringify({path:Ce})})}catch{}$(me=>me.map(Ye=>Ye.path===Ce?{...Ye,state:"rejected"}:Ye))},[n,$]),L=y.useCallback(()=>{$(Ce=>Ce.map(me=>me.state==="undecided"?{...me,state:"accepted"}:me))},[$]),Q=y.useCallback(async()=>{const Ce=h.filter(me=>me.state==="undecided").map(me=>me.path);if(Ce.length>0)try{const me={"Content-Type":"application/json"};n&&(me.Authorization=`Bearer ${n}`),await fetch(`${oo}/api/workspace/undo-all`,{method:"POST",headers:me,body:JSON.stringify({paths:Ce})})}catch{}$(me=>me.map(Ye=>Ye.state==="undecided"?{...Ye,state:"rejected"}:Ye))},[n,h,$]);y.useEffect(()=>{if(h.length===0||!h.every(Ye=>Ye.state!=="undecided"))return;const me=setTimeout(()=>g([]),1200);return()=>clearTimeout(me)},[h]);const X=y.useCallback(()=>{var me,Ye;T.current+=1;const Ce=O.current;Ce&&fetch(`${oo}/api/sessions/${Ce}/cancel`,{method:"POST",headers:sw(n)}).catch(()=>{}),(me=E.current)==null||me.abort(),(Ye=N.current)==null||Ye.abort(),N.current=null,s(tt=>({...tt,isLoading:!1,messages:tt.messages.map(Ue=>{var mt;return(mt=Ue.toolCalls)!=null&&mt.some(Dt=>Dt.status==="running")?{...Ue,toolCalls:Ue.toolCalls.map(Dt=>Dt.status==="running"?{...Dt,status:"error",result:{ok:!1,message:"Cancelled"},completedAt:Date.now()}:Dt)}:Ue})}))},[n]),ie=y.useCallback(()=>{s({messages:[],isLoading:!1,isLoadingHistory:!1,promptCount:0,remainingPrompts:null,error:null,hitMaxRounds:!1}),d([]),g([]),_([])},[]),se=y.useCallback((Ce={})=>(s(me=>({...me,hitMaxRounds:!1})),B("Continue from where you left off.",Ce)),[B]),ce=y.useCallback(async(Ce,me,Ye,tt,Ue={})=>{var Ne,Pe;const{token:mt,sessionId:Dt,onLoginRequired:Et}=Ue,St=mt??n,Ct=Et??r,qe=Dt??e;if(!(!qe||!me.trim()||P.current)){P.current=!0;try{const Fe={"Content-Type":"application/json"};St&&(Fe.Authorization=`Bearer ${St}`);const re=()=>fetch(`${oo}/api/sessions/${qe}/restart-from`,{method:"POST",headers:Fe,body:JSON.stringify({messageId:Ce,messageIndex:Ye,messageFromEnd:tt})}),he=Ie=>new Promise(Ae=>window.setTimeout(Ae,Ie)),_e=async()=>{for(let Ie=0;Ie<32;Ie+=1){const Ae=await fetch(`${oo}/api/sessions/${qe}/messages?limit=1`,{headers:Fe}).catch(()=>null);if(Ae!=null&&Ae.ok&&!(await Ae.json().catch(()=>({}))).streaming)return!0;await he(250)}return!1};T.current+=1,(Ne=E.current)==null||Ne.abort(),(Pe=N.current)==null||Pe.abort(),N.current=null,await fetch(`${oo}/api/sessions/${qe}/cancel`,{method:"POST",headers:sw(St)}).catch(()=>null),await _e();let ke=await re();if(ke.status===409&&(await _e(),ke=await re()),ke.status===401){(await ke.json().catch(()=>({}))).detail==="login_required"&&(Ct==null||Ct());return}if(!ke.ok){const Ie=await ke.text().catch(()=>"");throw new Error(Ie||`HTTP ${ke.status}`)}const Oe=await ke.json();s(Ie=>({...Ie,messages:Oe.messages??[],isLoading:!1,error:null})),await B(me.trim(),{token:St,sessionId:qe,mode:Ue.mode,provider:Ue.provider,onLoginRequired:Ct})}catch(Fe){s(re=>({...re,isLoading:!1,error:Fe instanceof Error?Fe.message:"Failed to restart from message"}))}finally{P.current=!1}}},[n,r,e,B]),be=y.useCallback(async Ce=>{var tt;const me=O.current;if(!me||!o)return;const Ye={"Content-Type":"application/json"};n&&(Ye.Authorization=`Bearer ${n}`);try{const Ue=await fetch(`${oo}/api/sessions/${me}/plan/execute`,{method:"POST",headers:Ye,body:JSON.stringify(Ce?{action_ids:Ce}:{})});if(!Ue.ok)throw new Error(`HTTP ${Ue.status}`);const mt=(tt=Ue.body)==null?void 0:tt.getReader();if(!mt)throw new Error("No response body");const Dt=new TextDecoder;let Et="";for(;;){const{done:St,value:Ct}=await mt.read();if(St)break;Et+=Dt.decode(Ct,{stream:!0});const qe=Et.split(`
|
|
810
|
+
`);Et=qe.pop()||"";for(const Ne of qe)if(Ne.startsWith("data: "))try{const Pe=JSON.parse(Ne.slice(6));Pe.type==="plan_action_start"?a(Fe=>Fe?{...Fe,actions:Fe.actions.map(re=>re.id===Pe.action_id?{...re,status:"approved"}:re)}:null):Pe.type==="plan_action_result"?a(Fe=>Fe?{...Fe,actions:Fe.actions.map(re=>re.id===Pe.action_id?{...re,status:Pe.ok?"executed":"failed",result:{ok:Pe.ok,message:Pe.message,data:Pe.data}}:re)}:null):Pe.type==="plan_execution_complete"&&setTimeout(()=>a(null),2e3)}catch{}}}catch(Ue){s(mt=>({...mt,error:Ue instanceof Error?Ue.message:"Plan execution failed"}))}},[n,o]),ze=y.useCallback(async()=>{const Ce=O.current;if(!Ce||!o)return;const me={"Content-Type":"application/json"};n&&(me.Authorization=`Bearer ${n}`);try{await fetch(`${oo}/api/sessions/${Ce}/plan/reject`,{method:"POST",headers:me}),a(null)}catch{a(null)}},[n,o]),fe=y.useCallback((Ce,me)=>{g(Ye=>Ye.some(tt=>tt.path===Ce)?Ye:[...Ye,{path:Ce,name:me,state:"undecided"}])},[]);return{messages:i.messages,isLoading:i.isLoading,isLoadingHistory:i.isLoadingHistory,remainingPrompts:i.remainingPrompts,error:i.error,hitMaxRounds:i.hitMaxRounds,pendingPlan:o,todoList:c,changedFiles:h,messageQueue:p,contextUsage:b,sessionInfo:C,sendMessage:B,restartFromMessage:ce,cancelRequest:X,clearMessages:ie,continueChat:se,executePlan:be,rejectPlan:ze,enqueueMessage:F,dequeueMessage:W,updateQueueItem:z,reorderQueueItem:V,setMessageQueueState:A,acceptFile:R,rejectFile:Z,acceptAllFiles:L,rejectAllFiles:Q,setTodoList:d,addChangedFile:fe,setChangedFiles:g,setOnChangedFilesSync:Y,refreshMessages:I}}function Q5e(){const[e,n]=y.useState(null),[r,i]=y.useState(null),[s,o]=y.useState(null),[a,c]=y.useState(!0);return y.useEffect(()=>{let d=!1;return fetch(`${Wn()}/health`).then(h=>h.json()).then(h=>{d||(n(h.provider??null),i(h.model??null),o(h.ollamaUrl??null))}).catch(()=>{}).finally(()=>{d||c(!1)}),()=>{d=!0}},[]),{provider:e,model:r,ollamaUrl:s,loading:a}}const q1=Wn(),K1=10;function G1(e){return e?{Authorization:`Bearer ${e}`}:{}}function eSe(e,n){const[r,i]=y.useState([]),[s,o]=y.useState(null),[a,c]=y.useState(K1),[d,h]=y.useState(!1),[g,p]=y.useState(!0),_=y.useCallback(async()=>{if(!e){i(E=>E.length===0?E:[]),o(null),h(!1),p(!1);return}p(!0);try{const[E,O]=await Promise.all([fetch(`${q1}/api/sessions?status=active&limit=${a}`,{headers:G1(e)}),fetch(`${q1}/api/sessions/last-active`,{headers:G1(e)})]);if((E.status===401||O.status===401)&&(n==null||n()),E.ok){const N=await E.json();i(N.sessions),h(!!N.hasMore)}if(O.ok){const N=await O.json();N.session&&o(T=>T??N.session.id)}}catch(E){console.error("Failed to fetch sessions:",E)}finally{p(!1)}},[n,e,a]),b=y.useCallback(async E=>{if(!e)return n==null||n(),null;try{const O=await fetch(`${q1}/api/sessions`,{method:"POST",headers:{...G1(e),"Content-Type":"application/json"},body:JSON.stringify({name:E||`Session ${new Date().toLocaleString()}`})});if(O.status===401)return n==null||n(),null;if(O.ok){const N=await O.json();return i(T=>[N,...T].slice(0,a)),o(N.id),N}}catch(O){console.error("Failed to create session:",O)}return null},[n,e]),x=y.useCallback(E=>{o(E)},[]),C=y.useCallback(async E=>{if(!e){n==null||n();return}try{if((await fetch(`${q1}/api/sessions/${E}/archive`,{method:"POST",headers:G1(e)})).status===401){n==null||n();return}await _(),s===E&&o(null)}catch(O){console.error("Failed to archive session:",O)}},[s,_,n,e]),j=y.useCallback(()=>{c(E=>E+K1)},[]),S=y.useCallback(()=>{c(K1)},[]);return y.useEffect(()=>{_()},[_]),{sessions:r,activeSessionId:s,loading:g,hasMoreSessions:d,fetchSessions:_,createSession:b,switchSession:x,archiveSession:C,showMoreSessions:j,showFewerSessions:S,sessionListLimit:K1}}const tSe=Pg();function nSe(e){let n=0;for(let r=0;r<e.length;r++)n=Math.imul(31,n)+e.charCodeAt(r)|0;return n}function rSe(){const e=qr(),n=navigator.userAgent;return e==="electron"?`Desktop (${navigator.platform})`:e==="capacitor"?"Mobile":n.includes("Chrome")?`Chrome (${navigator.platform})`:n.includes("Firefox")?`Firefox (${navigator.platform})`:n.includes("Safari")?`Safari (${navigator.platform})`:`Browser (${navigator.platform})`}function iSe(){var n;const e=qr();if(e==="capacitor")return"android";if(e==="electron"){const r=((n=navigator.platform)==null?void 0:n.toLowerCase())??"";return r.includes("win")?"windows":r.includes("mac")?"macos":"linux"}return"web"}function sSe(){const e=qr();return e==="electron"||e==="capacitor"}function oSe(e){const{listeners:n,sessionId:r,token:i,onStateSync:s,onFullState:o,onMessageComplete:a,onThreadEvent:c,onFsChanges:d,onConnectionStateChange:h}=e,g=y.useRef(n);g.current=n;const p=y.useRef(s);p.current=s;const _=y.useRef(o);_.current=o;const b=y.useRef(a);b.current=a;const x=y.useRef(c);x.current=c;const C=y.useRef(d);C.current=d;const j=y.useRef(h);j.current=h;const S=y.useRef(null),E=y.useRef(null),O=y.useRef(!0),N=y.useRef(!1),T=y.useRef(i);T.current=i;const P=y.useRef(r);P.current=r;const D=y.useRef([]),H=y.useCallback($=>{for(;D.current.length>0&&$.readyState===WebSocket.OPEN;){const R=D.current.shift();$.send(R)}},[]),J=y.useCallback(($,R)=>{!R||$.readyState!==WebSocket.OPEN||($.send(JSON.stringify({type:"subscribe",sessionId:R})),E.current=R)},[]),I=y.useCallback(async $=>{var Z;if((Z=window.jaitDesktop)!=null&&Z.notify){window.jaitDesktop.notify({title:$.title,body:$.body});return}if(window.Capacitor)try{const L="@capacitor/local-notifications",{LocalNotifications:Q}=await import(L);if((await Q.requestPermissions()).display==="granted"){await Q.schedule({notifications:[{id:Math.abs(nSe($.id)),title:$.title,body:$.body,schedule:{at:new Date}}]});return}}catch{}"Notification"in window&&(Notification.permission==="granted"?new Notification($.title,{body:$.body,tag:$.id}):Notification.permission!=="denied"&&await Notification.requestPermission()==="granted"&&new Notification($.title,{body:$.body,tag:$.id})),($.level==="error"?Pr.error:$.level==="warning"?Pr.warning:$.level==="success"?Pr.success:Pr.info)($.title,{description:$.body})},[]),B=y.useCallback($=>{var R,Z,L;try{const Q=JSON.parse($.data);if(Q.type==="ui.command"){const X=Q.payload,ie=g.current[X.command];ie&&ie(X.data)}else if(Q.type==="ui.state-sync"){const X=Q.payload;X!=null&&X.key&&p.current&&p.current(X.key,X.value??null)}else if(Q.type==="ui.full-state"){const X=Q.payload;X&&_.current&&_.current(X)}else if(Q.type==="message.complete")(R=b.current)==null||R.call(b);else if(Q.type==="fs.changes"){const X=Q.payload;(Z=C.current)==null||Z.call(C,X)}else Q.type==="fs.browse-request"?z(Q.payload):Q.type==="fs.roots-request"?V(Q.payload):Q.type==="fs.op-request"?A(Q.payload):Q.type==="provider.op-request"?U(Q.payload):Q.type==="tool.op-request"?K(Q.payload):Q.type==="notification"?I(Q.payload):(Q.type.startsWith("thread.")||Q.type.startsWith("repo.")||Q.type.startsWith("plan.")||Q.type.startsWith("fs.node-"))&&((L=x.current)==null||L.call(x,Q.type,Q.payload))}catch{}},[]),F=y.useCallback(async $=>{const R="@capacitor/filesystem",{Filesystem:Z,Directory:L}=await import(R);let Q,X=$;$==="~"||$==="/storage"||$==="/"?(Q=L.ExternalStorage,X=""):$.startsWith("/storage/emulated/0")&&(Q=L.ExternalStorage,X=$.replace("/storage/emulated/0","").replace(/^\//,""));const ie=await Z.readdir({path:X||"",...Q?{directory:Q}:{}}),se=Q===L.ExternalStorage?"/storage/emulated/0"+(X?"/"+X:""):$,ce=[];for(const fe of ie.files)fe.name.startsWith(".")||ce.push({name:fe.name,path:se+"/"+fe.name,type:fe.type==="directory"?"dir":"file"});ce.sort((fe,Ce)=>fe.type!==Ce.type?fe.type==="dir"?-1:1:fe.name.localeCompare(Ce.name));const be=se.replace(/\/+$/,"").split("/"),ze=be.length>3?be.slice(0,-1).join("/"):null;return{path:se,parent:ze,entries:ce}},[]),W=y.useCallback(async()=>[{name:"Internal Storage",path:"/storage/emulated/0",type:"dir"},{name:"Documents",path:"/storage/emulated/0/Documents",type:"dir"},{name:"Downloads",path:"/storage/emulated/0/Download",type:"dir"},{name:"Home",path:"/storage/emulated/0",type:"dir"}],[]),z=y.useCallback(async $=>{var Q;const R=S.current;if(!R||R.readyState!==WebSocket.OPEN)return;const{requestId:Z,path:L}=$;try{let X;const ie=qr();if(ie==="electron"&&((Q=window.jaitDesktop)!=null&&Q.browsePath))X=await window.jaitDesktop.browsePath(L);else if(ie==="capacitor")X=await F(L);else throw new Error("Local filesystem browsing not supported on this platform");R.send(JSON.stringify({type:"fs.browse-response",payload:{requestId:Z,path:X.path,parent:X.parent,entries:X.entries}}))}catch(X){R.send(JSON.stringify({type:"fs.browse-response",payload:{requestId:Z,error:X instanceof Error?X.message:"Browse failed"}}))}},[F]),V=y.useCallback(async $=>{var L;const R=S.current;if(!R||R.readyState!==WebSocket.OPEN)return;const{requestId:Z}=$;try{let Q;const X=qr();if(X==="electron"&&((L=window.jaitDesktop)!=null&&L.getRoots))Q=(await window.jaitDesktop.getRoots()).roots;else if(X==="capacitor")Q=await W();else throw new Error("Local filesystem browsing not supported on this platform");R.send(JSON.stringify({type:"fs.roots-response",payload:{requestId:Z,roots:Q}}))}catch(Q){R.send(JSON.stringify({type:"fs.roots-response",payload:{requestId:Z,error:Q instanceof Error?Q.message:"Roots request failed"}}))}},[W]),A=y.useCallback(async $=>{var X;const R=S.current;if(!R||R.readyState!==WebSocket.OPEN)return;const{requestId:Z,op:L,...Q}=$;try{const ie=qr();if(ie==="electron"&&((X=window.jaitDesktop)!=null&&X.fsOp)){const se=await window.jaitDesktop.fsOp(L,Q);R.send(JSON.stringify({type:"fs.op-response",payload:{requestId:Z,result:se}}))}else throw ie==="capacitor"?new Error("Full filesystem operations not yet supported on mobile"):new Error("Filesystem operations not supported on this platform")}catch(ie){R.send(JSON.stringify({type:"fs.op-response",payload:{requestId:Z,error:ie instanceof Error?ie.message:"Filesystem operation failed"}}))}},[]),U=y.useCallback(async $=>{var X;const R=S.current;if(!R||R.readyState!==WebSocket.OPEN)return;const{requestId:Z,op:L,...Q}=$;try{if(qr()==="electron"&&((X=window.jaitDesktop)!=null&&X.providerOp)){const se=await window.jaitDesktop.providerOp(L,Q);R.send(JSON.stringify({type:"provider.op-response",payload:{requestId:Z,result:se}}))}else throw new Error("Provider operations not supported on this platform")}catch(ie){R.send(JSON.stringify({type:"provider.op-response",payload:{requestId:Z,error:ie instanceof Error?ie.message:"Provider operation failed"}}))}},[]),K=y.useCallback(async $=>{var se;const R=S.current;if(!R||R.readyState!==WebSocket.OPEN)return;const{requestId:Z,tool:L,args:Q,sessionId:X,workspaceRoot:ie}=$;try{if(qr()==="electron"&&((se=window.jaitDesktop)!=null&&se.toolOp)){const be=await window.jaitDesktop.toolOp(L,Q,{sessionId:X,workspaceRoot:ie});R.send(JSON.stringify({type:"tool.op-response",payload:{requestId:Z,result:be}}))}else throw new Error("Tool execution not supported on this platform")}catch(ce){R.send(JSON.stringify({type:"tool.op-response",payload:{requestId:Z,error:ce instanceof Error?ce.message:"Tool execution failed"}}))}},[]);return y.useEffect(()=>{var L;O.current=!0;let $=null;const R=()=>{if(!O.current)return;const Q=new WebSocket(`${tSe}?token=${T.current??"dev"}`);S.current=Q,Q.onopen=()=>{var se;const X=N.current;N.current=!0,(se=j.current)==null||se.call(j,{connected:!0,reconnected:X});const ie=P.current;ie&&J(Q,ie),H(Q),sSe()&&b2e().then(async ce=>{var fe;let be=[];if(qr()==="electron"&&((fe=window.jaitDesktop)!=null&&fe.detectProviders))try{be=await window.jaitDesktop.detectProviders()}catch{}const ze=JSON.stringify({type:"fs.register-node",payload:{id:ce,name:rSe(),platform:iSe(),providers:be}});Q.readyState===WebSocket.OPEN&&Q.send(ze)})},Q.onmessage=B,Q.onclose=()=>{var X;S.current=null,E.current=null,(X=j.current)==null||X.call(j,{connected:!1,reconnected:!1}),O.current&&($=setTimeout(R,1e3))},Q.onerror=()=>{}};R();const Z=(Q,X)=>{if((X==null?void 0:X.type)==="provider.event-from-child"){const ie=S.current;ie&&ie.readyState===WebSocket.OPEN&&ie.send(JSON.stringify({type:"provider.event",payload:{sessionId:X.sessionId,event:X.notification}}))}};return qr()==="electron"&&((L=window.jaitDesktop)!=null&&L.onGatewayEvent)&&window.jaitDesktop.onGatewayEvent(Z),()=>{var X;O.current=!1,$&&clearTimeout($),qr()==="electron"&&((X=window.jaitDesktop)!=null&&X.removeGatewayEventListener)&&window.jaitDesktop.removeGatewayEventListener();const Q=S.current;Q&&(Q.onclose=null,Q.close(),S.current=null)}},[i]),y.useEffect(()=>{const $=S.current;$&&$.readyState===WebSocket.OPEN&&r!==E.current&&J($,r??null),P.current=r??null},[r,J]),{sendUIState:y.useCallback(($,R,Z)=>{const L=JSON.stringify({type:"ui.state",payload:{sessionId:Z??"",key:$,value:R}}),Q=S.current;Q&&Q.readyState===WebSocket.OPEN?Q.send(L):D.current.push(L)},[])}}const xO=Wn();function wO(e){const n={"Content-Type":"application/json"};return e&&(n.Authorization=`Bearer ${e}`),n}function ao(e,n,r){const[i,s]=y.useState(null),[o,a]=y.useState(!1),c=y.useRef(null),d=y.useRef(null);y.useEffect(()=>{if(!e||!r){s(null);return}let g=!1;return a(!0),fetch(`${xO}/api/sessions/${e}/state?keys=${encodeURIComponent(n)}`,{headers:wO(r)}).then(p=>p.ok?p.json():null).then(p=>{if(g)return;const _=(p==null?void 0:p[n])??null;s(_),d.current=_}).catch(()=>{g||s(null)}).finally(()=>{g||a(!1)}),()=>{g=!0}},[e,n,r]);const h=y.useCallback(g=>{s(g),d.current=g,!(!e||!r)&&(c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{fetch(`${xO}/api/sessions/${e}/state`,{method:"PATCH",headers:wO(r),body:JSON.stringify({[n]:d.current})}).catch(()=>{})},300))},[e,n,r]);return y.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]),[i,h,o]}function uv(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function aSe(e){const r=uv(e).split("/").filter(Boolean);return r[r.length-1]??e}function lSe(e){var r;const n=e.match(/^\[([^\]]+)\]/);return((r=n==null?void 0:n[1])==null?void 0:r.trim())||null}function ML(e){if(!e)return null;const r=uv(e).split("/").filter(Boolean),i=r.lastIndexOf("worktrees");return i===-1?null:r[i+1]??null}function a_(e){return lSe(e.title)??ML(e.workingDirectory)??(e.workingDirectory?aSe(e.workingDirectory):null)}function o5(e,n){var c,d;const r=n.name.trim().toLowerCase(),i=(c=a_(e))==null?void 0:c.toLowerCase(),s=e.workingDirectory?uv(e.workingDirectory):null,o=uv(n.localPath);if(s&&(s===o||s.startsWith(`${o}/`)))return!0;const a=(d=ML(e.workingDirectory))==null?void 0:d.toLowerCase();return a&&a===r?!0:i===r}function cSe(e,n){const r=[],i=new Set;for(const s of e){if(n.some(c=>o5(s,c)))continue;const o=a_(s),a=o==null?void 0:o.trim().toLowerCase();!o||!a||i.has(a)||(r.push({id:`shared:${a}`,name:o,defaultBranch:"main",localPath:s.workingDirectory??o,source:"shared"}),i.add(a))}return r}function uSe(e){return e==="jait"||e==="codex"||e==="claude-code"?e:null}function fSe(e){const n=new Set;for(const r of e){const i=uSe(r);i&&n.add(i)}return[...n]}function dSe(e,n){const{localDeviceId:r,localProviders:i,remoteProviders:s,providersLoaded:o}=n;if(!e.deviceId)return{hostType:"gateway",locationLabel:"Gateway",online:!0,loading:!1,availableProviders:i.filter(h=>h.available).map(h=>h.id)};const a=s.find(h=>h.nodeId===e.deviceId),c=e.deviceId===r?"This device":(a==null?void 0:a.nodeName)??"Desktop app",d=!!a;return{hostType:"device",locationLabel:c,online:d,loading:!d&&!o,availableProviders:fSe((a==null?void 0:a.providers)??[])}}function SO(e,n){return e.githubUrl?`Couldn't reach ${n.locationLabel}.`:n.hostType==="device"&&!n.online?`${n.locationLabel==="This device"?"This desktop app":n.locationLabel} is offline and no GitHub URL is configured for gateway fallback. Reconnect it or pick a connected repo/device.`:"No GitHub URL is configured for this repo, so the gateway cannot clone it as a fallback."}const ow=10;function hSe(e){const r=e.replace(/\\/g,"/").split("/").filter(Boolean);return r[r.length-1]??e}function pSe(){return`jait/${Math.random().toString(16).slice(2,10)}`}function RL(e){return[...e].sort((n,r)=>new Date(n.createdAt).getTime()-new Date(r.createdAt).getTime())}function mSe(e,n){if(n.length===0)return e;const r=new Map(e.map(i=>[i.id,i]));for(const i of n)r.set(i.id,i);return RL([...r.values()])}function op(e,n){return{id:e.id,name:e.name,defaultBranch:e.defaultBranch,localPath:e.localPath,deviceId:e.deviceId,githubUrl:e.githubUrl,source:!e.deviceId||e.deviceId===n?"local":"shared"}}function gSe(e=!0){const n=y.useMemo(()=>o4(),[]),[r,i]=y.useState([]),[s,o]=y.useState(null),[a,c]=y.useState(!1),[d,h]=y.useState([]),[g,p]=y.useState(ow),[_,b]=y.useState(!1),[x,C]=y.useState(null),[j,S]=y.useState([]),[E,O]=y.useState({}),[N,T]=y.useState(!0),[P,D]=y.useState([]),[H,J]=y.useState([]),[I,B]=y.useState(!1),[F,W]=y.useState(!1),[z,V]=y.useState(!1),[A,U]=y.useState(null),K=y.useRef(null),Y=y.useRef(new Map),$=y.useMemo(()=>cSe(d,r),[d,r]),R=y.useMemo(()=>[...r,...$],[r,$]),Z=y.useMemo(()=>R.find(Ne=>Ne.id===s)??null,[R,s]),L=y.useMemo(()=>d.find(Ne=>Ne.id===x)??null,[d,x]),Q=y.useCallback(Ne=>R.find(Pe=>o5(Ne,Pe))??null,[R]),X=y.useMemo(()=>L!=null&&Z!=null&&(L.status==="completed"||!!L.prUrl),[L,Z]);y.useEffect(()=>{var Ne;e&&(!s&&R.length>0&&o(R[0].id),s&&R.every(Pe=>Pe.id!==s)&&o(((Ne=R[0])==null?void 0:Ne.id)??null))},[R,s,e]),y.useEffect(()=>{if(!e||!L)return;const Ne=Q(L);Ne&&Ne.id!==s&&o(Ne.id)},[e,Q,s,L]);const ie=y.useCallback(async()=>{if(ou()){B(!0);try{const[Ne,Pe,Fe]=await Promise.all([en.listThreadsPage({limit:g}),en.listProviders(),en.listRepos()]);h(Ne.threads),b(Ne.hasMore),D(Pe.providers),J(Pe.remoteProviders),W(!0),i(Fe.map(re=>op(re,n))),U(null)}catch(Ne){U(Ne instanceof Error?Ne.message:"Failed to fetch data")}finally{B(!1)}}},[n,g]),se=y.useCallback(async()=>{if(ou())try{const[Ne,Pe]=await Promise.all([en.listProviders(),en.listRepos()]);D(Ne.providers),J(Ne.remoteProviders),i(Pe.map(Fe=>op(Fe,n)))}catch{}},[n]),ce=y.useCallback(Ne=>dSe(Ne,{localDeviceId:n,localProviders:P,remoteProviders:H,providersLoaded:F}),[n,P,H,F]);y.useEffect(()=>{e&&ie()},[ie,e]);const be=y.useRef(x);be.current=x;const ze=y.useCallback((Ne,Pe)=>{switch(Ne){case"thread.created":{const Fe=Pe.thread;Fe&&h(re=>re.some(he=>he.id===Fe.id)?re:[Fe,...re]);break}case"thread.updated":{const Fe=Pe.thread;Fe&&h(re=>re.map(he=>he.id===Fe.id?Fe:he));break}case"thread.deleted":{const Fe=Pe.threadId;Fe&&(Y.current.delete(Fe),h(re=>re.filter(he=>he.id!==Fe)),be.current===Fe&&C(null));break}case"thread.status":{const Fe=Pe.threadId,re=Pe.status,he=Pe.thread;Fe&&re&&h(_e=>he?_e.some(Oe=>Oe.id===Fe)?_e.map(Oe=>Oe.id===Fe?he:Oe):[he,..._e]:_e.map(ke=>ke.id===Fe?{...ke,status:re,error:re==="running"||re==="completed"?Pe.error??null:Pe.error??ke.error}:ke));break}case"thread.activity":{const Fe=Pe.threadId,re=Pe.activity;if(Fe&&re){const he=mSe(Y.current.get(Fe)??[],[re]);Y.current.set(Fe,he),Fe===be.current&&S(he)}break}case"repo.created":{const Fe=Pe.repo;Fe&&i(re=>re.some(he=>he.id===Fe.id)?re:[op(Fe,n),...re]);break}case"repo.updated":{const Fe=Pe.repo;Fe&&i(re=>re.map(he=>he.id===Fe.id?op(Fe,n):he));break}case"repo.deleted":{const Fe=Pe.repoId;Fe&&(i(re=>re.filter(he=>he.id!==Fe)),o(re=>re===Fe?null:re));break}case"fs.node-registered":case"fs.node-disconnected":{se();break}}},[]);y.useEffect(()=>{if(!e||!x){S([]),V(!1);return}const Ne=Y.current.get(x);if(Ne){S(Ne),V(!1);return}S([]),V(!0);let Pe=!1;return(async()=>{if(ou())try{const re=await en.getActivities(x);if(!Pe){const he=RL(re);Y.current.set(x,he),S(he)}}catch{}finally{Pe||V(!1)}})(),()=>{Pe=!0}},[x,e]),y.useEffect(()=>{var Ne;e&&((Ne=K.current)==null||Ne.scrollIntoView({behavior:"smooth"}))},[j,e]);const fe=y.useMemo(()=>Z?d.filter(Ne=>o5(Ne,Z)).sort((Ne,Pe)=>new Date(Pe.updatedAt).getTime()-new Date(Ne.updatedAt).getTime()):[],[d,Z]),Ce=y.useRef(0),me=10;y.useEffect(()=>{if(!e||!Z){O({});return}const Ne=++Ce.current,Pe=Z.localPath,Fe=fe.filter(_e=>typeof _e.branch=="string"&&_e.branch.length>0).slice(0,me),re=async()=>{var Ae;if(Fe.length===0){Ne===Ce.current&&O({});return}const _e=Fe.filter(Ke=>Ke.prState!=="merged"&&Ke.prState!=="closed"),ke=[];for(const Ke of _e){if(Ne!==Ce.current)return;try{const ht=Ke.workingDirectory??Pe,de=await Hi.status(ht,Ke.branch??void 0),gt=((Ae=de.pr)==null?void 0:Ae.state)??null;if(de.ghAvailable&&de.pr&&(Ke.prUrl!==de.pr.url||Ke.prState!==de.pr.state||Ke.prNumber!==de.pr.number))try{await en.updateThread(Ke.id,{prUrl:de.pr.url,prNumber:de.pr.number,prTitle:de.pr.title??null,prState:de.pr.state})}catch{}ke.push({threadId:Ke.id,prState:gt,ghAvailable:de.ghAvailable})}catch{}}if(Ne!==Ce.current)return;const Oe={};let Ie=!1;for(const Ke of ke)Oe[Ke.threadId]=Ke.prState,Ke.ghAvailable&&(Ie=!0);for(const Ke of Fe)!(Ke.id in Oe)&&(Ke.prState==="merged"||Ke.prState==="closed")&&(Oe[Ke.id]=Ke.prState);T(Ie),O(Oe)};re();const he=setInterval(()=>{Ce.current===Ne&&re()},6e4);return()=>clearInterval(he)},[e,fe,Z]);const Ye=y.useCallback(async(Ne,Pe)=>{const Fe=Pe&&Pe!=="gateway"?Pe:void 0,re=r.find(ke=>ke.localPath===Ne);if(re){o(re.id);const ke={},Oe=Fe??"";if((re.deviceId??"")!==Oe&&(ke.deviceId=Oe),!re.githubUrl)try{const Ie=await Hi.status(Ne);Ie.remoteUrl&&(ke.githubUrl=Ie.remoteUrl)}catch{}if(Object.keys(ke).length>0)try{await en.updateRepo(re.id,ke)}catch{}return}let he="main",_e;try{const ke=await Hi.status(Ne);ke.branch&&(he=ke.branch),ke.remoteUrl&&(_e=ke.remoteUrl)}catch{}try{const ke=await en.createRepo({name:hSe(Ne),defaultBranch:he,localPath:Ne,deviceId:Fe,githubUrl:_e}),Oe=op(ke,n);i(Ie=>Ie.some(Ae=>Ae.id===Oe.id)?Ie:[Oe,...Ie]),o(Oe.id),U(null)}catch(ke){U(ke instanceof Error?ke.message:"Failed to create repository")}},[r]),tt=y.useCallback(async Ne=>{try{await en.deleteRepo(Ne)}catch{}i(Pe=>Pe.filter(Fe=>Fe.id!==Ne)),s===Ne&&o(null)},[s]),Ue=y.useCallback(async(Ne,Pe,Fe="jait",re,he={})=>{if(!Pe.trim())return;const _e=Ne?d.find(Oe=>Oe.id===Ne)??null:L,ke=_e?Q(_e):Z;if(_e&&(_e.status==="running"||_e.providerSessionId))await en.sendTurn(_e.id,{message:Pe,...he}),ie();else if(_e&&(_e.status==="completed"||_e.status==="error"||_e.status==="interrupted"))try{const Oe=await en.startThread(_e.id,{message:Pe,...he});h(Ie=>Ie.map(Ae=>Ae.id===Oe.id?Oe:Ae)),ie()}catch(Oe){if(Oe.code==="NODE_OFFLINE"&&ke){const Ae=ke.githubUrl;if(Ae&&confirm("The desktop app is not connected. Clone the repo to the gateway and run the thread there?")){const Ke=await en.startThread(_e.id,{message:Pe,cloneToGateway:!0,repoUrl:Ae,...he});h(ht=>ht.map(de=>de.id===Ke.id?Ke:de)),ie()}else Ae||U(SO(ke,ce(ke)))}else throw Oe}else{if(!ke)return;Ne||C(null);const Oe=ke;(async()=>{var Ie,Ae;try{const Ke=pSe();let ht;try{ht=(await Hi.createWorktree(Oe.localPath,Oe.defaultBranch,Ke)).path}catch{try{await Hi.createBranch(Oe.localPath,Ke,Oe.defaultBranch)}catch{}}const de=await en.createThread({title:`[${Oe.name}] Generating title…`,providerId:Fe,...re?{model:re}:{},workingDirectory:ht??Oe.localPath,branch:Ke});try{await en.startThread(de.id,{message:Pe,titleTask:((Ie=he.displayContent)==null?void 0:Ie.trim())||Pe,titlePrefix:`[${Oe.name}] `,...he})}catch(gt){if(gt.code==="NODE_OFFLINE"){const Je=Oe.githubUrl;Je&&confirm("The desktop app is not connected. Clone the repo to the gateway and run the thread there?")?await en.startThread(de.id,{message:Pe,titleTask:((Ae=he.displayContent)==null?void 0:Ae.trim())||Pe,titlePrefix:`[${Oe.name}] `,cloneToGateway:!0,repoUrl:Je,...he}):Je||U(SO(Oe,ce(Oe)));return}throw gt}}catch(Ke){U(Ke instanceof Error?Ke.message:"Failed to create thread")}})()}},[ce,Q,ie,Z,L,d]),mt=y.useCallback(async(Ne,Pe="jait",Fe,re)=>{await Ue((L==null?void 0:L.id)??null,Ne,Pe,Fe,re)},[L==null?void 0:L.id,Ue]),Dt=y.useCallback(async(Ne,Pe,Fe="jait",re,he)=>{await Ue(Ne,Pe,Fe,re,he)},[Ue]),Et=y.useCallback(async Ne=>{try{await en.stopThread(Ne),ie()}catch(Pe){U(Pe instanceof Error?Pe.message:"Failed to stop thread")}},[ie]),St=y.useCallback(async Ne=>{try{await en.deleteThread(Ne),h(Pe=>Pe.filter(Fe=>Fe.id!==Ne)),x===Ne&&C(null)}catch(Pe){U(Pe instanceof Error?Pe.message:"Failed to delete thread")}},[x]),Ct=y.useCallback(()=>{p(Ne=>Ne+ow)},[]),qe=y.useCallback(()=>{p(ow)},[]);return{repositories:R,selectedRepoId:s,setSelectedRepoId:o,selectedRepo:Z,folderPickerOpen:a,setFolderPickerOpen:c,handleFolderSelected:Ye,removeRepository:tt,threads:d,hasMoreThreads:_,threadListLimit:g,showMoreThreads:Ct,showFewerThreads:qe,repoThreads:fe,selectedThreadId:x,setSelectedThreadId:C,selectedThread:L,getRepositoryForThread:Q,threadPrStates:E,ghAvailable:N,activities:j,loadingActivities:z,activityEndRef:K,providers:P,remoteProviders:H,loading:I,error:A,setError:U,creating:!1,showGitActions:X,getRuntimeInfoForRepository:ce,refresh:ie,handleSend:mt,handleSendToThread:Dt,handleStop:Et,handleDelete:St,handleThreadEvent:ze}}const DL=16,ySe=280,vSe=200;function fv(e,n,r){return Math.min(Math.max(e,n),r)}function Y1({size:e,viewport:n,margin:r=DL}){const i=Math.max(220,n.width-r*2),s=Math.max(160,n.height-r*2),o=Math.min(ySe,i),a=Math.min(vSe,s);return{w:fv(e.w,o,i),h:fv(e.h,a,s)}}function Cp({position:e,size:n,viewport:r}){return{x:fv(e.x,0,Math.max(0,r.width-n.w)),y:fv(e.y,0,Math.max(0,r.height-n.h))}}function _Se({size:e,viewport:n,margin:r=DL}){return Cp({position:{x:n.width-e.w-r,y:n.height-e.h-r},size:e,viewport:n})}const gi=Wn(),zL=28,a5=.05;function aw(){return Array.from({length:zL},()=>a5)}function LL(e){return e.trim()}function CO(e,n){const r=e.trim(),i=LL(n);return i?r?`${r} ${i}`:i:r}function bSe(e,n,r){const i=e.findIndex(c=>c.id===n),s=e.findIndex(c=>c.id===r);if(i<0||s<0||i===s)return e;const o=[...e],[a]=o.splice(i,1);return o.splice(s,0,a),o}const xSe=["What can you help me with?","Explain quantum computing","Write a Python script","What time is it?"];function lw(e){const n={};try{const i=localStorage.getItem("cliModelsByProvider");if(i){const s=JSON.parse(i);for(const o of["codex","claude-code"]){const a=s[o];typeof a=="string"&&a.trim()&&(n[o]=a)}}}catch{}const r=localStorage.getItem("cliModel");return r&&e!=="jait"&&!n[e]&&(n[e]=r),n}function jO(e){const n=window.matchMedia("(prefers-color-scheme: dark)").matches,r=e==="dark"||e==="system"&&n;document.documentElement.classList.toggle("dark",r)}const wSe="Generating title…";function y4(e){return e.replace(/^\[.*?\]\s*/,"").trim()===wSe}function $L({className:e=""}){return f.jsx("span",{className:`inline-block rounded bg-muted animate-pulse ${e}`,children:f.jsx("span",{className:"invisible",children:"Generating title"})})}function v4({status:e}){const n={running:{icon:kt,color:"text-blue-500 animate-spin"},paused:{icon:E8,color:"text-yellow-500"},interrupted:{icon:E8,color:"text-yellow-500"},done:{icon:Fs,color:"text-green-500"},completed:{icon:Fs,color:"text-green-500"},error:{icon:uu,color:"text-red-500"}},{icon:r,color:i}=n[e]??{icon:qa,color:"text-muted-foreground"};return f.jsx(r,{className:`h-3 w-3 shrink-0 ${i}`})}function IL({prState:e}){if(!e)return null;const n=e==="open"?"PR created":e==="merged"?"PR merged":"PR closed",r=e==="open"?"bg-blue-500/10 text-blue-700 border-blue-500/20 dark:text-blue-300 dark:bg-blue-500/20 dark:border-blue-400/30":e==="merged"?"bg-purple-500/10 text-purple-700 border-purple-500/20 dark:text-purple-300 dark:bg-purple-500/20 dark:border-purple-400/30":"bg-red-500/10 text-red-700 border-red-500/20 dark:text-red-300 dark:bg-red-500/20 dark:border-red-400/30";return f.jsx(ln,{variant:"outline",className:`h-4 shrink-0 whitespace-nowrap px-1 py-0 text-[9px] ${r}`,children:n})}const SSe={codex:"Codex","claude-code":"Claude"};function dv({runtime:e,className:n=""}){const r=e.availableProviders.filter(i=>i==="codex"||i==="claude-code");return f.jsxs("div",{className:`flex flex-wrap items-center gap-1 text-[10px] text-muted-foreground ${n}`.trim(),children:[f.jsx("span",{children:e.locationLabel}),e.loading?f.jsx(kt,{className:"h-3 w-3 animate-spin text-muted-foreground"}):!e.online&&f.jsx(ln,{variant:"outline",className:"h-4 border-amber-500/30 bg-amber-500/10 px-1 py-0 text-[9px] text-amber-700 dark:text-amber-300",children:"Offline"}),r.map(i=>f.jsx(ln,{variant:"outline",className:"h-4 px-1 py-0 text-[9px]",children:SSe[i]},i))]})}function CSe({repositories:e,selectedRepo:n,disabled:r=!1,getRuntimeInfo:i,onSelect:s,onAddRepository:o}){return f.jsxs(Eu,{children:[f.jsx(Ou,{asChild:!0,children:f.jsxs($e,{variant:"outline",size:"sm",className:"h-8 gap-1.5 rounded-lg px-2 text-xs",disabled:r,children:[f.jsx(fu,{className:"h-3.5 w-3.5 shrink-0"}),f.jsx("span",{className:"max-w-[140px] truncate",children:n?n.name:"Select repository"}),f.jsx(bo,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]})}),f.jsxs(dc,{align:"start",side:"top",className:"w-64",children:[f.jsx(Ov,{children:"Repository"}),e.map(a=>{const c=i(a);return f.jsx(Xo,{onSelect:()=>s(a.id),children:f.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[f.jsx(fu,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[f.jsx("span",{className:"truncate",children:a.name}),f.jsx("span",{className:"text-[10px] text-muted-foreground",children:a.defaultBranch}),a.source==="shared"&&f.jsx(ln,{variant:"outline",className:"h-4 px-1 py-0 text-[9px]",children:"Shared"})]}),f.jsx(dv,{runtime:c,className:"mt-1"})]})]})},a.id)}),e.length===0&&f.jsx("div",{className:"px-2 py-2 text-xs text-muted-foreground",children:"No repositories yet."}),f.jsx(Vo,{}),f.jsxs(Xo,{onSelect:o,children:[f.jsx(rc,{className:"mr-2 h-3.5 w-3.5"}),"Add repository"]})]})]})}function jSe({repositories:e,selectedRepoId:n,isMobile:r=!1,getRuntimeInfo:i,onSelect:s,onAddRepository:o,onRemoveRepository:a,onOpenStrategy:c,onOpenPlan:d}){return f.jsxs("div",{className:"flex h-full flex-col",children:[f.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[f.jsx("span",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Repositories"}),f.jsxs($e,{variant:"ghost",size:"sm",className:"h-6 gap-1.5 px-2 text-[11px]",onClick:o,children:[f.jsx(rc,{className:"h-3 w-3"}),"Add"]})]}),f.jsx("div",{className:r?"flex-1 overflow-y-auto p-1.5 space-y-0.5":"flex-1 overflow-y-auto p-2 space-y-1",children:e.length===0?f.jsxs("p",{className:"py-4 text-center text-xs text-muted-foreground",children:["No repositories yet.",f.jsx("br",{}),f.jsx("button",{type:"button",onClick:o,className:"mt-1 inline-block underline underline-offset-2 hover:text-foreground",children:"Add one"})]}):e.map(h=>{const g=i(h);return f.jsxs("div",{role:"button",tabIndex:0,className:`flex w-full items-start gap-2 px-2 py-1.5 text-left transition-colors ${r?"cursor-pointer rounded-md text-sm":"rounded-lg text-xs"} ${n===h.id?r?"bg-secondary text-secondary-foreground":"bg-primary/10 text-primary":r?"hover:bg-muted/50":"hover:bg-muted"}`,onClick:()=>s(h.id),onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),s(h.id))},children:[f.jsx(fu,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),f.jsxs("div",{className:"min-w-0 flex-1",children:[f.jsx("div",{className:r?"truncate text-xs font-medium":"truncate font-medium",children:h.name}),f.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-1",children:[f.jsx("span",{className:"text-[10px] text-muted-foreground",children:h.defaultBranch}),h.source==="shared"&&f.jsx(ln,{variant:"outline",className:"h-4 shrink-0 px-1 py-0 text-[9px]",children:"Shared"})]}),f.jsx(dv,{runtime:g,className:"mt-1"})]}),f.jsxs("div",{className:"mt-0.5 flex shrink-0 flex-col gap-0.5",children:[f.jsx("button",{type:"button",title:"Strategy",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-primary",onClick:p=>{p.stopPropagation(),c(h)},children:f.jsx(WO,{className:"h-3 w-3"})}),f.jsx("button",{type:"button",title:"Plans",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-primary",onClick:p=>{p.stopPropagation(),d(h)},children:f.jsx(FO,{className:"h-3 w-3"})}),h.source==="local"&&f.jsx("button",{type:"button",title:"Remove",className:"shrink-0 rounded p-0.5 text-muted-foreground transition-colors hover:text-destructive",onClick:p=>{p.stopPropagation(),a(h.id)},children:f.jsx(Zf,{className:"h-3 w-3"})})]})]},h.id)})})]})}function kSe({thread:e,repo:n,repoName:r,prState:i,ghAvailable:s,onOpen:o,onStop:a,onDelete:c}){const d=n!=null&&(e.status==="completed"||!!e.prUrl);return f.jsxs("div",{role:"button",tabIndex:0,className:"group relative grid w-full grid-cols-[minmax(0,1fr)_auto] items-center gap-5 border-b px-3 py-3.5 text-sm transition-colors hover:bg-muted/40",onClick:o,onKeyDown:h=>{h.target===h.currentTarget&&(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),o())},children:[f.jsxs("div",{className:"flex flex-col gap-0.5",children:[f.jsxs("div",{className:"flex w-full min-w-0 items-center gap-1.5",children:[f.jsx(v4,{status:e.status}),f.jsx("div",{className:"flex-1 truncate font-medium",children:y4(e.title)?f.jsx($L,{className:"h-3.5 w-28"}):f.jsx("span",{children:e.title.replace(/^\[.*?\]\s*/,"")})})]}),f.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 pl-[calc(0.75rem+6px)] text-xs text-muted-foreground sm:flex-nowrap sm:gap-x-1 sm:gap-y-0",children:[f.jsx("span",{className:"min-w-0 basis-full truncate sm:basis-auto",children:r}),e.branch&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"hidden sm:inline",children:"·"}),f.jsx("span",{className:"max-w-full truncate font-mono",children:e.branch})]}),e.providerId&&e.providerId!=="jait"&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"hidden sm:inline",children:"·"}),f.jsx("span",{className:"shrink-0 whitespace-nowrap",children:e.providerId})]}),e.executionNodeName&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"hidden sm:inline",children:"·"}),f.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 truncate text-blue-500 dark:text-blue-400",children:[f.jsx(gs,{className:"inline h-3 w-3 mr-0.5 -mt-px"}),e.executionNodeName]})]}),i&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"hidden sm:inline",children:"·"}),f.jsx(IL,{prState:i})]})]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[d&&n&&f.jsx("div",{className:"shrink-0",onClick:h=>h.stopPropagation(),onMouseDown:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),children:f.jsx(LS,{threadId:e.id,cwd:e.workingDirectory??n.localPath,branch:e.branch,baseBranch:n.defaultBranch,threadTitle:e.title,threadStatus:e.status,prUrl:e.prUrl,prState:i,ghAvailable:s,showStatusBadge:!1})}),e.status==="running"&&f.jsx($e,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg",onClick:h=>{h.stopPropagation(),a()},children:f.jsx($p,{className:"h-3 w-3"})}),f.jsx($e,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg opacity-100 transition-opacity",onClick:h=>{h.stopPropagation(),c()},children:f.jsx(Zf,{className:"h-3.5 w-3.5"})})]})]})}function ESe({threads:e,getRepositoryForThread:n,threadPrStates:r,ghAvailable:i,onOpenThread:s,onStopThread:o}){const[a,c]=y.useState(!1);return e.length===0?null:f.jsxs(Eu,{open:a,onOpenChange:c,children:[f.jsx(Ou,{asChild:!0,children:f.jsxs($e,{variant:"outline",size:"sm",className:"h-8 gap-1.5 rounded-lg px-2 text-xs",title:`${e.length} active ${e.length===1?"thread":"threads"}`,children:[f.jsx(kt,{className:"h-3.5 w-3.5 animate-spin text-blue-500"}),f.jsx("span",{className:"hidden sm:inline",children:"Active"}),f.jsx(ln,{variant:"secondary",className:"h-4 rounded-md px-1 text-[10px]",children:e.length})]})}),f.jsxs(dc,{align:"end",className:"w-[min(34rem,calc(100vw-1rem))] p-0",children:[f.jsx("div",{className:"flex items-center justify-between border-b px-3 py-2",children:f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx(kt,{className:"h-3.5 w-3.5 animate-spin text-blue-500"}),f.jsxs("span",{className:"text-sm font-medium",children:[e.length," active ",e.length===1?"thread":"threads"]})]})}),f.jsx("div",{className:"max-h-[min(28rem,70vh)] overflow-y-auto",children:e.map(d=>{const h=n(d),g=(h==null?void 0:h.name)??a_(d)??"Unknown repo";return f.jsxs("div",{className:"grid grid-cols-[minmax(0,1fr)_auto] gap-3 border-b px-3 py-3 last:border-b-0",children:[f.jsxs("button",{type:"button",className:"min-w-0 text-left transition-colors hover:text-foreground",onClick:()=>{c(!1),s(d.id)},children:[f.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[f.jsx(v4,{status:d.status}),f.jsx("span",{className:"truncate text-sm font-medium",children:y4(d.title)?"Generating title...":d.title.replace(/^\[.*?\]\s*/,"")})]}),f.jsxs("div",{className:"mt-1 flex min-w-0 flex-wrap items-center gap-1 text-[11px] text-muted-foreground",children:[f.jsx("span",{className:"truncate",children:g}),d.branch&&f.jsx(ln,{variant:"outline",className:"h-4 px-1 py-0 font-mono text-[9px]",children:d.branch}),d.providerId&&d.providerId!=="jait"&&f.jsx(ln,{variant:"outline",className:"h-4 px-1 py-0 text-[9px]",children:d.providerId}),d.executionNodeName&&f.jsxs(ln,{variant:"outline",className:"h-4 px-1 py-0 text-[9px] text-blue-500 dark:text-blue-400 border-blue-200 dark:border-blue-800",children:[f.jsx(gs,{className:"inline h-2.5 w-2.5 mr-0.5"}),d.executionNodeName]}),f.jsx(IL,{prState:d.id in r?r[d.id]:d.prState})]})]}),f.jsxs("div",{className:"flex items-center gap-1 self-start",children:[h&&f.jsx("div",{onClick:p=>p.stopPropagation(),onMouseDown:p=>p.stopPropagation(),children:f.jsx(LS,{threadId:d.id,cwd:d.workingDirectory??h.localPath,branch:d.branch,baseBranch:h.defaultBranch,threadTitle:d.title,threadStatus:d.status,prUrl:d.prUrl,prState:d.id in r?r[d.id]:d.prState,ghAvailable:i,showStatusBadge:!1})}),f.jsx($e,{variant:"ghost",size:"icon",className:"h-7 w-7 rounded-lg",onClick:p=>{p.stopPropagation(),Promise.resolve(o(d.id))},title:"Stop thread",children:f.jsx($p,{className:"h-3 w-3"})})]})]},d.id)})})]})]})}function OSe(){var yl,of,Po,Ss,ro,Cs,af;const[e,n]=y.useState(""),[r,i]=y.useState(!1),[s,o]=y.useState(null),[a,c]=y.useState("chat"),[d,h]=y.useState("system"),[g,p]=y.useState(()=>localStorage.getItem("showSessionsSidebar")==="true"),[_,b]=y.useState(!1),[x,C]=y.useState(!1),[j,S]=y.useState(null),[E,O]=y.useState(null),[N,T]=y.useState(!1),[P,D]=y.useState(!1),[H,J]=y.useState(!0),[I,B]=y.useState(!0),[F,W]=y.useState(!1),z=y.useRef(null),[V,A]=y.useState(()=>localStorage.getItem("showDebugPanel")==="true"),[U,K]=y.useState(280),[Y,$]=y.useState({x:-1,y:-1}),[R,Z]=y.useState({w:420,h:320}),L=y.useRef(null),Q=y.useRef(null),X=y.useRef(null),ie=y.useRef(null),[se,ce]=y.useState(!1),[be,ze]=y.useState("agent"),[fe,Ce]=y.useState("jait"),[me,Ye]=y.useState(()=>lw("jait")),tt=fe==="jait"?null:me[fe]??null,[Ue,mt]=y.useState("developer"),[Dt,Et]=y.useState("idle"),[St,Ct]=y.useState("idle"),qe=y.useRef(Ue),[Ne,Pe]=y.useState(""),[Fe,re]=y.useState(""),[he,_e]=y.useState(""),[ke,Oe]=y.useState(""),[Ie,Ae]=y.useState(""),[Ke,ht]=y.useState("login"),[de,gt]=y.useState(()=>ic()??""),Le=!!window.jaitDesktop||!!window.Capacitor,Je=!!window.jaitDesktop,rt=!!window.Capacitor,zt=Je?"electron":rt?"capacitor":"web",[jt,nn]=y.useState(null),[At,it]=y.useState(!1),[Tt,ft]=y.useState(!1),at=y.useRef(null),rn=y.useRef(!1),Ft=y.useRef(async()=>{}),[st,Bt]=y.useState(null),[Lt,Kt]=y.useState(!1),[An,In]=y.useState(()=>Le&&!R7()?"url":"auth"),[Gi,jo]=y.useState(!1),[Ci,En]=y.useState(null),[Bn,Us]=y.useState([]),[sa,zr]=y.useState(null),[il,oa]=y.useState([]),[ji,aa]=y.useState(!1),_s=y.useRef(!1),Lr=y.useRef(null),ki=y.useRef(null),sn=bS(),[On,la]=y.useState(0),Vs=!sn&&N,yr=sn&&N,cn=y.useCallback(()=>({width:window.innerWidth,height:window.innerHeight}),[]),gc=y.useCallback((q=R)=>_Se({size:q,viewport:cn()}),[R,cn]),yc=y.useCallback(q=>{var Pt;if(q.pointerType!=="touch"&&q.button!==0)return;q.preventDefault();const ee=cn(),ae=Y1({size:R,viewport:ee}),ve=Y.x<0||Y.y<0?gc(ae):Cp({position:Y,size:ae,viewport:ee});(ae.w!==R.w||ae.h!==R.h)&&Z(ae),(ve.x!==Y.x||ve.y!==Y.y)&&$(ve),L.current={pointerId:q.pointerId,startX:q.clientX,startY:q.clientY,posX:ve.x,posY:ve.y};const Re=Mt=>{!L.current||L.current.pointerId!==Mt.pointerId||$(Cp({position:{x:L.current.posX+Mt.clientX-L.current.startX,y:L.current.posY+Mt.clientY-L.current.startY},size:ae,viewport:cn()}))},Ve=()=>{document.removeEventListener("pointermove",Re),document.removeEventListener("pointerup",dt),document.removeEventListener("pointercancel",dt),document.body.style.cursor="",document.body.style.userSelect="",X.current=null},dt=Mt=>{!L.current||L.current.pointerId!==Mt.pointerId||(L.current=null,Ve())};q.pointerType!=="touch"&&(document.body.style.cursor="move"),document.body.style.userSelect="none",(Pt=X.current)==null||Pt.call(X),X.current=Ve,document.addEventListener("pointermove",Re),document.addEventListener("pointerup",dt),document.addEventListener("pointercancel",dt)},[Y,R,gc,cn]),Ru=y.useCallback(q=>{var dt;if(q.pointerType!=="touch"&&q.button!==0)return;q.preventDefault(),q.stopPropagation();const ee=cn(),ae=Y1({size:R,viewport:ee});(ae.w!==R.w||ae.h!==R.h)&&Z(ae),Q.current={pointerId:q.pointerId,startX:q.clientX,startY:q.clientY,w:ae.w,h:ae.h};const ve=Pt=>{if(!Q.current||Q.current.pointerId!==Pt.pointerId)return;const Mt=Y1({size:{w:Q.current.w+Pt.clientX-Q.current.startX,h:Q.current.h+Pt.clientY-Q.current.startY},viewport:cn()});Z(Mt),$(hn=>hn.x<0||hn.y<0?hn:Cp({position:hn,size:Mt,viewport:cn()}))},Re=()=>{document.removeEventListener("pointermove",ve),document.removeEventListener("pointerup",Ve),document.removeEventListener("pointercancel",Ve),document.body.style.cursor="",document.body.style.userSelect="",ie.current=null},Ve=Pt=>{!Q.current||Q.current.pointerId!==Pt.pointerId||(Q.current=null,Re())};q.pointerType!=="touch"&&(document.body.style.cursor="nwse-resize"),document.body.style.userSelect="none",(dt=ie.current)==null||dt.call(ie),ie.current=Re,document.addEventListener("pointermove",ve),document.addEventListener("pointerup",Ve),document.addEventListener("pointercancel",Ve)},[R,cn]);y.useEffect(()=>{var q,ee;P||(L.current=null,Q.current=null,(q=X.current)==null||q.call(X),(ee=ie.current)==null||ee.call(ie),document.body.style.cursor="",document.body.style.userSelect="")},[P]),y.useEffect(()=>()=>{var q,ee;(q=X.current)==null||q.call(X),(ee=ie.current)==null||ee.call(ie),document.body.style.cursor="",document.body.style.userSelect=""},[]),y.useEffect(()=>{if(!P)return;const q=()=>{const ee=cn();let ae;Z(ve=>{const Re=Y1({size:ve,viewport:ee});return ae=Re,Re.w===ve.w&&Re.h===ve.h?ve:Re}),$(ve=>{if(ve.x<0&&ve.y<0)return ve;const Re=Cp({position:ve,size:ae,viewport:ee});return Re.x===ve.x&&Re.y===ve.y?ve:Re})};return q(),window.addEventListener("resize",q),()=>window.removeEventListener("resize",q)},[P,cn]);const{user:Yi,token:ut,settings:Mn,isLoading:$r,isAuthenticated:Qn,login:te,register:pe,logout:Ee,bindSession:Se,updateSettings:Me,clearSessionArchive:bt}=Y5e(),lt=y.useCallback(async()=>{if(ut){it(!0);try{const q=await fetch(`${gi}/api/update/check`,{headers:{Authorization:`Bearer ${ut}`}});q.ok&&nn(await q.json())}catch{}it(!1)}},[ut]),yt=y.useCallback(async()=>{if(!(!ut||!(jt!=null&&jt.hasUpdate))){ft(!0);try{const q=await fetch(`${gi}/api/update/apply`,{method:"POST",headers:{Authorization:`Bearer ${ut}`,"Content-Type":"application/json"},body:JSON.stringify({version:jt.latestVersion})});if(q.ok)at.current=jt.latestVersion,rn.current=!1,Pr.success(`Updated to v${jt.latestVersion}. Gateway is restarting...`);else{const ee=await q.json().catch(()=>({}));Pr.error(ee.error??"Update failed")}}catch{Pr.error("Update request failed")}ft(!1)}},[ut,jt]),dn=y.useCallback(({connected:q,reconnected:ee})=>{if(!q){at.current&&(rn.current=!0);return}if(Ft.current(),ee&&at.current&&rn.current){const ae=at.current;at.current=null,rn.current=!1,Pr.success(`Gateway restarted on v${ae}.`),lt()}},[lt]);y.useEffect(()=>{ut&<()},[ut,lt]);const Gt=y.useCallback(()=>i(!0),[]),{sessions:wn,activeSessionId:Ge,createSession:Ir,switchSession:Ws,archiveSession:l_,fetchSessions:Kg,hasMoreSessions:Gg,showMoreSessions:Nd,showFewerSessions:c_,sessionListLimit:u_}=eSe(ut,Gt),{messages:qs,isLoading:vr,isLoadingHistory:Du,remainingPrompts:ca,error:Ei,hitMaxRounds:sl,pendingPlan:Td,todoList:zu,changedFiles:Xi,messageQueue:Oi,contextUsage:Ks,sessionInfo:vc,sendMessage:ko,restartFromMessage:Gs,cancelRequest:Lu,clearMessages:_c,continueChat:Yg,executePlan:$u,rejectPlan:Iu,enqueueMessage:ol,dequeueMessage:Xr,updateQueueItem:ua,reorderQueueItem:Bu,setMessageQueueState:Ni,acceptFile:Pd,rejectFile:Ad,acceptAllFiles:Md,rejectAllFiles:bc,setTodoList:Ys,addChangedFile:xc,setChangedFiles:wc,setOnChangedFilesSync:Rd,refreshMessages:f_}=Z5e(Ge,ut,Gt),[al,fa]=y.useState({}),Dd=y.useRef(new Set),{terminals:Sc,activeTerminalId:da,setActiveTerminalId:ll,createTerminal:Cc,killTerminal:Xg,refresh:Jg}=W5e(ut),{provider:d_,model:Fu}=Q5e(),Hu=j2e({token:ut}),we=gSe();Ft.current=we.refresh;const Uu=y.useMemo(()=>che(we.activities),[we.activities]),cl=y.useMemo(()=>[...we.threads].sort((q,ee)=>new Date(ee.updatedAt).getTime()-new Date(q.updatedAt).getTime()),[we.threads]),Vu=y.useMemo(()=>we.selectedRepo?we.getRuntimeInfoForRepository(we.selectedRepo):null,[we.getRuntimeInfoForRepository,we.selectedRepo]),bs=y.useMemo(()=>we.selectedThread?we.getRepositoryForThread(we.selectedThread):null,[we.getRepositoryForThread,we.selectedThread]),zd=y.useMemo(()=>bs?we.getRuntimeInfoForRepository(bs):null,[we.getRuntimeInfoForRepository,bs]),Zg=y.useMemo(()=>cl.filter(q=>q.status==="running"),[cl]),h_=sn&&Ue==="manager"&&!!we.selectedThread,Qg=y.useMemo(()=>we.selectedThread?al[we.selectedThread.id]??[]:[],[we.selectedThread,al]),p_=we.selectedRepo!=null,e0=we.creating||!p_,m_=we.selectedRepo?"Describe what you want to do...":"Select a repository to start a thread...",[_t,Ji]=y.useState(null);y.useEffect(()=>{var ae,ve,Re;const q=window.jaitDesktop;if(!q)return;(ae=q.getInfo)==null||ae.call(q).then(Ve=>Bt(Ve.platform)),(ve=q.windowIsMaximized)==null||ve.call(q).then(Ve=>Kt(Ve));const ee=(Re=q.onMaximizedChange)==null?void 0:Re.call(q,(Ve,dt)=>Kt(dt));return()=>{ee==null||ee()}},[]);const _r=y.useRef(!1);y.useEffect(()=>{_r.current=!1},[Ge]);const[ha,Zi]=ao(Ge,"workspace.panel",ut),[jc,Xs]=ao(Ge,"screen-share.panel",ut),[kc,pa]=ao(Ge,"terminal.panel",ut),[Js,t0,n0]=ao(Ge,"workspace.layout",ut),[Ld,$d,Id]=ao(Ge,"chat.mode",ut),[xs,ul,r0]=ao(Ge,"chat.cliModels",ut),[fl,Bd,Fd]=ao(Ge,"chat.view",ut),[Wu,qu]=ao(Ge,"workspace.tabs",ut),[Ku,Hd]=ao(Ge,"queued_messages",ut),[Ud,dl]=y.useState(null);y.useEffect(()=>{dl(null)},[Ge]);const[Gu]=ao(Ge,"todo_list",ut),[Yu]=ao(Ge,"changed_files",ut);y.useEffect(()=>{_r.current||ha&&(_t||ha.open&&ha.remotePath&&Ji({surfaceId:ha.surfaceId??"",workspaceRoot:ha.remotePath,nodeId:ha.nodeId}))},[ha]),y.useEffect(()=>{_r.current||jc!=null&&jc.open&&D(!0)},[jc]),y.useEffect(()=>{_r.current||kc!=null&&kc.open&&b(!0)},[kc]),y.useEffect(()=>{_r.current||Js&&(J(Js.tree!==!1),B(Js.editor!==!1))},[Js]),y.useEffect(()=>{_r.current||Ld&&ze(Ld)},[Ld]),y.useEffect(()=>{if(_r.current)return;if(xs&&Object.keys(xs).length>0){Ye(ee=>{const ae=Object.keys(xs);return ae.length===Object.keys(ee).length&&ae.every(ve=>ee[ve]===xs[ve])?ee:xs});return}const q=lw(fe);Object.keys(q).length>0&&Ye(q)},[xs,fe]),y.useEffect(()=>{_r.current||fl&&mt(fl)},[fl]),y.useEffect(()=>{_r.current||dl(Wu??null)},[Wu]);const i0=y.useRef(null);y.useEffect(()=>{if(_r.current)return;const q=JSON.stringify(Ku??[]);q!==i0.current&&(i0.current=q,Ni(Ku??[]))},[Ku,Ni]),y.useEffect(()=>{_r.current||Gu&&Gu.length>0&&Ys(Gu)},[Gu,Ys]),y.useEffect(()=>{if(!_r.current&&Yu&&Yu.length>0)for(const q of Yu)xc(q.path,q.name)},[Yu,xc]);const g_=y.useCallback((q,ee)=>{switch(q){case"workspace.panel":{if(!ee)T(!1),Ji(null);else{const ae=ee;ae.open?(T(!0),ae.remotePath&&Ji({surfaceId:ae.surfaceId??"",workspaceRoot:ae.remotePath,nodeId:ae.nodeId})):T(!1)}break}case"screen-share.panel":D(ee?ee.open!==!1:!1);break;case"terminal.panel":b(ee?ee.open!==!1:!1);break;case"workspace.layout":{const ae=ee;ae?(J(ae.tree!==!1),B(ae.editor!==!1)):(J(!0),B(!0));break}case"chat.mode":(ee==="ask"||ee==="agent"||ee==="plan")&&ze(ee);break;case"chat.cliModels":ee&&typeof ee=="object"&&!Array.isArray(ee)?Ye(ee):ee===null&&Ye({});break;case"chat.view":(ee==="developer"||ee==="manager")&&mt(ee);break;case"todo_list":Array.isArray(ee)&&Ys(ee);break;case"file_changed":{const ae=ee;ae!=null&&ae.path&&xc(ae.path,ae.name??ae.path.split("/").pop()??ae.path);break}case"changed_files":{Array.isArray(ee)?wc(ee):ee===null&&wc([]);break}case"workspace.tabs":{dl(ee&&typeof ee=="object"?ee:null);break}case"queued_messages":{Array.isArray(ee)?Ni(ee):ee===null&&Ni([]);break}}},[Ys,xc,wc,Ni]),ai=y.useCallback(q=>{_r.current=!0;const ee=q["workspace.panel"];ee&&ee.open?(T(!0),ee.remotePath&&Ji({surfaceId:ee.surfaceId??"",workspaceRoot:ee.remotePath,nodeId:ee.nodeId})):(T(!1),Ji(null));const ae=q["screen-share.panel"];ae&&ae.open!==!1?D(!0):D(!1);const ve=q["terminal.panel"];ve&&ve.open!==!1?b(!0):b(!1);const Re=q["workspace.layout"];Re?(J(Re.tree!==!1),B(Re.editor!==!1)):(J(!0),B(!0));const Ve=q["chat.mode"];(Ve==="ask"||Ve==="agent"||Ve==="plan")&&ze(Ve);const dt=q["chat.cliModels"];if(dt&&typeof dt=="object"&&!Array.isArray(dt))Ye(dt);else{const Qr=lw(fe);Ye(Qr)}const Pt=q["chat.view"];(Pt==="developer"||Pt==="manager")&&mt(Pt);const Mt=q.todo_list;Array.isArray(Mt)&&Mt.length>0&&Ys(Mt);const hn=q.changed_files;Array.isArray(hn)&&wc(hn);const $t=q["workspace.tabs"];dl($t&&typeof $t=="object"?$t:null);const br=q.queued_messages;Array.isArray(br)?Ni(br):Ni([])},[Ys,wc,Ni]),{sendUIState:un}=oSe({sessionId:Ge,token:ut,onStateSync:g_,onFullState:ai,onMessageComplete:f_,onThreadEvent:we.handleThreadEvent,onConnectionStateChange:dn,onFsChanges:y.useCallback(q=>{la(ee=>ee+1)},[]),listeners:{"workspace.open":y.useCallback(q=>{T(!0),Ji({surfaceId:q.surfaceId,workspaceRoot:q.workspaceRoot,nodeId:q.nodeId});const ee={open:!0,remotePath:q.workspaceRoot,surfaceId:q.surfaceId,nodeId:q.nodeId};Zi(ee)},[Zi]),"workspace.close":y.useCallback(()=>{T(!1),Ji(null),Zi(null)},[Zi]),"terminal.focus":y.useCallback(q=>{c("chat"),b(!0),pa({open:!0}),q.terminalId&&ll(q.terminalId),q.reason==="interactive-input-required"&&Pr(q.message??"Terminal wartet auf deine Eingabe (z. B. sudo Passwort).",{description:"Klicke ins Terminal und gib die erforderliche Eingabe ein.",duration:1e4})},[pa,ll]),"screen-share.open":y.useCallback(()=>{D(!0),Xs({open:!0})},[Xs]),"screen-share.close":y.useCallback(()=>{D(!1),Xs(null)},[Xs])}}),Vd=y.useCallback(q=>{dl(q),qu(q),un("workspace.tabs",q,Ge)},[qu,un,Ge]);y.useEffect(()=>{if(Ge&&ut&&n0)return;const q={tree:H,editor:I};t0(q),un("workspace.layout",q,Ge)},[H,I,t0,un,Ge,n0,ut]),y.useEffect(()=>{Ge&&ut&&Id||($d(be),un("chat.mode",be,Ge))},[be,$d,un,Ge,Id,ut]),y.useEffect(()=>{Ge&&ut&&Fd||(Bd(Ue),un("chat.view",Ue,Ge))},[Ue,Bd,un,Ge,Fd,ut]);const Wd=y.useRef(null);y.useEffect(()=>{const q=Oi.length>0?Oi:null,ee=JSON.stringify(q);ee!==Wd.current&&(Wd.current=ee,Hd(q),un("queued_messages",q,Ge))},[Oi,Hd,un,Ge]),y.useEffect(()=>(Rd(q=>{un("changed_files",q,Ge)}),()=>Rd(null)),[un,Ge,Rd]),y.useEffect(()=>{localStorage.setItem("showSessionsSidebar",g?"true":"false")},[g]),y.useEffect(()=>{localStorage.setItem("showDebugPanel",V?"true":"false")},[V]);const Ec=y.useCallback(q=>{Ce(q)},[]),Oc=y.useCallback(q=>{fe!=="jait"&&Ye(ee=>({...ee,[fe]:q}))},[fe]),Xu=y.useRef(null);y.useEffect(()=>{if(Ge&&ut&&r0)return;const q={};for(const ve of["codex","claude-code"]){const Re=me[ve];typeof Re=="string"&&Re.trim()&&(q[ve]=Re)}const ee=Object.keys(q).length>0?q:null,ae=JSON.stringify(ee);ae!==Xu.current&&(Xu.current=ae,ul(ee),un("chat.cliModels",ee,Ge),localStorage.removeItem("cliModelsByProvider"),localStorage.removeItem("cliModel"))},[me,Ge,r0,un,ul,ut]);const s0=y.useRef(!1);y.useEffect(()=>{if(!s0.current){s0.current=!0;return}ut&&Me({chat_provider:fe})},[fe]),y.useEffect(()=>{qe.current!=="manager"&&Ue==="manager"?(Et("center"),requestAnimationFrame(()=>{document.body.offsetHeight,requestAnimationFrame(()=>Et("top"))})):(qe.current==="manager"&&Ue==="developer"&&Ct("animating"),Et("idle")),qe.current=Ue},[Ue]),y.useEffect(()=>{Ue==="manager"&&V&&A(!1)},[Ue,V]);const hl=y.useCallback(()=>{D(!0),Xs({open:!0}),un("screen-share.panel",{open:!0},Ge)},[Xs,un,Ge]),Ju=y.useCallback(()=>{D(!1),Xs(null),un("screen-share.panel",null,Ge)},[Xs,un,Ge]),Eo=y.useCallback(()=>{b(!0),pa({open:!0}),un("terminal.panel",{open:!0},Ge)},[pa,un,Ge]),ma=y.useCallback(()=>{b(!1),pa(null),un("terminal.panel",null,Ge)},[pa,un,Ge]),Zu=y.useCallback(()=>{T(!1),Ji(null),Zi(null),un("workspace.panel",null,Ge)},[Zi,un,Ge]),Oo=y.useCallback(()=>{J(q=>!q)},[]),ga=y.useCallback(()=>{B(q=>!q)},[]),Nc=y.useCallback(()=>{J(!0)},[]),Zs=y.useCallback(()=>{B(!0)},[]),Qi=y.useCallback(async(q,ee,ae)=>{const ve=ae??Ge,Re=await fetch(`${gi}/api/workspace/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:q,sessionId:ve,nodeId:ee||"gateway"})});if(!Re.ok){const Ve=await Re.json().catch(()=>({message:"Unknown error"}));throw new Error(Ve.message??"Failed to open workspace")}ut&&Me({workspace_picker_path:q,workspace_picker_node_id:ee||"gateway"}).catch(()=>{})},[Ge,ut,Me]),o0=y.useCallback(async()=>{if(N){if(Xi.length>0){W(!0);return}Zu();return}if(Ue==="manager"&&we.selectedThread){const q=we.selectedThread.workingDirectory??(bs==null?void 0:bs.localPath);if(q){if((_t==null?void 0:_t.workspaceRoot)===q){T(!0);const ae={open:!0,remotePath:_t.workspaceRoot,surfaceId:_t.surfaceId};Zi(ae),un("workspace.panel",ae,Ge);return}let ee=Ge;if(!ee){const ae=await Ir();ee=(ae==null?void 0:ae.id)??null}if(!ee)return;await Qi(q,(bs==null?void 0:bs.deviceId)??void 0,ee);return}}if(_t){T(!0);const q={open:!0,remotePath:_t.workspaceRoot,surfaceId:_t.surfaceId};Zi(q),un("workspace.panel",q,Ge);return}aa(!0)},[N,_t,Zu,Zi,un,Ge,Qi,Xi.length,Ue,we.selectedThread,bs,Ir]);y.useEffect(()=>{_t&&(N||T(!0))},[_t]),y.useEffect(()=>{if(!(_t!=null&&_t.surfaceId)||!_t.workspaceRoot||!Ge)return;let q=!1;return(async()=>{try{if((await fetch(`${gi}/api/workspace/list?path=${encodeURIComponent(_t.workspaceRoot)}&surfaceId=${encodeURIComponent(_t.surfaceId)}`)).ok||q)return;const ae=await fetch(`${gi}/api/workspace/open`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:_t.workspaceRoot,sessionId:Ge})});if(!ae.ok||q)return;const ve=await ae.json();if(q)return;Ji({surfaceId:ve.surfaceId,workspaceRoot:ve.workspaceRoot});const Re={open:!0,remotePath:ve.workspaceRoot,surfaceId:ve.surfaceId};Zi(Re),un("workspace.panel",Re,Ge)}catch{}})(),()=>{q=!0}},[_t==null?void 0:_t.surfaceId,Ge]),y.useEffect(()=>{Xi.length!==0&&(N||T(!0))},[Xi.length]);const qd=y.useMemo(()=>Xi.filter(q=>q.state==="undecided").map(q=>q.path),[Xi]);y.useEffect(()=>{h(Mn.theme)},[Mn.theme]),y.useEffect(()=>{$r||Mn.chat_provider&&Mn.chat_provider!==fe&&Ce(Mn.chat_provider)},[Mn.chat_provider,$r]),y.useEffect(()=>{var ae,ve;if(jO(d),Je&&st==="win32"){const Re=d==="dark"||d==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches;(ve=(ae=window.jaitDesktop)==null?void 0:ae.setTitleBarOverlay)==null||ve.call(ae,{color:Re?"#202020":"#e8ecf1",symbolColor:Re?"#f2f2f2":"#0a0a0a",height:39})}const q=window.matchMedia("(prefers-color-scheme: dark)"),ee=()=>{var Re,Ve;if(d==="system"&&jO("system"),Je&&st==="win32"){const dt=q.matches;(Ve=(Re=window.jaitDesktop)==null?void 0:Re.setTitleBarOverlay)==null||Ve.call(Re,{color:dt?"#202020":"#e8ecf1",symbolColor:dt?"#f2f2f2":"#0a0a0a",height:39})}};return q.addEventListener("change",ee),()=>q.removeEventListener("change",ee)},[d,st]),y.useEffect(()=>{if(!$r&&!Qn){const q=requestAnimationFrame(()=>i(!0));return Le&&R7()&&fetch(`${Wn()}/health`,{signal:AbortSignal.timeout(4e3)}).then(ee=>{if(!ee.ok)throw new Error("unhealthy")}).catch(()=>{In("url"),En("Gateway is unreachable. Check the URL or try a different one."),gt(ic()??"")}),()=>cancelAnimationFrame(q)}},[$r,Qn]),y.useEffect(()=>{Qn&&Ge&&Se(Ge)},[Qn,Ge,Se]),y.useEffect(()=>{if(Ei==="login_required"){const q=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(q)}},[Ei]),y.useEffect(()=>{(async()=>{if(!Ge){ce(!1);return}try{const ae=await(await fetch(`${gi}/api/consent/pending/${Ge}/approve-all`)).json();ce(ae.approveAllEnabled===!0)}catch{ce(!1)}})()},[Ge]);const a0=y.useCallback(async q=>{const ee=d;h(q);try{await Me({theme:q})}catch{h(ee)}},[d,Me]),y_=y.useCallback(q=>{q.preventDefault(),_s.current=!0;const ee=q.clientY,ae=U,ve=window.innerHeight*.5,Re=dt=>{if(!_s.current)return;const Pt=ee-dt.clientY;K(Math.min(ve,Math.max(280,ae+Pt)))},Ve=()=>{_s.current=!1,document.removeEventListener("mousemove",Re),document.removeEventListener("mouseup",Ve),document.body.style.cursor="",document.body.style.userSelect=""};document.body.style.cursor="row-resize",document.body.style.userSelect="none",document.addEventListener("mousemove",Re),document.addEventListener("mouseup",Ve)},[U]),Qu=y.useCallback(async(q=null)=>{const ee=await Jg();if(q&&ee.some(Re=>Re.id===q))return ll(q),q;if(da&&ee.some(ve=>ve.id===da))return da;if(ee.length>0){const ve=ee[ee.length-1].id;return ll(ve),ve}return(await Cc(Ge??"default")).id},[Jg,ll,da,Cc,Ge]),v_=y.useCallback(async q=>{c("chat"),Eo(),await Qu(q)},[Qu,Eo]),l0=y.useCallback(async()=>{if(_){ma();return}c("chat"),Eo(),await Qu()},[_,Qu,Eo,ma]),c0=y.useCallback(async q=>{var ae;const ee=Sc.length===1&&((ae=Sc[0])==null?void 0:ae.id)===q;await Xg(q),ee&&ma()},[Sc,Xg,ma]),ws=y.useCallback(q=>{q.length!==0&&(Us(ee=>{const ae=[...ee];for(const ve of q){const Re=ae.findIndex(Ve=>Ve.path===ve.path);Re>=0?ae[Re]=ve:ae.push(ve)}return ae}),zr(ee=>{var ae;return ee??((ae=q[0])==null?void 0:ae.id)??null}))},[]),li=y.useCallback(async q=>{var ee,ae,ve;try{const Re={};ut&&(Re.Authorization=`Bearer ${ut}`);const Ve=_t!=null&&_t.surfaceId?`&surfaceId=${encodeURIComponent(_t.surfaceId)}`:"",dt=await fetch(`${gi}/api/workspace/backup?path=${encodeURIComponent(q)}${Ve}`,{headers:Re});if(dt.ok){const pi=await dt.json(),ts=q.split(/[\/\\]/).pop()??q;await((ee=Lr.current)==null?void 0:ee.openReviewDiff({path:pi.path,originalContent:pi.originalContent??"",modifiedContent:pi.currentContent,language:dp(ts)})),N||T(!0),Zs();return}if(await((ae=Lr.current)==null?void 0:ae.openFileByPath(q))){N||T(!0);return}const Mt=await((ve=Lr.current)==null?void 0:ve.readFileByPath(q));if(Mt){ws([Mt]),zr(Mt.id),N||T(!0);return}const hn=await fetch(`${gi}/api/workspace/read?path=${encodeURIComponent(q)}${Ve}`,{headers:Re});if(!hn.ok)return;const $t=await hn.json(),br=q.split("/").pop()??q,Qr={id:`changed-${q}`,name:br,path:$t.path,content:$t.content,language:dp(br)};ws([Qr]),zr(Qr.id),N||T(!0)}catch{}},[ut,_t==null?void 0:_t.surfaceId,N,ws,Zs]),Tc=y.useCallback(async q=>{var ee;try{let ae=(_t==null?void 0:_t.workspaceRoot)??null;if(jne(q,ae)||(ae=kne(q)),ae&&(!_t||_t.workspaceRoot!==ae)&&await Qi(ae,_t==null?void 0:_t.nodeId,Ge),await((ee=Lr.current)==null?void 0:ee.openFileByPath(q))){N||T(!0),Zs();return}const Re=Bn.find(Ve=>Ve.path===q);if(Re)ws([Re]),zr(Re.id);else{const Ve={};ut&&(Ve.Authorization=`Bearer ${ut}`);const dt=await fetch(`${gi}/api/workspace/read?path=${encodeURIComponent(q)}`,{headers:Ve});if(!dt.ok)throw new Error(`Failed to open file: ${dt.status}`);const Pt=await dt.json(),Mt=q.split(/[\\/]/).pop()??q,hn={id:Pt.path,name:Mt,path:Pt.path,content:Pt.content,language:dp(Mt)};ws([hn]),zr(hn.id)}N||T(!0),Zs()}catch(ae){Pr(ae instanceof Error?ae.message:"Failed to open linked file")}},[Ge,_t,ws,Qi,N,Zs,ut,Bn]),ci=y.useCallback(async(q,ee)=>{try{const ae={"Content-Type":"application/json"};ut&&(ae.Authorization=`Bearer ${ut}`),await fetch(`${gi}/api/workspace/apply-diff`,{method:"POST",headers:ae,body:JSON.stringify({path:q,content:ee})})}catch{}Pd(q)},[ut,Pd]),ya=y.useCallback(async q=>{const ee=Array.from(q),ae=await Promise.all(ee.filter(ve=>ve.size<1024*1024).map(async ve=>{const Re=await ve.text(),Ve=ve.webkitRelativePath||ve.name;return{id:`${Ve}-${ve.lastModified}`,name:ve.name,path:Ve,content:Re,language:dp(Ve)}}));ws(ae)},[ws]),Pc=y.useCallback(async(q,ee,ae)=>{var ve;return((ve=Lr.current)==null?void 0:ve.searchFiles(q,ee,ae))??[]},[]),Qs=y.useCallback(async(q,ee)=>{var dt;const ae=q.trim();if(!ae&&(!ee||ee.length===0))return null;const ve=[],Re=new Set;if(ee!=null&&ee.length){const Pt=new Set;for(const Mt of ee){if(Pt.has(Mt.path))continue;Pt.add(Mt.path),Re.add(Mt.path);const hn=Bn.find(br=>br.path===Mt.path);if(hn){ve.push({path:hn.path,content:hn.content});continue}const $t=await((dt=Lr.current)==null?void 0:dt.readFileByPath(Mt.path));$t&&ve.push({path:$t.path,content:$t.content})}}return{promptWithReferences:ve.length>0?`${ae}${ae?`
|
|
811
811
|
|
|
812
812
|
`:""}Referenced files:
|
|
813
813
|
${ve.map(Pt=>`- ${Pt.path}
|
|
814
814
|
\`\`\`
|
|
815
815
|
${Pt.content.slice(0,2e3)}
|
|
816
816
|
\`\`\``).join(`
|
|
817
|
-
`)}`:ae,displayContent:ae,referencedFiles:ee!=null&&ee.length?ee.map(Pt=>({path:Pt.path,name:Pt.name})):void 0,attachments:Re.size>0?[...Re]:void 0}},[Bn]),Ac=y.useCallback(async q=>{const ee=await Qs(e,q);ee&&(ol({content:ee.promptWithReferences,displayContent:ee.displayContent||ee.promptWithReferences,mode:be,provider:fe,model:fe!=="jait"?tt:void 0,referencedFiles:ee.referencedFiles}),n(""))},[be,fe,tt,ol,e,Qs]),pl=async q=>{if(Ue==="manager")return va(q);const ee=await Qs(e,q);if(!ee)return;if(!ut){i(!0);return}let ae=Ge;if(!ae){const ve=await Ir();ae=(ve==null?void 0:ve.id)??null}if(ae){if(vr||Oi.length>0){ol({content:ee.promptWithReferences,displayContent:ee.displayContent||ee.promptWithReferences,mode:be,provider:fe,model:fe!=="jait"?tt:void 0,referencedFiles:ee.referencedFiles}),n("");return}ko(ee.promptWithReferences,{token:ut,sessionId:ae,mode:be,provider:fe,model:fe!=="jait"?tt:void 0,onLoginRequired:()=>i(!0),...ee.referencedFiles?{displayContent:ee.displayContent||ee.promptWithReferences,referencedFiles:ee.referencedFiles}:{}}),n("")}},va=async q=>{const ee=await Qs(e,q);!ee||e0||(n(""),await we.handleSend(ee.promptWithReferences,fe,fe!=="jait"?tt:void 0,{displayContent:ee.displayContent||ee.promptWithReferences,referencedFiles:ee.referencedFiles,attachments:ee.attachments}))},Mc=y.useCallback((q,ee)=>{fa(ae=>({...ae,[q]:[...ae[q]??[],ee]}))},[]),ef=y.useCallback((q,ee)=>{fa(ae=>{const ve=ae[q]??[],Re=ve.filter(Ve=>Ve.id!==ee);if(Re.length===ve.length)return ae;if(Re.length===0){const{[q]:Ve,...dt}=ae;return dt}return{...ae,[q]:Re}})},[]),ml=y.useCallback((q,ee,ae)=>{const ve=ae.trim();ve&&fa(Re=>{const Ve=Re[q]??[];return Ve.length===0?Re:{...Re,[q]:Ve.map(dt=>dt.id===ee?{...dt,content:ve,displayContent:ve,fullContent:ve,referencedFiles:void 0,attachments:void 0}:dt)}})},[]),__=y.useCallback((q,ee,ae)=>{fa(ve=>{const Re=ve[q]??[];if(Re.length===0)return ve;const Ve=_Se(Re,ee,ae);return Ve===Re?ve:{...ve,[q]:Ve}})},[]),ui=y.useCallback(async q=>{const ee=we.selectedThread;if(!ee)return;const ae=await Qs(e,q);ae&&(Mc(ee.id,{id:`mq-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,content:ae.displayContent||ae.promptWithReferences,displayContent:ae.displayContent||ae.promptWithReferences,fullContent:ae.promptWithReferences,referencedFiles:ae.referencedFiles,attachments:ae.attachments,providerId:fe,model:fe!=="jait"?tt:void 0,queuedAt:Date.now()}),n(""))},[we.selectedThread,fe,tt,Mc,e,Qs]);y.useEffect(()=>{for(const[q,ee]of Object.entries(al)){if(ee.length===0||Dd.current.has(q))continue;const ae=we.threads.find(Re=>Re.id===q);if(!ae){fa(Re=>{if(!(q in Re))return Re;const{[q]:Ve,...dt}=Re;return dt});continue}if(ae.status==="running")continue;const[ve]=ee;ve&&(Dd.current.add(q),fa(Re=>{const Ve=Re[q]??[],[,...dt]=Ve;if(dt.length===0){const{[q]:Pt,...Mt}=Re;return Mt}return{...Re,[q]:dt}}),we.handleSendToThread(q,ve.fullContent,ve.providerId,ve.model,{displayContent:ve.displayContent??ve.content,referencedFiles:ve.referencedFiles,attachments:ve.attachments}).catch(Re=>{fa(Ve=>({...Ve,[q]:[ve,...Ve[q]??[]]})),we.setError(Re instanceof Error?Re.message:"Failed to process queued thread message")}).finally(()=>{Dd.current.delete(q)}))}},[we.handleSendToThread,we.setError,we.threads,al]);const tf=y.useCallback(async()=>{const q=we.selectedRepo;if(q)try{await en.updateRepo(q.id,{deviceId:""}),await we.refresh()}catch{we.setError("Failed to move repository to gateway")}},[we.selectedRepo,we.refresh,we.setError]),eo=async q=>{if(!ut){i(!0);return}let ee=Ge;if(!ee){const ae=await Ir();ee=(ae==null?void 0:ae.id)??null}ee&&ko(q,{token:ut,sessionId:ee,mode:be,provider:fe,model:fe!=="jait"?tt:void 0,onLoginRequired:()=>i(!0)})},u0=y.useCallback(async(q,ee,ae,ve)=>{!Ge||!ut||await Gs(q,ee,ae,ve,{token:ut,sessionId:Ge,mode:be,provider:fe,model:fe!=="jait"?tt:void 0,onLoginRequired:()=>i(!0)})},[Ge,Gs,ut,be,fe,tt]),nf=async q=>{q.preventDefault(),o(null);try{await te(Ne,Fe),i(!1),re(""),c("chat")}catch(ee){o(ee instanceof Error?ee.message:"Login failed")}},_a=async q=>{if(q.preventDefault(),o(null),!he||!ke){o("Username and password are required");return}if(ke!==Ie){o("Passwords do not match");return}try{await pe(he,ke),i(!1),Oe(""),Ae(""),c("chat")}catch(ee){o(ee instanceof Error?ee.message:"Registration failed")}},Kd=y.useCallback(async q=>{q.preventDefault();const ee=de.trim();if(!ee){En("Please enter a gateway URL");return}jo(!0),En(null);try{const ae=ee.replace(/\/+$/,""),ve=await fetch(`${ae}/health`,{signal:AbortSignal.timeout(5e3)});if(!ve.ok)throw new Error(`Server returned ${ve.status}`);const Re=Wn();if(ry(ae),ae!==Re){window.location.reload();return}In("auth")}catch(ae){En(ae instanceof Error?ae.name==="TimeoutError"||ae.name==="AbortError"?"Connection timed out":ae.message:"Failed to connect")}finally{jo(!1)}},[de]),f0=()=>{Ee(),_c(),c("chat"),i(!0)},Gd=async q=>{const ee=Object.fromEntries(Object.entries(q).map(([ae,ve])=>[ae,ve.trim()]).filter(([,ae])=>ae.length>0));await Me({api_keys:ee})},d0=async()=>{const q=await bt();return await Kg(),q.removed},Ti=y.useCallback(async()=>{if(Ge)try{await fetch(`${gi}/api/consent/pending/${Ge}/approve-all`,{method:"DELETE"}),ce(!1)}catch{}},[Ge]),No=y.useCallback(async q=>{const ee=LL(q);if(!ee)return;if(Ue==="manager"){const ve=we.selectedThread;if((ve==null?void 0:ve.status)==="running"){Mc(ve.id,{id:`mq-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,content:ee,displayContent:ee,fullContent:ee,referencedFiles:void 0,attachments:void 0,providerId:fe,model:fe!=="jait"?tt:void 0,queuedAt:Date.now()});return}await we.handleSend(ee,fe,fe!=="jait"?tt:void 0);return}let ae=Ge;if(!ae){const ve=await Ir();ae=(ve==null?void 0:ve.id)??null}if(!(!ae||!ut)){if(vr||Oi.length>0){ol({content:ee,displayContent:ee,mode:be,provider:fe,model:fe!=="jait"?tt:void 0});return}ko(ee,{token:ut,sessionId:ae,onLoginRequired:()=>i(!0)})}},[Ge,we.handleSend,we.selectedThread,be,fe,tt,Ir,Mc,ol,vr,Oi.length,ko,ut,Ue]),[to,Rc]=y.useState(!1),[To,Br]=y.useState(!1),[Fr,no]=y.useState(()=>aw()),fi=y.useRef(null),di=y.useRef([]),Jr=y.useRef(null),gl=y.useRef(aw()),Dc=y.useRef(null),zc=y.useRef(null),rf=y.useRef(null),er=y.useRef(null),yn=y.useRef(null),qt=y.useCallback(()=>{const q=aw();gl.current=q,no(q)},[]),Zr=y.useCallback(()=>{var ee;yn.current!==null&&(cancelAnimationFrame(yn.current),yn.current=null),(ee=zc.current)==null||ee.disconnect(),zc.current=null,rf.current=null,er.current=null;const q=Dc.current;Dc.current=null,q&&q.state!=="closed"&&q.close().catch(()=>{}),qt()},[qt]),hi=y.useCallback(q=>{Zr();try{const ee=new AudioContext,ae=ee.createAnalyser();ae.fftSize=256,ae.smoothingTimeConstant=.58;const ve=ee.createMediaStreamSource(q);ve.connect(ae);const Re=new Uint8Array(new ArrayBuffer(ae.frequencyBinCount));Dc.current=ee,zc.current=ve,rf.current=ae,er.current=Re;const Ve=()=>{const dt=rf.current,Pt=er.current;if(!dt||!Pt)return;dt.getByteTimeDomainData(Pt);let Mt=0;for(let ei=0;ei<Pt.length;ei++)Mt+=Math.abs((Pt[ei]-128)/128);const hn=Pt.length>0?Mt/Pt.length:0,$t=Math.pow(Math.min(1,hn*6.8),.78),br=Math.min(1,Math.max(a5,$t)),pi=(gl.current[gl.current.length-1]??a5)*.2+br*.8,ts=[...gl.current.slice(-(zL-1)),pi];gl.current=ts,no(ts),yn.current=requestAnimationFrame(Ve)};Ve()}catch(ee){console.warn("Voice visualizer unavailable:",ee),qt()}},[qt,Zr]),sf=y.useCallback(q=>{const ae=q.sampleRate,ve=q.getChannelData(0),Re=new ArrayBuffer(44+ve.length*2),Ve=new DataView(Re),dt=(Mt,hn)=>{for(let $t=0;$t<hn.length;$t++)Ve.setUint8(Mt+$t,hn.charCodeAt($t))};dt(0,"RIFF"),Ve.setUint32(4,36+ve.length*2,!0),dt(8,"WAVE"),dt(12,"fmt "),Ve.setUint32(16,16,!0),Ve.setUint16(20,1,!0),Ve.setUint16(22,1,!0),Ve.setUint32(24,ae,!0),Ve.setUint32(28,ae*1*2,!0),Ve.setUint16(32,2,!0),Ve.setUint16(34,16,!0),dt(36,"data"),Ve.setUint32(40,ve.length*2,!0);let Pt=44;for(let Mt=0;Mt<ve.length;Mt++){const hn=Math.max(-1,Math.min(1,ve[Mt]));Ve.setInt16(Pt,hn<0?hn*32768:hn*32767,!0),Pt+=2}return new Blob([Re],{type:"audio/wav"})},[]),es=y.useCallback(async()=>{var ae,ve,Re;Rc(!1),Zr();const q=fi.current;if(!q||q.state==="inactive"){(ae=Jr.current)==null||ae.getTracks().forEach(Ve=>Ve.stop()),Jr.current=null,fi.current=null;return}const ee=await new Promise(Ve=>{q.ondataavailable=dt=>{dt.data.size>0&&di.current.push(dt.data)},q.onstop=()=>{Ve(new Blob(di.current,{type:q.mimeType}))},q.stop()});if((ve=Jr.current)==null||ve.getTracks().forEach(Ve=>Ve.stop()),Jr.current=null,fi.current=null,ee.size!==0)if(Mn.stt_provider==="wyoming"||Mn.stt_provider==="whisper"){Br(!0);try{const Ve=await ee.arrayBuffer(),dt=new AudioContext({sampleRate:16e3}),Pt=await dt.decodeAudioData(Ve),Mt=sf(Pt);await dt.close();const hn=await Mt.arrayBuffer(),$t=new Uint8Array(hn);let br="";for(let ei=0;ei<$t.length;ei++)br+=String.fromCharCode($t[ei]);const Qr=btoa(br),ts=await(await fetch(`${gi}/api/voice/transcribe-audio`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ut}`},body:JSON.stringify({audioBase64:Qr,sessionId:Ge??"voice-input",provider:Mn.stt_provider})})).json();ts.text?n(ei=>CO(ei,ts.text??"")):console.warn("Transcription failed:",ts.details??ts.error)}catch(Ve){console.error("Transcription error:",Ve)}finally{Br(!1)}}else if(Mn.stt_provider==="browser"){Br(!0);try{const Ve=window;if(!(Ve.SpeechRecognition??Ve.webkitSpeechRecognition)){window.alert("Browser Speech-to-Text is not supported.");return}window.alert("Browser STT works best with direct microphone input. Consider switching to Wyoming for push-to-talk.")}finally{Br(!1)}}else{const Ve=((Re=window.prompt("Transcription (simulated):"))==null?void 0:Re.trim())??"";Ve&&n(dt=>CO(dt,Ve))}},[Ge,sf,Mn.stt_provider,ut]),Lc=y.useCallback(async()=>{var q;if(!ut){i(!0);return}if(Mn.stt_provider==="browser"){const ee=window,ae=ee.SpeechRecognition??ee.webkitSpeechRecognition;if(!ae){window.alert('Speech-to-Text provider "Browser" is not supported in this browser.');return}const ve=await new Promise(Re=>{const Ve=new ae;let dt=!1;const Pt=Mt=>{dt||(dt=!0,Re(Mt))};Ve.lang="de-DE",Ve.interimResults=!1,Ve.maxAlternatives=1,Ve.onresult=Mt=>{var $t,br,Qr,pi;const hn=((pi=(Qr=(br=($t=Mt.results)==null?void 0:$t[0])==null?void 0:br[0])==null?void 0:Qr.transcript)==null?void 0:pi.trim())??"";Pt(hn)},Ve.onerror=()=>Pt(""),Ve.onnomatch=()=>Pt(""),Ve.onend=()=>Pt(""),Ve.start()});if(!ve)return;try{const Ve=await(await fetch(`${gi}/api/voice/transcribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Ge??"voice-input",transcript:ve})})).json();Ve.text&&await No(Ve.text)}catch{}return}if(Mn.stt_provider==="simulated"){const ee=((q=window.prompt("Speak now (simulated transcript):"))==null?void 0:q.trim())??"";if(!ee)return;try{const ve=await(await fetch(`${gi}/api/voice/transcribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Ge??"voice-input",transcript:ee})})).json();ve.text&&await No(ve.text)}catch{}return}try{const ee=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:16e3}});Jr.current=ee,di.current=[],hi(ee);const ae=new MediaRecorder(ee);fi.current=ae,ae.ondataavailable=ve=>{ve.data.size>0&&di.current.push(ve.data)},ae.start(),Rc(!0)}catch(ee){Zr(),console.error("Microphone access denied:",ee),window.alert("Microphone access is required for push-to-talk.")}},[Ge,Mn.stt_provider,hi,Zr,No,ut]);y.useEffect(()=>()=>{var q;Zr(),(q=Jr.current)==null||q.getTracks().forEach(ee=>ee.stop())},[Zr]);const Yd=Ei==="limit_reached",ba=qs.length>0||Du,xa=((of=(yl=Yi==null?void 0:Yi.username)==null?void 0:yl[0])==null?void 0:of.toUpperCase())??"?",Xd=[...qs.slice(-10).map(q=>bO({id:`msg-${q.id}`,source:"chat",title:`Message: ${q.role}`,detail:q.content.slice(0,120)||"(empty message)"})),...Sc.map(q=>bO({id:`term-${q.id}`,source:"terminal",title:"Terminal session",detail:`${q.id} (${q.state})`}))];return f.jsx(tG,{children:f.jsxs("div",{className:"fixed inset-0 flex flex-col overflow-hidden safe-top safe-bottom safe-left safe-right",children:[f.jsxs("header",{className:`flex items-center px-2 sm:px-5 border-b shrink-0 gap-1 sm:gap-2 ${Je?"h-10 !pl-[0.8rem]":"h-14"}`,style:Je?{WebkitAppRegion:"drag",paddingLeft:st==="darwin"?70:void 0,paddingRight:st==="win32"?140:void 0}:void 0,children:[f.jsx("div",{className:"flex items-center shrink-0",style:Je?{WebkitAppRegion:"no-drag"}:void 0,children:f.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 1024 1024",className:"shrink-0",children:[f.jsx("path",{d:"M318 372 L430 486 L318 600",fill:"none",stroke:"currentColor",strokeWidth:"88",strokeLinecap:"round",strokeLinejoin:"round"}),f.jsx("path",{d:"M610 258 L610 642 C610 734 549 796 455 796 C393 796 338 766 299 715",fill:"none",stroke:"currentColor",strokeWidth:"88",strokeLinecap:"round",strokeLinejoin:"round"})]})}),f.jsxs("nav",{className:"flex items-center gap-1 min-w-0 overflow-x-auto scrollbar-none",style:Je?{WebkitAppRegion:"no-drag"}:void 0,children:[f.jsxs($e,{variant:a==="chat"?"secondary":"ghost",size:"sm",className:"h-8 text-xs shrink-0 px-2 sm:px-3",onClick:()=>c("chat"),children:[f.jsx(HO,{className:"h-3.5 w-3.5 sm:mr-1.5"}),f.jsx("span",{className:"hidden sm:inline",children:"Chat"})]}),f.jsxs($e,{variant:a==="jobs"?"secondary":"ghost",size:"sm",className:"h-8 text-xs shrink-0 px-2 sm:px-3",onClick:()=>c("jobs"),children:[f.jsx(fw,{className:"h-3.5 w-3.5 sm:mr-1.5"}),f.jsx("span",{className:"hidden sm:inline",children:"Jobs"})]}),f.jsxs($e,{variant:a==="network"?"secondary":"ghost",size:"sm",className:"h-8 text-xs shrink-0 px-2 sm:px-3",onClick:()=>c("network"),children:[f.jsx(pv,{className:"h-3.5 w-3.5 sm:mr-1.5"}),f.jsx("span",{className:"hidden sm:inline",children:"Network"})]})]}),f.jsx("div",{className:"flex-1 min-w-0"}),f.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5 shrink-0",style:Je?{WebkitAppRegion:"no-drag"}:void 0,children:[a==="chat"&&Zg.length>0&&f.jsx(kSe,{threads:Zg,getRepositoryForThread:we.getRepositoryForThread,threadPrStates:we.threadPrStates,ghAvailable:we.ghAvailable,onOpenThread:q=>{Ue!=="manager"&&mt("manager"),c("chat"),we.setSelectedThreadId(q)},onStopThread:q=>we.handleStop(q)}),Hu.isActive&&f.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted-foreground bg-muted/60 rounded px-1.5 py-0.5 shrink-0",children:[f.jsx(jp,{className:"h-3 w-3 text-green-500 animate-pulse"}),f.jsx("span",{className:"hidden sm:inline",children:"Sharing"})]}),f.jsx(pse,{usage:Ks}),(()=>{const q=fe==="codex"?"openai":fe==="claude-code"?"anthropic":d_??"ollama",ee=fe==="codex"?tt??"Codex":fe==="claude-code"?tt??"Claude Code":Fu?Wue(Fu):null,ae=fe==="codex"?`OpenAI Codex CLI${tt?` · ${tt}`:""}`:fe==="claude-code"?`Anthropic Claude Code CLI${tt?` · ${tt}`:""}`:Fu??"";return ee?f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5 sm:mr-2 px-1.5 sm:px-2 py-1 rounded-md bg-muted/50 cursor-default",children:[f.jsx(By,{provider:q,model:fe==="codex"?"codex":fe==="claude-code"?"claude-3":Fu??void 0,size:16}),f.jsx("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:ee})]})}),f.jsx(ir,{side:"bottom",children:ae})]}):null})(),ca!==null&&ca<=5&&f.jsxs("span",{className:"text-xs text-muted-foreground mr-1 sm:mr-2 hidden sm:inline",children:[ca," remaining"]}),(jt==null?void 0:jt.hasUpdate)&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("button",{onClick:()=>{zt==="web"?c("settings"):window.open("https://github.com/JakobWl/Jait/releases/latest","_blank")},className:"flex items-center gap-1 px-2 py-1 rounded-md bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors text-xs",children:[f.jsx(zO,{className:"h-3.5 w-3.5"}),f.jsxs("span",{className:"hidden sm:inline",children:["v",jt.latestVersion]})]})}),f.jsxs(ir,{side:"bottom",children:["Update available — v",jt.latestVersion]})]}),Qn?f.jsxs(Eu,{children:[f.jsx(Ou,{asChild:!0,children:f.jsx("button",{className:"rounded-full ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:f.jsx(dN,{className:"h-7 w-7",children:f.jsx(hN,{className:"text-[11px]",children:xa})})})}),f.jsxs(dc,{align:"end",children:[f.jsx(Ov,{children:Yi==null?void 0:Yi.username}),f.jsx(Vo,{}),f.jsxs(Xo,{onSelect:()=>c("settings"),children:[f.jsx(hB,{className:"h-4 w-4 mr-2"}),"Settings"]}),f.jsx(Vo,{}),f.jsxs("div",{className:"px-2 py-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Theme"}),f.jsx("div",{className:"flex items-center h-7 w-fit rounded-full border bg-muted/50 p-0.5 mt-1.5",children:[["light",gB],["system",gs],["dark",cB]].map(([q,ee])=>f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsx("button",{onClick:()=>{a0(q)},className:`relative flex items-center justify-center h-6 w-6 rounded-full transition-colors ${d===q?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:f.jsx(ee,{className:"h-3.5 w-3.5"})})}),f.jsx(ir,{side:"bottom",children:q.charAt(0).toUpperCase()+q.slice(1)})]},q))})]}),f.jsx(Vo,{}),f.jsxs(Xo,{onSelect:f0,children:[f.jsx(nB,{className:"h-4 w-4 mr-2"}),"Logout"]})]})]}):f.jsx($e,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:()=>i(!0),children:"Sign in"}),Je&&st==="linux"&&f.jsxs("div",{className:"flex items-center ml-2 -mr-2",children:[f.jsx("button",{onClick:()=>window.jaitDesktop.windowMinimize(),className:"flex items-center justify-center h-9 w-11 hover:bg-muted/80 transition-colors",children:f.jsx(aB,{className:"h-4 w-4"})}),f.jsx("button",{onClick:()=>window.jaitDesktop.windowMaximize(),className:"flex items-center justify-center h-9 w-11 hover:bg-muted/80 transition-colors",children:Lt?f.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",className:"fill-current",children:f.jsx("path",{d:"M2 0v2H0v8h8V8h2V0zm5 7H1V3h6zM9 1v6H8V2H3V1z"})}):f.jsx($p,{className:"h-3 w-3"})}),f.jsx("button",{onClick:()=>window.jaitDesktop.windowClose(),className:"flex items-center justify-center h-9 w-11 hover:bg-red-600 hover:text-white transition-colors",children:f.jsx(Mr,{className:"h-4 w-4"})})]})]})]}),a==="chat"&&f.jsxs("div",{className:`flex border-b bg-muted/30 px-2 sm:px-5 shrink-0 ${h_?"min-h-9 flex-wrap items-start gap-2 py-1.5":"h-9 items-center gap-1 overflow-x-auto scrollbar-none"}`,children:[Ue==="developer"&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:g?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>p(q=>!q),children:[g?f.jsx(j8,{className:`h-3 w-3 mr-1${sn?" rotate-90":""}`}):f.jsx(k8,{className:`h-3 w-3 mr-1${sn?" rotate-90":""}`}),"Sessions"]})}),f.jsx(ir,{side:"bottom",children:"Toggle sessions sidebar"})]}),(Ue==="developer"||Ue==="manager"&&we.selectedThread)&&f.jsxs(f.Fragment,{children:[Ue==="developer"&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:_?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>{l0()},children:[f.jsx(su,{className:"h-3 w-3 mr-1"}),"Terminal"]})}),f.jsx(ir,{side:"bottom",children:"Toggle terminal panel"})]}),f.jsxs("div",{className:"relative flex items-center shrink-0",children:[f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:N?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2",onClick:()=>{o0()},children:[f.jsx(c1,{className:"h-3 w-3 mr-1"}),"Workspace",N&&f.jsx(Mr,{className:"h-3 w-3 ml-1"})]})}),f.jsx(ir,{side:"bottom",children:N?"Close workspace":"Open workspace"})]}),F&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>W(!1)}),f.jsxs("div",{ref:z,className:"absolute top-full left-0 mt-1 z-50 w-64 rounded-lg border bg-background shadow-lg p-3 space-y-2",children:[f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(ap,{className:"h-4 w-4 text-amber-500 shrink-0 mt-0.5"}),f.jsxs("div",{className:"text-xs",children:[f.jsx("p",{className:"font-medium",children:"Close workspace?"}),f.jsxs("p",{className:"text-muted-foreground mt-0.5",children:["You have ",Xi.length," unsaved file ",Xi.length===1?"change":"changes"," that will be discarded."]})]})]}),f.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[f.jsx($e,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2",onClick:()=>W(!1),children:"Cancel"}),f.jsx($e,{variant:"destructive",size:"sm",className:"h-6 text-[11px] px-2",onClick:()=>{W(!1),Zu()},children:"Discard & Close"})]})]})]})]})]}),Ue==="developer"&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:V?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>A(q=>!q),children:[f.jsx(HI,{className:"h-3 w-3 mr-1"}),"Debug"]})}),f.jsx(ir,{side:"bottom",children:"SSE debug stream"})]}),Ue==="developer"&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:P?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>P?Ju():hl(),children:[f.jsx(jp,{className:"h-3 w-3 mr-1"}),"Share"]})}),f.jsx(ir,{side:"bottom",children:"Screen sharing"})]}),Ue==="manager"&&f.jsxs(f.Fragment,{children:[we.selectedThread?f.jsxs($e,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>{we.setSelectedThreadId(null),n("")},children:[f.jsx(uw,{className:"h-3 w-3 mr-1"}),"Back"]}):f.jsxs(f.Fragment,{children:[f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:x?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>C(q=>!q),children:[x?f.jsx(j8,{className:`h-3 w-3 mr-1${sn?" rotate-90":""}`}):f.jsx(k8,{className:`h-3 w-3 mr-1${sn?" rotate-90":""}`}),"Repositories"]})}),f.jsx(ir,{side:"bottom",children:"Toggle repositories panel"})]}),we.selectedRepo&&we.selectedRepo.source==="local"&&f.jsxs(f.Fragment,{children:[f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>S(we.selectedRepo),children:[f.jsx(WO,{className:"h-3 w-3 mr-1"}),"Strategy"]})}),f.jsx(ir,{side:"bottom",children:"Open repository strategy"})]}),f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>O(we.selectedRepo),children:[f.jsx(FO,{className:"h-3 w-3 mr-1"}),"Todos"]})}),f.jsx(ir,{side:"bottom",children:"Open todo plan"})]})]})]}),f.jsx("div",{className:"flex-1"}),we.selectedThread?f.jsxs("div",{className:sn?"flex min-w-0 basis-full items-start gap-2":"flex min-w-0 items-center gap-2 shrink-0",children:[f.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2",children:[f.jsx(v4,{status:we.selectedThread.status}),f.jsxs("div",{className:`min-w-0 ${sn?"flex-1":"flex items-center gap-2"}`,children:[y4(we.selectedThread.title)?f.jsx($L,{className:"text-[11px] h-3.5 w-28"}):f.jsx("span",{className:`text-[11px] text-muted-foreground truncate ${sn?"block":"max-w-[200px]"}`,children:we.selectedThread.title.replace(/^\[.*?\]\s*/,"")}),(we.selectedRepo||sn&&we.selectedThread.branch)&&f.jsxs("span",{className:`text-[10px] text-muted-foreground truncate ${sn?"mt-0.5 block":"max-w-[160px]"}`,children:[we.selectedRepo?`${we.selectedRepo.name} · ${we.selectedRepo.defaultBranch}`:"",sn&&we.selectedThread.branch?`${we.selectedRepo?" · ":""}${we.selectedThread.branch}`:""]})]})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1 ",children:[!sn&&we.selectedThread.branch&&f.jsx(ln,{variant:"outline",className:"text-[9px] px-1 py-0 font-mono",children:we.selectedThread.branch}),we.selectedThread.status==="running"&&f.jsx($e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>void we.handleStop(we.selectedThread.id),children:f.jsx($p,{className:"h-2.5 w-2.5"})}),we.showGitActions&&we.selectedRepo&&f.jsx("div",{className:sn?"shrink-0":"ml-2 shrink-0",children:f.jsx(LS,{threadId:we.selectedThread.id,cwd:we.selectedThread.workingDirectory??we.selectedRepo.localPath,branch:we.selectedThread.branch,baseBranch:we.selectedRepo.defaultBranch,threadTitle:we.selectedThread.title,threadStatus:we.selectedThread.status,prUrl:we.selectedThread.prUrl,prState:we.selectedThread.id in we.threadPrStates?we.threadPrStates[we.selectedThread.id]:we.selectedThread.prState,ghAvailable:we.ghAvailable,showStatusBadge:!sn})})]})]}):null]})]}),a==="jobs"?f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx(Bfe,{})}):a==="network"?f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx(m2e,{token:ut})}):a==="settings"?f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx(mge,{username:(Yi==null?void 0:Yi.username)??"",token:ut,apiKeys:Mn.api_keys,onSaveApiKeys:Gd,sttProvider:Mn.stt_provider,onSttProviderChange:async q=>{await Me({stt_provider:q})},onClearArchive:d0,activityEvents:Xd,updateInfo:jt,updateChecking:At,onCheckUpdate:()=>{lt()},onApplyUpdate:()=>{yt()},updateApplying:Tt,platform:zt})}):f.jsxs("div",{className:`flex flex-1 min-h-0 overflow-hidden ${sn?"flex-col":""}`,children:[Ue==="developer"&&g&&f.jsx("aside",{className:`overflow-hidden ${sn?"h-52 border-b shrink-0":"w-56 border-r shrink-0"}`,children:f.jsx(tse,{sessions:wn,activeSessionId:Ge,hasMoreSessions:Gg,showFewerSessions:wn.length>u_,onSelect:Ws,onCreate:()=>Ir(),onArchive:l_,onShowMore:Nd,onShowFewer:c_,sessionInfo:vc})}),(Ue==="developer"||Ue==="manager"&&we.selectedThread)&&Vs&&f.jsx(Lk,{ref:Lr,autoOpenRemotePath:(_t==null?void 0:_t.workspaceRoot)??null,surfaceId:(_t==null?void 0:_t.surfaceId)??null,files:Bn,activeFileId:sa,onActiveFileChange:zr,onFileDrop:q=>{ya(q)},onReferenceFile:q=>{var ee;return(ee=ki.current)==null?void 0:ee.insertChip({path:q.path,name:q.name})},onAvailableFilesChange:oa,showTree:H,showEditor:I,onToggleTree:Oo,onToggleEditor:ga,changedPaths:qd,fsWatcherVersion:On,savedTabsState:Ud,onTabsStateChange:Vd,onApplyDiff:ci,provider:fe,cliModel:tt}),(Ue==="developer"||Ue==="manager"&&we.selectedThread)&&yr&&(H||I)&&f.jsx("section",{className:`shrink-0 border-b bg-background overflow-hidden ${ba?"h-[50dvh] min-h-[220px]":"h-[55dvh] min-h-[260px]"}`,children:f.jsx(Lk,{ref:Lr,autoOpenRemotePath:(_t==null?void 0:_t.workspaceRoot)??null,surfaceId:(_t==null?void 0:_t.surfaceId)??null,files:Bn,activeFileId:sa,onActiveFileChange:zr,onFileDrop:q=>{ya(q)},onReferenceFile:q=>{var ee;return(ee=ki.current)==null?void 0:ee.insertChip({path:q.path,name:q.name})},onAvailableFilesChange:oa,showTree:H,showEditor:I,onToggleTree:Oo,onToggleEditor:ga,changedPaths:qd,isMobile:!0,savedTabsState:Ud,onTabsStateChange:Vd,onApplyDiff:ci,provider:fe,cliModel:tt})}),(Ue==="developer"||Ue==="manager"&&we.selectedThread)&&yr&&(!H||!I)&&f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b bg-muted/20 shrink-0",children:[!H&&f.jsxs("button",{onClick:Nc,className:"flex items-center gap-1 rounded px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3.5 w-3.5"}),f.jsx(c1,{className:"h-3.5 w-3.5"}),f.jsx(tu,{className:"h-3.5 w-3.5"}),!sn&&"Show Files + Changes"]}),!I&&f.jsxs("button",{onClick:Zs,className:"flex items-center gap-1 rounded px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3.5 w-3.5"}),f.jsx(X1,{className:"h-3.5 w-3.5"}),!sn&&"Show Editor"]})]}),Ue==="manager"?f.jsx("div",{className:"flex-1 min-w-0 flex flex-col min-h-0",children:we.selectedThread?f.jsxs(f.Fragment,{children:[N&&(!H||!I)&&!sn&&f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b bg-muted/20 shrink-0",children:[!H&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("button",{onClick:Nc,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3 w-3"}),f.jsx(c1,{className:"h-3 w-3"}),f.jsx(tu,{className:"h-3 w-3"}),"Show Files + Changes"]})}),f.jsx(ir,{side:"bottom",children:"Show files and source control"})]}),!I&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("button",{onClick:Zs,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3 w-3"}),f.jsx(X1,{className:"h-3 w-3"}),"Show Editor"]})}),f.jsx(ir,{side:"bottom",children:"Show editor"})]})]}),f.jsxs(pj,{className:"min-h-0 flex-1 border-b",loading:we.loadingActivities,children:[Uu.length===0&&!we.loadingActivities&&f.jsx("div",{className:"text-center text-sm text-muted-foreground py-8",children:"No activity yet"}),Uu.map((q,ee)=>{var ae;return f.jsx(Hw,{messageId:q.id,messageIndex:ee,messageFromEnd:Uu.length-1-ee,role:q.role,content:q.content,toolCalls:q.toolCalls,segments:q.segments,isStreaming:((ae=we.selectedThread)==null?void 0:ae.status)==="running"&&ee===Uu.length-1,compact:!0,preferLlmUi:!1,onOpenPath:Tc,onOpenDiff:li},q.id)})]},((Po=we.selectedThread)==null?void 0:Po.id)??"manager-empty"),f.jsx("div",{className:"shrink-0 py-3 px-4",children:f.jsxs("div",{className:"mx-auto max-w-3xl",children:[we.error&&f.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-red-500/40 bg-red-500/10 px-3.5 py-2.5 text-sm text-red-400 mb-2",children:[f.jsx(ap,{className:"h-4 w-4 shrink-0"}),f.jsx("span",{className:"min-w-0 break-words",children:we.error})]}),Qg.length>0&&we.selectedThread&&f.jsx(L7,{items:Qg,onRemove:q=>ef(we.selectedThread.id,q),onEdit:(q,ee)=>ml(we.selectedThread.id,q,ee),onReorder:(q,ee)=>__(we.selectedThread.id,q,ee),className:"mb-2"}),f.jsx(S1,{ref:ki,value:e,onChange:n,onSubmit:pl,onQueue:ui,onStop:()=>{we.selectedThread&&we.handleStop(we.selectedThread.id)},isLoading:((Ss=we.selectedThread)==null?void 0:Ss.status)==="running",disabled:we.creating,placeholder:(ro=we.selectedThread)!=null&&ro.providerSessionId||((Cs=we.selectedThread)==null?void 0:Cs.status)==="running"?"Send a follow-up message...":"Describe what you want to do...",onVoiceInput:Lc,voiceRecording:to,voiceLevels:Fr,voiceTranscribing:To,onVoiceStop:()=>{es()},viewMode:Ue,onViewModeChange:mt,provider:fe,onProviderChange:Ec,cliModel:tt,onCliModelChange:Oc,repoRuntime:zd,onMoveToGateway:tf,availableFiles:il,onSearchFiles:Pc,workspaceOpen:N}),f.jsxs("div",{className:"flex items-center gap-2 px-1 mt-1.5",children:[zd&&f.jsx(dv,{runtime:zd}),we.selectedThread&&we.selectedThread.status!=="running"&&!we.selectedThread.providerSessionId&&f.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:"Thread finished — start a new one"})]})]})})]}):f.jsxs("div",{className:`flex flex-1 min-h-0 ${sn?"flex-col":""}`,children:[x&&f.jsx("div",{className:`overflow-hidden ${sn?"h-52 shrink-0 border-b":"w-56 shrink-0 border-r"}`,children:f.jsx(CSe,{repositories:we.repositories,selectedRepoId:((af=we.selectedRepo)==null?void 0:af.id)??null,isMobile:sn,getRuntimeInfo:we.getRuntimeInfoForRepository,onSelect:we.setSelectedRepoId,onAddRepository:()=>we.setFolderPickerOpen(!0),onRemoveRepository:q=>{we.removeRepository(q)},onOpenStrategy:q=>S(q),onOpenPlan:q=>O(q)})}),f.jsxs("div",{className:"flex-1 flex flex-col min-w-0 overflow-y-auto",children:[f.jsx("div",{className:`relative z-10 flex flex-col items-center px-4 pb-2 pt-4${Dt!=="idle"?" will-change-transform transition-transform duration-300 ease-[cubic-bezier(0.4,0,0.2,1)]":""}`,style:Dt==="center"?{transform:"translateY(calc(50vh - 200px))"}:Dt==="top"?{transform:"translateY(0)"}:void 0,onTransitionEnd:()=>{Dt==="top"&&Et("idle")},children:f.jsxs("div",{className:"w-full max-w-3xl",children:[f.jsx("h1",{className:"mb-4 text-center text-2xl font-semibold tracking-tight",children:"What do you want to build?"}),we.error&&f.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-red-500/40 bg-red-500/10 px-3.5 py-2.5 text-sm text-red-400 mb-3",children:[f.jsx(ap,{className:"h-4 w-4 shrink-0"}),f.jsx("span",{className:"min-w-0 break-words",children:we.error})]}),f.jsx(S1,{ref:ki,value:e,onChange:n,onSubmit:pl,disabled:e0,controlsDisabled:we.creating,placeholder:m_,onVoiceInput:Lc,voiceRecording:to,voiceLevels:Fr,voiceTranscribing:To,onVoiceStop:()=>{es()},viewMode:Ue,onViewModeChange:mt,provider:fe,onProviderChange:Ec,cliModel:tt,onCliModelChange:Oc,repoRuntime:Vu,onMoveToGateway:tf,footerLeadingContent:f.jsx(SSe,{repositories:we.repositories,selectedRepo:we.selectedRepo,disabled:we.creating,getRuntimeInfo:we.getRuntimeInfoForRepository,onSelect:we.setSelectedRepoId,onAddRepository:()=>we.setFolderPickerOpen(!0)})}),Vu&&f.jsx(dv,{runtime:Vu,className:"mt-1 px-1"})]})}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsxs("div",{className:"mx-auto w-full max-w-3xl",children:[f.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"text-sm font-medium",children:"Threads"}),f.jsx(ln,{variant:"secondary",className:"h-5 rounded-md px-1.5 text-[10px]",children:cl.length})]}),f.jsx($e,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>void we.refresh(),children:f.jsx(du,{className:`h-3.5 w-3.5 ${we.loading?"animate-spin":""}`})})]}),cl.length===0?f.jsx("div",{className:"px-4 py-12 text-center text-sm text-muted-foreground",children:"No threads yet"}):f.jsxs("div",{className:"flex flex-col",children:[cl.map(q=>{const ee=we.getRepositoryForThread(q),ae=(ee==null?void 0:ee.name)??a_(q)??"Unknown repo";return f.jsx(jSe,{thread:q,repo:ee,repoName:ae,prState:q.id in we.threadPrStates?we.threadPrStates[q.id]:q.prState,ghAvailable:we.ghAvailable,onOpen:()=>we.setSelectedThreadId(q.id),onStop:()=>{we.handleStop(q.id)},onDelete:()=>{we.handleDelete(q.id)}},q.id)}),we.hasMoreThreads&&f.jsx("button",{className:"px-4 py-2 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:we.showMoreThreads,children:"Show more threads"}),cl.length>we.threadListLimit&&f.jsx("button",{className:"px-4 py-2 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:we.showFewerThreads,children:"Show less"})]})]})})]})]})}):ba?f.jsxs("div",{className:"flex flex-col flex-1 min-w-0 min-h-0 transition-all duration-300 ease-out",children:[N&&(!H||!I)&&!sn&&f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b bg-muted/20 shrink-0",children:[!H&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("button",{onClick:Nc,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3 w-3"}),f.jsx(c1,{className:"h-3 w-3"}),f.jsx(tu,{className:"h-3 w-3"}),"Show Files + Changes"]})}),f.jsx(ir,{side:"bottom",children:"Show files and source control"})]}),!I&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("button",{onClick:Zs,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3 w-3"}),f.jsx(X1,{className:"h-3 w-3"}),"Show Editor"]})}),f.jsx(ir,{side:"bottom",children:"Show editor"})]})]}),f.jsxs(pj,{className:"min-h-0 flex-1 border-b",compact:Vs,loading:Du,children:[qs.map((q,ee)=>f.jsx(Hw,{messageId:q.id,messageIndex:ee,messageFromEnd:qs.length-1-ee,role:q.role,content:q.content,displayContent:q.displayContent,referencedFiles:q.referencedFiles,thinking:q.thinking,thinkingDuration:q.thinkingDuration,toolCalls:q.toolCalls,segments:q.segments,isStreaming:vr&&q===qs[qs.length-1],compact:N||P,preferLlmUi:!0,onOpenTerminal:v_,onEditMessage:u0,onOpenPath:Tc,onOpenDiff:li},q.id)),Oi.length>0&&f.jsx(L7,{items:Oi,onRemove:Xr,onEdit:ua,onReorder:Bu})]},Ge??"developer-empty"),f.jsx("div",{className:`shrink-0 py-3 ${Vs?"px-3":"px-4"}`,children:f.jsxs("div",{className:"mx-auto w-full max-w-3xl space-y-1.5",children:[zu.length>0&&f.jsx(use,{items:zu}),Ei&&Ei!=="login_required"&&Ei!=="limit_reached"&&!vr&&f.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-red-500/40 bg-red-500/10 px-3.5 py-2.5 text-sm text-red-400 dark:text-red-400 dark:border-red-400/40 dark:bg-red-400/10",children:[f.jsx(ap,{className:"h-4 w-4 shrink-0"}),f.jsx("span",{className:"min-w-0 break-words",children:Ei})]}),sl&&!vr&&f.jsxs("div",{className:"flex items-center justify-center gap-2 py-1.5",children:[f.jsxs("button",{onClick:()=>Yg({token:ut,sessionId:Ge}),className:"inline-flex items-center gap-1.5 rounded-md border bg-background px-3 py-1.5 text-xs font-medium text-foreground shadow-sm hover:bg-accent transition-colors",children:[f.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:f.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Continue"]}),f.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Agent stopped — hit the tool execution limit"})]}),f.jsx(bse,{compact:!0,sessionId:Ge,onApproveAllEnabled:()=>ce(!0)}),Td&&f.jsx(lse,{plan:Td,onApprove:$u,onReject:Iu,isExecuting:vr}),Yd&&f.jsx("p",{className:"text-center text-sm text-destructive",children:"Daily limit reached. Come back tomorrow."}),Xi.length>0&&f.jsx(fse,{files:Xi,onAccept:Pd,onReject:Ad,onAcceptAll:Md,onRejectAll:bc,onFileClick:li}),f.jsx(S1,{ref:ki,value:e,onChange:n,onSubmit:pl,onStop:Lu,onQueue:Ac,isLoading:vr,disabled:Yd,onVoiceInput:Lc,voiceRecording:to,voiceLevels:Fr,voiceTranscribing:To,onVoiceStop:()=>{es()},mode:be,onModeChange:ze,provider:fe,onProviderChange:Ec,cliModel:tt,onCliModelChange:Oc,viewMode:Ue,onViewModeChange:mt,availableFiles:il,onSearchFiles:Pc,workspaceOpen:N,sessionInfo:vc,workspaceNodeId:_t==null?void 0:_t.nodeId}),f.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("button",{onClick:()=>{_c(),Ir()},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors shrink-0",children:"New chat"}),Ue==="manager"&&f.jsx("button",{onClick:()=>we.setSelectedThreadId(null),className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors shrink-0",children:"New thread"}),se&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-[11px] text-green-600 dark:text-green-400 truncate",children:"Approved all commands for this session"}),f.jsx("button",{onClick:Ti,className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors shrink-0",children:"Clear approve all"})]})]}),ca!==null&&f.jsxs("span",{className:"text-[11px] text-muted-foreground shrink-0",children:[ca," remaining"]})]})]})})]}):f.jsx("div",{className:`flex-1 min-w-0 flex flex-col items-center justify-center px-4 ${St==="animating"?"animate-slide-from-top":""}`,onAnimationEnd:()=>Ct("idle"),children:f.jsxs("div",{className:"w-full max-w-3xl space-y-8",children:[f.jsxs("div",{className:"text-center",children:[f.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Jait"}),f.jsx("p",{className:"text-base text-muted-foreground mt-1",children:"Just Another Intelligent Tool"})]}),f.jsx(nse,{suggestions:bSe,onSelect:eo}),f.jsx(S1,{ref:ki,value:e,onChange:n,onSubmit:pl,onStop:Lu,onQueue:Ac,isLoading:vr,onVoiceInput:Lc,voiceRecording:to,voiceLevels:Fr,voiceTranscribing:To,onVoiceStop:()=>{es()},mode:be,onModeChange:ze,provider:fe,onProviderChange:Ec,cliModel:tt,onCliModelChange:Oc,viewMode:Ue,onViewModeChange:mt,availableFiles:il,onSearchFiles:Pc,workspaceOpen:N,sessionInfo:vc,workspaceNodeId:_t==null?void 0:_t.nodeId})]})})]}),_&&a==="chat"&&Ue==="developer"&&f.jsxs("div",{className:"shrink-0 border-t overflow-hidden",style:{height:U},children:[f.jsx("div",{onMouseDown:y_,className:"h-1 cursor-row-resize hover:bg-primary/30 transition-colors"}),f.jsxs("div",{className:"relative",children:[f.jsx(q5e,{terminals:Sc,activeTerminalId:da,onSelect:ll,onCreate:()=>Cc(Ge??"default"),onKill:c0}),f.jsx("button",{onClick:ma,className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":"Close terminal",children:f.jsx(Mr,{className:"h-3.5 w-3.5"})})]}),da?f.jsx(W5e,{terminalId:da,className:"h-[calc(100%-2rem)]",token:ut}):f.jsx("div",{className:"flex items-center justify-center h-[calc(100%-2rem)] text-sm text-muted-foreground",children:f.jsx("button",{onClick:()=>Cc(Ge??"default"),className:"hover:text-foreground transition-colors",children:"+ New Terminal"})})]}),Ue==="developer"&&V&&f.jsx("div",{className:"fixed top-14 right-0 bottom-0 w-[420px] border-l z-50 shadow-xl",children:f.jsx(jse,{onClose:()=>A(!1)})}),f.jsx(Cu,{open:r,onOpenChange:i,children:f.jsx(fc,{className:"sm:max-w-md",children:An==="url"?f.jsxs(f.Fragment,{children:[f.jsxs(Ga,{children:[f.jsxs(Ya,{className:"flex items-center gap-2",children:[f.jsx(Ms,{className:"h-5 w-5"}),"Connect to Gateway"]}),f.jsx(Cy,{children:"Enter your Jait gateway URL to get started."})]}),f.jsxs("form",{onSubmit:Kd,className:"space-y-4 pt-2",children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"gateway-url",children:"Gateway URL"}),f.jsx(Kr,{id:"gateway-url",placeholder:"https://jait.example.com",value:de,onChange:q=>{gt(q.target.value),En(null)},autoFocus:!0})]}),Ci&&f.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[f.jsx(uu,{className:"h-4 w-4 shrink-0"}),Ci]}),f.jsx($e,{type:"submit",className:"w-full",disabled:Gi,children:Gi?f.jsxs(f.Fragment,{children:[f.jsx(kt,{className:"h-4 w-4 mr-2 animate-spin"}),"Connecting…"]}):"Connect"})]})]}):f.jsxs(f.Fragment,{children:[f.jsxs(Ga,{children:[f.jsx(Ya,{children:"Account"}),f.jsx(Cy,{asChild:!0,children:Le?f.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[f.jsx(Ms,{className:"h-3 w-3 text-green-500"}),f.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded",children:gi}),f.jsx("button",{type:"button",className:"text-xs text-primary underline underline-offset-2 hover:opacity-80",onClick:()=>In("url"),children:"Change"})]}):f.jsx("p",{children:"Sign in with a username and password."})})]}),f.jsxs(V5,{value:Ke,onValueChange:q=>ht(q),children:[f.jsxs(Pv,{className:"grid grid-cols-2 w-full",children:[f.jsx(Ba,{value:"login",children:"Login"}),f.jsx(Ba,{value:"register",children:"Register"})]}),f.jsx(Fa,{value:"login",className:"pt-4",children:f.jsxs("form",{className:"space-y-4",onSubmit:nf,children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"login-username",children:"Username"}),f.jsx(Kr,{id:"login-username",value:Ne,onChange:q=>Pe(q.target.value),autoComplete:"username",required:!0})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"login-password",children:"Password"}),f.jsx(Kr,{id:"login-password",type:"password",value:Fe,onChange:q=>re(q.target.value),autoComplete:"current-password",required:!0})]}),f.jsx($e,{type:"submit",className:"w-full",children:"Login"})]})}),f.jsx(Fa,{value:"register",className:"pt-4",children:f.jsxs("form",{className:"space-y-4",onSubmit:_a,children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"register-username",children:"Username"}),f.jsx(Kr,{id:"register-username",value:he,onChange:q=>_e(q.target.value),autoComplete:"username",required:!0})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"register-password",children:"Password"}),f.jsx(Kr,{id:"register-password",type:"password",value:ke,onChange:q=>Oe(q.target.value),autoComplete:"new-password",required:!0})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"register-password-confirm",children:"Confirm password"}),f.jsx(Kr,{id:"register-password-confirm",type:"password",value:Ie,onChange:q=>Ae(q.target.value),autoComplete:"new-password",required:!0})]}),f.jsx($e,{type:"submit",className:"w-full",children:"Create account"})]})})]}),s&&f.jsx("p",{className:"text-sm text-destructive",children:s})]})})}),f.jsx(_O,{open:ji,onOpenChange:aa,initialPath:Mn.workspace_picker_path,initialNodeId:Mn.workspace_picker_node_id,onSelect:(q,ee)=>{Qi(q,ee).catch(ae=>{console.error("Failed to open workspace:",ae),Pr.error(`Failed to open workspace: ${ae instanceof Error?ae.message:"Unknown error"}`)})}}),f.jsx(_O,{open:we.folderPickerOpen,onOpenChange:we.setFolderPickerOpen,onSelect:(q,ee)=>{we.handleFolderSelected(q,ee)}}),j&&f.jsx(ihe,{open:!!j,onOpenChange:q=>{q||S(null)},repoId:j.id,repoName:j.name}),E&&f.jsx(ahe,{open:!!E,onOpenChange:q=>{q||O(null)},repoId:E.id,repoName:E.name,defaultBranch:E.defaultBranch,repoLocalPath:E.localPath,onStartThread:(q,ee,ae)=>{(async()=>{const ve=E,Re=`jait/${Math.random().toString(16).slice(2,10)}`;let Ve;try{Ve=(await Hi.createWorktree(ve.localPath,ve.defaultBranch,Re)).path}catch{try{await Hi.createBranch(ve.localPath,Re,ve.defaultBranch)}catch{}}const dt=await en.createThread({title:`[${ve.name}] ${q.title}`,providerId:fe,workingDirectory:Ve??ve.localPath,branch:Re});await en.startThread(dt.id,{message:q.description||q.title,titleTask:q.title,titlePrefix:`[${ve.name}] `});const Pt=ee.tasks.map(Mt=>Mt.id===q.id?{...Mt,status:"running",threadId:dt.id}:Mt);await en.updatePlan(ee.id,{tasks:Pt})})()}}),P&&f.jsxs("div",{className:"fixed z-50 bg-background border rounded-lg shadow-2xl overflow-hidden flex flex-col",style:{left:Y.x<0?void 0:Y.x,top:Y.y<0?void 0:Y.y,right:Y.x<0?16:void 0,bottom:Y.y<0?16:void 0,width:R.w,height:R.h},children:[f.jsxs("div",{className:"flex items-center justify-between h-8 px-3 border-b bg-muted/30 shrink-0 cursor-move select-none",onPointerDown:yc,style:{touchAction:"none"},children:[f.jsxs("span",{className:"text-xs font-medium flex items-center gap-1.5",children:[f.jsx(jp,{className:"h-3 w-3"})," Screen Share"]}),f.jsx($e,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:Ju,children:f.jsx(Mr,{className:"h-3 w-3"})})]}),f.jsx(v2e,{screenShare:Hu}),f.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-nwse-resize opacity-50 hover:opacity-100",onPointerDown:Ru,style:{touchAction:"none"},children:f.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",className:"text-muted-foreground",children:f.jsx("path",{d:"M10 2L2 10M10 6L6 10M10 10L10 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})})}function OSe(){const[e,n]=Xe.useState(()=>document.documentElement.classList.contains("dark")?"dark":"light");return Xe.useEffect(()=>{const r=document.documentElement,i=()=>n(r.classList.contains("dark")?"dark":"light");i();const s=new MutationObserver(i);return s.observe(r,{attributes:!0,attributeFilter:["class"]}),()=>s.disconnect()},[]),f.jsx(zI,{position:"top-right",theme:e,closeButton:!1})}cI.createRoot(document.getElementById("root")).render(f.jsxs(Xe.StrictMode,{children:[f.jsx(ESe,{}),f.jsx(OSe,{})]}));
|
|
817
|
+
`)}`:ae,displayContent:ae,referencedFiles:ee!=null&&ee.length?ee.map(Pt=>({path:Pt.path,name:Pt.name})):void 0,attachments:Re.size>0?[...Re]:void 0}},[Bn]),Ac=y.useCallback(async q=>{const ee=await Qs(e,q);ee&&(ol({content:ee.promptWithReferences,displayContent:ee.displayContent||ee.promptWithReferences,mode:be,provider:fe,model:fe!=="jait"?tt:void 0,referencedFiles:ee.referencedFiles}),n(""))},[be,fe,tt,ol,e,Qs]),pl=async q=>{if(Ue==="manager")return va(q);const ee=await Qs(e,q);if(!ee)return;if(!ut){i(!0);return}let ae=Ge;if(!ae){const ve=await Ir();ae=(ve==null?void 0:ve.id)??null}if(ae){if(vr||Oi.length>0){ol({content:ee.promptWithReferences,displayContent:ee.displayContent||ee.promptWithReferences,mode:be,provider:fe,model:fe!=="jait"?tt:void 0,referencedFiles:ee.referencedFiles}),n("");return}ko(ee.promptWithReferences,{token:ut,sessionId:ae,mode:be,provider:fe,model:fe!=="jait"?tt:void 0,onLoginRequired:()=>i(!0),...ee.referencedFiles?{displayContent:ee.displayContent||ee.promptWithReferences,referencedFiles:ee.referencedFiles}:{}}),n("")}},va=async q=>{const ee=await Qs(e,q);!ee||e0||(n(""),await we.handleSend(ee.promptWithReferences,fe,fe!=="jait"?tt:void 0,{displayContent:ee.displayContent||ee.promptWithReferences,referencedFiles:ee.referencedFiles,attachments:ee.attachments}))},Mc=y.useCallback((q,ee)=>{fa(ae=>({...ae,[q]:[...ae[q]??[],ee]}))},[]),ef=y.useCallback((q,ee)=>{fa(ae=>{const ve=ae[q]??[],Re=ve.filter(Ve=>Ve.id!==ee);if(Re.length===ve.length)return ae;if(Re.length===0){const{[q]:Ve,...dt}=ae;return dt}return{...ae,[q]:Re}})},[]),ml=y.useCallback((q,ee,ae)=>{const ve=ae.trim();ve&&fa(Re=>{const Ve=Re[q]??[];return Ve.length===0?Re:{...Re,[q]:Ve.map(dt=>dt.id===ee?{...dt,content:ve,displayContent:ve,fullContent:ve,referencedFiles:void 0,attachments:void 0}:dt)}})},[]),__=y.useCallback((q,ee,ae)=>{fa(ve=>{const Re=ve[q]??[];if(Re.length===0)return ve;const Ve=bSe(Re,ee,ae);return Ve===Re?ve:{...ve,[q]:Ve}})},[]),ui=y.useCallback(async q=>{const ee=we.selectedThread;if(!ee)return;const ae=await Qs(e,q);ae&&(Mc(ee.id,{id:`mq-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,content:ae.displayContent||ae.promptWithReferences,displayContent:ae.displayContent||ae.promptWithReferences,fullContent:ae.promptWithReferences,referencedFiles:ae.referencedFiles,attachments:ae.attachments,providerId:fe,model:fe!=="jait"?tt:void 0,queuedAt:Date.now()}),n(""))},[we.selectedThread,fe,tt,Mc,e,Qs]);y.useEffect(()=>{for(const[q,ee]of Object.entries(al)){if(ee.length===0||Dd.current.has(q))continue;const ae=we.threads.find(Re=>Re.id===q);if(!ae){fa(Re=>{if(!(q in Re))return Re;const{[q]:Ve,...dt}=Re;return dt});continue}if(ae.status==="running")continue;const[ve]=ee;ve&&(Dd.current.add(q),fa(Re=>{const Ve=Re[q]??[],[,...dt]=Ve;if(dt.length===0){const{[q]:Pt,...Mt}=Re;return Mt}return{...Re,[q]:dt}}),we.handleSendToThread(q,ve.fullContent,ve.providerId,ve.model,{displayContent:ve.displayContent??ve.content,referencedFiles:ve.referencedFiles,attachments:ve.attachments}).catch(Re=>{fa(Ve=>({...Ve,[q]:[ve,...Ve[q]??[]]})),we.setError(Re instanceof Error?Re.message:"Failed to process queued thread message")}).finally(()=>{Dd.current.delete(q)}))}},[we.handleSendToThread,we.setError,we.threads,al]);const tf=y.useCallback(async()=>{const q=we.selectedRepo;if(q)try{await en.updateRepo(q.id,{deviceId:""}),await we.refresh()}catch{we.setError("Failed to move repository to gateway")}},[we.selectedRepo,we.refresh,we.setError]),eo=async q=>{if(!ut){i(!0);return}let ee=Ge;if(!ee){const ae=await Ir();ee=(ae==null?void 0:ae.id)??null}ee&&ko(q,{token:ut,sessionId:ee,mode:be,provider:fe,model:fe!=="jait"?tt:void 0,onLoginRequired:()=>i(!0)})},u0=y.useCallback(async(q,ee,ae,ve)=>{!Ge||!ut||await Gs(q,ee,ae,ve,{token:ut,sessionId:Ge,mode:be,provider:fe,model:fe!=="jait"?tt:void 0,onLoginRequired:()=>i(!0)})},[Ge,Gs,ut,be,fe,tt]),nf=async q=>{q.preventDefault(),o(null);try{await te(Ne,Fe),i(!1),re(""),c("chat")}catch(ee){o(ee instanceof Error?ee.message:"Login failed")}},_a=async q=>{if(q.preventDefault(),o(null),!he||!ke){o("Username and password are required");return}if(ke!==Ie){o("Passwords do not match");return}try{await pe(he,ke),i(!1),Oe(""),Ae(""),c("chat")}catch(ee){o(ee instanceof Error?ee.message:"Registration failed")}},Kd=y.useCallback(async q=>{q.preventDefault();const ee=de.trim();if(!ee){En("Please enter a gateway URL");return}jo(!0),En(null);try{const ae=ee.replace(/\/+$/,""),ve=await fetch(`${ae}/health`,{signal:AbortSignal.timeout(5e3)});if(!ve.ok)throw new Error(`Server returned ${ve.status}`);const Re=Wn();if(ry(ae),ae!==Re){window.location.reload();return}In("auth")}catch(ae){En(ae instanceof Error?ae.name==="TimeoutError"||ae.name==="AbortError"?"Connection timed out":ae.message:"Failed to connect")}finally{jo(!1)}},[de]),f0=()=>{Ee(),_c(),c("chat"),i(!0)},Gd=async q=>{const ee=Object.fromEntries(Object.entries(q).map(([ae,ve])=>[ae,ve.trim()]).filter(([,ae])=>ae.length>0));await Me({api_keys:ee})},d0=async()=>{const q=await bt();return await Kg(),q.removed},Ti=y.useCallback(async()=>{if(Ge)try{await fetch(`${gi}/api/consent/pending/${Ge}/approve-all`,{method:"DELETE"}),ce(!1)}catch{}},[Ge]),No=y.useCallback(async q=>{const ee=LL(q);if(!ee)return;if(Ue==="manager"){const ve=we.selectedThread;if((ve==null?void 0:ve.status)==="running"){Mc(ve.id,{id:`mq-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,content:ee,displayContent:ee,fullContent:ee,referencedFiles:void 0,attachments:void 0,providerId:fe,model:fe!=="jait"?tt:void 0,queuedAt:Date.now()});return}await we.handleSend(ee,fe,fe!=="jait"?tt:void 0);return}let ae=Ge;if(!ae){const ve=await Ir();ae=(ve==null?void 0:ve.id)??null}if(!(!ae||!ut)){if(vr||Oi.length>0){ol({content:ee,displayContent:ee,mode:be,provider:fe,model:fe!=="jait"?tt:void 0});return}ko(ee,{token:ut,sessionId:ae,onLoginRequired:()=>i(!0)})}},[Ge,we.handleSend,we.selectedThread,be,fe,tt,Ir,Mc,ol,vr,Oi.length,ko,ut,Ue]),[to,Rc]=y.useState(!1),[To,Br]=y.useState(!1),[Fr,no]=y.useState(()=>aw()),fi=y.useRef(null),di=y.useRef([]),Jr=y.useRef(null),gl=y.useRef(aw()),Dc=y.useRef(null),zc=y.useRef(null),rf=y.useRef(null),er=y.useRef(null),yn=y.useRef(null),qt=y.useCallback(()=>{const q=aw();gl.current=q,no(q)},[]),Zr=y.useCallback(()=>{var ee;yn.current!==null&&(cancelAnimationFrame(yn.current),yn.current=null),(ee=zc.current)==null||ee.disconnect(),zc.current=null,rf.current=null,er.current=null;const q=Dc.current;Dc.current=null,q&&q.state!=="closed"&&q.close().catch(()=>{}),qt()},[qt]),hi=y.useCallback(q=>{Zr();try{const ee=new AudioContext,ae=ee.createAnalyser();ae.fftSize=256,ae.smoothingTimeConstant=.58;const ve=ee.createMediaStreamSource(q);ve.connect(ae);const Re=new Uint8Array(new ArrayBuffer(ae.frequencyBinCount));Dc.current=ee,zc.current=ve,rf.current=ae,er.current=Re;const Ve=()=>{const dt=rf.current,Pt=er.current;if(!dt||!Pt)return;dt.getByteTimeDomainData(Pt);let Mt=0;for(let ei=0;ei<Pt.length;ei++)Mt+=Math.abs((Pt[ei]-128)/128);const hn=Pt.length>0?Mt/Pt.length:0,$t=Math.pow(Math.min(1,hn*6.8),.78),br=Math.min(1,Math.max(a5,$t)),pi=(gl.current[gl.current.length-1]??a5)*.2+br*.8,ts=[...gl.current.slice(-(zL-1)),pi];gl.current=ts,no(ts),yn.current=requestAnimationFrame(Ve)};Ve()}catch(ee){console.warn("Voice visualizer unavailable:",ee),qt()}},[qt,Zr]),sf=y.useCallback(q=>{const ae=q.sampleRate,ve=q.getChannelData(0),Re=new ArrayBuffer(44+ve.length*2),Ve=new DataView(Re),dt=(Mt,hn)=>{for(let $t=0;$t<hn.length;$t++)Ve.setUint8(Mt+$t,hn.charCodeAt($t))};dt(0,"RIFF"),Ve.setUint32(4,36+ve.length*2,!0),dt(8,"WAVE"),dt(12,"fmt "),Ve.setUint32(16,16,!0),Ve.setUint16(20,1,!0),Ve.setUint16(22,1,!0),Ve.setUint32(24,ae,!0),Ve.setUint32(28,ae*1*2,!0),Ve.setUint16(32,2,!0),Ve.setUint16(34,16,!0),dt(36,"data"),Ve.setUint32(40,ve.length*2,!0);let Pt=44;for(let Mt=0;Mt<ve.length;Mt++){const hn=Math.max(-1,Math.min(1,ve[Mt]));Ve.setInt16(Pt,hn<0?hn*32768:hn*32767,!0),Pt+=2}return new Blob([Re],{type:"audio/wav"})},[]),es=y.useCallback(async()=>{var ae,ve,Re;Rc(!1),Zr();const q=fi.current;if(!q||q.state==="inactive"){(ae=Jr.current)==null||ae.getTracks().forEach(Ve=>Ve.stop()),Jr.current=null,fi.current=null;return}const ee=await new Promise(Ve=>{q.ondataavailable=dt=>{dt.data.size>0&&di.current.push(dt.data)},q.onstop=()=>{Ve(new Blob(di.current,{type:q.mimeType}))},q.stop()});if((ve=Jr.current)==null||ve.getTracks().forEach(Ve=>Ve.stop()),Jr.current=null,fi.current=null,ee.size!==0)if(Mn.stt_provider==="wyoming"||Mn.stt_provider==="whisper"){Br(!0);try{const Ve=await ee.arrayBuffer(),dt=new AudioContext({sampleRate:16e3}),Pt=await dt.decodeAudioData(Ve),Mt=sf(Pt);await dt.close();const hn=await Mt.arrayBuffer(),$t=new Uint8Array(hn);let br="";for(let ei=0;ei<$t.length;ei++)br+=String.fromCharCode($t[ei]);const Qr=btoa(br),ts=await(await fetch(`${gi}/api/voice/transcribe-audio`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${ut}`},body:JSON.stringify({audioBase64:Qr,sessionId:Ge??"voice-input",provider:Mn.stt_provider})})).json();ts.text?n(ei=>CO(ei,ts.text??"")):console.warn("Transcription failed:",ts.details??ts.error)}catch(Ve){console.error("Transcription error:",Ve)}finally{Br(!1)}}else if(Mn.stt_provider==="browser"){Br(!0);try{const Ve=window;if(!(Ve.SpeechRecognition??Ve.webkitSpeechRecognition)){window.alert("Browser Speech-to-Text is not supported.");return}window.alert("Browser STT works best with direct microphone input. Consider switching to Wyoming for push-to-talk.")}finally{Br(!1)}}else{const Ve=((Re=window.prompt("Transcription (simulated):"))==null?void 0:Re.trim())??"";Ve&&n(dt=>CO(dt,Ve))}},[Ge,sf,Mn.stt_provider,ut]),Lc=y.useCallback(async()=>{var q;if(!ut){i(!0);return}if(Mn.stt_provider==="browser"){const ee=window,ae=ee.SpeechRecognition??ee.webkitSpeechRecognition;if(!ae){window.alert('Speech-to-Text provider "Browser" is not supported in this browser.');return}const ve=await new Promise(Re=>{const Ve=new ae;let dt=!1;const Pt=Mt=>{dt||(dt=!0,Re(Mt))};Ve.lang="de-DE",Ve.interimResults=!1,Ve.maxAlternatives=1,Ve.onresult=Mt=>{var $t,br,Qr,pi;const hn=((pi=(Qr=(br=($t=Mt.results)==null?void 0:$t[0])==null?void 0:br[0])==null?void 0:Qr.transcript)==null?void 0:pi.trim())??"";Pt(hn)},Ve.onerror=()=>Pt(""),Ve.onnomatch=()=>Pt(""),Ve.onend=()=>Pt(""),Ve.start()});if(!ve)return;try{const Ve=await(await fetch(`${gi}/api/voice/transcribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Ge??"voice-input",transcript:ve})})).json();Ve.text&&await No(Ve.text)}catch{}return}if(Mn.stt_provider==="simulated"){const ee=((q=window.prompt("Speak now (simulated transcript):"))==null?void 0:q.trim())??"";if(!ee)return;try{const ve=await(await fetch(`${gi}/api/voice/transcribe`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:Ge??"voice-input",transcript:ee})})).json();ve.text&&await No(ve.text)}catch{}return}try{const ee=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,sampleRate:16e3}});Jr.current=ee,di.current=[],hi(ee);const ae=new MediaRecorder(ee);fi.current=ae,ae.ondataavailable=ve=>{ve.data.size>0&&di.current.push(ve.data)},ae.start(),Rc(!0)}catch(ee){Zr(),console.error("Microphone access denied:",ee),window.alert("Microphone access is required for push-to-talk.")}},[Ge,Mn.stt_provider,hi,Zr,No,ut]);y.useEffect(()=>()=>{var q;Zr(),(q=Jr.current)==null||q.getTracks().forEach(ee=>ee.stop())},[Zr]);const Yd=Ei==="limit_reached",ba=qs.length>0||Du,xa=((of=(yl=Yi==null?void 0:Yi.username)==null?void 0:yl[0])==null?void 0:of.toUpperCase())??"?",Xd=[...qs.slice(-10).map(q=>bO({id:`msg-${q.id}`,source:"chat",title:`Message: ${q.role}`,detail:q.content.slice(0,120)||"(empty message)"})),...Sc.map(q=>bO({id:`term-${q.id}`,source:"terminal",title:"Terminal session",detail:`${q.id} (${q.state})`}))];return f.jsx(tG,{children:f.jsxs("div",{className:"fixed inset-0 flex flex-col overflow-hidden safe-top safe-bottom safe-left safe-right",children:[f.jsxs("header",{className:`flex items-center px-2 sm:px-5 border-b shrink-0 gap-1 sm:gap-2 ${Je?"h-10 !pl-[0.8rem]":"h-14"}`,style:Je?{WebkitAppRegion:"drag",paddingLeft:st==="darwin"?70:void 0,paddingRight:st==="win32"?140:void 0}:void 0,children:[f.jsx("div",{className:"flex items-center shrink-0",style:Je?{WebkitAppRegion:"no-drag"}:void 0,children:f.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 1024 1024",className:"shrink-0",children:[f.jsx("path",{d:"M318 372 L430 486 L318 600",fill:"none",stroke:"currentColor",strokeWidth:"88",strokeLinecap:"round",strokeLinejoin:"round"}),f.jsx("path",{d:"M610 258 L610 642 C610 734 549 796 455 796 C393 796 338 766 299 715",fill:"none",stroke:"currentColor",strokeWidth:"88",strokeLinecap:"round",strokeLinejoin:"round"})]})}),f.jsxs("nav",{className:"flex items-center gap-1 min-w-0 overflow-x-auto scrollbar-none",style:Je?{WebkitAppRegion:"no-drag"}:void 0,children:[f.jsxs($e,{variant:a==="chat"?"secondary":"ghost",size:"sm",className:"h-8 text-xs shrink-0 px-2 sm:px-3",onClick:()=>c("chat"),children:[f.jsx(HO,{className:"h-3.5 w-3.5 sm:mr-1.5"}),f.jsx("span",{className:"hidden sm:inline",children:"Chat"})]}),f.jsxs($e,{variant:a==="jobs"?"secondary":"ghost",size:"sm",className:"h-8 text-xs shrink-0 px-2 sm:px-3",onClick:()=>c("jobs"),children:[f.jsx(fw,{className:"h-3.5 w-3.5 sm:mr-1.5"}),f.jsx("span",{className:"hidden sm:inline",children:"Jobs"})]}),f.jsxs($e,{variant:a==="network"?"secondary":"ghost",size:"sm",className:"h-8 text-xs shrink-0 px-2 sm:px-3",onClick:()=>c("network"),children:[f.jsx(pv,{className:"h-3.5 w-3.5 sm:mr-1.5"}),f.jsx("span",{className:"hidden sm:inline",children:"Network"})]})]}),f.jsx("div",{className:"flex-1 min-w-0"}),f.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5 shrink-0",style:Je?{WebkitAppRegion:"no-drag"}:void 0,children:[a==="chat"&&Zg.length>0&&f.jsx(ESe,{threads:Zg,getRepositoryForThread:we.getRepositoryForThread,threadPrStates:we.threadPrStates,ghAvailable:we.ghAvailable,onOpenThread:q=>{Ue!=="manager"&&mt("manager"),c("chat"),we.setSelectedThreadId(q)},onStopThread:q=>we.handleStop(q)}),Hu.isActive&&f.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted-foreground bg-muted/60 rounded px-1.5 py-0.5 shrink-0",children:[f.jsx(jp,{className:"h-3 w-3 text-green-500 animate-pulse"}),f.jsx("span",{className:"hidden sm:inline",children:"Sharing"})]}),f.jsx(pse,{usage:Ks}),(()=>{const q=fe==="codex"?"openai":fe==="claude-code"?"anthropic":d_??"ollama",ee=fe==="codex"?tt??"Codex":fe==="claude-code"?tt??"Claude Code":Fu?Wue(Fu):null,ae=fe==="codex"?`OpenAI Codex CLI${tt?` · ${tt}`:""}`:fe==="claude-code"?`Anthropic Claude Code CLI${tt?` · ${tt}`:""}`:Fu??"";return ee?f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("div",{className:"flex items-center gap-1 sm:gap-1.5 sm:mr-2 px-1.5 sm:px-2 py-1 rounded-md bg-muted/50 cursor-default",children:[f.jsx(By,{provider:q,model:fe==="codex"?"codex":fe==="claude-code"?"claude-3":Fu??void 0,size:16}),f.jsx("span",{className:"text-xs text-muted-foreground hidden sm:inline",children:ee})]})}),f.jsx(ir,{side:"bottom",children:ae})]}):null})(),ca!==null&&ca<=5&&f.jsxs("span",{className:"text-xs text-muted-foreground mr-1 sm:mr-2 hidden sm:inline",children:[ca," remaining"]}),(jt==null?void 0:jt.hasUpdate)&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("button",{onClick:()=>{zt==="web"?c("settings"):window.open("https://github.com/JakobWl/Jait/releases/latest","_blank")},className:"flex items-center gap-1 px-2 py-1 rounded-md bg-amber-500/15 text-amber-600 dark:text-amber-400 hover:bg-amber-500/25 transition-colors text-xs",children:[f.jsx(zO,{className:"h-3.5 w-3.5"}),f.jsxs("span",{className:"hidden sm:inline",children:["v",jt.latestVersion]})]})}),f.jsxs(ir,{side:"bottom",children:["Update available — v",jt.latestVersion]})]}),Qn?f.jsxs(Eu,{children:[f.jsx(Ou,{asChild:!0,children:f.jsx("button",{className:"rounded-full ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",children:f.jsx(dN,{className:"h-7 w-7",children:f.jsx(hN,{className:"text-[11px]",children:xa})})})}),f.jsxs(dc,{align:"end",children:[f.jsx(Ov,{children:Yi==null?void 0:Yi.username}),f.jsx(Vo,{}),f.jsxs(Xo,{onSelect:()=>c("settings"),children:[f.jsx(hB,{className:"h-4 w-4 mr-2"}),"Settings"]}),f.jsx(Vo,{}),f.jsxs("div",{className:"px-2 py-1.5",children:[f.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Theme"}),f.jsx("div",{className:"flex items-center h-7 w-fit rounded-full border bg-muted/50 p-0.5 mt-1.5",children:[["light",gB],["system",gs],["dark",cB]].map(([q,ee])=>f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsx("button",{onClick:()=>{a0(q)},className:`relative flex items-center justify-center h-6 w-6 rounded-full transition-colors ${d===q?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:f.jsx(ee,{className:"h-3.5 w-3.5"})})}),f.jsx(ir,{side:"bottom",children:q.charAt(0).toUpperCase()+q.slice(1)})]},q))})]}),f.jsx(Vo,{}),f.jsxs(Xo,{onSelect:f0,children:[f.jsx(nB,{className:"h-4 w-4 mr-2"}),"Logout"]})]})]}):f.jsx($e,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:()=>i(!0),children:"Sign in"}),Je&&st==="linux"&&f.jsxs("div",{className:"flex items-center ml-2 -mr-2",children:[f.jsx("button",{onClick:()=>window.jaitDesktop.windowMinimize(),className:"flex items-center justify-center h-9 w-11 hover:bg-muted/80 transition-colors",children:f.jsx(aB,{className:"h-4 w-4"})}),f.jsx("button",{onClick:()=>window.jaitDesktop.windowMaximize(),className:"flex items-center justify-center h-9 w-11 hover:bg-muted/80 transition-colors",children:Lt?f.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",className:"fill-current",children:f.jsx("path",{d:"M2 0v2H0v8h8V8h2V0zm5 7H1V3h6zM9 1v6H8V2H3V1z"})}):f.jsx($p,{className:"h-3 w-3"})}),f.jsx("button",{onClick:()=>window.jaitDesktop.windowClose(),className:"flex items-center justify-center h-9 w-11 hover:bg-red-600 hover:text-white transition-colors",children:f.jsx(Mr,{className:"h-4 w-4"})})]})]})]}),a==="chat"&&f.jsxs("div",{className:`flex border-b bg-muted/30 px-2 sm:px-5 shrink-0 ${h_?"min-h-9 flex-wrap items-start gap-2 py-1.5":"h-9 items-center gap-1 overflow-x-auto scrollbar-none"}`,children:[Ue==="developer"&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:g?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>p(q=>!q),children:[g?f.jsx(j8,{className:`h-3 w-3 mr-1${sn?" rotate-90":""}`}):f.jsx(k8,{className:`h-3 w-3 mr-1${sn?" rotate-90":""}`}),"Sessions"]})}),f.jsx(ir,{side:"bottom",children:"Toggle sessions sidebar"})]}),(Ue==="developer"||Ue==="manager"&&we.selectedThread)&&f.jsxs(f.Fragment,{children:[Ue==="developer"&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:_?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>{l0()},children:[f.jsx(su,{className:"h-3 w-3 mr-1"}),"Terminal"]})}),f.jsx(ir,{side:"bottom",children:"Toggle terminal panel"})]}),f.jsxs("div",{className:"relative flex items-center shrink-0",children:[f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:N?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2",onClick:()=>{o0()},children:[f.jsx(c1,{className:"h-3 w-3 mr-1"}),"Workspace",N&&f.jsx(Mr,{className:"h-3 w-3 ml-1"})]})}),f.jsx(ir,{side:"bottom",children:N?"Close workspace":"Open workspace"})]}),F&&f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>W(!1)}),f.jsxs("div",{ref:z,className:"absolute top-full left-0 mt-1 z-50 w-64 rounded-lg border bg-background shadow-lg p-3 space-y-2",children:[f.jsxs("div",{className:"flex items-start gap-2",children:[f.jsx(ap,{className:"h-4 w-4 text-amber-500 shrink-0 mt-0.5"}),f.jsxs("div",{className:"text-xs",children:[f.jsx("p",{className:"font-medium",children:"Close workspace?"}),f.jsxs("p",{className:"text-muted-foreground mt-0.5",children:["You have ",Xi.length," unsaved file ",Xi.length===1?"change":"changes"," that will be discarded."]})]})]}),f.jsxs("div",{className:"flex items-center justify-end gap-1.5",children:[f.jsx($e,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2",onClick:()=>W(!1),children:"Cancel"}),f.jsx($e,{variant:"destructive",size:"sm",className:"h-6 text-[11px] px-2",onClick:()=>{W(!1),Zu()},children:"Discard & Close"})]})]})]})]})]}),Ue==="developer"&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:V?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>A(q=>!q),children:[f.jsx(HI,{className:"h-3 w-3 mr-1"}),"Debug"]})}),f.jsx(ir,{side:"bottom",children:"SSE debug stream"})]}),Ue==="developer"&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:P?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>P?Ju():hl(),children:[f.jsx(jp,{className:"h-3 w-3 mr-1"}),"Share"]})}),f.jsx(ir,{side:"bottom",children:"Screen sharing"})]}),Ue==="manager"&&f.jsxs(f.Fragment,{children:[we.selectedThread?f.jsxs($e,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>{we.setSelectedThreadId(null),n("")},children:[f.jsx(uw,{className:"h-3 w-3 mr-1"}),"Back"]}):f.jsxs(f.Fragment,{children:[f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:x?"secondary":"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>C(q=>!q),children:[x?f.jsx(j8,{className:`h-3 w-3 mr-1${sn?" rotate-90":""}`}):f.jsx(k8,{className:`h-3 w-3 mr-1${sn?" rotate-90":""}`}),"Repositories"]})}),f.jsx(ir,{side:"bottom",children:"Toggle repositories panel"})]}),we.selectedRepo&&we.selectedRepo.source==="local"&&f.jsxs(f.Fragment,{children:[f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>S(we.selectedRepo),children:[f.jsx(WO,{className:"h-3 w-3 mr-1"}),"Strategy"]})}),f.jsx(ir,{side:"bottom",children:"Open repository strategy"})]}),f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs($e,{variant:"ghost",size:"sm",className:"h-6 text-[11px] px-2 shrink-0",onClick:()=>O(we.selectedRepo),children:[f.jsx(FO,{className:"h-3 w-3 mr-1"}),"Todos"]})}),f.jsx(ir,{side:"bottom",children:"Open todo plan"})]})]})]}),f.jsx("div",{className:"flex-1"}),we.selectedThread?f.jsxs("div",{className:sn?"flex min-w-0 basis-full items-start gap-2":"flex min-w-0 items-center gap-2 shrink-0",children:[f.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-2",children:[f.jsx(v4,{status:we.selectedThread.status}),f.jsxs("div",{className:`min-w-0 ${sn?"flex-1":"flex items-center gap-2"}`,children:[y4(we.selectedThread.title)?f.jsx($L,{className:"text-[11px] h-3.5 w-28"}):f.jsx("span",{className:`text-[11px] text-muted-foreground truncate ${sn?"block":"max-w-[200px]"}`,children:we.selectedThread.title.replace(/^\[.*?\]\s*/,"")}),(we.selectedRepo||sn&&we.selectedThread.branch)&&f.jsxs("span",{className:`text-[10px] text-muted-foreground truncate ${sn?"mt-0.5 block":"max-w-[160px]"}`,children:[we.selectedRepo?`${we.selectedRepo.name} · ${we.selectedRepo.defaultBranch}`:"",sn&&we.selectedThread.branch?`${we.selectedRepo?" · ":""}${we.selectedThread.branch}`:""]})]})]}),f.jsxs("div",{className:"flex shrink-0 items-center gap-1 ",children:[!sn&&we.selectedThread.branch&&f.jsx(ln,{variant:"outline",className:"text-[9px] px-1 py-0 font-mono",children:we.selectedThread.branch}),we.selectedThread.status==="running"&&f.jsx($e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>void we.handleStop(we.selectedThread.id),children:f.jsx($p,{className:"h-2.5 w-2.5"})}),we.showGitActions&&we.selectedRepo&&f.jsx("div",{className:sn?"shrink-0":"ml-2 shrink-0",children:f.jsx(LS,{threadId:we.selectedThread.id,cwd:we.selectedThread.workingDirectory??we.selectedRepo.localPath,branch:we.selectedThread.branch,baseBranch:we.selectedRepo.defaultBranch,threadTitle:we.selectedThread.title,threadStatus:we.selectedThread.status,prUrl:we.selectedThread.prUrl,prState:we.selectedThread.id in we.threadPrStates?we.threadPrStates[we.selectedThread.id]:we.selectedThread.prState,ghAvailable:we.ghAvailable,showStatusBadge:!sn})})]})]}):null]})]}),a==="jobs"?f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx(Bfe,{})}):a==="network"?f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx(g2e,{token:ut})}):a==="settings"?f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsx(mge,{username:(Yi==null?void 0:Yi.username)??"",token:ut,apiKeys:Mn.api_keys,onSaveApiKeys:Gd,sttProvider:Mn.stt_provider,onSttProviderChange:async q=>{await Me({stt_provider:q})},onClearArchive:d0,activityEvents:Xd,updateInfo:jt,updateChecking:At,onCheckUpdate:()=>{lt()},onApplyUpdate:()=>{yt()},updateApplying:Tt,platform:zt})}):f.jsxs("div",{className:`flex flex-1 min-h-0 overflow-hidden ${sn?"flex-col":""}`,children:[Ue==="developer"&&g&&f.jsx("aside",{className:`overflow-hidden ${sn?"h-52 border-b shrink-0":"w-56 border-r shrink-0"}`,children:f.jsx(tse,{sessions:wn,activeSessionId:Ge,hasMoreSessions:Gg,showFewerSessions:wn.length>u_,onSelect:Ws,onCreate:()=>Ir(),onArchive:l_,onShowMore:Nd,onShowFewer:c_,sessionInfo:vc})}),(Ue==="developer"||Ue==="manager"&&we.selectedThread)&&Vs&&f.jsx(Lk,{ref:Lr,autoOpenRemotePath:(_t==null?void 0:_t.workspaceRoot)??null,surfaceId:(_t==null?void 0:_t.surfaceId)??null,files:Bn,activeFileId:sa,onActiveFileChange:zr,onFileDrop:q=>{ya(q)},onReferenceFile:q=>{var ee;return(ee=ki.current)==null?void 0:ee.insertChip({path:q.path,name:q.name})},onAvailableFilesChange:oa,showTree:H,showEditor:I,onToggleTree:Oo,onToggleEditor:ga,changedPaths:qd,fsWatcherVersion:On,savedTabsState:Ud,onTabsStateChange:Vd,onApplyDiff:ci,provider:fe,cliModel:tt}),(Ue==="developer"||Ue==="manager"&&we.selectedThread)&&yr&&(H||I)&&f.jsx("section",{className:`shrink-0 border-b bg-background overflow-hidden ${ba?"h-[50dvh] min-h-[220px]":"h-[55dvh] min-h-[260px]"}`,children:f.jsx(Lk,{ref:Lr,autoOpenRemotePath:(_t==null?void 0:_t.workspaceRoot)??null,surfaceId:(_t==null?void 0:_t.surfaceId)??null,files:Bn,activeFileId:sa,onActiveFileChange:zr,onFileDrop:q=>{ya(q)},onReferenceFile:q=>{var ee;return(ee=ki.current)==null?void 0:ee.insertChip({path:q.path,name:q.name})},onAvailableFilesChange:oa,showTree:H,showEditor:I,onToggleTree:Oo,onToggleEditor:ga,changedPaths:qd,isMobile:!0,savedTabsState:Ud,onTabsStateChange:Vd,onApplyDiff:ci,provider:fe,cliModel:tt})}),(Ue==="developer"||Ue==="manager"&&we.selectedThread)&&yr&&(!H||!I)&&f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b bg-muted/20 shrink-0",children:[!H&&f.jsxs("button",{onClick:Nc,className:"flex items-center gap-1 rounded px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3.5 w-3.5"}),f.jsx(c1,{className:"h-3.5 w-3.5"}),f.jsx(tu,{className:"h-3.5 w-3.5"}),!sn&&"Show Files + Changes"]}),!I&&f.jsxs("button",{onClick:Zs,className:"flex items-center gap-1 rounded px-2 py-1 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3.5 w-3.5"}),f.jsx(X1,{className:"h-3.5 w-3.5"}),!sn&&"Show Editor"]})]}),Ue==="manager"?f.jsx("div",{className:"flex-1 min-w-0 flex flex-col min-h-0",children:we.selectedThread?f.jsxs(f.Fragment,{children:[N&&(!H||!I)&&!sn&&f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b bg-muted/20 shrink-0",children:[!H&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("button",{onClick:Nc,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3 w-3"}),f.jsx(c1,{className:"h-3 w-3"}),f.jsx(tu,{className:"h-3 w-3"}),"Show Files + Changes"]})}),f.jsx(ir,{side:"bottom",children:"Show files and source control"})]}),!I&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("button",{onClick:Zs,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3 w-3"}),f.jsx(X1,{className:"h-3 w-3"}),"Show Editor"]})}),f.jsx(ir,{side:"bottom",children:"Show editor"})]})]}),f.jsxs(pj,{className:"min-h-0 flex-1 border-b",loading:we.loadingActivities,children:[Uu.length===0&&!we.loadingActivities&&f.jsx("div",{className:"text-center text-sm text-muted-foreground py-8",children:"No activity yet"}),Uu.map((q,ee)=>{var ae;return f.jsx(Hw,{messageId:q.id,messageIndex:ee,messageFromEnd:Uu.length-1-ee,role:q.role,content:q.content,toolCalls:q.toolCalls,segments:q.segments,isStreaming:((ae=we.selectedThread)==null?void 0:ae.status)==="running"&&ee===Uu.length-1,compact:!0,preferLlmUi:!1,onOpenPath:Tc,onOpenDiff:li},q.id)})]},((Po=we.selectedThread)==null?void 0:Po.id)??"manager-empty"),f.jsx("div",{className:"shrink-0 py-3 px-4",children:f.jsxs("div",{className:"mx-auto max-w-3xl",children:[we.error&&f.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-red-500/40 bg-red-500/10 px-3.5 py-2.5 text-sm text-red-400 mb-2",children:[f.jsx(ap,{className:"h-4 w-4 shrink-0"}),f.jsx("span",{className:"min-w-0 break-words",children:we.error})]}),Qg.length>0&&we.selectedThread&&f.jsx(L7,{items:Qg,onRemove:q=>ef(we.selectedThread.id,q),onEdit:(q,ee)=>ml(we.selectedThread.id,q,ee),onReorder:(q,ee)=>__(we.selectedThread.id,q,ee),className:"mb-2"}),f.jsx(S1,{ref:ki,value:e,onChange:n,onSubmit:pl,onQueue:ui,onStop:()=>{we.selectedThread&&we.handleStop(we.selectedThread.id)},isLoading:((Ss=we.selectedThread)==null?void 0:Ss.status)==="running",disabled:we.creating,placeholder:(ro=we.selectedThread)!=null&&ro.providerSessionId||((Cs=we.selectedThread)==null?void 0:Cs.status)==="running"?"Send a follow-up message...":"Describe what you want to do...",onVoiceInput:Lc,voiceRecording:to,voiceLevels:Fr,voiceTranscribing:To,onVoiceStop:()=>{es()},viewMode:Ue,onViewModeChange:mt,provider:fe,onProviderChange:Ec,cliModel:tt,onCliModelChange:Oc,repoRuntime:zd,onMoveToGateway:tf,availableFiles:il,onSearchFiles:Pc,workspaceOpen:N}),f.jsxs("div",{className:"flex items-center gap-2 px-1 mt-1.5",children:[zd&&f.jsx(dv,{runtime:zd}),we.selectedThread&&we.selectedThread.status!=="running"&&!we.selectedThread.providerSessionId&&f.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:"Thread finished — start a new one"})]})]})})]}):f.jsxs("div",{className:`flex flex-1 min-h-0 ${sn?"flex-col":""}`,children:[x&&f.jsx("div",{className:`overflow-hidden ${sn?"h-52 shrink-0 border-b":"w-56 shrink-0 border-r"}`,children:f.jsx(jSe,{repositories:we.repositories,selectedRepoId:((af=we.selectedRepo)==null?void 0:af.id)??null,isMobile:sn,getRuntimeInfo:we.getRuntimeInfoForRepository,onSelect:we.setSelectedRepoId,onAddRepository:()=>we.setFolderPickerOpen(!0),onRemoveRepository:q=>{we.removeRepository(q)},onOpenStrategy:q=>S(q),onOpenPlan:q=>O(q)})}),f.jsxs("div",{className:"flex-1 flex flex-col min-w-0 overflow-y-auto",children:[f.jsx("div",{className:`relative z-10 flex flex-col items-center px-4 pb-2 pt-4${Dt!=="idle"?" will-change-transform transition-transform duration-300 ease-[cubic-bezier(0.4,0,0.2,1)]":""}`,style:Dt==="center"?{transform:"translateY(calc(50vh - 200px))"}:Dt==="top"?{transform:"translateY(0)"}:void 0,onTransitionEnd:()=>{Dt==="top"&&Et("idle")},children:f.jsxs("div",{className:"w-full max-w-3xl",children:[f.jsx("h1",{className:"mb-4 text-center text-2xl font-semibold tracking-tight",children:"What do you want to build?"}),we.error&&f.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-red-500/40 bg-red-500/10 px-3.5 py-2.5 text-sm text-red-400 mb-3",children:[f.jsx(ap,{className:"h-4 w-4 shrink-0"}),f.jsx("span",{className:"min-w-0 break-words",children:we.error})]}),f.jsx(S1,{ref:ki,value:e,onChange:n,onSubmit:pl,disabled:e0,controlsDisabled:we.creating,placeholder:m_,onVoiceInput:Lc,voiceRecording:to,voiceLevels:Fr,voiceTranscribing:To,onVoiceStop:()=>{es()},viewMode:Ue,onViewModeChange:mt,provider:fe,onProviderChange:Ec,cliModel:tt,onCliModelChange:Oc,repoRuntime:Vu,onMoveToGateway:tf,footerLeadingContent:f.jsx(CSe,{repositories:we.repositories,selectedRepo:we.selectedRepo,disabled:we.creating,getRuntimeInfo:we.getRuntimeInfoForRepository,onSelect:we.setSelectedRepoId,onAddRepository:()=>we.setFolderPickerOpen(!0)})}),Vu&&f.jsx(dv,{runtime:Vu,className:"mt-1 px-1"})]})}),f.jsx("div",{className:"flex-1 overflow-y-auto",children:f.jsxs("div",{className:"mx-auto w-full max-w-3xl",children:[f.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[f.jsxs("div",{className:"flex items-center gap-3",children:[f.jsx("span",{className:"text-sm font-medium",children:"Threads"}),f.jsx(ln,{variant:"secondary",className:"h-5 rounded-md px-1.5 text-[10px]",children:cl.length})]}),f.jsx($e,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>void we.refresh(),children:f.jsx(du,{className:`h-3.5 w-3.5 ${we.loading?"animate-spin":""}`})})]}),cl.length===0?f.jsx("div",{className:"px-4 py-12 text-center text-sm text-muted-foreground",children:"No threads yet"}):f.jsxs("div",{className:"flex flex-col",children:[cl.map(q=>{const ee=we.getRepositoryForThread(q),ae=(ee==null?void 0:ee.name)??a_(q)??"Unknown repo";return f.jsx(kSe,{thread:q,repo:ee,repoName:ae,prState:q.id in we.threadPrStates?we.threadPrStates[q.id]:q.prState,ghAvailable:we.ghAvailable,onOpen:()=>we.setSelectedThreadId(q.id),onStop:()=>{we.handleStop(q.id)},onDelete:()=>{we.handleDelete(q.id)}},q.id)}),we.hasMoreThreads&&f.jsx("button",{className:"px-4 py-2 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:we.showMoreThreads,children:"Show more threads"}),cl.length>we.threadListLimit&&f.jsx("button",{className:"px-4 py-2 text-xs text-muted-foreground hover:text-foreground transition-colors",onClick:we.showFewerThreads,children:"Show less"})]})]})})]})]})}):ba?f.jsxs("div",{className:"flex flex-col flex-1 min-w-0 min-h-0 transition-all duration-300 ease-out",children:[N&&(!H||!I)&&!sn&&f.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 border-b bg-muted/20 shrink-0",children:[!H&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("button",{onClick:Nc,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3 w-3"}),f.jsx(c1,{className:"h-3 w-3"}),f.jsx(tu,{className:"h-3 w-3"}),"Show Files + Changes"]})}),f.jsx(ir,{side:"bottom",children:"Show files and source control"})]}),!I&&f.jsxs(dr,{children:[f.jsx(hr,{asChild:!0,children:f.jsxs("button",{onClick:Zs,className:"flex items-center gap-1 rounded px-2 py-0.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",children:[f.jsx(Gl,{className:"h-3 w-3"}),f.jsx(X1,{className:"h-3 w-3"}),"Show Editor"]})}),f.jsx(ir,{side:"bottom",children:"Show editor"})]})]}),f.jsxs(pj,{className:"min-h-0 flex-1 border-b",compact:Vs,loading:Du,children:[qs.map((q,ee)=>f.jsx(Hw,{messageId:q.id,messageIndex:ee,messageFromEnd:qs.length-1-ee,role:q.role,content:q.content,displayContent:q.displayContent,referencedFiles:q.referencedFiles,thinking:q.thinking,thinkingDuration:q.thinkingDuration,toolCalls:q.toolCalls,segments:q.segments,isStreaming:vr&&q===qs[qs.length-1],compact:N||P,preferLlmUi:!0,onOpenTerminal:v_,onEditMessage:u0,onOpenPath:Tc,onOpenDiff:li},q.id)),Oi.length>0&&f.jsx(L7,{items:Oi,onRemove:Xr,onEdit:ua,onReorder:Bu})]},Ge??"developer-empty"),f.jsx("div",{className:`shrink-0 py-3 ${Vs?"px-3":"px-4"}`,children:f.jsxs("div",{className:"mx-auto w-full max-w-3xl space-y-1.5",children:[zu.length>0&&f.jsx(use,{items:zu}),Ei&&Ei!=="login_required"&&Ei!=="limit_reached"&&!vr&&f.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-red-500/40 bg-red-500/10 px-3.5 py-2.5 text-sm text-red-400 dark:text-red-400 dark:border-red-400/40 dark:bg-red-400/10",children:[f.jsx(ap,{className:"h-4 w-4 shrink-0"}),f.jsx("span",{className:"min-w-0 break-words",children:Ei})]}),sl&&!vr&&f.jsxs("div",{className:"flex items-center justify-center gap-2 py-1.5",children:[f.jsxs("button",{onClick:()=>Yg({token:ut,sessionId:Ge}),className:"inline-flex items-center gap-1.5 rounded-md border bg-background px-3 py-1.5 text-xs font-medium text-foreground shadow-sm hover:bg-accent transition-colors",children:[f.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:f.jsx("polygon",{points:"5 3 19 12 5 21 5 3"})}),"Continue"]}),f.jsx("span",{className:"text-[11px] text-muted-foreground",children:"Agent stopped — hit the tool execution limit"})]}),f.jsx(bse,{compact:!0,sessionId:Ge,onApproveAllEnabled:()=>ce(!0)}),Td&&f.jsx(lse,{plan:Td,onApprove:$u,onReject:Iu,isExecuting:vr}),Yd&&f.jsx("p",{className:"text-center text-sm text-destructive",children:"Daily limit reached. Come back tomorrow."}),Xi.length>0&&f.jsx(fse,{files:Xi,onAccept:Pd,onReject:Ad,onAcceptAll:Md,onRejectAll:bc,onFileClick:li}),f.jsx(S1,{ref:ki,value:e,onChange:n,onSubmit:pl,onStop:Lu,onQueue:Ac,isLoading:vr,disabled:Yd,onVoiceInput:Lc,voiceRecording:to,voiceLevels:Fr,voiceTranscribing:To,onVoiceStop:()=>{es()},mode:be,onModeChange:ze,provider:fe,onProviderChange:Ec,cliModel:tt,onCliModelChange:Oc,viewMode:Ue,onViewModeChange:mt,availableFiles:il,onSearchFiles:Pc,workspaceOpen:N,sessionInfo:vc,workspaceNodeId:_t==null?void 0:_t.nodeId}),f.jsxs("div",{className:"flex items-center justify-between gap-2 px-1",children:[f.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[f.jsx("button",{onClick:()=>{_c(),Ir()},className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors shrink-0",children:"New chat"}),Ue==="manager"&&f.jsx("button",{onClick:()=>we.setSelectedThreadId(null),className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors shrink-0",children:"New thread"}),se&&f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"text-[11px] text-green-600 dark:text-green-400 truncate",children:"Approved all commands for this session"}),f.jsx("button",{onClick:Ti,className:"text-[11px] text-muted-foreground hover:text-foreground transition-colors shrink-0",children:"Clear approve all"})]})]}),ca!==null&&f.jsxs("span",{className:"text-[11px] text-muted-foreground shrink-0",children:[ca," remaining"]})]})]})})]}):f.jsx("div",{className:`flex-1 min-w-0 flex flex-col items-center justify-center px-4 ${St==="animating"?"animate-slide-from-top":""}`,onAnimationEnd:()=>Ct("idle"),children:f.jsxs("div",{className:"w-full max-w-3xl space-y-8",children:[f.jsxs("div",{className:"text-center",children:[f.jsx("h1",{className:"text-3xl font-semibold tracking-tight",children:"Jait"}),f.jsx("p",{className:"text-base text-muted-foreground mt-1",children:"Just Another Intelligent Tool"})]}),f.jsx(nse,{suggestions:xSe,onSelect:eo}),f.jsx(S1,{ref:ki,value:e,onChange:n,onSubmit:pl,onStop:Lu,onQueue:Ac,isLoading:vr,onVoiceInput:Lc,voiceRecording:to,voiceLevels:Fr,voiceTranscribing:To,onVoiceStop:()=>{es()},mode:be,onModeChange:ze,provider:fe,onProviderChange:Ec,cliModel:tt,onCliModelChange:Oc,viewMode:Ue,onViewModeChange:mt,availableFiles:il,onSearchFiles:Pc,workspaceOpen:N,sessionInfo:vc,workspaceNodeId:_t==null?void 0:_t.nodeId})]})})]}),_&&a==="chat"&&Ue==="developer"&&f.jsxs("div",{className:"shrink-0 border-t overflow-hidden",style:{height:U},children:[f.jsx("div",{onMouseDown:y_,className:"h-1 cursor-row-resize hover:bg-primary/30 transition-colors"}),f.jsxs("div",{className:"relative",children:[f.jsx(K5e,{terminals:Sc,activeTerminalId:da,onSelect:ll,onCreate:()=>Cc(Ge??"default"),onKill:c0}),f.jsx("button",{onClick:ma,className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":"Close terminal",children:f.jsx(Mr,{className:"h-3.5 w-3.5"})})]}),da?f.jsx(q5e,{terminalId:da,className:"h-[calc(100%-2rem)]",token:ut}):f.jsx("div",{className:"flex items-center justify-center h-[calc(100%-2rem)] text-sm text-muted-foreground",children:f.jsx("button",{onClick:()=>Cc(Ge??"default"),className:"hover:text-foreground transition-colors",children:"+ New Terminal"})})]}),Ue==="developer"&&V&&f.jsx("div",{className:"fixed top-14 right-0 bottom-0 w-[420px] border-l z-50 shadow-xl",children:f.jsx(jse,{onClose:()=>A(!1)})}),f.jsx(Cu,{open:r,onOpenChange:i,children:f.jsx(fc,{className:"sm:max-w-md",children:An==="url"?f.jsxs(f.Fragment,{children:[f.jsxs(Ga,{children:[f.jsxs(Ya,{className:"flex items-center gap-2",children:[f.jsx(Ms,{className:"h-5 w-5"}),"Connect to Gateway"]}),f.jsx(Cy,{children:"Enter your Jait gateway URL to get started."})]}),f.jsxs("form",{onSubmit:Kd,className:"space-y-4 pt-2",children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"gateway-url",children:"Gateway URL"}),f.jsx(Kr,{id:"gateway-url",placeholder:"https://jait.example.com",value:de,onChange:q=>{gt(q.target.value),En(null)},autoFocus:!0})]}),Ci&&f.jsxs("div",{className:"flex items-center gap-2 text-sm text-destructive",children:[f.jsx(uu,{className:"h-4 w-4 shrink-0"}),Ci]}),f.jsx($e,{type:"submit",className:"w-full",disabled:Gi,children:Gi?f.jsxs(f.Fragment,{children:[f.jsx(kt,{className:"h-4 w-4 mr-2 animate-spin"}),"Connecting…"]}):"Connect"})]})]}):f.jsxs(f.Fragment,{children:[f.jsxs(Ga,{children:[f.jsx(Ya,{children:"Account"}),f.jsx(Cy,{asChild:!0,children:Le?f.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[f.jsx(Ms,{className:"h-3 w-3 text-green-500"}),f.jsx("code",{className:"text-xs bg-muted px-1.5 py-0.5 rounded",children:gi}),f.jsx("button",{type:"button",className:"text-xs text-primary underline underline-offset-2 hover:opacity-80",onClick:()=>In("url"),children:"Change"})]}):f.jsx("p",{children:"Sign in with a username and password."})})]}),f.jsxs(V5,{value:Ke,onValueChange:q=>ht(q),children:[f.jsxs(Pv,{className:"grid grid-cols-2 w-full",children:[f.jsx(Ba,{value:"login",children:"Login"}),f.jsx(Ba,{value:"register",children:"Register"})]}),f.jsx(Fa,{value:"login",className:"pt-4",children:f.jsxs("form",{className:"space-y-4",onSubmit:nf,children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"login-username",children:"Username"}),f.jsx(Kr,{id:"login-username",value:Ne,onChange:q=>Pe(q.target.value),autoComplete:"username",required:!0})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"login-password",children:"Password"}),f.jsx(Kr,{id:"login-password",type:"password",value:Fe,onChange:q=>re(q.target.value),autoComplete:"current-password",required:!0})]}),f.jsx($e,{type:"submit",className:"w-full",children:"Login"})]})}),f.jsx(Fa,{value:"register",className:"pt-4",children:f.jsxs("form",{className:"space-y-4",onSubmit:_a,children:[f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"register-username",children:"Username"}),f.jsx(Kr,{id:"register-username",value:he,onChange:q=>_e(q.target.value),autoComplete:"username",required:!0})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"register-password",children:"Password"}),f.jsx(Kr,{id:"register-password",type:"password",value:ke,onChange:q=>Oe(q.target.value),autoComplete:"new-password",required:!0})]}),f.jsxs("div",{className:"space-y-1.5",children:[f.jsx(or,{htmlFor:"register-password-confirm",children:"Confirm password"}),f.jsx(Kr,{id:"register-password-confirm",type:"password",value:Ie,onChange:q=>Ae(q.target.value),autoComplete:"new-password",required:!0})]}),f.jsx($e,{type:"submit",className:"w-full",children:"Create account"})]})})]}),s&&f.jsx("p",{className:"text-sm text-destructive",children:s})]})})}),f.jsx(_O,{open:ji,onOpenChange:aa,initialPath:Mn.workspace_picker_path,initialNodeId:Mn.workspace_picker_node_id,onSelect:(q,ee)=>{Qi(q,ee).catch(ae=>{console.error("Failed to open workspace:",ae),Pr.error(`Failed to open workspace: ${ae instanceof Error?ae.message:"Unknown error"}`)})}}),f.jsx(_O,{open:we.folderPickerOpen,onOpenChange:we.setFolderPickerOpen,onSelect:(q,ee)=>{we.handleFolderSelected(q,ee)}}),j&&f.jsx(ihe,{open:!!j,onOpenChange:q=>{q||S(null)},repoId:j.id,repoName:j.name}),E&&f.jsx(ahe,{open:!!E,onOpenChange:q=>{q||O(null)},repoId:E.id,repoName:E.name,defaultBranch:E.defaultBranch,repoLocalPath:E.localPath,onStartThread:(q,ee,ae)=>{(async()=>{const ve=E,Re=`jait/${Math.random().toString(16).slice(2,10)}`;let Ve;try{Ve=(await Hi.createWorktree(ve.localPath,ve.defaultBranch,Re)).path}catch{try{await Hi.createBranch(ve.localPath,Re,ve.defaultBranch)}catch{}}const dt=await en.createThread({title:`[${ve.name}] ${q.title}`,providerId:fe,workingDirectory:Ve??ve.localPath,branch:Re});await en.startThread(dt.id,{message:q.description||q.title,titleTask:q.title,titlePrefix:`[${ve.name}] `});const Pt=ee.tasks.map(Mt=>Mt.id===q.id?{...Mt,status:"running",threadId:dt.id}:Mt);await en.updatePlan(ee.id,{tasks:Pt})})()}}),P&&f.jsxs("div",{className:"fixed z-50 bg-background border rounded-lg shadow-2xl overflow-hidden flex flex-col",style:{left:Y.x<0?void 0:Y.x,top:Y.y<0?void 0:Y.y,right:Y.x<0?16:void 0,bottom:Y.y<0?16:void 0,width:R.w,height:R.h},children:[f.jsxs("div",{className:"flex items-center justify-between h-8 px-3 border-b bg-muted/30 shrink-0 cursor-move select-none",onPointerDown:yc,style:{touchAction:"none"},children:[f.jsxs("span",{className:"text-xs font-medium flex items-center gap-1.5",children:[f.jsx(jp,{className:"h-3 w-3"})," Screen Share"]}),f.jsx($e,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:Ju,children:f.jsx(Mr,{className:"h-3 w-3"})})]}),f.jsx(_2e,{screenShare:Hu}),f.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-nwse-resize opacity-50 hover:opacity-100",onPointerDown:Ru,style:{touchAction:"none"},children:f.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",className:"text-muted-foreground",children:f.jsx("path",{d:"M10 2L2 10M10 6L6 10M10 10L10 10",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]})]})})}function NSe(){const[e,n]=Xe.useState(()=>document.documentElement.classList.contains("dark")?"dark":"light");return Xe.useEffect(()=>{const r=document.documentElement,i=()=>n(r.classList.contains("dark")?"dark":"light");i();const s=new MutationObserver(i);return s.observe(r,{attributes:!0,attributeFilter:["class"]}),()=>s.disconnect()},[]),f.jsx(zI,{position:"top-right",theme:e,closeButton:!1})}cI.createRoot(document.getElementById("root")).render(f.jsxs(Xe.StrictMode,{children:[f.jsx(OSe,{}),f.jsx(NSe,{})]}));
|